Home | History | Annotate | Download | only in src
      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 {
     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   }
     25 
     26   public static void callMain(Main m) {
     27     System.out.println("Calling verifiable function on Main");
     28     System.out.println(m.sayHi());
     29     System.out.println("Calling unverifiable function on Main");
     30     try {
     31       m.verificationSoftFail();
     32       System.out.println("Unexpected no error Thrown on Main");
     33     } catch (NoSuchMethodError e) {
     34       System.out.println("Expected NSME Thrown on Main");
     35     } catch (Throwable e) {
     36       System.out.println("Unexpected Error Thrown on Main");
     37       e.printStackTrace(System.out);
     38     }
     39     System.out.println("Calling verifiable function on Main");
     40     System.out.println(m.sayHi());
     41     return;
     42   }
     43 
     44   public static void callIface(Iface m) {
     45     System.out.println("Calling verifiable function on Iface");
     46     System.out.println(m.sayHi());
     47     System.out.println("Calling unverifiable function on Iface");
     48     try {
     49       m.verificationSoftFail();
     50       System.out.println("Unexpected no error Thrown on Iface");
     51     } catch (NoSuchMethodError e) {
     52       System.out.println("Expected NSME Thrown on Iface");
     53     } catch (Throwable e) {
     54       System.out.println("Unexpected Error Thrown on Iface");
     55       e.printStackTrace(System.out);
     56     }
     57     System.out.println("Calling verifiable function on Iface");
     58     System.out.println(m.sayHi());
     59     return;
     60   }
     61 }
     62