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

Fix Tooling API compatibility #14428

Closed
wants to merge 21 commits into from
Closed

Conversation

donat
Copy link
Member

@donat donat commented Sep 4, 2020

When a Tooling API client connects to Gradle, it loads classes from the target version and uses those to interact with the daemon. Unfortunately, the JavaVersion class is also involved in this process. The old versions of that class are not prepared for the new Java version number schemes. This means when a TAPI client (i.e. an IDE process) is running on a newer JDK it effectively cannot connect to older Gradle versions.

Fortunately, the JavaVersion class is isolated: it doesn't have any dependency on other Gradle classes. Consequently, we can easily load a variant different from the one provided by the target Gradle version. This PR does just that: it forces the tooling implementation loader to load the class from the Tooling API jar, which contains the latest version.

Our CI infrastructure missed this regression as all integration tests use the same Java version for the Tooling API client and for the Gradle daemon. This PR also implements this missing test coverage.

@donat donat self-assigned this Sep 4, 2020
@donat donat requested a review from a team September 4, 2020 09:46
@donat donat added this to the 6.7 RC1 milestone Sep 4, 2020
@donat donat added from:member a:regression This used to work labels Sep 4, 2020
@donat donat marked this pull request as ready for review September 4, 2020 09:46
Copy link
Contributor

@JLLeitschuh JLLeitschuh left a comment

Choose a reason for hiding this comment

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

LGTM!

@big-guy big-guy changed the base branch from master to release September 4, 2020 22:54

@Unroll
@Requires(adhoc = { TestPrecondition.JDK11_OR_LATER.fulfilled && !GradleContextualExecuter.embedded })
def "Java #compilerJdkVersion.majorVersion client can launch task on Java #clientJdkVersion.majorVersion with Gradle #gradleVersion on Java #gradleDaemonJdkVersion.majorVersion"(JavaVersion compilerJdkVersion, JavaVersion clientJdkVersion, JavaVersion gradleDaemonJdkVersion, String gradleVersion) {
Copy link
Member

Choose a reason for hiding this comment

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

This is close to what I was thinking we could do, but I think we should avoid running the compiler ourselves. I also think we should run this test regardless if the test is running on JDK8, JDK11 or beyond.

Take a look at this reworking of this test:
89e981a

Instead of compiling the TAPI client by hand, everything is wrapped into a Gradle build that can do a few things for us:

  • Resolve the TAPI client dependencies (vs relying on the classpath of the test to have it)
  • Find a JDK8 toolchain so we can build 6-8 compatible classes
  • Target the right compatibility level

I think this makes it a little easier to also compile a custom action since everything is contained in the 'client-runner' project.

PTAL and see if this is helpful.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is absolutely helpful, thanks Sterling, for making the modeling much nicer.

@donat donat force-pushed the donat/tapi-javaversion-experiment branch from 5573f17 to b6a16c7 Compare September 7, 2020 09:48
@donat donat requested a review from pioterj as a code owner September 7, 2020 09:48
@donat donat force-pushed the donat/tapi-javaversion-experiment branch from 465636c to 39412be Compare September 7, 2020 12:45
@donat donat force-pushed the donat/tapi-javaversion-experiment branch from 39412be to 181caa3 Compare September 7, 2020 12:46
donat and others added 2 commits September 7, 2020 14:52
- Instead of compiling a class from resources via the command-line, use a Gradle build with different JDK targets
- We do not need to test the current release against itself, we have other TAPI tests to cover that
- We do not need to test that a new JDK can compile backwards to older bytecode
@donat donat force-pushed the donat/tapi-javaversion-experiment branch from 181caa3 to 19a4648 Compare September 7, 2020 12:54
@donat
Copy link
Member Author

donat commented Sep 7, 2020

I was not able to properly rebase the PR without including a bunch of unrelated files. It seems like a bug in GH. I've moved the PR to #14444.

@donat donat closed this Sep 7, 2020
@donat donat deleted the donat/tapi-javaversion-experiment branch September 7, 2020 13:04
@ov7a ov7a removed this from the 6.7 RC1 milestone Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants