-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
8332497: javac prints an AssertionError when annotation processing runs on program with module imports #19292
Conversation
👋 Welcome back Evemose! A progress list of the required criteria for merging this PR into |
@Evemose 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:
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 86 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vicente-romero-oracle, @lahodaj) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
I recommend adding a minimal test case for this bug, like the one from the JBS issue. |
@liach been done. It's my first time writing javac tests so I am not sure I have done everything in the best way, but I've tried my best |
The test is not wrong, but could be made shorter like here: Also, the similar |
Thanks for suggestion. Is it ok to just out bug-related test into some pre-existing test class? I just saw that issue-related tests are all in separate folders so figured its how it should be. Also will annotaion processing run if there is no annotated elemnts at all? If i remeber correctly, it will not. Also im not really sure why it fails in ci workflow cause on my local machine test passes. Im not sure where is the issue, so I guess I will just use code you have provided instead PS: i found the issue. For some reason, when I ran in local, tests did not require --enable-preview, but in ci it does |
Yes. If you look at git blame (available from Intellij Idea annotations) you will find those Txxxxxxxx tests are from long ago; they are legacy and no longer encouraged in newer tests, which usually group by their subjects. |
test/langtools/tools/javac/annotations/ModuleImportProcessingTest.java
Outdated
Show resolved
Hide resolved
Drive-by comment: I was curious about the "crashes" in the bug description, but this is no crash. It is an AssertionError. Could we please improve JBS issue title and PR title to say that? |
I would be happy to, but I am not the one who created the issue. I filed mine report too, but I guess it has been discarded as duplicate. I was just the one to do the fix. @lahodaj I guess this request should be addressed to you |
I've changed the issue title to: "javac prints an AssertionError when annotation processing runs on program with module imports". OTOH, not sure what's wrong with "crash". It crashes (the program stops working) with an exception. |
Maybe its just me. When I read "crash", I think segfault, or core dump. A javac core'ing would be interesting, that's why I looked. |
test/langtools/tools/javac/processing/ModuleImportProcessingTest.java
Outdated
Show resolved
Hide resolved
@vicente-romero-oracle I have addressed your review comments in last commit. Hope I got everything correctly and now everything is fine! |
ok this is what I would do, please feel free to use it, it is applicable on top of your current code. As you can see I have reformatted the test to align it better with the rest of similar tests in our code base. Also as Jan suggested I have added an equivalent method to TreeTranslator for completeness.
|
Thanks for suggestions. I have sliglty changed the test code you have provided. I saw that people use base.resolve("src") for source file path, but as I understand, the context of base is flushed after each test so effectively it doesnt make much of a difference but adds some noise in the code making harder to distinguish the flow of test. Same goes for test source string. I thought that this way test may be more readable. As for TreeTranslator, I also have thought about adding visit method in this issue, but I figured that it doesnt really relate to the issue title so this change could kind of subtle. Still, If you think it should be fixed in the same issue, than I dont see anything against it as long as such expromt changes are usual there. Maybe its worth renaming the issue to something like "Some visitors dont override visitModuleImport resulting in AssertionError" though. I also guess maybe if we add visitModuleImport for TreeTranslator here then we should also add a test for it just in case, but I didnt find mockito in jtreg suite so im not sure that it is possible to verify how many times exactly method has been called and writing full translation test just to verify simple 2-line methods works correctly seems like overkill. (I didnt even find any tests for TreeTranslator, seems like its not covered by tests at all) |
test/langtools/tools/javac/processing/ModuleImportProcessingTest.java
Outdated
Show resolved
Hide resolved
test/langtools/tools/javac/processing/ModuleImportProcessingTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
yes we don't have tests for TreeTranslator, at least not targeting it explicitly, so it is OK not to provide one now. I think the title of the bug is OK as it is |
/integrate |
There was a problem hiding this comment.
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 for working on this!
I am running tests now.
@Evemose, please note you'll need to type:
/integrate
in a separate comment, so that a committer can sponsor.
Thanks!
Hi! |
Right. Sorry, I missed the label. |
/sponsor |
Going to push as commit 617edf3.
Your commit was automatically rebased without conflicts. |
Fix is pretty simple: visitModuleImport in com.sun.tools.javac.tree.TreeScanner has notbeen overriden, so defaulted to Visitor::visitModuleImport, which forwards to Visitor::visitTree, which is also not overriden, and, therefore, threw AssertionError.
PS: Im not even sure how it worked before without crashing, seems like there is some intermidiate implementation between this TreeScanner and actual scanners because otherwise it should have resultedin compile error the moment it encounter module importin any visitor
Progress
Warning
8332497: javac prints an AssertionError when annotation processing runs on program with module imports
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19292/head:pull/19292
$ git checkout pull/19292
Update a local copy of the PR:
$ git checkout pull/19292
$ git pull https://git.openjdk.org/jdk.git pull/19292/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19292
View PR using the GUI difftool:
$ git pr show -t 19292
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19292.diff
Webrev
Link to Webrev Comment