Skip to content

Sanitize erroneous package annotations before index generation - #9777

Merged
ebarboni merged 1 commit into
apache:deliveryfrom
mvanhorn:fix/9740-erroneous-package-annotations
Nov 3, 2026
Merged

ebarboni merged 1 commit into
apache:deliveryfrom
mvanhorn:fix/9740-erroneous-package-annotations

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

LLMs, Commit messages and PR description:

Java indexing can fail with an AssertionError when a package annotation contains an unresolved type, preventing index signature generation. The annotation sanitization pass skipped package symbol metadata. Erroneous package annotations could therefore reach javac's class writer, which cannot generate signatures for error types.

VanillaCompileWorker now sanitizes package annotations through the existing clearAnnotations logic when a package symbol is present. The regression test covers unresolved annotation types, class literals, and nested annotations, checking that signature generation succeeds, valid @deprecated annotations remain, and source errors are still recorded.

jvm_tests found no Maven or Gradle build owning the touched files, so it ran no tests.
ant $OPTS -f java/debugger.jpda.truffle test was invoked, but the transcript reports no result.
The tests in java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java fail without the fix in the netbeans VanillaCompileWorker change (checked by reverting the source changes).

Fixes #9740

PR approval and merge checklist:

  1. Was this PR correctly labeled, did the right tests run? When did they run?
  2. Is this PR squashed?
  3. Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?

If this PR targets the delivery branch: don't merge. (full wiki article)

AI was used for assistance.

@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) labels Nov 2, 2026
@apache apache locked and limited conversation to collaborators Nov 2, 2026
@apache apache unlocked this conversation Nov 2, 2026
@mbien
mbien requested review from dbalek, lahodaj and mbien November 2, 2026 10:39
@mbien

mbien commented Nov 2, 2026

Copy link
Copy Markdown
Member

potentially RC3 candidate. But needs eyes and testing first.

@lahodaj lahodaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@mbien mbien added the do not merge Don't merge this PR, it is not ready or just demonstration purposes. label Nov 2, 2026
@mbien
mbien changed the base branch from master to delivery November 2, 2026 11:40
@mbien mbien added this to the NB32 milestone Nov 2, 2026
@mbien

mbien commented Nov 2, 2026

Copy link
Copy Markdown
Member

@mvanhorn to get this last minute change into NB 32 we would have to fix two things:

  1. please use a real email address on the commit header (see CI failure)
  2. base the branch on delivery instead of master and put your commit on it (force push into your PR branch)

thanks for working on this fix btw!

VanillaCompileWorker now sanitizes package annotations through the
existing clearAnnotations logic when a package symbol is present. The
regression test covers unresolved annotation types, class literals, and
nested annotations, checking that signature generation succeeds, valid
@deprecated annotations remain, and source errors are still recorded.

Fixes apache#9740

Assisted-by: AI
@mvanhorn
mvanhorn force-pushed the fix/9740-erroneous-package-annotations branch from fe4c0cf to b54928f Compare November 2, 2026 13:51
@mvanhorn

mvanhorn commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. The branch is now a single commit on top of delivery and is force pushed, and the commit author is a real address instead of the GitHub noreply one. The code change is the same as before.

VanillaCompileWorkerTest passes on the rebased tree locally on JDK 21, 63 tests with 0 failures. CI on the new head has only just started, so I'll leave that to report on its own.

@mvanhorn

mvanhorn commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Small correction to my note above: CI has not started on the new head. The workflow run is waiting on a maintainer to approve it (action_required).

@mbien mbien removed the do not merge Don't merge this PR, it is not ready or just demonstration purposes. label Nov 2, 2026
@mvanhorn

mvanhorn commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

CI has now run on b54928f. Two jobs failed, Java Hints batch1 on JDK 21 and on JDK 27, both on the same test: OrganizeMembersTest.testSimpleMemberSort, which did not get its expected "Members order does not correspond to the specified code style rules" warning.

I don't know the cause yet. The same job passed on both JDKs on the earlier master-based head (fe4c0cf), and on JDK 21 on the delivery head (3fedd65). This PR only touches VanillaCompileWorker and its test. I tried to run the test locally, but the test dependencies did not build in my checkout, so I have not reproduced it either way.

Could someone re-run those two jobs? I can't re-run them myself, and that would show whether this is a flake or something the PR needs to fix.

@mbien

mbien commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

OrganizeMembersTest is a bit unreliable if I remember correctly. More concerning is the timeout we will get in the java.source.base since its stuck atm. At least I don't remember seeing this before.

running two test loops in parallel:

lets see what happens

@mbien mbien added do not merge Don't merge this PR, it is not ready or just demonstration purposes. and removed do not merge Don't merge this PR, it is not ready or just demonstration purposes. labels Nov 2, 2026

@mbien mbien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets book this under "CI gremlins"

seems good now. Ran the indexer smoke test locally indexing all ~860 modules and it indexed them all without exceptions.

@ebarboni
ebarboni merged commit 711b843 into apache:delivery Nov 3, 2026
128 of 136 checks passed
@mvanhorn

mvanhorn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Many thanks for the review and merge, @ebarboni. Sanitizing erroneous package annotations should keep Java indexing from tripping over unresolved types.

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssertionError typeSig ERROR

4 participants