1 /* 2 * Copyright (C) 2015 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 class Main implements Iface, Iface2, Iface3 { main(String[] args)17 public static void main(String[] args) { 18 System.out.println("Create Main instance"); 19 Main m = new Main(); 20 System.out.println("Calling functions on concrete Main"); 21 callMain(m); 22 System.out.println("Calling functions on interface Iface"); 23 callIface(m); 24 System.out.println("Calling functions on interface Iface2"); 25 callIface2(m); 26 } callMain(Main m)27 public static void callMain(Main m) { 28 System.out.println("Calling non-abstract function on Main"); 29 System.out.println(m.charge()); 30 System.out.println("Calling abstract function on Main"); 31 try { 32 System.out.println(m.sayHi()); 33 System.out.println("Unexpected no error Thrown on Main"); 34 } catch (AbstractMethodError e) { 35 System.out.println("Expected AME Thrown on Main"); 36 } catch (IncompatibleClassChangeError e) { 37 System.out.println("Unexpected ICCE Thrown on Main"); 38 } 39 System.out.println("Calling non-abstract function on Main"); 40 System.out.println(m.charge()); 41 return; 42 } callIface(Iface m)43 public static void callIface(Iface m) { 44 System.out.println("Calling non-abstract function on Iface"); 45 System.out.println(m.charge()); 46 System.out.println("Calling abstract function on Iface"); 47 try { 48 System.out.println(m.sayHi()); 49 System.out.println("Unexpected no error Thrown on Iface"); 50 } catch (AbstractMethodError e) { 51 System.out.println("Expected AME Thrown on Iface"); 52 } catch (IncompatibleClassChangeError e) { 53 System.out.println("Unexpected ICCE Thrown on Iface"); 54 } 55 System.out.println("Calling non-abstract function on Iface"); 56 System.out.println(m.charge()); 57 return; 58 } callIface2(Iface2 m)59 public static void callIface2(Iface2 m) { 60 System.out.println("Calling abstract function on Iface2"); 61 try { 62 System.out.println(m.sayHi()); 63 System.out.println("Unexpected no error Thrown on Iface2"); 64 } catch (AbstractMethodError e) { 65 System.out.println("Expected AME Thrown on Iface2"); 66 } catch (IncompatibleClassChangeError e) { 67 System.out.println("Unexpected ICCE Thrown on Iface2"); 68 } 69 return; 70 } 71 } 72