Skip to content

Commit

Permalink
Support Java 23.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Feb 16, 2024
1 parent a47a19a commit 8e43244
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public class ClassFileVersion implements Comparable<ClassFileVersion>, Serializa
*/
public static final ClassFileVersion JAVA_V22 = new ClassFileVersion(Opcodes.V22);

/**
* The class file version of Java 23.
*/
public static final ClassFileVersion JAVA_V23 = new ClassFileVersion(Opcodes.V22 + 1);

/**
* A version locator for the executing JVM.
*/
Expand Down Expand Up @@ -251,6 +256,8 @@ public static ClassFileVersion ofJavaVersionString(String javaVersionString) {
return JAVA_V21;
} else if (javaVersionString.equals("1.22") || javaVersionString.equals("22")) {
return JAVA_V22;
} else if (javaVersionString.equals("1.23") || javaVersionString.equals("23")) {
return JAVA_V23;
} else {
if (OpenedClassReader.EXPERIMENTAL) {
try {
Expand Down Expand Up @@ -320,6 +327,8 @@ public static ClassFileVersion ofJavaVersion(int javaVersion) {
return JAVA_V21;
case 22:
return JAVA_V22;
case 23:
return JAVA_V23;
default:
if (OpenedClassReader.EXPERIMENTAL && javaVersion > 0) {
return new ClassFileVersion(BASE_VERSION + javaVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testClassFile() throws Exception {

@Test
public void testThisVm() {
ClassFileVersion.ofThisVm();
assertThat(ClassFileVersion.ofThisVm(), is(ClassFileVersion.ofThisVm()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static Collection<Object[]> data() {
{19, 19, Arrays.asList("1.19", "19"), Opcodes.V19, (short) 63, (short) 0, true, true, true},
{20, 20, Arrays.asList("1.20", "20"), Opcodes.V20, (short) 64, (short) 0, true, true, true},
{21, 21, Arrays.asList("1.21", "21"), Opcodes.V21, (short) 65, (short) 0, true, true, true},
{22, 22, Arrays.asList("1.22", "22"), Opcodes.V22, (short) 66, (short) 0, true, true, true}
{22, 22, Arrays.asList("1.22", "22"), Opcodes.V22, (short) 66, (short) 0, true, true, true},
{23, 23, Arrays.asList("1.23", "23"), Opcodes.V22 + 1, (short) 67, (short) 0, true, true, true}
});
}

Expand Down
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,21 @@
<jacoco.skip>true</jacoco.skip>
</properties>
</profile>
<!-- Runs the build with compatibility for Java 22 JVMs. -->
<profile>
<id>java23-compatibility</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>23</jdk>
</activation>
<properties>
<sourcecode.main.version>8</sourcecode.main.version>
<sourcecode.test.version>8</sourcecode.test.version>
<bytecode.main.version>8</bytecode.main.version>
<bytecode.test.version>8</bytecode.test.version>
<jacoco.skip>true</jacoco.skip>
</properties>
</profile>
<!-- Builds using a byte code target for Java 6. -->
<profile>
<id>java6</id>
Expand Down Expand Up @@ -956,6 +971,18 @@
<spotbugs.skip>true</spotbugs.skip>
</properties>
</profile>
<!-- Builds using a byte code target for Java 22. -->
<profile>
<id>java23</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<bytecode.main.version>23</bytecode.main.version>
<bytecode.test.version>23</bytecode.test.version>
<spotbugs.skip>true</spotbugs.skip>
</properties>
</profile>
<!-- Enables dynamic agent loading when running a JDK 22 or newer. -->
<profile>
<id>surefire-enable-dynamic-attach</id>
Expand Down

0 comments on commit 8e43244

Please sign in to comment.