Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [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 | public class Main extends UnresolvedSuperClass { |
| 18 | |
| 19 | /// CHECK-START: void Main.callInvokeUnresolvedStatic() register (before) |
| 20 | /// CHECK: InvokeUnresolved invoke_type:static |
| 21 | static public void callInvokeUnresolvedStatic() { |
| 22 | UnresolvedClass.staticMethod(); |
| 23 | } |
| 24 | |
| 25 | /// CHECK-START: void Main.callInvokeUnresolvedVirtual(UnresolvedClass) register (before) |
| 26 | /// CHECK: InvokeUnresolved invoke_type:virtual |
| 27 | static public void callInvokeUnresolvedVirtual(UnresolvedClass c) { |
| 28 | c.virtualMethod(); |
| 29 | } |
| 30 | |
| 31 | /// CHECK-START: void Main.callInvokeUnresolvedInterface(UnresolvedInterface) register (before) |
| 32 | /// CHECK: InvokeUnresolved invoke_type:interface |
| 33 | static public void callInvokeUnresolvedInterface(UnresolvedInterface c) { |
| 34 | c.interfaceMethod(); |
| 35 | } |
| 36 | |
| 37 | static public void callInvokeUnresolvedSuper(Main c) { |
| 38 | c.superMethod(); |
| 39 | } |
| 40 | |
| 41 | /// CHECK-START: void Main.superMethod() register (before) |
| 42 | /// CHECK: InvokeUnresolved invoke_type:super |
| 43 | public void superMethod() { |
| 44 | super.superMethod(); |
| 45 | } |
| 46 | |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame^] | 47 | /// CHECK-START: void Main.callUnresolvedStaticFieldAccess() register (before) |
| 48 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimByte |
| 49 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimChar |
| 50 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimInt |
| 51 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimLong |
| 52 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimFloat |
| 53 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimDouble |
| 54 | /// CHECK: UnresolvedStaticFieldSet field_type:PrimNot |
| 55 | |
| 56 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimByte |
| 57 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimChar |
| 58 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimInt |
| 59 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimLong |
| 60 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimFloat |
| 61 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimDouble |
| 62 | /// CHECK: UnresolvedStaticFieldGet field_type:PrimNot |
| 63 | static public void callUnresolvedStaticFieldAccess() { |
| 64 | Object o = new Object(); |
| 65 | UnresolvedClass.staticByte = (byte)1; |
| 66 | UnresolvedClass.staticChar = '1'; |
| 67 | UnresolvedClass.staticInt = 123456789; |
| 68 | UnresolvedClass.staticLong = 123456789123456789l; |
| 69 | UnresolvedClass.staticFloat = 123456789123456789f; |
| 70 | UnresolvedClass.staticDouble = 123456789123456789d; |
| 71 | UnresolvedClass.staticObject = o; |
| 72 | |
| 73 | expectEquals((byte)1, UnresolvedClass.staticByte); |
| 74 | expectEquals('1', UnresolvedClass.staticChar); |
| 75 | expectEquals(123456789, UnresolvedClass.staticInt); |
| 76 | expectEquals(123456789123456789l, UnresolvedClass.staticLong); |
| 77 | expectEquals(123456789123456789f, UnresolvedClass.staticFloat); |
| 78 | expectEquals(123456789123456789d, UnresolvedClass.staticDouble); |
| 79 | expectEquals(o, UnresolvedClass.staticObject); |
| 80 | } |
| 81 | |
| 82 | /// CHECK-START: void Main.callUnresolvedInstanceFieldAccess(UnresolvedClass) register (before) |
| 83 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimByte |
| 84 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimChar |
| 85 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimInt |
| 86 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimLong |
| 87 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimFloat |
| 88 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimDouble |
| 89 | /// CHECK: UnresolvedInstanceFieldSet field_type:PrimNot |
| 90 | |
| 91 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimByte |
| 92 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimChar |
| 93 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimInt |
| 94 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimLong |
| 95 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimFloat |
| 96 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimDouble |
| 97 | /// CHECK: UnresolvedInstanceFieldGet field_type:PrimNot |
| 98 | static public void callUnresolvedInstanceFieldAccess(UnresolvedClass c) { |
| 99 | Object o = new Object(); |
| 100 | c.instanceByte = (byte)1; |
| 101 | c.instanceChar = '1'; |
| 102 | c.instanceInt = 123456789; |
| 103 | c.instanceLong = 123456789123456789l; |
| 104 | c.instanceFloat = 123456789123456789f; |
| 105 | c.instanceDouble = 123456789123456789d; |
| 106 | c.instanceObject = o; |
| 107 | |
| 108 | expectEquals((byte)1, c.instanceByte); |
| 109 | expectEquals('1', c.instanceChar); |
| 110 | expectEquals(123456789, c.instanceInt); |
| 111 | expectEquals(123456789123456789l, c.instanceLong); |
| 112 | expectEquals(123456789123456789f, c.instanceFloat); |
| 113 | expectEquals(123456789123456789d, c.instanceDouble); |
| 114 | expectEquals(o, c.instanceObject); |
| 115 | } |
| 116 | |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 117 | /// CHECK-START: void Main.main(java.lang.String[]) register (before) |
| 118 | /// CHECK: InvokeUnresolved invoke_type:direct |
| 119 | static public void main(String[] args) { |
| 120 | UnresolvedClass c = new UnresolvedClass(); |
| 121 | callInvokeUnresolvedStatic(); |
| 122 | callInvokeUnresolvedVirtual(c); |
| 123 | callInvokeUnresolvedInterface(c); |
| 124 | callInvokeUnresolvedSuper(new Main()); |
Calin Juravle | e460d1d | 2015-09-29 04:52:17 +0100 | [diff] [blame^] | 125 | callUnresolvedStaticFieldAccess(); |
| 126 | callUnresolvedInstanceFieldAccess(c); |
| 127 | } |
| 128 | |
| 129 | public static void expectEquals(byte expected, byte result) { |
| 130 | if (expected != result) { |
| 131 | throw new Error("Expected: " + expected + ", found: " + result); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | public static void expectEquals(char expected, char result) { |
| 136 | if (expected != result) { |
| 137 | throw new Error("Expected: " + expected + ", found: " + result); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | public static void expectEquals(int expected, int result) { |
| 142 | if (expected != result) { |
| 143 | throw new Error("Expected: " + expected + ", found: " + result); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | public static void expectEquals(long expected, long result) { |
| 148 | if (expected != result) { |
| 149 | throw new Error("Expected: " + expected + ", found: " + result); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | public static void expectEquals(float expected, float result) { |
| 154 | if (expected != result) { |
| 155 | throw new Error("Expected: " + expected + ", found: " + result); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | public static void expectEquals(double expected, double result) { |
| 160 | if (expected != result) { |
| 161 | throw new Error("Expected: " + expected + ", found: " + result); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | public static void expectEquals(Object expected, Object result) { |
| 166 | if (expected != result) { |
| 167 | throw new Error("Expected: " + expected + ", found: " + result); |
| 168 | } |
Calin Juravle | 175dc73 | 2015-08-25 15:42:32 +0100 | [diff] [blame] | 169 | } |
| 170 | } |