Add tests for accessing referrer's class.

Prepare for improving codegen for accessing referrer's class
from unresolved compiling class by improving test coverage.
The disabled CHECK statements show the intended results.

Test: Additional tests in 727-checker-unresolved-class.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 161898207
Change-Id: I7473d2693060b843670ea81f5f0e7bbb3c2d9031
diff --git a/test/727-checker-unresolved-class/expected.txt b/test/727-checker-unresolved-class/expected.txt
index 2fbc3f4..b33a798 100644
--- a/test/727-checker-unresolved-class/expected.txt
+++ b/test/727-checker-unresolved-class/expected.txt
@@ -1,5 +1,6 @@
 ResolvedPackagePrivateClass.$noinline$publicStaticMethod()
 UnresolvedPublicClass passed
+UnresolvedPackagePrivateClass passed
 ResolvedPackagePrivateClass.$noinline$publicStaticMethod()
 ResolvedPackagePrivateClass.$noinline$publicStaticMethod()
 ResolvedPackagePrivateClass.$noinline$staticMethod()
@@ -7,3 +8,5 @@
 PublicSubclassOfUnresolvedClass passed
 ResolvedPackagePrivateClass.$noinline$publicStaticMethod()
 PublicSubclassOfUnresolvedClass2 passed
+PackagePrivateSubclassOfUnresolvedClass passed
+PackagePrivateSubclassOfUnresolvedClass2 passed
diff --git a/test/727-checker-unresolved-class/jasmin/GetPackagePrivateSubclassOfUnresolvedClass2FromSamePackage.j b/test/727-checker-unresolved-class/jasmin/GetPackagePrivateSubclassOfUnresolvedClass2FromSamePackage.j
new file mode 100644
index 0000000..0add87b
--- /dev/null
+++ b/test/727-checker-unresolved-class/jasmin/GetPackagePrivateSubclassOfUnresolvedClass2FromSamePackage.j
@@ -0,0 +1,27 @@
+; Copyright (C) 2020 The Android Open Source Project
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+
+.bytecode 49.0
+
+.class                   public resolved/GetPackagePrivateSubclassOfUnresolvedClass2FromSamePackage
+.super                   java/lang/Object
+
+; TODO: Make $inline$ when we relax the verifier. b/28313047
+.method                  public static get()Ljava/lang/Class;
+  .limit stack           1
+  .limit locals          0
+  ; Fail to resolve class in same literal package but defined in child ClassLoader.
+  ldc resolved/PackagePrivateSubclassOfUnresolvedClass2
+  areturn
+.end method
diff --git a/test/727-checker-unresolved-class/jasmin/GetPublicSubclassOfUnresolvedClass2FromSamePackage.j b/test/727-checker-unresolved-class/jasmin/GetPublicSubclassOfUnresolvedClass2FromSamePackage.j
new file mode 100644
index 0000000..0868365
--- /dev/null
+++ b/test/727-checker-unresolved-class/jasmin/GetPublicSubclassOfUnresolvedClass2FromSamePackage.j
@@ -0,0 +1,27 @@
+; Copyright (C) 2020 The Android Open Source Project
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+
+.bytecode 49.0
+
+.class                   public resolved/GetPublicSubclassOfUnresolvedClass2FromSamePackage
+.super                   java/lang/Object
+
+; TODO: Make $inline$ when we relax the verifier. b/28313047
+.method                  public static get()Ljava/lang/Class;
+  .limit stack           1
+  .limit locals          0
+  ; Fail to resolve class in same literal package but defined in child ClassLoader.
+  ldc resolved/PublicSubclassOfUnresolvedClass2
+  areturn
+.end method
diff --git a/test/727-checker-unresolved-class/src-ex/Test.java b/test/727-checker-unresolved-class/src-ex/Test.java
index 839de6d..54d7b8d 100644
--- a/test/727-checker-unresolved-class/src-ex/Test.java
+++ b/test/727-checker-unresolved-class/src-ex/Test.java
@@ -14,14 +14,20 @@
  * limitations under the License.
  */
 
