Honor --release for current JDK - #5254
Conversation
Use ct.sym metadata to filter the live JRT image when --release targets the running JDK. This prevents implementation-specific modules from leaking through the standard API view. Assisted-by: OpenAI Codex (GPT-5)
b381708 to
65d1f54
Compare
|
I don't see Question: is your use case about modular or non-modular client code? For the latter, it's JEP 261 that decides what is observable and what is not. Actually, JEP 247 is quite specific about this:
So, to resolve this issue, we'd need to figure out what "documented modules" are - documented where and how? Is there a relationship to JEP 261's "default set of root modules for the unnamed module"? Also note that JEP 247 is not an official feature of Java SE, which is also the reason why it is scarcely documented. |
|
My motivation was the reported disparity between ECJ and javac when handling I think that "documented modules" is basically this The names flow into the processing and eventually to The test uses the I think JEP 261 applies after JEP 247 has restricted the set. |
That's great and I am all for eliminating such differences -- based on official specifications, where humanly possible.
You are right, and I admit that until today I hadn't seen that JEP 247 says "The list of observable modules is limited, however, to the documented modules and the jdk.unsupported module". BTW, have you checked the case of
We need to base the implementation on some clear definition which modules should be observable. And "documented modules" sure sounded like something that would be documented somewhere ;-P
That doesn't explain which modules are "documented".
Now I see where you are coming from. In this particular scenario To me this still feels odd, because |
|
It is all searching, looking at the JDK source code, guessing, and AI, of course. They changed the contents of the |
What it does
ECJ now applies the JEP 247 API restrictions when
--releasetargets the same version as the JDK running the compiler.Previously, this case bypassed
ct.symand used the live JRT image directly, which made implementation-specific modules observable. The change reads the current releasesystem-modulesmetadata fromct.sym, uses the live JRT classes as intended, and filters class, module, and package lookup to the documented module set.This aligns ECJ with
javacand prevents modules such as OpenJ9openj9.criuor HotSpotjdk.internal.vm.cifrom being exposed through--release. The OpenJ9 behavior was reported in eclipse-openj9/openj9#18205 and diagnosed as an ECJ same-release issue in my comment on that issue.The regression tests verify both that the current-release path uses
ct.symmetadata and that an implementation-specific module available without--releaseis rejected when--releaseis present.AI assistance: OpenAI Codex (GPT-5) helped investigate, implement, test, and prepare this change; the assistance is also recorded in the commit trailer.
How to test
BatchCompilerTeston a JDK that containsjdk.internal.vm.ci.testReleaseCurrentJdkUsesCtSymselects the JEP 247 classpath for--release <current>.testReleaseCurrentJdkFiltersImplementationSpecificModulesacceptsjdk.internal.vm.ciwithout--releaseand rejects it with--release <current>.BatchCompilerTestsuite passed on Temurin 21: 370 tests, 0 failures, 0 errors, and 0 skipped tests.git diff --checkpasses.Author checklist