1 /* 2 * Copyright (C) 2020 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 package resolved; 18 19 import getters.GetPublicSubclassOfUnresolvedClass; 20 import unresolved.UnresolvedPublicClass; 21 22 public class PublicSubclassOfUnresolvedClass extends UnresolvedPublicClass { $noinline$main()23 public static void $noinline$main() { 24 $noinline$testReferrersClass(); 25 $noinline$testInlinedReferrersClass(); 26 $noinline$testInlinedReferrersClassFromSamePackage(); 27 28 $noinline$testResolvedPublicClass(); 29 $noinline$testResolvedPackagePrivateClass(); 30 31 $noinline$testPublicFieldInResolvedPackagePrivateClass(); 32 $noinline$testPublicFieldInPackagePrivateClassViaResolvedPublicSubclass(); 33 $noinline$testPrivateFieldInResolvedPackagePrivateClass(); 34 $noinline$testPrivateFieldInPackagePrivateClassViaResolvedPublicSubclass(); 35 $noinline$testPackagePrivateFieldInResolvedPackagePrivateClass(); 36 $noinline$testPackagePrivateFieldInPackagePrivateClassViaResolvedPublicSubclass(); 37 38 $noinline$testPublicMethodInResolvedPackagePrivateClass(); 39 $noinline$testPublicMethodInPackagePrivateClassViaResolvedPublicSubclass(); 40 $noinline$testPrivateMethodInResolvedPackagePrivateClass(); 41 $noinline$testPrivateMethodInPackagePrivateClassViaResolvedPublicSubclass(); 42 $noinline$testPackagePrivateMethodInResolvedPackagePrivateClass(); 43 $noinline$testPackagePrivateMethodInPackagePrivateClassViaResolvedPublicSubclass(); 44 45 System.out.println("PublicSubclassOfUnresolvedClass passed"); 46 } 47 48 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testReferrersClass() builder (after) 49 /// CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass needs_access_check:false $noinline$testReferrersClass()50 static void $noinline$testReferrersClass() { 51 Class<?> c = PublicSubclassOfUnresolvedClass.class; 52 } 53 54 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testInlinedReferrersClass() inliner (after) 55 // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass needs_access_check:false $noinline$testInlinedReferrersClass()56 static void $noinline$testInlinedReferrersClass() { 57 // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047 58 Class<?> c = GetPublicSubclassOfUnresolvedClass.get(); 59 } 60 61 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testInlinedReferrersClassFromSamePackage() inliner (after) 62 // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass needs_access_check:false $noinline$testInlinedReferrersClassFromSamePackage()63 static void $noinline$testInlinedReferrersClassFromSamePackage() { 64 // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047 65 Class<?> c = GetPublicSubclassOfUnresolvedClassFromSamePackage.get(); 66 } 67 68 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testResolvedPublicClass() builder (after) 69 /// CHECK: LoadClass class_name:resolved.ResolvedPublicSubclassOfPackagePrivateClass needs_access_check:false $noinline$testResolvedPublicClass()70 static void $noinline$testResolvedPublicClass() { 71 Class<?> c = ResolvedPublicSubclassOfPackagePrivateClass.class; 72 } 73 74 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testResolvedPackagePrivateClass() builder (after) 75 /// CHECK: LoadClass class_name:resolved.ResolvedPackagePrivateClass needs_access_check:false $noinline$testResolvedPackagePrivateClass()76 static void $noinline$testResolvedPackagePrivateClass() { 77 Class<?> c = ResolvedPackagePrivateClass.class; 78 } 79 80 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicFieldInResolvedPackagePrivateClass() builder (after) 81 /// CHECK: StaticFieldSet 82 83 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicFieldInResolvedPackagePrivateClass() builder (after) 84 /// CHECK-NOT: UnresolvedStaticFieldSet $noinline$testPublicFieldInResolvedPackagePrivateClass()85 static void $noinline$testPublicFieldInResolvedPackagePrivateClass() { 86 ResolvedPackagePrivateClass.publicIntField = 42; 87 } 88 89 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicFieldInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 90 /// CHECK: StaticFieldSet 91 92 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicFieldInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 93 /// CHECK-NOT: UnresolvedStaticFieldSet $noinline$testPublicFieldInPackagePrivateClassViaResolvedPublicSubclass()94 static void $noinline$testPublicFieldInPackagePrivateClassViaResolvedPublicSubclass() { 95 ResolvedPublicSubclassOfPackagePrivateClass.publicIntField = 42; 96 } 97 98 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateFieldInResolvedPackagePrivateClass() builder (after) 99 /// CHECK: UnresolvedStaticFieldSet 100 101 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateFieldInResolvedPackagePrivateClass() builder (after) 102 /// CHECK-NOT: StaticFieldSet $noinline$testPrivateFieldInResolvedPackagePrivateClass()103 static void $noinline$testPrivateFieldInResolvedPackagePrivateClass() { 104 try { 105 ResolvedPackagePrivateClass.privateIntField = 42; 106 throw new Error("Unreachable"); 107 } catch (IllegalAccessError expected) {} 108 } 109 110 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateFieldInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 111 /// CHECK: UnresolvedStaticFieldSet 112 113 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateFieldInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 114 /// CHECK-NOT: StaticFieldSet $noinline$testPrivateFieldInPackagePrivateClassViaResolvedPublicSubclass()115 static void $noinline$testPrivateFieldInPackagePrivateClassViaResolvedPublicSubclass() { 116 try { 117 ResolvedPublicSubclassOfPackagePrivateClass.privateIntField = 42; 118 throw new Error("Unreachable"); 119 } catch (IllegalAccessError expected) {} 120 } 121 122 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateFieldInResolvedPackagePrivateClass() builder (after) 123 /// CHECK: StaticFieldSet 124 125 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateFieldInResolvedPackagePrivateClass() builder (after) 126 /// CHECK-NOT: UnresolvedStaticFieldSet $noinline$testPackagePrivateFieldInResolvedPackagePrivateClass()127 static void $noinline$testPackagePrivateFieldInResolvedPackagePrivateClass() { 128 ResolvedPackagePrivateClass.intField = 42; 129 } 130 131 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateFieldInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 132 /// CHECK: StaticFieldSet 133 134 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateFieldInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 135 /// CHECK-NOT: UnresolvedStaticFieldSet $noinline$testPackagePrivateFieldInPackagePrivateClassViaResolvedPublicSubclass()136 static void $noinline$testPackagePrivateFieldInPackagePrivateClassViaResolvedPublicSubclass() { 137 ResolvedPublicSubclassOfPackagePrivateClass.intField = 42; 138 } 139 140 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicMethodInResolvedPackagePrivateClass() builder (after) 141 /// CHECK: InvokeStaticOrDirect method_name:{{[^$]*}}$noinline$publicStaticMethod 142 143 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicMethodInResolvedPackagePrivateClass() builder (after) 144 /// CHECK-NOT: InvokeUnresolved method_name:{{[^$]*}}$noinline$publicStaticMethod $noinline$testPublicMethodInResolvedPackagePrivateClass()145 static void $noinline$testPublicMethodInResolvedPackagePrivateClass() { 146 ResolvedPackagePrivateClass.$noinline$publicStaticMethod(); 147 } 148 149 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicMethodInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 150 /// CHECK: InvokeStaticOrDirect method_name:{{[^$]*}}$noinline$publicStaticMethod 151 152 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPublicMethodInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 153 /// CHECK-NOT: InvokeUnresolved method_name:{{[^$]*}}$noinline$publicStaticMethod $noinline$testPublicMethodInPackagePrivateClassViaResolvedPublicSubclass()154 static void $noinline$testPublicMethodInPackagePrivateClassViaResolvedPublicSubclass() { 155 ResolvedPublicSubclassOfPackagePrivateClass.$noinline$publicStaticMethod(); 156 } 157 158 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateMethodInResolvedPackagePrivateClass() builder (after) 159 /// CHECK: InvokeUnresolved method_name:{{[^$]*}}$noinline$privateStaticMethod 160 161 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateMethodInResolvedPackagePrivateClass() builder (after) 162 /// CHECK-NOT: InvokeStaticOrDirect method_name:{{[^$]*}}$noinline$privateStaticMethod $noinline$testPrivateMethodInResolvedPackagePrivateClass()163 static void $noinline$testPrivateMethodInResolvedPackagePrivateClass() { 164 try { 165 ResolvedPackagePrivateClass.$noinline$privateStaticMethod(); 166 throw new Error("Unreachable"); 167 } catch (IllegalAccessError expected) {} 168 } 169 170 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateMethodInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 171 /// CHECK: InvokeUnresolved method_name:{{[^$]*}}$noinline$privateStaticMethod 172 173 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPrivateMethodInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 174 /// CHECK-NOT: InvokeStaticOrDirect method_name:{{[^$]*}}$noinline$privateStaticMethod $noinline$testPrivateMethodInPackagePrivateClassViaResolvedPublicSubclass()175 static void $noinline$testPrivateMethodInPackagePrivateClassViaResolvedPublicSubclass() { 176 try { 177 ResolvedPublicSubclassOfPackagePrivateClass.$noinline$privateStaticMethod(); 178 throw new Error("Unreachable"); 179 } catch (IllegalAccessError expected) {} 180 } 181 182 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateMethodInResolvedPackagePrivateClass() builder (after) 183 /// CHECK: InvokeStaticOrDirect method_name:{{[^$]*}}$noinline$staticMethod 184 185 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateMethodInResolvedPackagePrivateClass() builder (after) 186 /// CHECK-NOT: InvokeUnresolved method_name:{{[^$]*}}$noinline$staticMethod $noinline$testPackagePrivateMethodInResolvedPackagePrivateClass()187 static void $noinline$testPackagePrivateMethodInResolvedPackagePrivateClass() { 188 ResolvedPackagePrivateClass.$noinline$staticMethod(); 189 } 190 191 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateMethodInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 192 /// CHECK: InvokeStaticOrDirect method_name:{{[^$]*}}$noinline$staticMethod 193 194 /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testPackagePrivateMethodInPackagePrivateClassViaResolvedPublicSubclass() builder (after) 195 /// CHECK-NOT: InvokeUnresolved method_name:{{[^$]*}}$noinline$staticMethod $noinline$testPackagePrivateMethodInPackagePrivateClassViaResolvedPublicSubclass()196 static void $noinline$testPackagePrivateMethodInPackagePrivateClassViaResolvedPublicSubclass() { 197 ResolvedPublicSubclassOfPackagePrivateClass.$noinline$staticMethod(); 198 } 199 } 200