summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sorin Basca <sorinbasca@google.com> 2024-11-20 17:24:25 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-21 11:07:20 +0000
commit52d7390bf9b6bb63304d80c052d2acc41ce49205 (patch)
tree7109399512556dcb6bc25623c01d0328f8e0dfa2
parent9d4c98438d4922c63b1947df96d4476839ef7279 (diff)
Fix the 918-fields test
The test relied on a synthetic field that the newer Java compiler was not generating since the field was not being used. In order to cause the synthetic generation of the field, which allows an inner class to refer to its parent, the inner class has been changed to have a reference to an outer field. Bug: 378676805 Test: atest CtsJvmtiRunTest918HostTestCases:android.jvmti.cts.JvmtiHostTest918#testJvmti Change-Id: I499154372fb4123c6ccd13e479cbeeb2a2ec1203
-rw-r--r--test/918-fields/expected-stdout.txt4
-rw-r--r--test/918-fields/src/art/Test918.java13
2 files changed, 14 insertions, 3 deletions
diff --git a/test/918-fields/expected-stdout.txt b/test/918-fields/expected-stdout.txt
index bd42f75f8a..0114ccc998 100644
--- a/test/918-fields/expected-stdout.txt
+++ b/test/918-fields/expected-stdout.txt
@@ -6,6 +6,10 @@ false
class java.io.InterruptedIOException
1
false
+[this$0, Lart/Test918;, null]
+class art.Test918$Foo
+4112
+true
[VAL, I, null]
interface art.Test918$Bar
25
diff --git a/test/918-fields/src/art/Test918.java b/test/918-fields/src/art/Test918.java
index 593c99c908..7d8050e453 100644
--- a/test/918-fields/src/art/Test918.java
+++ b/test/918-fields/src/art/Test918.java
@@ -28,8 +28,7 @@ public class Test918 {
public static void doTest() throws Exception {
testField(Math.class, "PI");
testField(InterruptedIOException.class, "bytesTransferred");
- // TODO(b/378676805): Update this check.
- // testField(Foo.class, "this$0");
+ testField(Foo.class, "this$0");
testField(Bar.class, "VAL");
testField(Generics.class, "generics");
testField(Generics.class, "privateValue");
@@ -65,7 +64,15 @@ public class Test918 {
private static native int getFieldModifiers(Field f);
private static native boolean isFieldSynthetic(Field f);
- private class Foo {}
+ private class Foo {
+ public void inc() {
+ // Touch a field in the outer class. Needed to avoid a javac optimization which removes
+ // the synthetic field that refers to the instance of the outer class (this$0).
+ fooVal++;
+ }
+ }
+
+ private int fooVal = 0;
private static interface Bar {
public static int VAL = 1;