google / google/error-prone

Consider using an embedded standalone javac compiler instead of relying on JVM internals

Open
#4,144 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

As per your [documentation](https://errorprone.info/docs/installation), on JDK 16 and newer, additional flags are required due to [JEP 396: Strongly Encapsulate JDK Internals by Default](https://openjdk.java.net/jeps/396).

You suggest adding certain `--add-exports`/`--add-opens` incantations to Maven when using error-prone.

This may work for the foreseeable future but since this is really prying upon JVM internals that are marked to be not stable API, we're at the mercy of Oracle to not change things too quickly. In the worst case, we're slowing down compiler development because of this "quasi API".

Moreover, I think the suggestion to add these configuration options to `.mvn/jvm.config` is not a good idea since this will apply to other projects and plugins, too, further complicating the situation.

Have you considered switching to an embedded standalone javac compiler/AST parser instead of relying on these rather unstable internals?

I've run across a similar issue and released [jdk.compiler.standalone](https://github.com/kohlschutter/jdk.compiler.standalone), which exposes both a mostly unmodified original Java 11 compiler as well as the Java 21 compiler backported to run on Java 11 and newer.

I'm curious if this is something you'd be interested in exploring. For what it's worth, `jdk.compiler.standalone` is able to compile itself. It also works with GraalVM native-image and on JRE-only Java installations version 11 or newer.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.