rewrite-migrate-java icon indicating copy to clipboard operation
rewrite-migrate-java copied to clipboard

Run on Java toolchain 21

Open timtebeek opened this issue 2 years ago • 4 comments

Mostly to flush out issues with the build, and to be able to add new SequencedCollection recipes for getFirst, getLast & addFirst.

timtebeek avatar Nov 02 '23 21:11 timtebeek

As discussed one on one; copied here for future follow up

Ah yes, I have seen that. Here's what's happening: Anywhere in the tests we construct a gradle dependency model, which any test that calls withToolingApi() does, it is achieved by writing the build.gradle to disk at some temporary location and calling OpenRewriteModelBuilder.forProjectDirectory(). That in turn uses Gradle's tooling API to extract the relevant dependency information and translate it into our GradleProject marker.

Now the problem seems to be that Gradle's tooling API doesn't work quite right when running on Java 21 I haven't debugged into Gradle's code, but I speculate that it is compiling the build script itself to a Java 21 (bytecode version 65) class file, and then passes that in to part of its process which does not support it So we should probably tell Gradle about it

timtebeek avatar Nov 03 '23 07:11 timtebeek

@sambsnyd We're now instead getting this stacktrace on anything that tries to open classpath resource jars:

at java.util.Objects.requireNonNull(Objects.java:233)	
at org.openrewrite.java.JavaParser.dependenciesFromResources(JavaParser.java:185)	
at org.openrewrite.java.JavaParser$Builder.classpathFromResources(JavaParser.java:379)	
at org.openrewrite.java.migrate.jakarta.RemovedUIComponentConstantTest.defaults(RemovedUIComponentConstantTest.java:32)	
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:140)	
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:132)	
at org.openrewrite.test.RewriteTest.rewriteRun(RewriteTest.java:127)	
at org.openrewrite.java.migrate.jakarta.RemovedUIComponentConstantTest.removedUIComponentConstant_1(RemovedUIComponentConstantTest.java:40)	
at java.lang.invoke.LambdaForm$DMH/0x00007f81c4164000.invokeVirtual(LambdaForm$DMH)	
at java.lang.invoke.LambdaForm$MH/0x00007f81c4098800.invoke(LambdaForm$MH)	
at java.lang.invoke.Invokers$Holder.invokeExact_MT(Invokers$Holder)	
at java.lang.reflect.Method.invoke(Method.java:580)	
at java.util.ArrayList.forEach(ArrayList.java:1596)	
at java.util.ArrayList.forEach(ArrayList.java:1596)	

I'm going to guess and say that's progress, but don't yet know what we'd need now. :)

timtebeek avatar Nov 21 '23 15:11 timtebeek

There's quite some fixes in this branch that can already be merged, as those tests are only run on Java 21:

  • https://github.com/openrewrite/rewrite-migrate-java/pull/403

Then when run here they lead to less to debug and fix; likely only the classpath resource jar issues

timtebeek avatar Jan 26 '24 21:01 timtebeek

Wondering if there might have been any relation to this reported issue & fix:

  • https://github.com/openrewrite/rewrite/issues/4123
  • https://github.com/openrewrite/rewrite/pull/4124

timtebeek avatar Apr 15 '24 08:04 timtebeek

Closing for now as there's no immediate fix expected in this repository.

timtebeek avatar Jul 29 '24 14:07 timtebeek