cincheo / jsweet

A Java to JavaScript transpiler.
http://www.jsweet.org
Other
1.45k stars 159 forks source link

Java 16 support : Reflection issue in the compiler? #751

Open kspalaiologos opened 1 year ago

kspalaiologos commented 1 year ago

Hello. I am using JSweet and its Maven plugin. When trying to generate JS code, I stumble upon the following error from the compiler:

[INFO] --- jsweet-maven-plugin:3.1.0:jsweet (default-cli) @ maja ---
[INFO] JSweet transpiler version 3.1.0 (build date: 2021-04-21 20:24:55)
[WARNING] dependency type not-jar excluded from candies detection: Dependency {groupId=org.junit.jupiter, artifactId=junit-jupiter, version=5.9.2, type=jar}
[WARNING] dependency type not-jar excluded from candies detection: Dependency {groupId=org.assertj, artifactId=assertj-core, version=3.24.2, type=jar}
dependency type not-jar excluded from candies detection: Dependency {groupId=org.assertj, artifactId=assertj-core, version=3.24.2, type=jar}

I'm not sure if the transpiler didn't catch onto the fact that junit/assertj are not needed for the production build, but the greater issue here is the following error:

Unable to make field public com.sun.tools.javac.code.Type com.sun.tools.javac.tree.JCTree.type accessible: module jdk.compiler does not "exports com.sun.tools.javac.tree" to unnamed module @604b1e1d

I think that JSweet is not compatible with Java16, but it doesn't seem like this is stated anywhere. Regardless, J16 support would be amazing.

lgrignon commented 1 year ago

Hello, yes unfortunately JSweet 3 brought support for Java 11 but was not tested for more recent versions. Note : some users seem to use Java version over 11 without problem, but I am not sure which version breaks compatibility

kohlschuetter commented 8 months ago

This should be fixed by using standalone compiler instead of relying on whatever JDK provides. see PR https://github.com/cincheo/jsweet/pull/770 for details.