+import resolved.PackagePrivateSubclassOfUnresolvedClassProxy;
+import resolved.PackagePrivateSubclassOfUnresolvedClass2Proxy;
 import resolved.PublicSubclassOfUnresolvedClass;
 import resolved.PublicSubclassOfUnresolvedClass2;
+import unresolved.UnresolvedPackagePrivateClassProxy;
 import unresolved.UnresolvedPublicClass;
 
 public class Test {
   public static void $noinline$main() {
     UnresolvedPublicClass.$noinline$main();
+    UnresolvedPackagePrivateClassProxy.$noinline$main();
     PublicSubclassOfUnresolvedClass.$noinline$main();
     PublicSubclassOfUnresolvedClass2.$noinline$main();
+    PackagePrivateSubclassOfUnresolvedClassProxy.$noinline$main();
+    PackagePrivateSubclassOfUnresolvedClass2Proxy.$noinline$main();
   }
 }
diff --git a/test/727-checker-unresolved-class/src-ex/getters/GetPackagePrivateSubclassOfUnresolvedClass2.java b/test/727-checker-unresolved-class/src-ex/getters/GetPackagePrivateSubclassOfUnresolvedClass2.java
new file mode 100644
index 0000000..41ba071
--- /dev/null
+++ b/test/727-checker-unresolved-class/src-ex/getters/GetPackagePrivateSubclassOfUnresolvedClass2.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package getters;
+
+import resolved.PackagePrivateSubclassOfUnresolvedClass2;
+
+public class GetPackagePrivateSubclassOfUnresolvedClass2 {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return PackagePrivateSubclassOfUnresolvedClass2.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src-ex/getters/GetPublicSubclassOfUnresolvedClass2.java b/test/727-checker-unresolved-class/src-ex/getters/GetPublicSubclassOfUnresolvedClass2.java
new file mode 100644
index 0000000..9020f97
--- /dev/null
+++ b/test/727-checker-unresolved-class/src-ex/getters/GetPublicSubclassOfUnresolvedClass2.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package getters;
+
+import resolved.PublicSubclassOfUnresolvedClass2;
+
+public class GetPublicSubclassOfUnresolvedClass2 {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return PublicSubclassOfUnresolvedClass2.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src-ex/resolved/PackagePrivateSubclassOfUnresolvedClass2.java b/test/727-checker-unresolved-class/src-ex/resolved/PackagePrivateSubclassOfUnresolvedClass2.java
new file mode 100644
index 0000000..3f0bc05
--- /dev/null
+++ b/test/727-checker-unresolved-class/src-ex/resolved/PackagePrivateSubclassOfUnresolvedClass2.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+import getters.GetPackagePrivateSubclassOfUnresolvedClass2;
+import unresolved.UnresolvedPublicClass;
+
+// This class is used for compiling code that accesses it but it is
+// replaced by a package-private class from src-ex2/ with reduced access
+// to run tests, including access check tests.
+public class PackagePrivateSubclassOfUnresolvedClass2 extends UnresolvedPublicClass {
+  public static void $noinline$main() {
+    throw new Error("Unreachable");
+  }
+}
diff --git a/test/727-checker-unresolved-class/src-ex/resolved/PackagePrivateSubclassOfUnresolvedClass2Proxy.java b/test/727-checker-unresolved-class/src-ex/resolved/PackagePrivateSubclassOfUnresolvedClass2Proxy.java
new file mode 100644
index 0000000..a6dc803
--- /dev/null
+++ b/test/727-checker-unresolved-class/src-ex/resolved/PackagePrivateSubclassOfUnresolvedClass2Proxy.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+public class PackagePrivateSubclassOfUnresolvedClass2Proxy
+    extends PackagePrivateSubclassOfUnresolvedClass2 {
+}
diff --git a/test/727-checker-unresolved-class/src-ex/resolved/PublicSubclassOfUnresolvedClass2.java b/test/727-checker-unresolved-class/src-ex/resolved/PublicSubclassOfUnresolvedClass2.java
index 4846c2d..8dcc2e4 100644
--- a/test/727-checker-unresolved-class/src-ex/resolved/PublicSubclassOfUnresolvedClass2.java
+++ b/test/727-checker-unresolved-class/src-ex/resolved/PublicSubclassOfUnresolvedClass2.java
@@ -16,6 +16,7 @@
 
 package resolved;
 
+import getters.GetPublicSubclassOfUnresolvedClass2;
 import unresolved.UnresolvedPublicClass;
 
 // This class is defined by the child class loader, so access to
@@ -23,6 +24,10 @@
 // loader is illegal even though the package name is the same.
 public class PublicSubclassOfUnresolvedClass2 extends UnresolvedPublicClass {
   public static void $noinline$main() {
+    $noinline$testReferrersClass();
+    $noinline$testInlinedReferrersClass();
+    $noinline$testInlinedReferrersClassFromSamePackage();
+
     $noinline$testResolvedPublicClass();
     $noinline$testResolvedPackagePrivateClass();
 
@@ -43,6 +48,30 @@
     System.out.println("PublicSubclassOfUnresolvedClass2 passed");
   }
 
+  /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass2.$noinline$testReferrersClass() builder (after)
+  // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass2 needs_access_check:false
+  static void $noinline$testReferrersClass() {
+    Class<?> c = PublicSubclassOfUnresolvedClass2.class;
+  }
+
+  /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass2.$noinline$testInlinedReferrersClass() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass2 needs_access_check:false
+  static void $noinline$testInlinedReferrersClass() {
+    // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+    Class<?> c = GetPublicSubclassOfUnresolvedClass2.get();
+  }
+
+  /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass2.$noinline$testInlinedReferrersClassFromSamePackage() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass2 needs_access_check:true
+  static void $noinline$testInlinedReferrersClassFromSamePackage() {
+    // Trying to resolve this class by name in parent class loader throws NoClassDefFoundError.
+    try{
+      // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+      Class<?> c = GetPublicSubclassOfUnresolvedClass2FromSamePackage.get();
+      throw new Error("Unreachable");
+    } catch (NoClassDefFoundError expected) {}
+  }
+
   /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass2.$noinline$testResolvedPublicClass() builder (after)
   /// CHECK: LoadClass class_name:resolved.ResolvedPublicSubclassOfPackagePrivateClass needs_access_check:false
   static void $noinline$testResolvedPublicClass() {
diff --git a/test/727-checker-unresolved-class/src-ex2/resolved/PackagePrivateSubclassOfUnresolvedClass2.java b/test/727-checker-unresolved-class/src-ex2/resolved/PackagePrivateSubclassOfUnresolvedClass2.java
new file mode 100644
index 0000000..52e2448
--- /dev/null
+++ b/test/727-checker-unresolved-class/src-ex2/resolved/PackagePrivateSubclassOfUnresolvedClass2.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+import getters.GetPackagePrivateSubclassOfUnresolvedClass2;
+import unresolved.UnresolvedPublicClass;
+
+// This class is defined by the child class loader, so access to
+// package-private classes and members defined in the parent class
+// loader is illegal even though the package name is the same.
+public class PackagePrivateSubclassOfUnresolvedClass2 extends UnresolvedPublicClass {
+  public static void $noinline$main() {
+    $noinline$testReferrersClass();
+    $noinline$testInlinedReferrersClass();
+    $noinline$testInlinedReferrersClassFromSamePackage();
+
+    System.out.println("PackagePrivateSubclassOfUnresolvedClass2 passed");
+  }
+
+  /// CHECK-START: void resolved.PackagePrivateSubclassOfUnresolvedClass2.$noinline$testReferrersClass() builder (after)
+  // CHECK: LoadClass class_name:resolved.PackagePrivateSubclassOfUnresolvedClass2 needs_access_check:false
+  static void $noinline$testReferrersClass() {
+    Class<?> c = PackagePrivateSubclassOfUnresolvedClass2.class;
+  }
+
+  /// CHECK-START: void resolved.PackagePrivateSubclassOfUnresolvedClass2.$noinline$testInlinedReferrersClass() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PackagePrivateSubclassOfUnresolvedClass2 needs_access_check:true
+  static void $noinline$testInlinedReferrersClass() {
+    // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+    Class<?> c = GetPackagePrivateSubclassOfUnresolvedClass2.get();
+  }
+
+  /// CHECK-START: void resolved.PackagePrivateSubclassOfUnresolvedClass2.$noinline$testInlinedReferrersClassFromSamePackage() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PackagePrivateSubclassOfUnresolvedClass2 needs_access_check:true
+  static void $noinline$testInlinedReferrersClassFromSamePackage() {
+    // Trying to resolve this class by name in parent class loader throws NoClassDefFoundError.
+    try {
+      // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+      Class<?> c = GetPackagePrivateSubclassOfUnresolvedClass2FromSamePackage.get();
+      throw new Error("Unreachable");
+    } catch (NoClassDefFoundError expected) {}
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/getters/GetPackagePrivateSubclassOfUnresolvedClass.java b/test/727-checker-unresolved-class/src/getters/GetPackagePrivateSubclassOfUnresolvedClass.java
new file mode 100644
index 0000000..cf79d80
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/getters/GetPackagePrivateSubclassOfUnresolvedClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package getters;
+
+import resolved.PackagePrivateSubclassOfUnresolvedClass;
+
+public class GetPackagePrivateSubclassOfUnresolvedClass {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return PackagePrivateSubclassOfUnresolvedClass.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/getters/GetPublicSubclassOfUnresolvedClass.java b/test/727-checker-unresolved-class/src/getters/GetPublicSubclassOfUnresolvedClass.java
new file mode 100644
index 0000000..099fd53
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/getters/GetPublicSubclassOfUnresolvedClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package getters;
+
+import resolved.PublicSubclassOfUnresolvedClass;
+
+public class GetPublicSubclassOfUnresolvedClass {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return PublicSubclassOfUnresolvedClass.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/getters/GetUnresolvedPackagePrivateClass.java b/test/727-checker-unresolved-class/src/getters/GetUnresolvedPackagePrivateClass.java
new file mode 100644
index 0000000..356d0e0
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/getters/GetUnresolvedPackagePrivateClass.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package getters;
+
+import unresolved.UnresolvedPackagePrivateClass;
+
+public class GetUnresolvedPackagePrivateClass {
+  // TODO: When we relax verifier to ignore access check failures,
+  // change this method to `$inline$`.
+  public static Class<?> get() {
+    return UnresolvedPackagePrivateClass.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/getters/GetUnresolvedPublicClass.java b/test/727-checker-unresolved-class/src/getters/GetUnresolvedPublicClass.java
new file mode 100644
index 0000000..2c0bb0b
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/getters/GetUnresolvedPublicClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package getters;
+
+import unresolved.UnresolvedPublicClass;
+
+public class GetUnresolvedPublicClass {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return UnresolvedPublicClass.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/resolved/GetPackagePrivateSubclassOfUnresolvedClassFromSamePackage.java b/test/727-checker-unresolved-class/src/resolved/GetPackagePrivateSubclassOfUnresolvedClassFromSamePackage.java
new file mode 100644
index 0000000..2c221c5
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/resolved/GetPackagePrivateSubclassOfUnresolvedClassFromSamePackage.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+public class GetPackagePrivateSubclassOfUnresolvedClassFromSamePackage {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return PackagePrivateSubclassOfUnresolvedClass.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/resolved/GetPublicSubclassOfUnresolvedClassFromSamePackage.java b/test/727-checker-unresolved-class/src/resolved/GetPublicSubclassOfUnresolvedClassFromSamePackage.java
new file mode 100644
index 0000000..6874906
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/resolved/GetPublicSubclassOfUnresolvedClassFromSamePackage.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+public class GetPublicSubclassOfUnresolvedClassFromSamePackage {
+  // TODO: Make $inline$ when we relax the verifier. b/28313047
+  public static Class<?> get() {
+    return PublicSubclassOfUnresolvedClass.class;
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/resolved/PackagePrivateSubclassOfUnresolvedClass.java b/test/727-checker-unresolved-class/src/resolved/PackagePrivateSubclassOfUnresolvedClass.java
new file mode 100644
index 0000000..7ba0c2c
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/resolved/PackagePrivateSubclassOfUnresolvedClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+// This class is used for compiling code that accesses it but it is
+// replaced by a package-private class from src2/ with reduced access
+// to run tests, including access check tests.
+public class PackagePrivateSubclassOfUnresolvedClass {
+  public static void $noinline$main() {
+    throw new Error("Unreachable");
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/resolved/PackagePrivateSubclassOfUnresolvedClassProxy.java b/test/727-checker-unresolved-class/src/resolved/PackagePrivateSubclassOfUnresolvedClassProxy.java
new file mode 100644
index 0000000..8d07de6
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/resolved/PackagePrivateSubclassOfUnresolvedClassProxy.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+public class PackagePrivateSubclassOfUnresolvedClassProxy
+    extends PackagePrivateSubclassOfUnresolvedClass {
+}
diff --git a/test/727-checker-unresolved-class/src/resolved/PublicSubclassOfUnresolvedClass.java b/test/727-checker-unresolved-class/src/resolved/PublicSubclassOfUnresolvedClass.java
index fc9d24d..168853c 100644
--- a/test/727-checker-unresolved-class/src/resolved/PublicSubclassOfUnresolvedClass.java
+++ b/test/727-checker-unresolved-class/src/resolved/PublicSubclassOfUnresolvedClass.java
@@ -16,10 +16,15 @@
 
 package resolved;
 
+import getters.GetPublicSubclassOfUnresolvedClass;
 import unresolved.UnresolvedPublicClass;
 
 public class PublicSubclassOfUnresolvedClass extends UnresolvedPublicClass {
   public static void $noinline$main() {
+    $noinline$testReferrersClass();
+    $noinline$testInlinedReferrersClass();
+    $noinline$testInlinedReferrersClassFromSamePackage();
+
     $noinline$testResolvedPublicClass();
     $noinline$testResolvedPackagePrivateClass();
 
@@ -40,6 +45,26 @@
     System.out.println("PublicSubclassOfUnresolvedClass passed");
   }
 
+  /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testReferrersClass() builder (after)
+  // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass needs_access_check:false
+  static void $noinline$testReferrersClass() {
+    Class<?> c = PublicSubclassOfUnresolvedClass.class;
+  }
+
+  /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testInlinedReferrersClass() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass needs_access_check:false
+  static void $noinline$testInlinedReferrersClass() {
+    // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+    Class<?> c = GetPublicSubclassOfUnresolvedClass.get();
+  }
+
+  /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testInlinedReferrersClassFromSamePackage() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PublicSubclassOfUnresolvedClass needs_access_check:false
+  static void $noinline$testInlinedReferrersClassFromSamePackage() {
+    // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+    Class<?> c = GetPublicSubclassOfUnresolvedClassFromSamePackage.get();
+  }
+
   /// CHECK-START: void resolved.PublicSubclassOfUnresolvedClass.$noinline$testResolvedPublicClass() builder (after)
   /// CHECK: LoadClass class_name:resolved.ResolvedPublicSubclassOfPackagePrivateClass needs_access_check:false
   static void $noinline$testResolvedPublicClass() {
diff --git a/test/727-checker-unresolved-class/src/resolved/ResolvedPackagePrivateClass.java b/test/727-checker-unresolved-class/src/resolved/ResolvedPackagePrivateClass.java
index 132e967..0c7d055 100644
--- a/test/727-checker-unresolved-class/src/resolved/ResolvedPackagePrivateClass.java
+++ b/test/727-checker-unresolved-class/src/resolved/ResolvedPackagePrivateClass.java
@@ -20,19 +20,19 @@
 // replaced by a package-private class from src2/ with reduced access to
 // some members to test different access checks.
 public class ResolvedPackagePrivateClass {
-    public static int publicIntField;
-    public static int privateIntField;
-    public static int intField;
+  public static int publicIntField;
+  public static int privateIntField;
+  public static int intField;
 
-    public static void $noinline$publicStaticMethod() {
-      System.out.println("ResolvedPackagePrivateClass.$noinline$publicStaticMethod()");
-    }
+  public static void $noinline$publicStaticMethod() {
+    System.out.println("ResolvedPackagePrivateClass.$noinline$publicStaticMethod()");
+  }
 
-    public static void $noinline$privateStaticMethod() {
-      System.out.println("ResolvedPackagePrivateClass.$noinline$privateStaticMethod()");
-    }
+  public static void $noinline$privateStaticMethod() {
+    System.out.println("ResolvedPackagePrivateClass.$noinline$privateStaticMethod()");
+  }
 
-    public static void $noinline$staticMethod() {
-      System.out.println("ResolvedPackagePrivateClass.$noinline$staticMethod()");
-    }
+  public static void $noinline$staticMethod() {
+    System.out.println("ResolvedPackagePrivateClass.$noinline$staticMethod()");
+  }
 }
diff --git a/test/727-checker-unresolved-class/src/unresolved/UnresolvedPackagePrivateClass.java b/test/727-checker-unresolved-class/src/unresolved/UnresolvedPackagePrivateClass.java
new file mode 100644
index 0000000..b5ed7ff
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/unresolved/UnresolvedPackagePrivateClass.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package unresolved;
+
+// This class is used for compiling code that accesses it but it is
+// replaced by a package-private class from src2/ with reduced access
+// to run tests, including access check tests.
+public class UnresolvedPackagePrivateClass {
+  public static void $noinline$main() {
+    throw new Error("Unreachable");
+  }
+}
diff --git a/test/727-checker-unresolved-class/src/unresolved/UnresolvedPackagePrivateClassProxy.java b/test/727-checker-unresolved-class/src/unresolved/UnresolvedPackagePrivateClassProxy.java
new file mode 100644
index 0000000..b880a87
--- /dev/null
+++ b/test/727-checker-unresolved-class/src/unresolved/UnresolvedPackagePrivateClassProxy.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package unresolved;
+
+public class UnresolvedPackagePrivateClassProxy extends UnresolvedPackagePrivateClass {
+}
diff --git a/test/727-checker-unresolved-class/src/unresolved/UnresolvedPublicClass.java b/test/727-checker-unresolved-class/src/unresolved/UnresolvedPublicClass.java
index 477425c..8bbe4f6 100644
--- a/test/727-checker-unresolved-class/src/unresolved/UnresolvedPublicClass.java
+++ b/test/727-checker-unresolved-class/src/unresolved/UnresolvedPublicClass.java
@@ -16,11 +16,15 @@
 
 package unresolved;
 
+import getters.GetUnresolvedPublicClass;
 import resolved.ResolvedPackagePrivateClass;
 import resolved.ResolvedPublicSubclassOfPackagePrivateClass;
 
 public class UnresolvedPublicClass {
   public static void $noinline$main() {
+    $noinline$testReferrersClass();
+    $noinline$testInlinedReferrersClass();
+
     $noinline$testResolvedPublicClass();
     $noinline$testResolvedPackagePrivateClass();
 
@@ -41,6 +45,19 @@
     System.out.println("UnresolvedPublicClass passed");
   }
 
+  /// CHECK-START: void unresolved.UnresolvedPublicClass.$noinline$testReferrersClass() builder (after)
+  // CHECK: LoadClass class_name:unresolved.UnresolvedPublicClass needs_access_check:false
+  static void $noinline$testReferrersClass() {
+    Class<?> c = UnresolvedPublicClass.class;
+  }
+
+  /// CHECK-START: void unresolved.UnresolvedPublicClass.$noinline$testInlinedReferrersClass() inliner (after)
+  // CHECK: LoadClass class_name:unresolved.UnresolvedPublicClass needs_access_check:false
+  static void $noinline$testInlinedReferrersClass() {
+    // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+    Class<?> c = GetUnresolvedPublicClass.get();
+  }
+
   /// CHECK-START: void unresolved.UnresolvedPublicClass.$noinline$testResolvedPublicClass() builder (after)
   /// CHECK: LoadClass class_name:resolved.ResolvedPublicSubclassOfPackagePrivateClass needs_access_check:false
   static void $noinline$testResolvedPublicClass() {
diff --git a/test/727-checker-unresolved-class/src2/resolved/PackagePrivateSubclassOfUnresolvedClass.java b/test/727-checker-unresolved-class/src2/resolved/PackagePrivateSubclassOfUnresolvedClass.java
new file mode 100644
index 0000000..ce94cce
--- /dev/null
+++ b/test/727-checker-unresolved-class/src2/resolved/PackagePrivateSubclassOfUnresolvedClass.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package resolved;
+
+import getters.GetPackagePrivateSubclassOfUnresolvedClass;
+import unresolved.UnresolvedPublicClass;
+
+class PackagePrivateSubclassOfUnresolvedClass extends UnresolvedPublicClass {
+  public static void $noinline$main() {
+    $noinline$testReferrersClass();
+    $noinline$testInlinedReferrersClass();
+    $noinline$testInlinedReferrersClassFromSamePackage();
+
+    System.out.println("PackagePrivateSubclassOfUnresolvedClass passed");
+  }
+
+  /// CHECK-START: void resolved.PackagePrivateSubclassOfUnresolvedClass.$noinline$testReferrersClass() builder (after)
+  // CHECK: LoadClass class_name:resolved.PackagePrivateSubclassOfUnresolvedClass needs_access_check:false
+  static void $noinline$testReferrersClass() {
+    Class<?> c = PackagePrivateSubclassOfUnresolvedClass.class;
+  }
+
+  /// CHECK-START: void resolved.PackagePrivateSubclassOfUnresolvedClass.$noinline$testInlinedReferrersClass() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PackagePrivateSubclassOfUnresolvedClass needs_access_check:true
+  static void $noinline$testInlinedReferrersClass() {
+    try {
+      // TODO: Make $inline$ and enable CHECK above when we relax the verifier. b/28313047
+      Class<?> c = GetPackagePrivateSubclassOfUnresolvedClass.get();
+      throw new Error("Unreachable");
+    } catch (IllegalAccessError expected) {}
+  }
+
+  /// CHECK-START: void resolved.PackagePrivateSubclassOfUnresolvedClass.$noinline$testInlinedReferrersClassFromSamePackage() inliner (after)
+  // CHECK: LoadClass class_name:resolved.PackagePrivateSubclassOfUnresolvedClass needs_access_check:false
+  static void $noinline$testInlinedReferrersClassFromSamePackage() {
+    Class<?> c = GetPackagePrivateSubclassOfUnresolvedClassFromSamePackage.get();
+  }
+}
diff --git a/test/727-checker-unresolved-class/src2/unresolved/UnresolvedPackagePrivateClass.java b/test/727-checker-unresolved-class/src2/unresolved/UnresolvedPackagePrivateClass.java
new file mode 100644
index 0000000..81a76a1
--- /dev/null
+++ b/test/727-checker-unresolved-class/src2/unresolved/UnresolvedPackagePrivateClass.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package unresolved;
+
+import getters.GetUnresolvedPackagePrivateClass;
+
+class UnresolvedPackagePrivateClass {
+  public static void $noinline$main() {
+    $noinline$testReferrersClass();
+    $noinline$testInlinedReferrersClass();
+
+    System.out.println("UnresolvedPackagePrivateClass passed");
+  }
+
+  /// CHECK-START: void unresolved.UnresolvedPackagePrivateClass.$noinline$testReferrersClass() builder (after)
+  // CHECK: LoadClass class_name:unresolved.UnresolvedPackagePrivateClass needs_access_check:false
+  static void $noinline$testReferrersClass() {
+    Class<?> c = UnresolvedPackagePrivateClass.class;
+  }
+
+  /// CHECK-START: void unresolved.UnresolvedPackagePrivateClass.$noinline$testInlinedReferrersClass() inliner (after)
+  // CHECK: LoadClass class_name:unresolved.UnresolvedPackagePrivateClass needs_access_check:true
+  static void $noinline$testInlinedReferrersClass() {
+    try {
+      // TODO: When we relax verifier to ignore access check failures,
+      // change the called method to `$inline$` and enable the CHECK above.
+      Class<?> c = GetUnresolvedPackagePrivateClass.get();
+      throw new Error("Unreachable");
+    } catch (IllegalAccessError expected) {}
+  }
+}
diff --git a/test/etc/default-build b/test/etc/default-build
index 1122c01..03e029f 100755
--- a/test/etc/default-build
+++ b/test/etc/default-build
@@ -92,6 +92,12 @@
   HAS_SRC_EX=false
 fi
 
+if [ -d src-ex2 ]; then
+  HAS_SRC_EX2=true
+else
+  HAS_SRC_EX2=false
+fi
+
 if [ -d src-dex2oat-unresolved ]; then
   HAS_SRC_DEX2OAT_UNRESOLVED=true
 else
@@ -153,6 +159,9 @@
   elif [ "x$1" = "x--no-src-ex" ]; then
     HAS_SRC_EX=false
     shift
+  elif [ "x$1" = "x--no-src-ex2" ]; then
+    HAS_SRC_EX2=false
+    shift
   elif [ "x$1" = "x--no-smali" ]; then
     HAS_SMALI=false
     shift
@@ -411,7 +420,7 @@
   else
     # Move jasmin classes into classes directory so that they are picked up with -cp classes.
     mkdir -p classes
-    mv jasmin_classes/* classes
+    cp -r jasmin_classes/* classes/
   fi
 fi
 
@@ -447,21 +456,35 @@
   make_dexmerge classes2.dex smali_classes2.dex
 fi
 
-if [ ${HAS_SRC_EX} = "true" ]; then
+if [ ${HAS_SRC_EX} = "true" -o ${HAS_SRC_EX2} = "true" ]; then
   # Build src-ex into classes-ex.
-  # Includes 'src', 'src-art' source when compiling classes-ex, but exclude their .class files.
-  if [[ "${HAS_SRC}" == "true" ]]; then
+  # Includes 'src', 'src-art' and 'jasmin' source when compiling classes-ex,
+  # but exclude their .class files.
+  if [ "${HAS_SRC}" = "true" -o "${HAS_SRC_ART}" = "true" -o "${HAS_JASMIN}" = "true" ]; then
     mkdir -p classes-tmp-for-ex
-    javac_with_bootclasspath -d classes-tmp-for-ex `find src -name '*.java'`
     src_tmp_for_ex="-cp classes-tmp-for-ex"
   fi
+  if [[ "${HAS_SRC}" == "true" ]]; then
+    javac_with_bootclasspath -d classes-tmp-for-ex `find src -name '*.java'`
+  fi
   if [[ "${HAS_SRC_ART}" == "true" ]]; then
-    mkdir -p classes-tmp-for-ex
     javac_with_bootclasspath -d classes-tmp-for-ex `find src-art -name '*.java'`
-    src_tmp_for_ex="-cp classes-tmp-for-ex"
+  fi
+  if [[ "${HAS_JASMIN}" == "true" ]]; then
+    make_jasmin classes-tmp-for-ex $(find 'jasmin' -name '*.j')
   fi
   mkdir -p classes-ex
-  javac_with_bootclasspath -d classes-ex $src_tmp_for_ex `find src-ex -name '*.java'`
+  if [ ${HAS_SRC_EX} = "true" ]; then
+    javac_with_bootclasspath -d classes-ex $src_tmp_for_ex `find src-ex -name '*.java'`
+    if [[ "x$src_tmp_for_ex" = "x" ]]; then
+      src_tmp_for_ex="-cp classes-ex"
+    else
+      src_tmp_for_ex="$src_tmp_for_ex:classes-ex"
+    fi
+  fi
+  if [ ${HAS_SRC_EX2} = "true" ]; then
+    javac_with_bootclasspath -d classes-ex $src_tmp_for_ex `find src-ex2 -name '*.java'`
+  fi
 fi
 
 if [[ -d classes-ex ]] && [ ${NEED_DEX} = "true" ]; then
diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files
index 4a4bdfa..066d747 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -296,6 +296,7 @@
   [[ -d "$tests_dir/$run_test/jasmin-multidex" ]] && continue
   [[ -d "$tests_dir/$run_test/smali-ex" ]] && continue
   [[ -d "$tests_dir/$run_test/src-ex" ]] && continue
+  [[ -d "$tests_dir/$run_test/src-ex2" ]] && continue
   [[ -d "$tests_dir/$run_test/src-dex2oat-unresolved" ]] && continue
   # Ignore test with a copy of `sun.misc.Unsafe`.
   [[ -f "$tests_dir/$run_test/src/sun/misc/Unsafe.java" ]] && continue