Skip to content

Improving error messages when an annotation processor crashes. - #9560

Open
lahodaj wants to merge 3 commits into
apache:masterfrom
lahodaj:improve-ap-error-messages
Open

Improving error messages when an annotation processor crashes.#9560
lahodaj wants to merge 3 commits into
apache:masterfrom
lahodaj:improve-ap-error-messages

Conversation

@lahodaj

@lahodaj lahodaj commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Improving error messages when an annotation processor crashes and clear AP cache on failure.

  • use printStackTrace(writer) to format exception
  • add jar location, AP name and javac version to exception message
  • use update advice message for APs with known compatibility issues (e.g lombok) but generic failure msg by default

example:

image

@lahodaj lahodaj added this to the NB32 milestone Aug 13, 2026
@lahodaj
lahodaj requested review from dbalek and mbien August 13, 2026 11:53
@lahodaj lahodaj 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) labels Aug 13, 2026
@lahodaj
lahodaj force-pushed the improve-ap-error-messages branch from 1f12e3c to 86f0b8a Compare August 13, 2026 12:14
@mbien

mbien commented Aug 13, 2026

Copy link
Copy Markdown
Member

thanks for looking into this. The key puzzle piece was the fact that printMessage() wouldn't display in UI when no element was passed as parameter. Given that it was already used that way (but it didn't work?), I assumed It must be me looking at the wrong place.

I made some changes on top of this PR:

  • switch back to generic (but improved) AP message: even though the changes here are mainly due to lombok, lets try to make the improvements useful for all APs
  • use SourceVersion.latest().runtimeVersion().feature() instead of constant as msg parameter
  • use printStackTrace(writer) to format exception to make it look "native"
  • add jar location, AP name and javac version to exception message
  • clear class cache on AP failure

commit would be at https://github.com/mbien/netbeans/tree/improve-ap-error-messages, let me know what you think.

lahodaj and others added 3 commits August 28, 2026 02:52
 - add jar location, AP name and javac version to exception message
 - clear class cache on AP failure
 - use update advice message for APs with known compatibility issues
   (e.g lombok) but generic failure msg by default
@mbien
mbien force-pushed the improve-ap-error-messages branch from b3a448c to ec0634f Compare August 28, 2026 05:45
@mbien

mbien commented Aug 28, 2026

Copy link
Copy Markdown
Member

added commit, rebased, updated PR text with screenshot.

changes:

  • back to two messages, one with update advice for APs with known compatibility issues like lombok and for all other failures the same msg just without advice.
  • cache is cleared on all failures

would be good to squash after review

@lahodaj
lahodaj marked this pull request as ready for review August 28, 2026 14:07
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) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Need Squashing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants