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

OpenRewrite still fails on Java 23 #4534

Closed
triceo opened this issue Sep 30, 2024 · 3 comments · Fixed by openrewrite/rewrite-maven-plugin#872
Closed

OpenRewrite still fails on Java 23 #4534

triceo opened this issue Sep 30, 2024 · 3 comments · Fixed by openrewrite/rewrite-maven-plugin#872
Assignees
Labels
bug Something isn't working

Comments

@triceo
Copy link

triceo commented Sep 30, 2024

Using the latest version of OpenRewrite (incl. #4516), I get the following exception:

Caused by: java.lang.AssertionError: Failed to parse sources or run recipe
at org.openrewrite.test.RewriteTest.lambda$defaultExecutionContext$14(RewriteTest.java:631)
at org.openrewrite.java.isolated.ReloadableJava17ParserVisitor.convert(ReloadableJava17ParserVisitor.java:1692)
at org.openrewrite.java.isolated.ReloadableJava17ParserVisitor.convert(ReloadableJava17ParserVisitor.java:1698)
at org.openrewrite.java.isolated.ReloadableJava17ParserVisitor.convertAll(ReloadableJava17ParserVisitor.java:1734)
at org.openrewrite.java.isolated.ReloadableJava17ParserVisitor.visitCompilationUnit(ReloadableJava17ParserVisitor.java:551)
at org.openrewrite.java.isolated.ReloadableJava17ParserVisitor.visitCompilationUnit(ReloadableJava17ParserVisitor.java:73)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:625)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
at org.openrewrite.java.isolated.ReloadableJava17Parser.lambda$parseInputs$0(ReloadableJava17Parser.java:166)
... 16 more
Caused by: org.openrewrite.java.JavaParsingException: Failed to convert for the following cursor stack:--- BEGIN PATH ---
    JCCompilationUnit(sourceFile = test.java)
--- END PATH ---

... 24 more
Caused by: java.lang.NoSuchMethodError: 'com.sun.tools.javac.tree.DCTree$DCDocComment com.sun.tools.javac.tree.DocCommentTable.getCommentTree(com.sun.tools.javac.tree.JCTree)'
at org.openrewrite.java.isolated.ReloadableJava17ParserVisitor.convert(ReloadableJava17ParserVisitor.java:1669)
... 23 more

To reproduce:

  1. Clone https://github.com/TimefoldAI/timefold-solver
  2. mvn clean install -Dquickly
  3. cd migration
  4. mvn test
  5. See failing tests.

No tests are failing on either JDK 17, 21 or 22.

@timtebeek
Copy link
Contributor

hi @triceo, Thanks for the update! #4516 Had changed our Java 21 parser, whereas your stacktrace for some reason is picking up the Java 17 parser. I've backported the fix to our Java 17 parser as well in 1e4a8d9, just to get you unblocked. Likely the proper fix is to add our Java 21 parser to the Maven plugin.

timtebeek added a commit to openrewrite/rewrite-maven-plugin that referenced this issue Sep 30, 2024
@timtebeek timtebeek moved this to Ready to Review in OpenRewrite Sep 30, 2024
@timtebeek timtebeek self-assigned this Sep 30, 2024
@triceo
Copy link
Author

triceo commented Sep 30, 2024

Thank you, @timtebeek! I'll validate when a release is out.

@Col-E
Copy link

Col-E commented Oct 1, 2024

Confirming I've also encountered this stacktrace on Java 23 using OpenRewrite21

java.lang.NoSuchMethodError: 'com.sun.tools.javac.tree.DCTree$DCDocComment com.sun.tools.javac.tree.DocCommentTable.getCommentTree(com.sun.tools.javac.tree.JCTree)'
  org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.convert(ReloadableJava21ParserVisitor.java:1667)
  org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitCompilationUnit(ReloadableJava21ParserVisitor.java:538)
  org.openrewrite.java.isolated.ReloadableJava21ParserVisitor.visitCompilationUnit(ReloadableJava21ParserVisitor.java:74)
  com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:625)
  com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)

timtebeek added a commit to openrewrite/rewrite-maven-plugin that referenced this issue Oct 1, 2024
* Add rewrite-java-21

Fixes openrewrite/rewrite#4534

* Continue to build on Java 17
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants