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

jdk.compiler does not export com.sun.tools.javac.parser to unnamed module #950

Open
ivangsa opened this issue Nov 11, 2023 · 0 comments
Open

Comments

@ivangsa
Copy link

ivangsa commented Nov 11, 2023

What happened?

When trying to run programatically palantir java formatter:

var formatter = com.palantir.javaformat.java.Formatter.create();
formatter.formatSourceAndFixImports(source);

Throw the following exception

java.lang.IllegalAccessError: class com.palantir.javaformat.java.ImportOrderer (in unnamed module @0x544fe44c) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module @0x544fe44c

	at com.palantir.javaformat.java.ImportOrderer.<clinit>(ImportOrderer.java:111)
	at com.palantir.javaformat.java.Formatter.formatSourceAndFixImports(Formatter.java:260)

What did you want to happen?

Wouldn't replacing com.sun imports with org.openjdk fix this errors?

https://github.com/palantir/palantir-java-format/blob/develop/palantir-java-format/src/main/java/com/palantir/javaformat/java/ImportOrderer.java#L29

(I much rather not have to add those jvm args as this is for a cli tool and it will be a bit inconvenient)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant