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 { return1()19 public int return1(); return2()20 public int return2(); return3()21 public int return3(); return4()22 public int return4(); return5()23 public int return5(); return6()24 public int return6(); return7()25 public int return7(); return8()26 public int return8(); return9()27 public int return9(); return10()28 public int return10(); return11()29 public int return11(); return12()30 public int return12(); return13()31 public int return13(); return14()32 public int return14(); return15()33 public int return15(); return16()34 public int return16(); return17()35 public int return17(); return18()36 public int return18(); return19()37 public int return19(); return20()38 public int return20(); 39 } 40 41 static class ItfImpl1 implements Itf { return1()42 public int return1() { return 1; } return2()43 public int return2() { return 2; } return3()44 public int return3() { return 3; } return4()45 public int return4() { return 4; } return5()46 public int return5() { return 5; } return6()47 public int return6() { return 6; } return7()48 public int return7() { return 7; } return8()49 public int return8() { return 8; } return9()50 public int return9() { return 9; } return10()51 public int return10() { return 10; } return11()52 public int return11() { return 11; } return12()53 public int return12() { return 12; } return13()54 public int return13() { return 13; } return14()55 public int return14() { return 14; } return15()56 public int return15() { return 15; } return16()57 public int return16() { return 16; } return17()58 public int return17() { return 17; } return18()59 public int return18() { return 18; } return19()60 public int return19() { return 19; } return20()61 public int return20() { return 20; } 62 } 63 64 static class ItfImpl2 implements Itf { return1()65 public int return1() { return -1; } return2()66 public int return2() { return -2; } return3()67 public int return3() { return -3; } return4()68 public int return4() { return -4; } return5()69 public int return5() { return -5; } return6()70 public int return6() { return -6; } return7()71 public int return7() { return -7; } return8()72 public int return8() { return -8; } return9()73 public int return9() { return -9; } return10()74 public int return10() { return -10; } return11()75 public int return11() { return -11; } return12()76 public int return12() { return -12; } return13()77 public int return13() { return -13; } return14()78 public int return14() { return -14; } return15()79 public int return15() { return -15; } return16()80 public int return16() { return -16; } return17()81 public int return17() { return -17; } return18()82 public int return18() { return -18; } return19()83 public int return19() { return -19; } return20()84 public int return20() { return -20; } 85 } 86 main(String[] args)87 public static void main(String[] args) { 88 $opt$InvokeInterface(new ItfImpl1(), 1); 89 $opt$InvokeInterface(new ItfImpl2(), -1); 90 } 91 assertEquals(int expected, int value)92 public static void assertEquals(int expected, int value) { 93 if (expected != value) { 94 throw new Error("Expected " + expected + ", got " + value); 95 } 96 } 97 $opt$InvokeInterface(Itf object, int factor)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