Alex Light | 9139e00 | 2015-10-09 15:59:48 -0700 | [diff] [blame^] | 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 | # |
| 17 | # class Main implements Iface, Iface2 { |
| 18 | # public static void main(String[] args) { |
| 19 | # System.out.println("Create Main instance"); |
| 20 | # Main m = new Main(); |
| 21 | # System.out.println("Calling functions on concrete Main"); |
| 22 | # callMain(m); |
| 23 | # System.out.println("Calling functions on interface Iface"); |
| 24 | # callIface(m); |
| 25 | # System.out.println("Calling functions on interface Iface2"); |
| 26 | # callIface2(m); |
| 27 | # } |
| 28 | # |
| 29 | # public static void callMain(Main m) { |
| 30 | # System.out.println("Calling non-conflicting function on Main"); |
| 31 | # System.out.println(m.charge()); |
| 32 | # System.out.println("Calling conflicting function on Main"); |
| 33 | # try { |
| 34 | # System.out.println(m.sayHi()); |
| 35 | # System.out.println("Unexpected no error Thrown on Main"); |
| 36 | # } catch (AbstractMethodError e) { |
| 37 | # System.out.println("Unexpected AME Thrown on Main"); |
| 38 | # } catch (IncompatibleClassChangeError e) { |
| 39 | # System.out.println("Expected ICCE Thrown on Main"); |
| 40 | # } |
| 41 | # System.out.println("Calling non-conflicting function on Main"); |
| 42 | # System.out.println(m.charge()); |
| 43 | # return; |
| 44 | # } |
| 45 | # |
| 46 | # public static void callIface(Iface m) { |
| 47 | # System.out.println("Calling non-conflicting function on Iface"); |
| 48 | # System.out.println(m.charge()); |
| 49 | # System.out.println("Calling conflicting function on Iface"); |
| 50 | # try { |
| 51 | # System.out.println(m.sayHi()); |
| 52 | # System.out.println("Unexpected no error Thrown on Iface"); |
| 53 | # } catch (AbstractMethodError e) { |
| 54 | # System.out.println("Unexpected AME Thrown on Iface"); |
| 55 | # } catch (IncompatibleClassChangeError e) { |
| 56 | # System.out.println("Expected ICCE Thrown on Iface"); |
| 57 | # } |
| 58 | # System.out.println("Calling non-conflicting function on Iface"); |
| 59 | # System.out.println(m.charge()); |
| 60 | # return; |
| 61 | # } |
| 62 | # |
| 63 | # public static void callIface2(Iface2 m) { |
| 64 | # System.out.println("Calling conflicting function on Iface2"); |
| 65 | # try { |
| 66 | # System.out.println(m.sayHi()); |
| 67 | # System.out.println("Unexpected no error Thrown on Iface2"); |
| 68 | # } catch (AbstractMethodError e) { |
| 69 | # System.out.println("Unexpected AME Thrown on Iface2"); |
| 70 | # } catch (IncompatibleClassChangeError e) { |
| 71 | # System.out.println("Expected ICCE Thrown on Iface2"); |
| 72 | # } |
| 73 | # return; |
| 74 | # } |
| 75 | # } |
| 76 | |
| 77 | .class public LMain; |
| 78 | .super Ljava/lang/Object; |
| 79 | .implements LIface; |
| 80 | .implements LIface2; |
| 81 | |
| 82 | .method public constructor <init>()V |
| 83 | .registers 1 |
| 84 | invoke-direct {p0}, Ljava/lang/Object;-><init>()V |
| 85 | return-void |
| 86 | .end method |
| 87 | |
| 88 | .method public static main([Ljava/lang/String;)V |
| 89 | .locals 3 |
| 90 | sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream; |
| 91 | |
| 92 | const-string v0, "Create Main instance" |
| 93 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 94 | |
| 95 | new-instance v2, LMain; |
| 96 | invoke-direct {v2}, LMain;-><init>()V |
| 97 | |
| 98 | const-string v0, "Calling functions on concrete Main" |
| 99 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 100 | invoke-static {v2}, LMain;->callMain(LMain;)V |
| 101 | |
| 102 | const-string v0, "Calling functions on interface Iface" |
| 103 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 104 | invoke-static {v2}, LMain;->callIface(LIface;)V |
| 105 | |
| 106 | const-string v0, "Calling functions on interface Iface2" |
| 107 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 108 | invoke-static {v2}, LMain;->callIface2(LIface2;)V |
| 109 | |
| 110 | return-void |
| 111 | .end method |
| 112 | |
| 113 | .method public static callIface(LIface;)V |
| 114 | .locals 2 |
| 115 | sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream; |
| 116 | const-string v0, "Calling non-conflicting function on Iface" |
| 117 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 118 | |
| 119 | invoke-interface {p0}, LIface;->charge()Ljava/lang/String; |
| 120 | move-result-object v0 |
| 121 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 122 | |
| 123 | const-string v0, "Calling conflicting function on Iface" |
| 124 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 125 | :try_start |
| 126 | invoke-interface {p0}, LIface;->sayHi()Ljava/lang/String; |
| 127 | move-result-object v0 |
| 128 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 129 | |
| 130 | const-string v0, "Unexpected no error Thrown on Iface" |
| 131 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 132 | |
| 133 | goto :error_end |
| 134 | :try_end |
| 135 | .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start |
| 136 | .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start |
| 137 | :AME_error_start |
| 138 | const-string v0, "Unexpected AME Thrown on Iface" |
| 139 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 140 | goto :error_end |
| 141 | :ICCE_error_start |
| 142 | const-string v0, "Expected ICCE Thrown on Iface" |
| 143 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 144 | goto :error_end |
| 145 | :error_end |
| 146 | const-string v0, "Calling non-conflicting function on Iface" |
| 147 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 148 | |
| 149 | invoke-interface {p0}, LIface;->charge()Ljava/lang/String; |
| 150 | move-result-object v0 |
| 151 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 152 | |
| 153 | return-void |
| 154 | .end method |
| 155 | |
| 156 | .method public static callIface2(LIface2;)V |
| 157 | .locals 2 |
| 158 | sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream; |
| 159 | const-string v0, "Calling conflicting function on Iface2" |
| 160 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 161 | :try_start |
| 162 | invoke-interface {p0}, LIface2;->sayHi()Ljava/lang/String; |
| 163 | move-result-object v0 |
| 164 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 165 | |
| 166 | const-string v0, "Unexpected no error Thrown on Iface2" |
| 167 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 168 | |
| 169 | goto :error_end |
| 170 | :try_end |
| 171 | .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start |
| 172 | .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start |
| 173 | :AME_error_start |
| 174 | const-string v0, "Unexpected AME Thrown on Iface2" |
| 175 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 176 | goto :error_end |
| 177 | :ICCE_error_start |
| 178 | const-string v0, "Expected ICCE Thrown on Iface2" |
| 179 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 180 | goto :error_end |
| 181 | :error_end |
| 182 | |
| 183 | return-void |
| 184 | .end method |
| 185 | |
| 186 | .method public static callMain(LMain;)V |
| 187 | .locals 2 |
| 188 | sget-object v1, Ljava/lang/System;->out:Ljava/io/PrintStream; |
| 189 | const-string v0, "Calling non-conflicting function on Main" |
| 190 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 191 | |
| 192 | invoke-virtual {p0}, LMain;->charge()Ljava/lang/String; |
| 193 | move-result-object v0 |
| 194 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 195 | |
| 196 | const-string v0, "Calling conflicting function on Main" |
| 197 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 198 | :try_start |
| 199 | invoke-virtual {p0}, LMain;->sayHi()Ljava/lang/String; |
| 200 | move-result-object v0 |
| 201 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 202 | |
| 203 | const-string v0, "Unexpected no error Thrown on Main" |
| 204 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 205 | |
| 206 | goto :error_end |
| 207 | :try_end |
| 208 | .catch Ljava/lang/AbstractMethodError; {:try_start .. :try_end} :AME_error_start |
| 209 | .catch Ljava/lang/IncompatibleClassChangeError; {:try_start .. :try_end} :ICCE_error_start |
| 210 | :AME_error_start |
| 211 | const-string v0, "Unexpected AME Thrown on Main" |
| 212 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 213 | goto :error_end |
| 214 | :ICCE_error_start |
| 215 | const-string v0, "Expected ICCE Thrown on Main" |
| 216 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 217 | goto :error_end |
| 218 | :error_end |
| 219 | const-string v0, "Calling non-conflicting function on Main" |
| 220 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 221 | |
| 222 | invoke-virtual {p0}, LMain;->charge()Ljava/lang/String; |
| 223 | move-result-object v0 |
| 224 | invoke-virtual {v1,v0}, Ljava/io/PrintStream;->println(Ljava/lang/Object;)V |
| 225 | |
| 226 | return-void |
| 227 | .end method |