Move record test to java 17 package
Bug: b/363926134
Change-Id: I8d0749abe1f8ae55cd3a34166b443d7aabf67e67
diff --git a/src/test/examplesJava17/records/RecordComponentAnnotationsTest.java b/src/test/examplesJava17/records/RecordComponentAnnotationsTest.java
new file mode 100644
index 0000000..8aba71c
--- /dev/null
+++ b/src/test/examplesJava17/records/RecordComponentAnnotationsTest.java
@@ -0,0 +1,476 @@
+// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package records;
+
+import static com.android.tools.r8.utils.codeinspector.AnnotationMatchers.hasAnnotationTypes;
+import static com.android.tools.r8.utils.codeinspector.AnnotationMatchers.hasElements;
+import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndNotRenamed;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeTrue;
+
+import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestRuntime.CfVm;
+import com.android.tools.r8.TestShrinkerBuilder;
+import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.utils.BooleanUtils;
+import com.android.tools.r8.utils.Pair;
+import com.android.tools.r8.utils.StringUtils;
+import com.android.tools.r8.utils.codeinspector.ClassSubject;
+import com.android.tools.r8.utils.codeinspector.FieldSubject;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Field;
+import java.lang.reflect.RecordComponent;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+public class RecordComponentAnnotationsTest extends TestBase {
+
+ private static final String JVM_UNTIL_20_EXPECTED_RESULT =
+ StringUtils.lines(
+ "Jane Doe",
+ "42",
+ "true",
+ "2",
+ "name",
+ "java.lang.String",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"a\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(\"c\")",
+ "age",
+ "int",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"x\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(\"z\")",
+ "2",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"x\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(\"y\")",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"a\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(\"b\")");
+ private static final String JVM_FROM_21_EXPECTED_RESULT =
+ JVM_UNTIL_20_EXPECTED_RESULT.replaceAll(
+ "records.RecordComponentAnnotationsTest\\$Annotation",
+ "records.RecordComponentAnnotationsTest.Annotation");
+ private static final String ART_EXPECTED_RESULT =
+ StringUtils.lines(
+ "Jane Doe",
+ "42",
+ "true",
+ "2",
+ "name",
+ "java.lang.String",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=a)",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(value=c)",
+ "age",
+ "int",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=x)",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(value=z)",
+ "2",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=x)",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(value=y)",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=a)",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(value=b)");
+ private static final String JVM_EXPECTED_RESULT_R8 =
+ StringUtils.lines(
+ "Jane Doe",
+ "42",
+ "true",
+ "2",
+ "a",
+ "java.lang.String",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"a\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(\"c\")",
+ "b",
+ "int",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"x\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(\"z\")",
+ "2",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"a\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(\"b\")",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"x\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(\"y\")");
+ private static final String ART_EXPECTED_RESULT_R8 =
+ StringUtils.lines(
+ "Jane Doe",
+ "42",
+ "true",
+ "2",
+ "a",
+ "java.lang.String",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=a)",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(value=c)",
+ "b",
+ "int",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=x)",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(value=z)",
+ "2",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=a)",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(value=b)",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=x)",
+ "@records.RecordComponentAnnotationsTest$AnnotationFieldOnly(value=y)");
+ private static final String JVM_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS =
+ StringUtils.lines(
+ "Jane Doe",
+ "42",
+ "true",
+ "2",
+ "a",
+ "java.lang.String",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"a\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(\"c\")",
+ "b",
+ "int",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(\"x\")",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(\"z\")",
+ "2",
+ "0",
+ "0");
+ private static final String ART_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS =
+ StringUtils.lines(
+ "Jane Doe",
+ "42",
+ "true",
+ "2",
+ "a",
+ "java.lang.String",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=a)",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(value=c)",
+ "b",
+ "int",
+ "true",
+ "2",
+ "@records.RecordComponentAnnotationsTest$Annotation(value=x)",
+ "@records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly(value=z)",
+ "2",
+ "0",
+ "0");
+ private static final String EXPECTED_RESULT_DESUGARED_RECORD_SUPPORT =
+ StringUtils.lines("Jane Doe", "42", "false");
+ private static final String EXPECTED_RESULT_DESUGARED_NO_RECORD_SUPPORT =
+ StringUtils.lines("Jane Doe", "42", "Class.isRecord not present");
+
+ @Parameter(0)
+ public TestParameters parameters;
+
+ @Parameter(1)
+ public Boolean keepAnnotations;
+
+ // Enable once records are no longer partially desugared on platform.
+ public boolean recordDesugaringIsOffOnDex = false;
+
+ @Parameters(name = "{0}, keepAnnotations: {1}")
+ public static List<Object[]> data() {
+ return buildParameters(
+ getTestParameters()
+ .withDexRuntimesAndAllApiLevels()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withAllApiLevelsAlsoForCf()
+ .build(),
+ BooleanUtils.values());
+ }
+
+ @Test
+ public void testJvm() throws Exception {
+ parameters.assumeJvmTestParameters();
+ assumeTrue(keepAnnotations);
+ testForJvm(parameters)
+ .addInnerClassesAndStrippedOuter(getClass())
+ .run(parameters.getRuntime(), RecordWithAnnotations.class)
+ .assertSuccessWithOutput(
+ parameters.getRuntime().asCf().getVm().isLessThanOrEqualTo(CfVm.JDK20)
+ ? JVM_UNTIL_20_EXPECTED_RESULT
+ : JVM_FROM_21_EXPECTED_RESULT);
+ }
+
+ @Test
+ public void testDesugaring() throws Exception {
+ parameters.assumeDexRuntime();
+ assumeTrue(keepAnnotations);
+ testForDesugaring(parameters)
+ .addInnerClassesAndStrippedOuter(getClass())
+ .run(parameters.getRuntime(), RecordWithAnnotations.class)
+ .applyIf(
+ parameters.isDexRuntime(),
+ r ->
+ r.assertSuccessWithOutput(
+ runtimeWithRecordsSupport(parameters.getRuntime())
+ ? EXPECTED_RESULT_DESUGARED_RECORD_SUPPORT
+ : EXPECTED_RESULT_DESUGARED_NO_RECORD_SUPPORT),
+ r ->
+ r.assertSuccessWithOutput(ART_EXPECTED_RESULT)
+ .inspect(
+ inspector -> {
+ ClassSubject person =
+ inspector.clazz("records.RecordComponentAnnotationsTest$Person");
+ FieldSubject name = person.uniqueFieldWithOriginalName("name");
+ assertThat(name, isPresentAndNotRenamed());
+ FieldSubject age = person.uniqueFieldWithOriginalName("age");
+ assertThat(age, isPresentAndNotRenamed());
+ assertEquals(2, person.getFinalRecordComponents().size());
+
+ assertEquals(
+ name.getFinalName(),
+ person.getFinalRecordComponents().get(0).getName());
+ assertTrue(
+ person
+ .getFinalRecordComponents()
+ .get(0)
+ .getType()
+ .is("java.lang.String"));
+ assertNull(person.getFinalRecordComponents().get(0).getSignature());
+ assertEquals(
+ 2, person.getFinalRecordComponents().get(0).getAnnotations().size());
+ assertThat(
+ person.getFinalRecordComponents().get(0).getAnnotations(),
+ hasAnnotationTypes(
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$Annotation"),
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly")));
+ assertThat(
+ person.getFinalRecordComponents().get(0).getAnnotations().get(0),
+ hasElements(new Pair<>("value", "a")));
+ assertThat(
+ person.getFinalRecordComponents().get(0).getAnnotations().get(1),
+ hasElements(new Pair<>("value", "c")));
+
+ assertEquals(
+ age.getFinalName(),
+ person.getFinalRecordComponents().get(1).getName());
+ assertTrue(person.getFinalRecordComponents().get(1).getType().is("int"));
+ assertNull(person.getFinalRecordComponents().get(1).getSignature());
+ assertEquals(
+ 2, person.getFinalRecordComponents().get(1).getAnnotations().size());
+ assertThat(
+ person.getFinalRecordComponents().get(1).getAnnotations(),
+ hasAnnotationTypes(
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$Annotation"),
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly")));
+ assertThat(
+ person.getFinalRecordComponents().get(1).getAnnotations().get(0),
+ hasElements(new Pair<>("value", "x")));
+ assertThat(
+ person.getFinalRecordComponents().get(1).getAnnotations().get(1),
+ hasElements(new Pair<>("value", "z")));
+ }));
+ }
+
+ @Test
+ public void testR8() throws Exception {
+ parameters.assumeR8TestParameters();
+ testForR8(parameters.getBackend())
+ .addInnerClassesAndStrippedOuter(getClass())
+ .addLibraryFiles(ToolHelper.getAndroidJar(35))
+ .addKeepMainRule(RecordWithAnnotations.class)
+ .addKeepClassAndMembersRulesWithAllowObfuscation(
+ "records.RecordComponentAnnotationsTest$Person")
+ .addKeepClassAndMembersRules(
+ "records.RecordComponentAnnotationsTest$Annotation",
+ "records.RecordComponentAnnotationsTest$AnnotationFieldOnly",
+ "records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly")
+ .applyIf(keepAnnotations, TestShrinkerBuilder::addKeepRuntimeVisibleAnnotations)
+ .setMinApi(parameters)
+ .compile()
+ .inspect(
+ inspector -> {
+ ClassSubject person =
+ inspector.clazz("records.RecordComponentAnnotationsTest$Person");
+ FieldSubject name = person.uniqueFieldWithOriginalName("name");
+ FieldSubject age = person.uniqueFieldWithOriginalName("age");
+ if (parameters.isCfRuntime()) {
+ assertEquals(2, person.getFinalRecordComponents().size());
+
+ assertEquals(
+ name.getFinalName(), person.getFinalRecordComponents().get(0).getName());
+ assertTrue(
+ person.getFinalRecordComponents().get(0).getType().is("java.lang.String"));
+ assertNull(person.getFinalRecordComponents().get(0).getSignature());
+ assertEquals(2, person.getFinalRecordComponents().get(0).getAnnotations().size());
+ assertThat(
+ person.getFinalRecordComponents().get(0).getAnnotations(),
+ hasAnnotationTypes(
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$Annotation"),
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly")));
+ assertThat(
+ person.getFinalRecordComponents().get(0).getAnnotations().get(0),
+ hasElements(new Pair<>("value", "a")));
+ assertThat(
+ person.getFinalRecordComponents().get(0).getAnnotations().get(1),
+ hasElements(new Pair<>("value", "c")));
+
+ assertEquals(
+ age.getFinalName(), person.getFinalRecordComponents().get(1).getName());
+ assertTrue(person.getFinalRecordComponents().get(1).getType().is("int"));
+ assertNull(person.getFinalRecordComponents().get(1).getSignature());
+ assertEquals(2, person.getFinalRecordComponents().get(1).getAnnotations().size());
+ assertThat(
+ person.getFinalRecordComponents().get(1).getAnnotations(),
+ hasAnnotationTypes(
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$Annotation"),
+ inspector.getTypeSubject(
+ "records.RecordComponentAnnotationsTest$AnnotationRecordComponentOnly")));
+ assertThat(
+ person.getFinalRecordComponents().get(1).getAnnotations().get(0),
+ hasElements(new Pair<>("value", "x")));
+ assertThat(
+ person.getFinalRecordComponents().get(1).getAnnotations().get(1),
+ hasElements(new Pair<>("value", "z")));
+ } else {
+ assertEquals(0, person.getFinalRecordComponents().size());
+ }
+ })
+ .run(parameters.getRuntime(), RecordWithAnnotations.class)
+ .applyIf(
+ // TODO(b/274888318): EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS still has component
+ // annotations.
+ parameters.isCfRuntime(),
+ r ->
+ r.assertSuccessWithOutput(
+ keepAnnotations
+ ? JVM_EXPECTED_RESULT_R8
+ : JVM_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS),
+ recordDesugaringIsOffOnDex,
+ r ->
+ r.assertSuccessWithOutput(
+ keepAnnotations
+ ? ART_EXPECTED_RESULT_R8
+ : ART_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS),
+ r ->
+ r.assertSuccessWithOutput(
+ runtimeWithRecordsSupport(parameters.getRuntime())
+ ? EXPECTED_RESULT_DESUGARED_RECORD_SUPPORT
+ : EXPECTED_RESULT_DESUGARED_NO_RECORD_SUPPORT));
+ }
+
+ @Target({ElementType.FIELD, ElementType.RECORD_COMPONENT})
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface Annotation {
+
+ String value();
+ }
+
+ @Target(ElementType.FIELD)
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface AnnotationFieldOnly {
+
+ String value();
+ }
+
+ @Target(ElementType.RECORD_COMPONENT)
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface AnnotationRecordComponentOnly {
+
+ String value();
+ }
+
+ record Person(
+ @Annotation("a") @AnnotationFieldOnly("b") @AnnotationRecordComponentOnly("c") String name,
+ @Annotation("x") @AnnotationFieldOnly("y") @AnnotationRecordComponentOnly("z") int age) {}
+
+ public static class RecordWithAnnotations {
+
+ public static void main(String[] args) {
+ Person janeDoe = new Person("Jane Doe", 42);
+ System.out.println(janeDoe.name());
+ System.out.println(janeDoe.age());
+ try {
+ Class.class.getDeclaredMethod("isRecord");
+ } catch (NoSuchMethodException e) {
+ System.out.println("Class.isRecord not present");
+ return;
+ }
+ System.out.println(Person.class.isRecord());
+ if (Person.class.isRecord()) {
+ System.out.println(Person.class.getRecordComponents().length);
+ for (int i = 0; i < Person.class.getRecordComponents().length; i++) {
+ RecordComponent c = Person.class.getRecordComponents()[i];
+ System.out.println(c.getName());
+ System.out.println(c.getType().getName());
+ System.out.println(c.getGenericSignature() == null);
+ System.out.println(c.getAnnotations().length);
+ // Collect and sort the annotations, as the order is not deterministic on Art (tested
+ // on Art 14 Beta 3).
+ List<String> annotations = new ArrayList<>();
+ for (int j = 0; j < c.getAnnotations().length; j++) {
+ annotations.add(c.getAnnotations()[j].toString());
+ }
+ annotations.sort(Comparator.naturalOrder());
+ for (int j = 0; j < annotations.size(); j++) {
+ System.out.println(annotations.get(j));
+ }
+ }
+ System.out.println(Person.class.getDeclaredFields().length);
+ List<Field> fields = new ArrayList<>();
+ for (int i = 0; i < Person.class.getDeclaredFields().length; i++) {
+ fields.add(Person.class.getDeclaredFields()[i]);
+ }
+ fields.sort(
+ new Comparator<Field>() {
+ @Override
+ public int compare(Field o1, Field o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ for (int i = 0; i < fields.size(); i++) {
+ Field f = fields.get(i);
+ System.out.println(f.getDeclaredAnnotations().length);
+ List<String> annotations = new ArrayList<>();
+ for (int j = 0; j < f.getDeclaredAnnotations().length; j++) {
+ annotations.add(f.getAnnotations()[j].toString());
+ }
+ annotations.sort(Comparator.naturalOrder());
+ for (int j = 0; j < annotations.size(); j++) {
+ System.out.println(annotations.get(j));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/desugar/records/RecordComponentSignatureTest.java b/src/test/examplesJava17/records/RecordComponentSignatureTest.java
similarity index 74%
rename from src/test/java/com/android/tools/r8/desugar/records/RecordComponentSignatureTest.java
rename to src/test/examplesJava17/records/RecordComponentSignatureTest.java
index 27e7e0b..d2d530b 100644
--- a/src/test/java/com/android/tools/r8/desugar/records/RecordComponentSignatureTest.java
+++ b/src/test/examplesJava17/records/RecordComponentSignatureTest.java
@@ -1,7 +1,7 @@
// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.desugar.records;
+package records;
import static com.android.tools.r8.utils.codeinspector.Matchers.isAbsent;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -13,10 +13,12 @@
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestRuntime.CfVm;
import com.android.tools.r8.TestShrinkerBuilder;
+import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.utils.BooleanUtils;
import com.android.tools.r8.utils.StringUtils;
import com.android.tools.r8.utils.codeinspector.ClassSubject;
import com.android.tools.r8.utils.codeinspector.FieldSubject;
+import java.lang.reflect.RecordComponent;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -27,15 +29,10 @@
@RunWith(Parameterized.class)
public class RecordComponentSignatureTest extends TestBase {
- private static final String RECORD_NAME = "RecordWithSignature";
- private static final byte[][] PROGRAM_DATA = RecordTestUtils.getProgramData(RECORD_NAME);
- private static final String MAIN_TYPE = RecordTestUtils.getMainType(RECORD_NAME);
private static final String EXPECTED_RESULT =
StringUtils.lines(
"Jane Doe",
"42",
- "Jane Doe",
- "42",
"true",
"2",
"name",
@@ -46,12 +43,11 @@
"java.lang.Object",
"TA;",
"0");
- private static final String EXPECTED_RESULT_R8 =
- StringUtils.lines("Jane Doe", "42", "Jane Doe", "42", "true", "0");
+ private static final String EXPECTED_RESULT_R8 = StringUtils.lines("Jane Doe", "42", "true", "0");
private static final String EXPECTED_RESULT_DESUGARED_NO_NATIVE_RECORDS_SUPPORT =
- StringUtils.lines("Jane Doe", "42", "Jane Doe", "42", "Class.isRecord not present");
+ StringUtils.lines("Jane Doe", "42", "Class.isRecord not present");
private static final String EXPECTED_RESULT_DESUGARED_NATIVE_RECORD_SUPPORT =
- StringUtils.lines("Jane Doe", "42", "Jane Doe", "42", "false");
+ StringUtils.lines("Jane Doe", "42", "false");
@Parameter(0)
public TestParameters parameters;
@@ -75,8 +71,8 @@
parameters.assumeJvmTestParameters();
assumeTrue(keepSignatures);
testForJvm(parameters)
- .addProgramClassFileData(PROGRAM_DATA)
- .run(parameters.getRuntime(), MAIN_TYPE)
+ .addInnerClassesAndStrippedOuter(getClass())
+ .run(parameters.getRuntime(), RecordWithSignature.class)
.assertSuccessWithOutput(EXPECTED_RESULT);
}
@@ -85,8 +81,8 @@
parameters.assumeDexRuntime();
assumeTrue(keepSignatures);
testForDesugaring(parameters)
- .addProgramClassFileData(PROGRAM_DATA)
- .run(parameters.getRuntime(), MAIN_TYPE)
+ .addInnerClassesAndStrippedOuter(getClass())
+ .run(parameters.getRuntime(), RecordWithSignature.class)
.applyIf(
parameters.isCfRuntime(),
r -> r.assertSuccessWithOutput(EXPECTED_RESULT),
@@ -98,7 +94,7 @@
.inspect(
inspector -> {
ClassSubject person =
- inspector.clazz("records.RecordWithSignature$Person");
+ inspector.clazz("records.RecordComponentSignatureTest$Person");
if (parameters.isCfRuntime()) {
assertEquals(2, person.getFinalRecordComponents().size());
@@ -138,22 +134,20 @@
public void testR8() throws Exception {
parameters.assumeR8TestParameters();
testForR8(parameters.getBackend())
- .addProgramClassFileData(PROGRAM_DATA)
- // TODO(b/231930852): Change to android.jar for Android U when that contains
- // java.lang.Record.
- .addLibraryFiles(RecordTestUtils.getJdk15LibraryFiles(temp))
- .addKeepMainRule(MAIN_TYPE)
+ .addInnerClassesAndStrippedOuter(getClass())
+ .addLibraryFiles(ToolHelper.getAndroidJar(35))
+ .addKeepMainRule(RecordWithSignature.class)
.applyIf(keepSignatures, TestShrinkerBuilder::addKeepAttributeSignature)
.setMinApi(parameters)
.compile()
.inspect(
inspector -> {
- ClassSubject person = inspector.clazz("records.RecordWithSignature$Person");
+ ClassSubject person = inspector.clazz("records.RecordComponentSignatureTest$Person");
FieldSubject age = person.uniqueFieldWithOriginalName("age");
assertThat(age, isAbsent());
assertEquals(0, person.getFinalRecordComponents().size());
})
- .run(parameters.getRuntime(), MAIN_TYPE)
+ .run(parameters.getRuntime(), RecordWithSignature.class)
.applyIf(
runtimeWithRecordsSupport(parameters.getRuntime()),
r ->
@@ -163,4 +157,32 @@
: EXPECTED_RESULT_R8),
r -> r.assertSuccessWithOutput(EXPECTED_RESULT_DESUGARED_NO_NATIVE_RECORDS_SUPPORT));
}
+
+ record Person<N extends CharSequence, A>(N name, A age) {}
+
+ public class RecordWithSignature {
+
+ public static void main(String[] args) {
+ Person<String, Integer> janeDoe = new Person<>("Jane Doe", 42);
+ System.out.println(janeDoe.name());
+ System.out.println(janeDoe.age());
+ try {
+ Class.class.getDeclaredMethod("isRecord");
+ } catch (NoSuchMethodException e) {
+ System.out.println("Class.isRecord not present");
+ return;
+ }
+ System.out.println(Person.class.isRecord());
+ if (Person.class.isRecord()) {
+ System.out.println(Person.class.getRecordComponents().length);
+ for (int i = 0; i < Person.class.getRecordComponents().length; i++) {
+ RecordComponent c = Person.class.getRecordComponents()[i];
+ System.out.println(c.getName());
+ System.out.println(c.getType().getName());
+ System.out.println(c.getGenericSignature());
+ System.out.println(c.getAnnotations().length);
+ }
+ }
+ }
+ }
}
diff --git a/src/test/examplesJava17/records/RecordWithAnnotations.java b/src/test/examplesJava17/records/RecordWithAnnotations.java
deleted file mode 100644
index fe9fd95..0000000
--- a/src/test/examplesJava17/records/RecordWithAnnotations.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package records;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.reflect.Field;
-import java.lang.reflect.RecordComponent;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-public class RecordWithAnnotations {
-
- @Target({ElementType.FIELD, ElementType.RECORD_COMPONENT})
- @Retention(RetentionPolicy.RUNTIME)
- @interface Annotation {
- String value();
- }
-
- @Target(ElementType.FIELD)
- @Retention(RetentionPolicy.RUNTIME)
- @interface AnnotationFieldOnly {
- String value();
- }
-
- @Target(ElementType.RECORD_COMPONENT)
- @Retention(RetentionPolicy.RUNTIME)
- @interface AnnotationRecordComponentOnly {
- String value();
- }
-
- record Person(
- @Annotation("a") @AnnotationFieldOnly("b") @AnnotationRecordComponentOnly("c") String name,
- @Annotation("x") @AnnotationFieldOnly("y") @AnnotationRecordComponentOnly("z") int age) {}
-
- public static void main(String[] args) {
- Person janeDoe = new Person("Jane Doe", 42);
- System.out.println(janeDoe.name);
- System.out.println(janeDoe.age);
- System.out.println(janeDoe.name());
- System.out.println(janeDoe.age());
- try {
- Class.class.getDeclaredMethod("isRecord");
- } catch (NoSuchMethodException e) {
- System.out.println("Class.isRecord not present");
- return;
- }
- System.out.println(Person.class.isRecord());
- if (Person.class.isRecord()) {
- System.out.println(Person.class.getRecordComponents().length);
- for (int i = 0; i < Person.class.getRecordComponents().length; i++) {
- RecordComponent c = Person.class.getRecordComponents()[i];
- System.out.println(c.getName());
- System.out.println(c.getType().getName());
- System.out.println(c.getGenericSignature() == null);
- System.out.println(c.getAnnotations().length);
- // Collect and sort the annotations, as the order is not deterministic on Art (tested
- // on Art 14 Beta 3).
- List<String> annotations = new ArrayList<>();
- for (int j = 0; j < c.getAnnotations().length; j++) {
- annotations.add(c.getAnnotations()[j].toString());
- }
- annotations.sort(Comparator.naturalOrder());
- for (int j = 0; j < annotations.size(); j++) {
- System.out.println(annotations.get(j));
- }
- }
- System.out.println(Person.class.getDeclaredFields().length);
- List<Field> fields = new ArrayList<>();
- for (int i = 0; i < Person.class.getDeclaredFields().length; i++) {
- fields.add(Person.class.getDeclaredFields()[i]);
- }
- fields.sort(
- new Comparator<Field>() {
- @Override
- public int compare(Field o1, Field o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
- for (int i = 0; i < fields.size(); i++) {
- Field f = fields.get(i);
- System.out.println(f.getDeclaredAnnotations().length);
- List<String> annotations = new ArrayList<>();
- for (int j = 0; j < f.getDeclaredAnnotations().length; j++) {
- annotations.add(f.getAnnotations()[j].toString());
- }
- annotations.sort(Comparator.naturalOrder());
- for (int j = 0; j < annotations.size(); j++) {
- System.out.println(annotations.get(j));
- }
- }
- }
- }
-}
diff --git a/src/test/examplesJava17/records/RecordWithSignature.java b/src/test/examplesJava17/records/RecordWithSignature.java
deleted file mode 100644
index be31024..0000000
--- a/src/test/examplesJava17/records/RecordWithSignature.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package records;
-
-import java.lang.reflect.RecordComponent;
-
-public class RecordWithSignature {
-
- record Person<N extends CharSequence, A>(N name, A age) {}
-
- public static void main(String[] args) {
- Person<String, Integer> janeDoe = new Person<>("Jane Doe", 42);
- System.out.println(janeDoe.name);
- System.out.println(janeDoe.age);
- System.out.println(janeDoe.name());
- System.out.println(janeDoe.age());
- try {
- Class.class.getDeclaredMethod("isRecord");
- } catch (NoSuchMethodException e) {
- System.out.println("Class.isRecord not present");
- return;
- }
- System.out.println(Person.class.isRecord());
- if (Person.class.isRecord()) {
- System.out.println(Person.class.getRecordComponents().length);
- for (int i = 0; i < Person.class.getRecordComponents().length; i++) {
- RecordComponent c = Person.class.getRecordComponents()[i];
- System.out.println(c.getName());
- System.out.println(c.getType().getName());
- System.out.println(c.getGenericSignature());
- System.out.println(c.getAnnotations().length);
- }
- }
- }
-}
diff --git a/src/test/java/com/android/tools/r8/desugar/records/RecordComponentAnnotationsTest.java b/src/test/java/com/android/tools/r8/desugar/records/RecordComponentAnnotationsTest.java
deleted file mode 100644
index 41f97f8..0000000
--- a/src/test/java/com/android/tools/r8/desugar/records/RecordComponentAnnotationsTest.java
+++ /dev/null
@@ -1,394 +0,0 @@
-// Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.desugar.records;
-
-import static com.android.tools.r8.utils.codeinspector.AnnotationMatchers.hasAnnotationTypes;
-import static com.android.tools.r8.utils.codeinspector.AnnotationMatchers.hasElements;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndNotRenamed;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeTrue;
-
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestRuntime.CfVm;
-import com.android.tools.r8.TestShrinkerBuilder;
-import com.android.tools.r8.utils.BooleanUtils;
-import com.android.tools.r8.utils.Pair;
-import com.android.tools.r8.utils.StringUtils;
-import com.android.tools.r8.utils.codeinspector.ClassSubject;
-import com.android.tools.r8.utils.codeinspector.FieldSubject;
-import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class RecordComponentAnnotationsTest extends TestBase {
-
- private static final String RECORD_NAME = "RecordWithAnnotations";
- private static final byte[][] PROGRAM_DATA = RecordTestUtils.getProgramData(RECORD_NAME);
- private static final String MAIN_TYPE = RecordTestUtils.getMainType(RECORD_NAME);
- private static final String JVM_UNTIL_20_EXPECTED_RESULT =
- StringUtils.lines(
- "Jane Doe",
- "42",
- "Jane Doe",
- "42",
- "true",
- "2",
- "name",
- "java.lang.String",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"a\")",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(\"c\")",
- "age",
- "int",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"x\")",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(\"z\")",
- "2",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"x\")",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(\"y\")",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"a\")",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(\"b\")");
- private static final String JVM_FROM_21_EXPECTED_RESULT =
- JVM_UNTIL_20_EXPECTED_RESULT.replaceAll(
- "RecordWithAnnotations\\$Annotation", "RecordWithAnnotations.Annotation");
- private static final String ART_EXPECTED_RESULT =
- StringUtils.lines(
- "Jane Doe",
- "42",
- "Jane Doe",
- "42",
- "true",
- "2",
- "name",
- "java.lang.String",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=a)",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(value=c)",
- "age",
- "int",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=x)",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(value=z)",
- "2",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=x)",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(value=y)",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=a)",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(value=b)");
- private static final String JVM_EXPECTED_RESULT_R8 =
- StringUtils.lines(
- "Jane Doe",
- "42",
- "Jane Doe",
- "42",
- "true",
- "2",
- "a",
- "java.lang.String",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"a\")",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(\"c\")",
- "b",
- "int",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"x\")",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(\"z\")",
- "2",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"a\")",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(\"b\")",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"x\")",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(\"y\")");
- private static final String ART_EXPECTED_RESULT_R8 =
- StringUtils.lines(
- "Jane Doe",
- "42",
- "Jane Doe",
- "42",
- "true",
- "2",
- "a",
- "java.lang.String",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=a)",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(value=c)",
- "b",
- "int",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=x)",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(value=z)",
- "2",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=a)",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(value=b)",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=x)",
- "@records.RecordWithAnnotations$AnnotationFieldOnly(value=y)");
- private static final String JVM_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS =
- StringUtils.lines(
- "Jane Doe",
- "42",
- "Jane Doe",
- "42",
- "true",
- "2",
- "a",
- "java.lang.String",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"a\")",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(\"c\")",
- "b",
- "int",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(\"x\")",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(\"z\")",
- "2",
- "0",
- "0");
- private static final String ART_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS =
- StringUtils.lines(
- "Jane Doe",
- "42",
- "Jane Doe",
- "42",
- "true",
- "2",
- "a",
- "java.lang.String",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=a)",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(value=c)",
- "b",
- "int",
- "true",
- "2",
- "@records.RecordWithAnnotations$Annotation(value=x)",
- "@records.RecordWithAnnotations$AnnotationRecordComponentOnly(value=z)",
- "2",
- "0",
- "0");
- private static final String EXPECTED_RESULT_DESUGARED_RECORD_SUPPORT =
- StringUtils.lines("Jane Doe", "42", "Jane Doe", "42", "false");
- private static final String EXPECTED_RESULT_DESUGARED_NO_RECORD_SUPPORT =
- StringUtils.lines("Jane Doe", "42", "Jane Doe", "42", "Class.isRecord not present");
-
- @Parameter(0)
- public TestParameters parameters;
-
- @Parameter(1)
- public Boolean keepAnnotations;
-
- // Enable once records are no longer partially desugared on platform.
- public boolean recordDesugaringIsOffOnDex = false;
-
- @Parameters(name = "{0}, keepAnnotations: {1}")
- public static List<Object[]> data() {
- return buildParameters(
- getTestParameters()
- .withDexRuntimesAndAllApiLevels()
- .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
- .withAllApiLevelsAlsoForCf()
- .build(),
- BooleanUtils.values());
- }
-
- @Test
- public void testJvm() throws Exception {
- parameters.assumeJvmTestParameters();
- assumeTrue(keepAnnotations);
- testForJvm(parameters)
- .addProgramClassFileData(PROGRAM_DATA)
- .run(parameters.getRuntime(), MAIN_TYPE)
- .assertSuccessWithOutput(
- parameters.getRuntime().asCf().getVm().isLessThanOrEqualTo(CfVm.JDK20)
- ? JVM_UNTIL_20_EXPECTED_RESULT
- : JVM_FROM_21_EXPECTED_RESULT);
- }
-
- @Test
- public void testDesugaring() throws Exception {
- parameters.assumeDexRuntime();
- assumeTrue(keepAnnotations);
- testForDesugaring(parameters)
- .addProgramClassFileData(PROGRAM_DATA)
- .run(parameters.getRuntime(), MAIN_TYPE)
- .applyIf(
- parameters.isDexRuntime(),
- r ->
- r.assertSuccessWithOutput(
- runtimeWithRecordsSupport(parameters.getRuntime())
- ? EXPECTED_RESULT_DESUGARED_RECORD_SUPPORT
- : EXPECTED_RESULT_DESUGARED_NO_RECORD_SUPPORT),
- r ->
- r.assertSuccessWithOutput(ART_EXPECTED_RESULT)
- .inspect(
- inspector -> {
- ClassSubject person =
- inspector.clazz("records.RecordWithAnnotations$Person");
- FieldSubject name = person.uniqueFieldWithOriginalName("name");
- assertThat(name, isPresentAndNotRenamed());
- FieldSubject age = person.uniqueFieldWithOriginalName("age");
- assertThat(age, isPresentAndNotRenamed());
- assertEquals(2, person.getFinalRecordComponents().size());
-
- assertEquals(
- name.getFinalName(),
- person.getFinalRecordComponents().get(0).getName());
- assertTrue(
- person
- .getFinalRecordComponents()
- .get(0)
- .getType()
- .is("java.lang.String"));
- assertNull(person.getFinalRecordComponents().get(0).getSignature());
- assertEquals(
- 2, person.getFinalRecordComponents().get(0).getAnnotations().size());
- assertThat(
- person.getFinalRecordComponents().get(0).getAnnotations(),
- hasAnnotationTypes(
- inspector.getTypeSubject(
- "records.RecordWithAnnotations$Annotation"),
- inspector.getTypeSubject(
- "records.RecordWithAnnotations$AnnotationRecordComponentOnly")));
- assertThat(
- person.getFinalRecordComponents().get(0).getAnnotations().get(0),
- hasElements(new Pair<>("value", "a")));
- assertThat(
- person.getFinalRecordComponents().get(0).getAnnotations().get(1),
- hasElements(new Pair<>("value", "c")));
-
- assertEquals(
- age.getFinalName(),
- person.getFinalRecordComponents().get(1).getName());
- assertTrue(person.getFinalRecordComponents().get(1).getType().is("int"));
- assertNull(person.getFinalRecordComponents().get(1).getSignature());
- assertEquals(
- 2, person.getFinalRecordComponents().get(1).getAnnotations().size());
- assertThat(
- person.getFinalRecordComponents().get(1).getAnnotations(),
- hasAnnotationTypes(
- inspector.getTypeSubject(
- "records.RecordWithAnnotations$Annotation"),
- inspector.getTypeSubject(
- "records.RecordWithAnnotations$AnnotationRecordComponentOnly")));
- assertThat(
- person.getFinalRecordComponents().get(1).getAnnotations().get(0),
- hasElements(new Pair<>("value", "x")));
- assertThat(
- person.getFinalRecordComponents().get(1).getAnnotations().get(1),
- hasElements(new Pair<>("value", "z")));
- }));
- }
-
- @Test
- public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
- testForR8(parameters.getBackend())
- .addProgramClassFileData(PROGRAM_DATA)
- // TODO(b/231930852): Change to android.jar for Android U when that contains
- // java.lang.Record.
- .addLibraryFiles(RecordTestUtils.getJdk15LibraryFiles(temp))
- .addKeepMainRule(MAIN_TYPE)
- .addKeepClassAndMembersRulesWithAllowObfuscation("records.RecordWithAnnotations$Person")
- .addKeepClassAndMembersRules(
- "records.RecordWithAnnotations$Annotation",
- "records.RecordWithAnnotations$AnnotationFieldOnly",
- "records.RecordWithAnnotations$AnnotationRecordComponentOnly")
- .applyIf(keepAnnotations, TestShrinkerBuilder::addKeepRuntimeVisibleAnnotations)
- .setMinApi(parameters)
- .compile()
- .inspect(
- inspector -> {
- ClassSubject person = inspector.clazz("records.RecordWithAnnotations$Person");
- FieldSubject name = person.uniqueFieldWithOriginalName("name");
- FieldSubject age = person.uniqueFieldWithOriginalName("age");
- if (parameters.isCfRuntime()) {
- assertEquals(2, person.getFinalRecordComponents().size());
-
- assertEquals(
- name.getFinalName(), person.getFinalRecordComponents().get(0).getName());
- assertTrue(
- person.getFinalRecordComponents().get(0).getType().is("java.lang.String"));
- assertNull(person.getFinalRecordComponents().get(0).getSignature());
- assertEquals(2, person.getFinalRecordComponents().get(0).getAnnotations().size());
- assertThat(
- person.getFinalRecordComponents().get(0).getAnnotations(),
- hasAnnotationTypes(
- inspector.getTypeSubject("records.RecordWithAnnotations$Annotation"),
- inspector.getTypeSubject(
- "records.RecordWithAnnotations$AnnotationRecordComponentOnly")));
- assertThat(
- person.getFinalRecordComponents().get(0).getAnnotations().get(0),
- hasElements(new Pair<>("value", "a")));
- assertThat(
- person.getFinalRecordComponents().get(0).getAnnotations().get(1),
- hasElements(new Pair<>("value", "c")));
-
- assertEquals(
- age.getFinalName(), person.getFinalRecordComponents().get(1).getName());
- assertTrue(person.getFinalRecordComponents().get(1).getType().is("int"));
- assertNull(person.getFinalRecordComponents().get(1).getSignature());
- assertEquals(2, person.getFinalRecordComponents().get(1).getAnnotations().size());
- assertThat(
- person.getFinalRecordComponents().get(1).getAnnotations(),
- hasAnnotationTypes(
- inspector.getTypeSubject("records.RecordWithAnnotations$Annotation"),
- inspector.getTypeSubject(
- "records.RecordWithAnnotations$AnnotationRecordComponentOnly")));
- assertThat(
- person.getFinalRecordComponents().get(1).getAnnotations().get(0),
- hasElements(new Pair<>("value", "x")));
- assertThat(
- person.getFinalRecordComponents().get(1).getAnnotations().get(1),
- hasElements(new Pair<>("value", "z")));
- } else {
- assertEquals(0, person.getFinalRecordComponents().size());
- }
- })
- .run(parameters.getRuntime(), MAIN_TYPE)
- .applyIf(
- // TODO(b/274888318): EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS still has component
- // annotations.
- parameters.isCfRuntime(),
- r ->
- r.assertSuccessWithOutput(
- keepAnnotations
- ? JVM_EXPECTED_RESULT_R8
- : JVM_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS),
- recordDesugaringIsOffOnDex,
- r ->
- r.assertSuccessWithOutput(
- keepAnnotations
- ? ART_EXPECTED_RESULT_R8
- : ART_EXPECTED_RESULT_R8_NO_KEEP_ANNOTATIONS),
- r ->
- r.assertSuccessWithOutput(
- runtimeWithRecordsSupport(parameters.getRuntime())
- ? EXPECTED_RESULT_DESUGARED_RECORD_SUPPORT
- : EXPECTED_RESULT_DESUGARED_NO_RECORD_SUPPORT));
- }
-}