1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 public class Main { 18 static interface Itf { 19 public int return1(); 20 public int return2(); 21 public int return3(); 22 public int return4(); 23 public int return5(); 24 public int return6(); 25 public int return7(); 26 public int return8(); 27 public int return9(); 28 public int return10(); 29 public int return11(); 30 public int return12(); 31 public int return13(); 32 public int return14(); 33 public int return15(); 34 public int return16(); 35 public int return17(); 36 public int return18(); 37 public int return19(); 38 public int return20(); 39 } 40 41 static class ItfImpl1 implements Itf { 42 public int return1() { return 1; } 43 public int return2() { return 2; } 44 public int return3() { return 3; } 45 public int return4() { return 4; } 46 public int return5() { return 5; } 47 public int return6() { return 6; } 48 public int return7() { return 7; } 49 public int return8() { return 8; } 50 public int return9() { return 9; } 51 public int return10() { return 10; } 52 public int return11() { return 11; } 53 public int return12() { return 12; } 54 public int return13() { return 13; } 55 public int return14() { return 14; } 56 public int return15() { return 15; } 57 public int return16() { return 16; } 58 public int return17() { return 17; } 59 public int return18() { return 18; } 60 public int return19() { return 19; } 61 public int return20() { return 20; } 62 } 63 64 static class ItfImpl2 implements Itf { 65 public int return1() { return -1; } 66 public int return2() { return -2; } 67 public int return3() { return -3; } 68 public int return4() { return -4; } 69 public int return5() { return -5; } 70 public int return6() { return -6; } 71 public int return7() { return -7; } 72 public int return8() { return -8; } 73 public int return9() { return -9; } 74 public int return10() { return -10; } 75 public int return11() { return -11; } 76 public int return12() { return -12; } 77 public int return13() { return -13; } 78 public int return14() { return -14; } 79 public int return15() { return -15; } 80 public int return16() { return -16; } 81 public int return17() { return -17; } 82 public int return18() { return -18; } 83 public int return19() { return -19; } 84 public int return20() { return -20; } 85 } 86 87 public static void main(String[] args) { 88 $opt$InvokeInterface(new ItfImpl1(), 1); 89 $opt$InvokeInterface(new ItfImpl2(), -1); 90 } 91 92 public static void assertEquals(int expected, int value) { 93 if (expected != value) { 94 throw new Error("Expected " + expected + ", got " + value); 95 } 96 } 97 98 public static void $opt$InvokeInterface(Itf object, int factor) { 99 assertEquals(factor * 1, object.return1()); 100 assertEquals(factor * 2, object.return2()); 101 assertEquals(factor * 3, object.return3()); 102 assertEquals(factor * 4, object.return4()); 103 assertEquals(factor * 5, object.return5()); 104 assertEquals(factor * 6, object.return6()); 105 assertEquals(factor * 7, object.return7()); 106 assertEquals(factor * 8, object.return8()); 107 assertEquals(factor * 9, object.return9()); 108 assertEquals(factor * 10, object.return10()); 109 assertEquals(factor * 11, object.return11()); 110 assertEquals(factor * 12, object.return12()); 111 assertEquals(factor * 13, object.return13()); 112 assertEquals(factor * 14, object.return14()); 113 assertEquals(factor * 15, object.return15()); 114 assertEquals(factor * 16, object.return16()); 115 assertEquals(factor * 17, object.return17()); 116 assertEquals(factor * 18, object.return18()); 117 assertEquals(factor * 19, object.return19()); 118 assertEquals(factor * 20, object.return20()); 119 } 120 } 121