Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8321164: javac with annotation processor throws AssertionError: Filling jrt:/... during JarFileObject[/...] #17001

Closed
wants to merge 2 commits into from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Dec 6, 2023

This is a latent bug revealed by the recent JDK-8225377/https://git.openjdk.org/jdk/commit/de6667cf11aa59d1bab78ae5fb235ea0b901d5c4.

The problem (to my understanding) is as follows:

  • ClassReader cannot be used recursively, i.e. while completing one class from a classfile, we cannot complete another one. ClassReader carefully avoids situations like this.
  • when reading an anonymous class, the EnclosingMethod attribute is read, and the enclosing method must be found. ClassReader uses a special ClassReader. isSameBinaryType method, that is supposed to avoid completion:
    private boolean isSameBinaryType(MethodType mt1, MethodType mt2) {
  • the isSameBinaryType method uses erasure, and if the given type has type annotations, the erasure will try to remove the annotations:
    default: return s.dropMetadata(Annotations.class);

The problem is that this method uses Type.getKind() which completes.

The proposal in this patch is to avoid the completion by not using getKind, but rather getTag. While I am not completely sure why the code avoids doing dropMetadata for some types, I tried to replicate the existing behavior. One caveat is that certain types may have getTag() == CLASS, but getKind() == ERROR (e.g. if the class is not found). The new code is not replicating this aspect, as we cannot reliably determine whether a ClassType is erroneous or not without completing it. But, it is not clear to me why dropping annotations from an erroneous ClassType should be problematic.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8321164: javac with annotation processor throws AssertionError: Filling jrt:/... during JarFileObject[/...] (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17001/head:pull/17001
$ git checkout pull/17001

Update a local copy of the PR:
$ git checkout pull/17001
$ git pull https://git.openjdk.org/jdk.git pull/17001/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17001

View PR using the GUI difftool:
$ git pr show -t 17001

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17001.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 6, 2023

👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Dec 6, 2023

@lahodaj The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler compiler-dev@openjdk.org label Dec 6, 2023
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle left a comment

Choose a reason for hiding this comment

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

lgtm, nice test

case BYTE, CHAR, SHORT, LONG, FLOAT, INT, DOUBLE, BOOLEAN,
ARRAY, MODULE, TYPEVAR, WILDCARD:
return s.dropMetadata(Annotations.class);
case VOID, METHOD, PACKAGE, FORALL, DEFERRED, BOT,
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that it should matter much (as it cannot be annotated) but the BOT type seemed to receive a different treatment before (the kind for that is NULL). Separately, I'm a bit hazy of the rationale behind the logic here. E.g. is it an optimization to avoid removing metadata that we know isn't there, or is it something else? Anyway, not something to fix now (mostly thinking aloud)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uh, I somehow missed the NULL. Thanks for noticing. My intent here is not to change the behavior if possible, so I restored the NULL/BOT behavior as it was before.

As for the logic, I agree, I don't know why it is written like this. We could possibly try to cleanup early in a release and test.

@openjdk
Copy link

openjdk bot commented Dec 7, 2023

@lahodaj This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8321164: javac with annotation processor throws AssertionError: Filling jrt:/... during JarFileObject[/...]

Reviewed-by: vromero, mcimadamore

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 43 new commits pushed to the master branch:

  • 632a3c5: 8305825: getBounds API returns wrong value resulting in multiple Regression Test Failures on Ubuntu 23.04
  • 75a7c19: 8315827: Kitchensink.java and RenaissanceStressTest.java time out with jvmti module errors
  • 91ffdfb: 8320365: IPPPrintService.getAttributes() causes blanket re-initialisation
  • 50baaf4: 8321013: Parallel: Refactor ObjectStartArray
  • afb8964: 8320443: [macos] Test java/awt/print/PrinterJob/PrinterDevice.java fails on macOS
  • 82796bd: 8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters
  • 781775d: 8321484: Make TestImplicitlyDeclaredClasses release independent
  • b02fc86: 8321122: Shenandoah: Remove ShenandoahLoopOptsAfterExpansion flag
  • 2830dd2: 8321410: Shenandoah: Remove ShenandoahSuspendibleWorkers flag
  • f482260: 8319969: os::large_page_init() turns off THPs for ZGC
  • ... and 33 more: https://git.openjdk.org/jdk/compare/87516e29dc5015c4cab2c07c5539ad30f2768667...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 7, 2023
@mlbridge
Copy link

mlbridge bot commented Dec 7, 2023

Webrevs

@lahodaj
Copy link
Contributor Author

lahodaj commented Dec 7, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Dec 7, 2023

Going to push as commit 03c4595.
Since your change was applied there have been 43 commits pushed to the master branch:

  • 632a3c5: 8305825: getBounds API returns wrong value resulting in multiple Regression Test Failures on Ubuntu 23.04
  • 75a7c19: 8315827: Kitchensink.java and RenaissanceStressTest.java time out with jvmti module errors
  • 91ffdfb: 8320365: IPPPrintService.getAttributes() causes blanket re-initialisation
  • 50baaf4: 8321013: Parallel: Refactor ObjectStartArray
  • afb8964: 8320443: [macos] Test java/awt/print/PrinterJob/PrinterDevice.java fails on macOS
  • 82796bd: 8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters
  • 781775d: 8321484: Make TestImplicitlyDeclaredClasses release independent
  • b02fc86: 8321122: Shenandoah: Remove ShenandoahLoopOptsAfterExpansion flag
  • 2830dd2: 8321410: Shenandoah: Remove ShenandoahSuspendibleWorkers flag
  • f482260: 8319969: os::large_page_init() turns off THPs for ZGC
  • ... and 33 more: https://git.openjdk.org/jdk/compare/87516e29dc5015c4cab2c07c5539ad30f2768667...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Dec 7, 2023
@openjdk openjdk bot closed this Dec 7, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 7, 2023
@openjdk
Copy link

openjdk bot commented Dec 7, 2023

@lahodaj Pushed as commit 03c4595.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
3 participants