Skip to content

Commit d0af4de

Browse files
committed
Made compatible with Java 23
1 parent de01fa8 commit d0af4de

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

pom.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,22 @@
99
<version>1.0-SNAPSHOT</version>
1010

1111
<properties>
12-
<maven.compiler.source>22</maven.compiler.source>
13-
<maven.compiler.target>22</maven.compiler.target>
12+
<maven.compiler.source>23</maven.compiler.source>
13+
<maven.compiler.target>23</maven.compiler.target>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
</properties>
16+
<build>
17+
<plugins>
18+
<plugin>
19+
<groupId>org.apache.maven.plugins</groupId>
20+
<artifactId>maven-compiler-plugin</artifactId>
21+
<configuration>
22+
<source>23</source>
23+
<target>23</target>
24+
<compilerArgs>--enable-preview</compilerArgs>
25+
</configuration>
26+
</plugin>
27+
</plugins>
28+
</build>
1629

1730
</project>

run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
javac -d output --release 22 --enable-preview --source-path "./*/src" \
3+
javac -d output --release 23 --enable-preview --source-path "./*/src" \
44
$(find . -name "*.java")
55

66
cd output

src/main/java/org/jugistanbul/GenerateClass.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
***/
1616
public class GenerateClass
1717
{
18-
public static void main(String[] args) throws IOException {
18+
void main() throws IOException {
1919

2020
var className = Info.CLASS_NAME.getClassName();
21-
ClassFile.of().buildTo(Path.of(STR."\{className}.class"), of(className),
21+
ClassFile.of().buildTo(Path.of(className + ".class"), of(className),
2222
classBuilder -> classBuilder
2323
.withField("myField", of("java.lang.String"), ACC_PRIVATE)
2424
.withMethodBody("hello", MethodTypeDesc.of(CD_void), ACC_STATIC,
@@ -30,7 +30,7 @@ public static void main(String[] args) throws IOException {
3030
.return_())
3131
.withMethodBody("main", MethodTypeDesc.of(CD_void, of("java.lang.String").arrayType()), ACC_PUBLIC | ACC_STATIC,
3232
codeBuilder -> codeBuilder
33-
.invokeInstruction(Opcode.INVOKESTATIC, of(className), "hello", MethodTypeDesc.of(CD_void), false)
33+
.invoke(Opcode.INVOKESTATIC, of(className), "hello", MethodTypeDesc.of(CD_void), false)
3434
.return_()));
3535
}
3636

src/main/java/org/jugistanbul/ParseClass.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
***/
1414
public class ParseClass {
1515

16-
public static void main(String[] args) {
16+
void main() {
1717

1818
var classModel = ClassFile.of().parse(getGivenClassBytes(Info.CLASS_NAME.getClassName()));
1919
for (var classElement : classModel) {
@@ -28,7 +28,7 @@ public static void main(String[] args) {
2828

2929
private static byte[] getGivenClassBytes(final String className) {
3030
try {
31-
var path = STR."\{System.getProperty("user.dir")}/\{className}.class";
31+
var path = System.getProperty("user.dir") + "/" + className + ".class";
3232
File file = new File(path);
3333
return Files.readAllBytes(file.toPath());
3434
} catch (IOException ioe){

0 commit comments

Comments
 (0)