Skip to content

Commit 83f3dff

Browse files
Copilotslachiewicz
andcommitted
Add documentation and improve Java version handling for Class File API
Co-authored-by: slachiewicz <[email protected]>
1 parent 18d2784 commit 83f3dff

File tree

4 files changed

+70
-12
lines changed

4 files changed

+70
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/plexus-java/target
99
*.iml
1010
.idea/
11+
/META-INF

META-INF/MANIFEST.MF

Lines changed: 0 additions & 11 deletions
This file was deleted.

plexus-java/pom.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
<profile>
132132
<id>jdk22</id>
133133
<activation>
134-
<jdk>[22,)</jdk>
134+
<jdk>[22,24)</jdk>
135135
</activation>
136136
<build>
137137
<pluginManagement>
@@ -162,6 +162,37 @@
162162
</pluginManagement>
163163
</build>
164164
</profile>
165+
<profile>
166+
<id>jdk24</id>
167+
<activation>
168+
<jdk>[24,)</jdk>
169+
</activation>
170+
<build>
171+
<pluginManagement>
172+
<plugins>
173+
<plugin>
174+
<groupId>org.apache.maven.plugins</groupId>
175+
<artifactId>maven-compiler-plugin</artifactId>
176+
<executions>
177+
<execution>
178+
<id>jdk24</id>
179+
<goals>
180+
<goal>compile</goal>
181+
</goals>
182+
<configuration>
183+
<release>22</release>
184+
<multiReleaseOutput>true</multiReleaseOutput>
185+
<compileSourceRoots>
186+
<compileSourceRoot>${project.basedir}/src/main/java22</compileSourceRoot>
187+
</compileSourceRoots>
188+
</configuration>
189+
</execution>
190+
</executions>
191+
</plugin>
192+
</plugins>
193+
</pluginManagement>
194+
</build>
195+
</profile>
165196
</profiles>
166197

167198
</project>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Java 22+ Class File API Implementation
2+
3+
This directory contains an implementation of the module-info parser using the Java Class File API, which was introduced as a preview feature in Java 22 (JEP 457).
4+
5+
## Background
6+
7+
The Class File API provides a native Java API for parsing and generating class files, eliminating the need for external libraries like ASM for this purpose.
8+
9+
### Timeline
10+
11+
- **Java 22** (March 2024): Preview feature (JEP 457) - requires `--enable-preview`
12+
- **Java 23** (September 2024): Second Preview (JEP 466) - requires `--enable-preview`
13+
- **Java 24** (March 2025): Expected to be finalized (JEP 484) - no preview flag needed
14+
15+
## Implementation
16+
17+
This implementation uses:
18+
- `java.lang.classfile.ClassFile` for parsing class files
19+
- `java.lang.classfile.attribute.ModuleAttribute` for accessing module information
20+
- The same `JavaModuleDescriptor` builder pattern as other implementations
21+
22+
## Building
23+
24+
When building with Java 22 or 23, the `--enable-preview` flag is automatically added by the Maven compiler plugin configuration.
25+
26+
When building with Java 24+, the preview flag should not be needed as the API should be finalized.
27+
28+
When building with Java 17 or earlier, this code is not compiled, and the Java 9 implementation (using `java.lang.module.ModuleDescriptor`) is used instead.
29+
30+
## Multi-Release JAR
31+
32+
This implementation is part of a multi-release JAR structure:
33+
- Java 8: Uses ASM-based parser
34+
- Java 9-21: Uses `java.lang.module.ModuleDescriptor`
35+
- Java 22+: Uses Class File API (this implementation)
36+
37+
The appropriate version is automatically selected at runtime based on the JVM version.

0 commit comments

Comments
 (0)