1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker class Main implements Iface, Iface2, Iface3 { main(String[] args)17*795d594fSAndroid Build Coastguard Worker public static void main(String[] args) { 18*795d594fSAndroid Build Coastguard Worker System.out.println("Create Main instance"); 19*795d594fSAndroid Build Coastguard Worker Main m = new Main(); 20*795d594fSAndroid Build Coastguard Worker System.out.println("Calling functions on concrete Main"); 21*795d594fSAndroid Build Coastguard Worker callMain(m); 22*795d594fSAndroid Build Coastguard Worker System.out.println("Calling functions on interface Iface"); 23*795d594fSAndroid Build Coastguard Worker callIface(m); 24*795d594fSAndroid Build Coastguard Worker System.out.println("Calling functions on interface Iface2"); 25*795d594fSAndroid Build Coastguard Worker callIface2(m); 26*795d594fSAndroid Build Coastguard Worker } callMain(Main m)27*795d594fSAndroid Build Coastguard Worker public static void callMain(Main m) { 28*795d594fSAndroid Build Coastguard Worker System.out.println("Calling non-abstract function on Main"); 29*795d594fSAndroid Build Coastguard Worker System.out.println(m.charge()); 30*795d594fSAndroid Build Coastguard Worker System.out.println("Calling abstract function on Main"); 31*795d594fSAndroid Build Coastguard Worker try { 32*795d594fSAndroid Build Coastguard Worker System.out.println(m.sayHi()); 33*795d594fSAndroid Build Coastguard Worker System.out.println("Unexpected no error Thrown on Main"); 34*795d594fSAndroid Build Coastguard Worker } catch (AbstractMethodError e) { 35*795d594fSAndroid Build Coastguard Worker System.out.println("Expected AME Thrown on Main"); 36*795d594fSAndroid Build Coastguard Worker } catch (IncompatibleClassChangeError e) { 37*795d594fSAndroid Build Coastguard Worker System.out.println("Unexpected ICCE Thrown on Main"); 38*795d594fSAndroid Build Coastguard Worker } 39*795d594fSAndroid Build Coastguard Worker System.out.println("Calling non-abstract function on Main"); 40*795d594fSAndroid Build Coastguard Worker System.out.println(m.charge()); 41*795d594fSAndroid Build Coastguard Worker return; 42*795d594fSAndroid Build Coastguard Worker } callIface(Iface m)43*795d594fSAndroid Build Coastguard Worker public static void callIface(Iface m) { 44*795d594fSAndroid Build Coastguard Worker System.out.println("Calling non-abstract function on Iface"); 45*795d594fSAndroid Build Coastguard Worker System.out.println(m.charge()); 46*795d594fSAndroid Build Coastguard Worker System.out.println("Calling abstract function on Iface"); 47*795d594fSAndroid Build Coastguard Worker try { 48*795d594fSAndroid Build Coastguard Worker System.out.println(m.sayHi()); 49*795d594fSAndroid Build Coastguard Worker System.out.println("Unexpected no error Thrown on Iface"); 50*795d594fSAndroid Build Coastguard Worker } catch (AbstractMethodError e) { 51*795d594fSAndroid Build Coastguard Worker System.out.println("Expected AME Thrown on Iface"); 52*795d594fSAndroid Build Coastguard Worker } catch (IncompatibleClassChangeError e) { 53*795d594fSAndroid Build Coastguard Worker System.out.println("Unexpected ICCE Thrown on Iface"); 54*795d594fSAndroid Build Coastguard Worker } 55*795d594fSAndroid Build Coastguard Worker System.out.println("Calling non-abstract function on Iface"); 56*795d594fSAndroid Build Coastguard Worker System.out.println(m.charge()); 57*795d594fSAndroid Build Coastguard Worker return; 58*795d594fSAndroid Build Coastguard Worker } callIface2(Iface2 m)59*795d594fSAndroid Build Coastguard Worker public static void callIface2(Iface2 m) { 60*795d594fSAndroid Build Coastguard Worker System.out.println("Calling abstract function on Iface2"); 61*795d594fSAndroid Build Coastguard Worker try { 62*795d594fSAndroid Build Coastguard Worker System.out.println(m.sayHi()); 63*795d594fSAndroid Build Coastguard Worker System.out.println("Unexpected no error Thrown on Iface2"); 64*795d594fSAndroid Build Coastguard Worker } catch (AbstractMethodError e) { 65*795d594fSAndroid Build Coastguard Worker System.out.println("Expected AME Thrown on Iface2"); 66*795d594fSAndroid Build Coastguard Worker } catch (IncompatibleClassChangeError e) { 67*795d594fSAndroid Build Coastguard Worker System.out.println("Unexpected ICCE Thrown on Iface2"); 68*795d594fSAndroid Build Coastguard Worker } 69*795d594fSAndroid Build Coastguard Worker return; 70*795d594fSAndroid Build Coastguard Worker } 71*795d594fSAndroid Build Coastguard Worker } 72