Update PermittedSubclasses tests
Tests where expecting the previous erronous behaviour where the
PermittedSubclasses annotation was removed when writing DEX.
Also stop testing class file 61 (JDK 17) code on JVM versions not
supporting it.
Bug: b/434135087
Change-Id: I44a28c3629b64a33a5e930a60d7e69dc88250e8d
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsTest.java
index cbc1f65..491f730 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsTest.java
@@ -101,7 +101,7 @@
assertTrue(sub1.getFinalName().startsWith(getClass().getPackage().getName()));
}
assertEquals(
- parameters.isCfRuntime() && keepPermittedSubclassesAttribute
+ hasSealedClassesSupport(parameters) && keepPermittedSubclassesAttribute
? ImmutableList.of(sub1.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
@@ -110,6 +110,8 @@
@Test
public void testR8() throws Exception {
parameters.assumeR8TestParameters();
+ assumeTrue(
+ parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17));
testForR8(parameters)
.apply(this::addTestClasses)
.applyIf(
@@ -122,10 +124,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public byte[] getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsVerticalMergeTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsVerticalMergeTest.java
index da5fc55..8e7f691 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsVerticalMergeTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesExtendsVerticalMergeTest.java
@@ -35,8 +35,9 @@
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -52,7 +53,7 @@
assertThat(subSub, isPresentAndRenamed());
for (ClassSubject clazz : ImmutableList.of(superClass, unrelated)) {
assertEquals(
- parameters.isCfRuntime()
+ hasSealedClassesSupport(parameters)
? ImmutableList.of(subSub.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
@@ -61,7 +62,6 @@
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
testForR8(parameters)
.addProgramClasses(TestClass.class, Sub1.class, Sub2.class, SubSub.class)
.addProgramClassFileData(getTransformedClasses())
@@ -76,10 +76,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public List<byte[]> getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesHorizontalMergeTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesHorizontalMergeTest.java
index ed4e97e..2924f94 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesHorizontalMergeTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesHorizontalMergeTest.java
@@ -33,8 +33,9 @@
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -45,13 +46,14 @@
ClassSubject sub1 = inspector.clazz(Sub1.class);
assertThat(sub1, isPresentAndRenamed());
assertEquals(
- parameters.isCfRuntime() ? ImmutableList.of(sub1.asTypeSubject()) : ImmutableList.of(),
+ hasSealedClassesSupport(parameters)
+ ? ImmutableList.of(sub1.asTypeSubject())
+ : ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
}
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
testForR8(parameters)
.addProgramClasses(TestClass.class, Sub1.class, Sub2.class)
.addProgramClassFileData(getTransformedClasses())
@@ -67,10 +69,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public byte[] getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassMergedTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassMergedTest.java
index 79696d8..78dcfeb 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassMergedTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassMergedTest.java
@@ -39,8 +39,9 @@
@Parameters(name = "{0}, keepPermittedSubclasses = {1}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -67,13 +68,14 @@
ClassSubject sub1 = inspector.clazz(Sub1.class);
assertThat(sub1, isPresentAndRenamed());
assertEquals(
- parameters.isCfRuntime() ? ImmutableList.of(sub1.asTypeSubject()) : ImmutableList.of(),
+ hasSealedClassesSupport(parameters)
+ ? ImmutableList.of(sub1.asTypeSubject())
+ : ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
}
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
testForR8(parameters)
.apply(this::addTestClasses)
.addKeepAttributePermittedSubclasses()
@@ -88,13 +90,9 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- // On JDK 17 the class merging also prevents "cannot inherit from sealed class".
- r ->
- r.assertSuccessWithOutput(
- EXPECTED_WITHOUT_PERMITTED_SUBCLASSES_ATTRIBUTE_OR_FIXED_ATTRIBUTE),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ // On JDK 17 the class merging also prevents "cannot inherit from sealed class".
+ .assertSuccessWithOutput(
+ EXPECTED_WITHOUT_PERMITTED_SUBCLASSES_ATTRIBUTE_OR_FIXED_ATTRIBUTE);
}
public byte[] getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassTest.java
index 4e9d847..77d9de2 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesIllegalSubclassTest.java
@@ -96,7 +96,7 @@
assertThat(sub2, isPresentAndNotRenamed());
assertThat(sub3, isPresentAndNotRenamed());
assertEquals(
- parameters.isCfRuntime() && keepPermittedSubclassesAttribute
+ hasSealedClassesSupport(parameters) && keepPermittedSubclassesAttribute
? ImmutableList.of(sub1.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
@@ -105,6 +105,8 @@
@Test
public void testR8() throws Exception {
parameters.assumeR8TestParameters();
+ assumeTrue(
+ parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17));
assumeFalse(parameters.isDexRuntime() && keepPermittedSubclassesAttribute);
testForR8(parameters)
.apply(this::addTestClasses)
@@ -123,7 +125,6 @@
&& parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17)),
r -> r.assertSuccessWithOutput(EXPECTED_WITHOUT_PERMITTED_SUBCLASSES_ATTRIBUTE),
parameters.isCfRuntime()
- && parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17)
&& keepPermittedSubclassesAttribute,
r -> r.assertFailureWithErrorThatMatches(EXPECTED),
r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsTest.java
index 02b9455..65e3425 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsTest.java
@@ -92,12 +92,12 @@
assertThat(sub1, isPresentAndRenamed());
assertThat(sub2, isPresentAndRenamed());
assertEquals(
- parameters.isCfRuntime() && keepPermittedSubclassesAttribute
+ hasSealedClassesSupport(parameters) && keepPermittedSubclassesAttribute
? ImmutableList.of(sub1.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
iface1.getFinalPermittedSubclassAttributes());
assertEquals(
- parameters.isCfRuntime() && keepPermittedSubclassesAttribute
+ hasSealedClassesSupport(parameters) && keepPermittedSubclassesAttribute
? ImmutableList.of(sub1.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
iface2.getFinalPermittedSubclassAttributes());
@@ -106,6 +106,8 @@
@Test
public void testR8() throws Exception {
parameters.assumeR8TestParameters();
+ assumeTrue(
+ parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17));
testForR8(parameters)
.apply(this::addTestClasses)
.applyIf(
@@ -121,10 +123,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public List<byte[]> getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsVerticalMergeTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsVerticalMergeTest.java
index cb426d5..af02587 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsVerticalMergeTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesImplementsVerticalMergeTest.java
@@ -7,6 +7,7 @@
import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndRenamed;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.NoUnusedInterfaceRemoval;
import com.android.tools.r8.TestBase;
@@ -37,8 +38,9 @@
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -56,7 +58,7 @@
assertThat(subSub, Matchers.isPresentAndRenamed());
for (ClassSubject clazz : ImmutableList.of(iface1, iface2, ifaceUnrelated)) {
assertEquals(
- parameters.isCfRuntime()
+ hasSealedClassesSupport(parameters)
? ImmutableList.of(subSub.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
@@ -65,7 +67,8 @@
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
+ assumeTrue(
+ parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17));
testForR8(parameters)
.addProgramClasses(TestClass.class, Super.class, Sub1.class, Sub2.class, SubSub.class)
.addProgramClassFileData(getTransformedClasses())
@@ -82,10 +85,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public List<byte[]> getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesMergeTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesMergeTest.java
index f686e7a..e1a0b30 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesMergeTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesMergeTest.java
@@ -7,6 +7,7 @@
import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndRenamed;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.TestBase;
import com.android.tools.r8.TestParameters;
@@ -33,8 +34,9 @@
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -45,13 +47,16 @@
ClassSubject sub1 = inspector.clazz(Sub1.class);
assertThat(sub1, isPresentAndRenamed());
assertEquals(
- parameters.isCfRuntime() ? ImmutableList.of(sub1.asTypeSubject()) : ImmutableList.of(),
+ hasSealedClassesSupport(parameters)
+ ? ImmutableList.of(sub1.asTypeSubject())
+ : ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
}
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
+ assumeTrue(
+ parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17));
testForR8(parameters)
.addProgramClasses(TestClass.class, Sub1.class, Sub2.class)
.addProgramClassFileData(getTransformedClasses())
@@ -67,10 +72,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public byte[] getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesShrinkingTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesShrinkingTest.java
index 68d9dd1..b174107 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesShrinkingTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesShrinkingTest.java
@@ -7,6 +7,7 @@
import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndRenamed;
import static junit.framework.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.TestBase;
import com.android.tools.r8.TestParameters;
@@ -33,8 +34,9 @@
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -45,13 +47,16 @@
ClassSubject sub1 = inspector.clazz(UsedSub.class);
assertThat(sub1, isPresentAndRenamed());
assertEquals(
- parameters.isCfRuntime() ? ImmutableList.of(sub1.asTypeSubject()) : ImmutableList.of(),
+ hasSealedClassesSupport(parameters)
+ ? ImmutableList.of(sub1.asTypeSubject())
+ : ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
}
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
+ assumeTrue(
+ parameters.isDexRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17));
testForR8(parameters)
.addProgramClasses(TestClass.class, UsedSub.class, UnusedSub.class)
.addProgramClassFileData(getTransformedClasses())
@@ -61,10 +66,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public byte[] getTransformedClasses() throws Exception {
diff --git a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesTestAllowPermittedSubclassesRemovalTest.java b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesTestAllowPermittedSubclassesRemovalTest.java
index cf06c90..d352901 100644
--- a/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesTestAllowPermittedSubclassesRemovalTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/sealed/SealedClassesTestAllowPermittedSubclassesRemovalTest.java
@@ -34,8 +34,9 @@
@Parameters(name = "{0}")
public static TestParametersCollection data() {
return getTestParameters()
- .withAllRuntimes()
- .withAllApiLevelsAlsoForCf()
+ .withCfRuntimesStartingFromIncluding(CfVm.JDK17)
+ .withDexRuntimes()
+ .withAllApiLevels()
.withPartialCompilation()
.build();
}
@@ -48,7 +49,7 @@
assertThat(sub1, isPresentAndRenamed());
assertThat(sub2, isPresentAndRenamed());
assertEquals(
- parameters.isCfRuntime()
+ hasSealedClassesSupport(parameters)
? ImmutableList.of(sub1.asTypeSubject(), sub2.asTypeSubject())
: ImmutableList.of(),
clazz.getFinalPermittedSubclassAttributes());
@@ -56,7 +57,6 @@
@Test
public void testR8() throws Exception {
- parameters.assumeR8TestParameters();
testForR8(parameters)
.addProgramClasses(TestClass.class, Sub1.class, Sub2.class)
.addProgramClassFileData(getTransformedClasses())
@@ -67,10 +67,7 @@
.compile()
.inspectIf(!parameters.isRandomPartialCompilation(), this::inspect)
.run(parameters.getRuntime(), TestClass.class)
- .applyIf(
- !parameters.isCfRuntime() || parameters.asCfRuntime().isNewerThanOrEqual(CfVm.JDK17),
- r -> r.assertSuccessWithOutput(EXPECTED),
- r -> r.assertFailureWithErrorThatThrows(UnsupportedClassVersionError.class));
+ .assertSuccessWithOutput(EXPECTED);
}
public byte[] getTransformedClasses() throws Exception {
diff --git a/src/test/testbase/java/com/android/tools/r8/TestBase.java b/src/test/testbase/java/com/android/tools/r8/TestBase.java
index 0ba9f8a..23e0f00 100644
--- a/src/test/testbase/java/com/android/tools/r8/TestBase.java
+++ b/src/test/testbase/java/com/android/tools/r8/TestBase.java
@@ -1869,6 +1869,15 @@
throw new Unreachable();
}
+ public static AndroidApiLevel apiLevelWithSealedClassesSupport() {
+ return AndroidApiLevel.U;
+ }
+
+ public static boolean hasSealedClassesSupport(TestParameters parameters) {
+ return (parameters.isCfRuntime() && parameters.getCfRuntime().hasRecordsSupport())
+ || parameters.getApiLevel().isGreaterThanOrEqualTo(apiLevelWithSealedClassesSupport());
+ }
+
public static boolean isRecordsFullyDesugaredForD8(TestParameters parameters) {
assert parameters.getApiLevel() != null;
return parameters.getApiLevel().isLessThan(AndroidApiLevel.V);
diff --git a/src/test/testbase/java/com/android/tools/r8/TestRuntime.java b/src/test/testbase/java/com/android/tools/r8/TestRuntime.java
index f49a781..84059ff 100644
--- a/src/test/testbase/java/com/android/tools/r8/TestRuntime.java
+++ b/src/test/testbase/java/com/android/tools/r8/TestRuntime.java
@@ -89,6 +89,10 @@
public boolean hasRecordsSupport() {
return isGreaterThanOrEqualTo(JDK17);
}
+
+ public boolean hasSealedClassesSupport() {
+ return isGreaterThanOrEqualTo(JDK17);
+ }
}
private static final Path JDK8_PATH = Paths.get(ToolHelper.THIRD_PARTY_DIR, "openjdk", "jdk8");
@@ -430,6 +434,10 @@
public boolean hasRecordsSupport() {
return getVm().hasRecordsSupport();
}
+
+ public boolean hasSealedClassesSupport() {
+ return getVm().hasSealedClassesSupport();
+ }
}
public <T> T match(Function<CfRuntime, T> onCf, BiFunction<DexRuntime, DexVm.Version, T> onDex) {
diff --git a/src/test/testbase/java/com/android/tools/r8/ToolHelper.java b/src/test/testbase/java/com/android/tools/r8/ToolHelper.java
index 547024a..7ecd693 100644
--- a/src/test/testbase/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/testbase/java/com/android/tools/r8/ToolHelper.java
@@ -436,6 +436,11 @@
return isNewerThanOrEqual(V14_0_0);
}
+ public boolean hasSealedClassesSupport() {
+ // Records support is present from Android U.
+ return isNewerThanOrEqual(V14_0_0);
+ }
+
public String toString() {
return shortName;
}