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

Drop the dependency on com.google.errorprone:javac #197

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

Stephan202
Copy link
Member

Suggested commit message:

Drop the dependency on `com.google.errorprone:javac` (#197)

This new setup matches the upstream Error Prone build configuration and
simplifies development against JDK 11+ internal APIs.

This new setup matches the upstream Error Prone build configuration and
simplifies development against JDK 11+ internal APIs.
@Stephan202 Stephan202 added this to the 0.1.1 milestone Aug 14, 2022
@Stephan202 Stephan202 requested a review from rickie August 14, 2022 12:44
Copy link
Member Author

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Some context.

Comment on lines -855 to +856
<release>${version.jdk}</release>
<source>${version.jdk}</source>
<target>${version.jdk}</target>
Copy link
Member Author

Choose a reason for hiding this comment

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

Javac does not allow --release i.c.w. the above --add-exports flags.

Copy link
Member

Choose a reason for hiding this comment

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

https://openjdk.org/jeps/247 Do we want to link to a related explanation or not really?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that JEP link would clarify too much unless one reads very carefully. Any person wondering why we're not using --release will likely give it a try and find out 🙃

I'm not necessarily opposed to adding a comment, but it'd be a rather complicated sentence. Not sure it's worth the effort.

Copy link
Member

Choose a reason for hiding this comment

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

Let's leave it at this then.

Comment on lines -36 to +45
When loading the project in IntelliJ IDEA (and perhaps other IDEs) errors about
the inaccessibility of `com.sun.tools.javac.*` classes may be reported. If this
happens, configure your IDE to enable the `add-exports` profile.
When running the project's tests in IntelliJ IDEA, you might see the following
error:
```
java: exporting a package from system module jdk.compiler is not allowed with --release
```

If this happens, go to _Settings -> Build, Execution, Deployment -> Compiler ->
Java Compiler_ and deselect the option _Use '--release' option for
cross-compilation (Java 9 and later)_. See [IDEA-288052][idea-288052] for
details.
Copy link
Member Author

Choose a reason for hiding this comment

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

We're trading one manual bit of configuration for another; acceptable, IMHO.

Copy link
Member

Choose a reason for hiding this comment

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

IMO this is easier to detect and fix then the previous manual config.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is also nicer, as the previous profile existed solely for the purpose of IDEA: now we've reduced it to a comment (due to a bug) so IMO this is an improvement. :)

Comment on lines -340 to +350
[sonarcloud]: https://sonarcloud.io
[pitest]: https://pitest.org
[pitest-maven]: https://pitest.org/quickstart/maven
[sonarcloud]: https://sonarcloud.io
Copy link
Member Author

Choose a reason for hiding this comment

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

To be sure: there's a lot more stuff to fix/update/remove in this README, but that's out of scope.

Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

Changes LGTM.

One proposal but already approving.

Comment on lines -855 to +856
<release>${version.jdk}</release>
<source>${version.jdk}</source>
<target>${version.jdk}</target>
Copy link
Member

Choose a reason for hiding this comment

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

https://openjdk.org/jeps/247 Do we want to link to a related explanation or not really?

Comment on lines -36 to +45
When loading the project in IntelliJ IDEA (and perhaps other IDEs) errors about
the inaccessibility of `com.sun.tools.javac.*` classes may be reported. If this
happens, configure your IDE to enable the `add-exports` profile.
When running the project's tests in IntelliJ IDEA, you might see the following
error:
```
java: exporting a package from system module jdk.compiler is not allowed with --release
```

If this happens, go to _Settings -> Build, Execution, Deployment -> Compiler ->
Java Compiler_ and deselect the option _Use '--release' option for
cross-compilation (Java 9 and later)_. See [IDEA-288052][idea-288052] for
details.
Copy link
Member

Choose a reason for hiding this comment

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

IMO this is easier to detect and fix then the previous manual config.

Copy link
Contributor

@nathankooij nathankooij left a comment

Choose a reason for hiding this comment

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

Just one question and not a blocker, but feel a bit underqualified to review this. :)

Comment on lines -36 to +45
When loading the project in IntelliJ IDEA (and perhaps other IDEs) errors about
the inaccessibility of `com.sun.tools.javac.*` classes may be reported. If this
happens, configure your IDE to enable the `add-exports` profile.
When running the project's tests in IntelliJ IDEA, you might see the following
error:
```
java: exporting a package from system module jdk.compiler is not allowed with --release
```

If this happens, go to _Settings -> Build, Execution, Deployment -> Compiler ->
Java Compiler_ and deselect the option _Use '--release' option for
cross-compilation (Java 9 and later)_. See [IDEA-288052][idea-288052] for
details.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is also nicer, as the previous profile existed solely for the purpose of IDEA: now we've reduced it to a comment (due to a bug) so IMO this is an improvement. :)

--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't check in detail what we do(n't) need from this module, so trust that this reduced visibility is OK. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The entry added above is for the same module, but now with --add-exports rather than --add-opens. So IIUC this means that we no longer rely on reflective access non-public members of this module. A nice improvement :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed! I meant that I didn't go through what we need but if it compiles, then idd a very nice improvement. 😄

<arg>--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
Copy link
Contributor

Choose a reason for hiding this comment

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

How come we don't need to match what we have in jvm.config here?

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH: we could! The flags in <argLine> and ./mvn/jvm.config specify which modules can be accessed at (test) runtime. The flags in <compilerArgs> specify which modules can be referenced explicitly by the code being compiled. The list here is the minimal configuration required to compile the current code; over time this list might shrink or expand. (And likewise for the other two sets of flags, though ideally we don't rely on any compiler internals not already depended on by Error Prone itself.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack. Was mostly concerned with having to do triple bookkeeping, but keeping it minimal sounds like a good improvement. 👍

@Stephan202 Stephan202 merged commit 4c8e125 into master Sep 5, 2022
@Stephan202 Stephan202 deleted the sschroevers/drop-javac-dependency branch September 5, 2022 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants