Closed regrog closed 3 years ago
OULALA. T'es sur que c'était une bonne idée cette version 3 finalement ;)
:D
On Fri, Jul 31, 2020 at 1:08 PM Andrea notifications@github.com wrote:
Hi,
I'm using jsweet in an eclipse project using you project ( https://github.com/cincheo/jsweet-eclipse-plugin). Actually running it with java 8 everything works perfectly.
Now I'm migrating to java 11+ but I'm having some issues. I' replaced the old jsweet-transpiler-latest-jar-with-dependencies.jar with the new release candidate jsweet-transpiler-3.0.0-RC3-jar-with-dependencies.jar
I changed the call to Utils.addFiles to Utils.Static.addFiles and removed the call to JSweetConfig.jinitClassPath(jdkHome).
But when I run the transpilation this error occurs that doesn't seem to be part of what I changed.
Can I have any help? Thanks
dumping transpiler's strack trace: [JCMethodDecl] public
() {... (myHome/myProject/src/main/java/myClass.java(6,8)) [JCClassDecl] public class IsAccTraIdSettedC... (myHome/myProject/src/main/java/myClass.java(6,1)) [JCCompilationUnit] package it.smi.galileo.acc.acc... (myHome/myProject/src/main/java/myClass.java(1,1)) java.lang.RuntimeException: Cannot call internal Javac API :( please adapt this code if API changed at org.jsweet.transpiler.util.Util.isGeneratedConstructor(Util.java:2194) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:2163) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:146) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898) at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82) at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269) at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitClass(Java2TypeScriptTranslator.java:1746) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitClass(Java2TypeScriptTranslator.java:146) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808) at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82) at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269) at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitCompilationUnit(Java2TypeScriptTranslator.java:857) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitCompilationUnit(Java2TypeScriptTranslator.java:146) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591) at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82) at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:269) at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:121) at org.jsweet.transpiler.JSweetTranspiler.generateTsFiles(JSweetTranspiler.java:880) at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:843) at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:771) at org.jsweet.plugin.builder.JSweetBuilderJob.transpileFiles(JSweetBuilderJob.java:300) at org.jsweet.plugin.builder.JSweetBuilderJob.run(JSweetBuilderJob.java:126) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.lang.IllegalArgumentException: Can not set int field com.sun.tools.javac.tree.JCTree.pos to com.sun.tools.javac.tree.JCTree$JCMethodDecl at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:58) at java.base/jdk.internal.reflect.UnsafeIntegerFieldAccessorImpl.getInt(UnsafeIntegerFieldAccessorImpl.java:56) at java.base/jdk.internal.reflect.UnsafeIntegerFieldAccessorImpl.get(UnsafeIntegerFieldAccessorImpl.java:36) at java.base/java.lang.reflect.Field.get(Field.java:418) at org.jsweet.transpiler.util.Util.isGeneratedConstructor(Util.java:2189) ... 24 more — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cincheo/jsweet/issues/612, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABP7FPPXAQ4RHL2OED6IFDLR6KQ37ANCNFSM4PQBMTAA .
-- Renaud Pawlak Founder, Ph.D. - CINCHEO renaud.pawlak@gmail.com
Hemmm... what do you mean? Is this something that concerns jsweet transpiler?
@regrog Even if Eclipse plugin is not officially supported yet with JSweet 3. It seems that you hit an intersting bug. Thanks for reporting.
@renaudpawlak I assume this was meant to be a PM? :)
Great! I know that the Eclipse plugin is not officially supported but as it turned out I suspected that the bug is something else. Thanks!
@regrog Could you please post here the code which caused this error (myHome/myProject/src/main/java/myClass.java I guess)
Well...I can't replicate on my own but one of my colleague can... I recently reset my PC and tried to reproduce the error from the git repo I have but it's impossible.. Now the transpilation seems to work normally but I can't figure out how. These are the classes to transpile: main class
public class IsAccTraIdSettedCondition extends BooleanCondition {
@Override
public boolean evaluate(final ExecutionContext context) {
return !context.isVariableEmpty("accounting_transaction_id");
}
}
public abstract class BooleanCondition {
public native boolean evaluate(ExecutionContext context);
}
public interface ExecutionContext {
public boolean isVariableEmpty(String variableName);
}
Tomorrow I will try to understand more
Thanks for your reply.
If you try again, please start from this branch: https://github.com/cincheo/jsweet/commits/JSweet3.0-moduleInfo
Many errors have been fixed recently
Can you please publish a new RC for jsweet 3.0.0 so I can include it in my project? Thanks
Absolutely.
We are currently doing a lot of stabilisation work on JSweet 3. I will publish it right after
Hello again @regrog
3.0.0-RC4 has been deployed (and maven plugin is up to date)
Warning : if you declare jsweet-core as a dependency, groupId is now <groupId>org.jsweet.v3</groupId>
I hope it will work for you
Hello @lgrignon I figured out the problem! my colleagues are using nodejs 8.1.2 I'm using nodejs 10.22.0 after I reinstalled it on my machine. I'm going to do more tests next week and close this issue if everything is ok.
Thanks @regrog !
3.0.0-RC5 is deployed, if you test please do it on this version. groupId is org.jsweet.v3 for almost all artifacts now (please see pom.xml & build.gradle here: https://github.com/cincheo/jsweet-examples)
Actually the test is not going anywhere... We have different errors in windows but in Linux it works... keep searching what is not working properly. Can you tell me what's your jdk and which version of node are you using? Thanks
Oh, shoot
I use Node 12.18.3 but I know for sure it's working with 10.16.0 (so I guess LTS 10.22.1 is ok too) JDK is 11.0.4 but I think any JDK 11 will be ok. Please I would be glad to read any information you have about this because I didn't think node version (>= 10) could be a problem.
See you soon. Bye
Hello @regrog Did you find time to investigate further?
Hi sorry for the delay but this thing is really annoying me... I have trouble reproducing this in different systems and I'm really busy during these months :cry:
No problem, there is no rush. I just want to understand what's going on because this is the only repro I have for this problem. Given the original error, it might come from the JDK variant installed? Oracle vs openjdk? Are all your machines running the same JDK?
Yes we are using the same JDK: https://adoptopenjdk.net/ The strange thing is that I created our environment in both Linux and windows and I managed to get it to work BUT when my colleagues try do replicate the same env with the same jdk, nodejs and jsweet...they have different errors... I think this is something not connected to jsweet but I can't prove that so far.
I am looking forward to learn more about this. It could reveal some unexpected problems. Please keep us informed if you make progress :) Thanks for your time & interest for JSweet
Hey. Did you find time to try again? :) FYI you can now use 3.1.0-SNAPSHOT
Not yet sorry. The time is always short. I'm updating and trying each release and java 11 but without good results. I hope to debug the issue soon next month :crossed_fingers:
Maybe this can be useful for some debug or improvement. This warning shows up in console (on a working machine):
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jsweet.transpiler.util.Util (file:/home/myHome/myProject/org.jsweet.plugin/lib/jsweet-transpiler-3.1.0-SNAPSHOT.jar) to field com.sun.tools.javac.tree.JCTree.type
WARNING: Please consider reporting this to the maintainers of org.jsweet.transpiler.util.Util
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Thanks. I am sorry but it's unfortunately irrelevant here, those are only warnings to tell that some reflective accesses are unsafe, but it works on multiple JDK versions. I hope we will find more clues to get you out of troubles.
Maybe the warning can lead to somethings.
It says that in org.jsweet.transpiler.util.Util
there is an illegal reflective access.
Can this have different behavior in JDK in different platforms? (I'm using jdk-11.0.9.1+1 https://adoptopenjdk.net/)
The stack trace is changed with the latest jdk 11 and the 3.1.0-SNAPSHOT
java.lang.RuntimeException: Cannot call internal Javac API 🙁 please adapt this code if API changed
at org.jsweet.transpiler.util.Util.erasureRecursive(Util.java:2375)
at org.jsweet.transpiler.OverloadScanner$Overload.hasMethodType(OverloadScanner.java:371)
at org.jsweet.transpiler.OverloadScanner$Overload.safeAdd(OverloadScanner.java:388)
at org.jsweet.transpiler.OverloadScanner$Overload.register(OverloadScanner.java:478)
at org.jsweet.transpiler.OverloadScanner.processMethod(OverloadScanner.java:551)
at org.jsweet.transpiler.OverloadScanner.visitClass(OverloadScanner.java:523)
at org.jsweet.transpiler.OverloadScanner.visitClass(OverloadScanner.java:69)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:279)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:65)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
at org.jsweet.transpiler.OverloadScanner.visitCompilationUnit(OverloadScanner.java:563)
at org.jsweet.transpiler.OverloadScanner.visitCompilationUnit(OverloadScanner.java:69)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:279)
at org.jsweet.transpiler.OverloadScanner.process(OverloadScanner.java:574)
at org.jsweet.transpiler.JSweetTranspiler.generateTsFiles(JSweetTranspiler.java:916)
at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:898)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:821)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:779)
at org.jsweet.plugin.builder.JSweetBuilderJob.transpileFiles(JSweetBuilderJob.java:295)
at org.jsweet.plugin.builder.JSweetBuilderJob.run(JSweetBuilderJob.java:124)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jsweet.transpiler.util.Util.erasureRecursive(Util.java:2373)
... 26 more
This stacktrace is interesting. This should not happen. Can you reproduce on multiple machines with the same JDK? If so, please send here JDK version, I will try to reproduce. Can you please also try to narrow down the transpiled Java source code that caused this issue?
Thanks for your efforts on this :)
Beware that JSweetBuilderJob is something we created to run in eclipse plugin. We basically duplicated the JSweetBuilder to use as a job in eclipse because we use that on multiple projects. I'm thinking to make a PR on you jsweet-eclipse-plugin with our improvements if can help you more. I'm also working in a simple example but I need to test on my team mate pc.
Ok, I hope this can help a bit and maybe you can merge my PR. https://github.com/cincheo/jsweet-eclipse-plugin/pull/30
Are you saying that you do not face this error with jsweet maven plugin for instance? Are you sure you start Eclipse with JDK >= 11? Is adoptjdk used to start Eclipse itself?
Are you sure you start Eclipse with JDK >= 11? Is adoptjdk used to start Eclipse itself?
I'm 110% sure eclipse is started with jdk >= 11 as you can see the stacktrace shows java modules and I only have java 8 or java 11 on my machine. The adopted jdk is used to start eclipse.
Are you saying that you do not face this error with jsweet maven plugin for instance?
I only used jsweet from the eclipse plugin, I will provide an example as soon as I can not using the plugin but the gradle/maven plugin.
Hello. I noticed your PR on the gradle plugin :) Did you give it a try for your project?
Yes, I'm trying to use the gradle plugin to create a sample to test on other machines.
Actually I'm having some strange issue because sometimes ./gradlew jsweet
generates the folder generated_js
but sometimes doesn't.
I hope to have some news soon this week :muscle:
https://github.com/lgrignon/jsweet-gradle-plugin/pull/32 Recap: I tried my sample project with jdk 11 in a windows machine and everything works fine. But the example project is really skinny. I'm starting to think the problem is something that comes from the classpath I pass to the transpiler.
Hi, I am the colleague with the "problematic" environment. 😄
We managed to find some time to go a bit deeper into this problem, and I'm sorry to report that I still encounter the issue with the eclipse plugin.
To streamline everything and see if we were doing something wrong, we decided to:
org.jsweet.plugin
) from the GitHub repo without modifications: fork linkJsweet runs fine on the same project when using the Gradle plugin, but I get the error reported above with org.jsweet.plugin
(eclipse plugin).
We even tried to replicate the same parameters for the Jsweet transpiler across the Gradle plugin and org.jsweet.plugin
without success.
We debugged into the org.jsweet.transpiler.util.Util
class and found some bizarre things: at
erasureRecursiveMethod
's declaring class is not assignable to the javacInternals().typesInstance
's class (see attached screenshot).
Breakpoint's screenshot from the jsweet-transpiler 3.0.0 sources:
The strangest thing, though, is that the "same" type com.sun.tools.javac.code.Types
differ "only" from classloader: the erasureRecursiveMethod
declaring class uses the eclipse OSGi classloader implementation, while the javacInternals().typesInstance
's class is using the standard JDK 11 classloader.
We believe this is the cause of the issue we encounter with the eclipse plugin. In the instances where org.jsweet.plugin
ran fine, we found that the classloaders used were the same JDK 11 classloader.
Do you think this could relate to the issues we're having? Is there anything we could try to do on the Eclipse plugin side to ensure the classloaders are consistent?
Sample project: example.zip
Java runtime info:
Thanks a lot @niktekusho for your time on this, and your explanation
I just deployed this commit https://github.com/cincheo/jsweet/commit/5a81ff72865e729a4642509a0be746120a030f9c which in our opinion could fix your problem.
Could you please try again with latest 3.1.0-SNAPSHOT? Let's cross fingers 🤞
Still something not working ;(
java.lang.RuntimeException: Cannot call internal Javac API :( please adapt this code if API changed
at org.jsweet.transpiler.util.Util.erasureRecursive(Util.java:2278)
at org.jsweet.transpiler.OverloadScanner$Overload.hasMethodType(OverloadScanner.java:371)
at org.jsweet.transpiler.OverloadScanner$Overload.safeAdd(OverloadScanner.java:388)
at org.jsweet.transpiler.OverloadScanner$Overload.register(OverloadScanner.java:475)
at org.jsweet.transpiler.OverloadScanner.processMethod(OverloadScanner.java:548)
at org.jsweet.transpiler.OverloadScanner.visitClass(OverloadScanner.java:520)
at org.jsweet.transpiler.OverloadScanner.visitClass(OverloadScanner.java:69)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:279)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:65)
at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
at org.jsweet.transpiler.OverloadScanner.visitCompilationUnit(OverloadScanner.java:560)
at org.jsweet.transpiler.OverloadScanner.visitCompilationUnit(OverloadScanner.java:69)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:279)
at org.jsweet.transpiler.OverloadScanner.process(OverloadScanner.java:571)
at org.jsweet.transpiler.JSweetTranspiler.generateTsFiles(JSweetTranspiler.java:923)
at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:905)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:828)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:786)
at org.jsweet.plugin.builder.JSweetBuilderJob.transpileFiles(JSweetBuilderJob.java:307)
at org.jsweet.plugin.builder.JSweetBuilderJob.run(JSweetBuilderJob.java:132)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.jsweet.transpiler.util.Util.erasureRecursive(Util.java:2276)
... 26 more
Hi I recently started again to work on this problem. After more test, we decided to switch to the Gradle plugin to avoid this behavior. I think this issue could be closed.
Thanks for the update
Hi,
I'm using jsweet in an eclipse project using you project (https://github.com/cincheo/jsweet-eclipse-plugin). Actually running it with java 8 everything works perfectly.
Now I'm migrating to java 11+ but I'm having some issues. I' replaced the old jsweet-transpiler-latest-jar-with-dependencies.jar with the new release candidate jsweet-transpiler-3.0.0-RC3-jar-with-dependencies.jar
I changed the call to Utils.addFiles to Utils.Static.addFiles and removed the call to JSweetConfig.jinitClassPath(jdkHome).
But when I run the transpilation this error occurs that doesn't seem to be part of what I changed.
Can I have any help? Thanks