Skip to content

CodeGenerator: replace legacy cf API usage with javap tool call - #9839

Open
mbien wants to merge 1 commit into
apache:masterfrom
mbien:remove-legacy-cf-api-usage
Open

mbien wants to merge 1 commit into
apache:masterfrom
mbien:remove-legacy-cf-api-usage

Conversation

@mbien

@mbien mbien commented Nov 29, 2026 •

Copy link
Copy Markdown
Member
  • temporary implementation until JDK 25 bump which unlocks public classfile API
  • uses javap of the runtime JDK (in process) if possible and a compatible JDK from the platform manager as fallback (extra process)

related: #8931

fixes #9368

@mbien mbien added this to the NB33 milestone Nov 29, 2026
@mbien
mbien requested a review from lahodaj November 29, 2026 17:31
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Code cleanup Label for cleanup done on the Netbeans IDE labels Nov 29, 2026
@mbien

mbien commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

forgot to commit the test. one sec.

edit unfortunately this can't be easily end-to-end tested within this module since the test JVM doesn't have the javap module in it due to how it sets up nb-javac. It could be made testable by changing the impl to get javap via the default java platform and spawn a process, but the nice thing about the current impl is that it remains in-process.

@mbien
mbien force-pushed the remove-legacy-cf-api-usage branch from 29b7520 to 756da86 Compare November 29, 2026 19:48
@lahodaj

lahodaj commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

One thing to note is that javap in newer versions of JDK - those that use the ClassFile API do not tolerate newer classfiles anymore. How much that is a problem, not sure.

@mbien

mbien commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

thanks for the heads up. I mostly checked the lower bound case (JDK 21 javap used on bytecode of 28). Will do a bit of testing using 25 on bytecode of 28.

 - temporary implementation until JDK 25 bump which unlocks public
   classfile API
 - uses javap of the runtime JDK (in process) if possible and a
   compatible JDK from the platform manager as fallback (extra process)

fixes apache#9368
@mbien
mbien force-pushed the remove-legacy-cf-api-usage branch from 756da86 to 8fa3332 Compare December 1, 2026 02:38
@mbien

mbien commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

confirmed. javap of JDK 25+ only supports bytecode up to its own version, while JDK 21 is more tolerant. Thanks for pointing this out since I would have overlooked that.

changed it into two code paths:

  • if runtime JDK supports classfile version -> use in-process javap
  • if it doesn't -> pick a compatible JDK from the platform manager and use that javap using an extra process

situation regarding future JDK 25 bump changes slightly too: the first path could be rewritten and the fallback kept

(updated PR description)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Code cleanup Label for cleanup done on the Netbeans IDE Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate com.sun.tools.classfile usage

2 participants