Open jnape opened 6 years ago
Hello, First of all: thanks for taking the time to report your problems.
This seems indeed like a bug challenge to transpile this nice library. Out of curiosity: can I ask what are your motivations to transpile this Java lib to the JS world (personal project? professional integration? open source contribution?)
Anyway, I would say, for a start, that you should be using JSweet maven plugin version 2.2.0-SNAPSHOT, and not 1.X
Could you please try and tell us what happens?
Thanks
Thanks for the quick reply, @lgrignon.
Updating to the plugin version 2.2.0-SNAPSHOT dramatically improved the situation: there are now only 2 errors and 8 warnings after running mvn verify
. Given that there are only 10 issues total, I've pasted everything below:
2018-09-07 14:55:49.049 ERROR output:55 - internal transpiler error at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn1/Upcast.java(30)
dumping transpiler's strack trace:
[JCMethodDecl] @Override()... (/src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn1/Upcast.java:31)
[JCClassDecl] public final class Upcast<A ex... (/src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn1/Upcast.java:23)
[JCCompilationUnit] package com.jnape.palatable.la... (/src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn1/Upcast.java:1)
java.lang.NullPointerException
at org.jsweet.transpiler.util.JSDoc.getMappedDocType(JSDoc.java:89)
at org.jsweet.transpiler.util.JSDoc.getMappedDocType(JSDoc.java:93)
at org.jsweet.transpiler.util.JSDoc.applyForMethod(JSDoc.java:307)
at org.jsweet.transpiler.util.JSDoc.adaptDocComment(JSDoc.java:234)
at org.jsweet.transpiler.Java2TypeScriptTranslator.printDocComment(Java2TypeScriptTranslator.java:995)
at org.jsweet.transpiler.Java2TypeScriptTranslator.printDocComment(Java2TypeScriptTranslator.java:989)
at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethodDef(Java2TypeScriptTranslator.java:2243)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:238)
at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:125)
at org.jsweet.transpiler.Java2TypeScriptTranslator.visitClassDef(Java2TypeScriptTranslator.java:1676)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:238)
at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:125)
at org.jsweet.transpiler.Java2TypeScriptTranslator.visitTopLevel(Java2TypeScriptTranslator.java:943)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:238)
at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:125)
at org.jsweet.transpiler.JSweetTranspiler.createBundle(JSweetTranspiler.java:1107)
at org.jsweet.transpiler.JSweetTranspiler.generateTsBundle(JSweetTranspiler.java:1061)
at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:902)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:831)
at org.jsweet.AbstractJSweetMojo.transpile(AbstractJSweetMojo.java:515)
at org.jsweet.JSweetMojo.execute(JSweetMojo.java:43)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Partition.java(35)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Partition.java(35)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Partition.java(49)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Partition.java(54)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Partition.java(54)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/functions/Fn1.java(227)
2018-09-07 14:55:49.049 ERROR output:55 - internal transpiler error at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/adt/hlist/Index.java(44)
dumping transpiler's strack trace:
[JCMethodDecl] public abstract <L extends Tar... (/src/git/lambda/src/main/java/com/jnape/palatable/lambda/adt/hlist/Index.java:44)
[JCClassDecl] public abstract class Index<Ta... (/src/git/lambda/src/main/java/com/jnape/palatable/lambda/adt/hlist/Index.java:13)
[JCCompilationUnit] package com.jnape.palatable.la... (/src/git/lambda/src/main/java/com/jnape/palatable/lambda/adt/hlist/Index.java:1)
java.lang.NullPointerException
at org.jsweet.transpiler.util.JSDoc.getMappedDocType(JSDoc.java:89)
at org.jsweet.transpiler.util.JSDoc.getMappedDocType(JSDoc.java:93)
at org.jsweet.transpiler.util.JSDoc.applyForMethod(JSDoc.java:293)
at org.jsweet.transpiler.util.JSDoc.adaptDocComment(JSDoc.java:245)
at org.jsweet.transpiler.Java2TypeScriptTranslator.printDocComment(Java2TypeScriptTranslator.java:995)
at org.jsweet.transpiler.Java2TypeScriptTranslator.printDocComment(Java2TypeScriptTranslator.java:989)
at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethodDef(Java2TypeScriptTranslator.java:2243)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:238)
at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:125)
at org.jsweet.transpiler.Java2TypeScriptTranslator.visitClassDef(Java2TypeScriptTranslator.java:1676)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:693)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:238)
at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:125)
at org.jsweet.transpiler.Java2TypeScriptTranslator.visitTopLevel(Java2TypeScriptTranslator.java:943)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
at org.jsweet.transpiler.util.AbstractTreeScanner.scan(AbstractTreeScanner.java:238)
at org.jsweet.transpiler.util.AbstractTreePrinter.print(AbstractTreePrinter.java:125)
at org.jsweet.transpiler.JSweetTranspiler.createBundle(JSweetTranspiler.java:1107)
at org.jsweet.transpiler.JSweetTranspiler.generateTsBundle(JSweetTranspiler.java:1061)
at org.jsweet.transpiler.JSweetTranspiler.java2ts(JSweetTranspiler.java:902)
at org.jsweet.transpiler.JSweetTranspiler.transpile(JSweetTranspiler.java:831)
at org.jsweet.AbstractJSweetMojo.transpile(AbstractJSweetMojo.java:515)
at org.jsweet.JSweetMojo.execute(JSweetMojo.java:43)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/iteration/MappingIterator.java(11)
2018-09-07 14:55:49.049 WARN output:58 - local variable name 'function' is not allowed and is automatically generated to '__function' at /src/git/lambda/src/main/java/com/jnape/palatable/lambda/iteration/UnfoldingIterator.java(16)
[ERROR] transpilation failed
org.apache.maven.plugin.MojoFailureException: transpilation failed with 2 error(s) and 8 warning(s)
at org.jsweet.AbstractJSweetMojo.transpile(AbstractJSweetMojo.java:527)
at org.jsweet.JSweetMojo.execute(JSweetMojo.java:43)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
As for my motivations, my employer has teams that heavily rely on the library in question and I would like to offer the same capabilities for UI development via JavaScript/TypeScript.
Checking back in: I added a quick and dirty hack locally to fix the errors above (they're failures in attempting to parse out javadocs from source), at which point over 1000 errors were spewed to the console involving all sorts of AST failures.
Does it seem realistic to be able to transpile this library in the foreseeable future (i.e. is it on your radar), or is it currently insurmountable?
Hello @jnape, I am happy to read that you solved your first error, but now it is actually worse :)
This is a lot of errors, but you may have multiple errors of the same type. The first step would be to list all different kinds of errors you got, then file separate issues for each of them (we may have some issues already registered on GitHub by the way).
If you have time and feel like it, you could contribute, we would be glad to review / merge any PR. However, we will try to resolve your issues when possible if you don't have time for this but we are quite busy as well :)
Hello @jnape Did you try again with JSweet's last version?
EDIT: I see there is an issue created for Java 11 compatibility, which is the version I use by default. I'll try with 1.8 and see how it goes.
Hi @lgrignon,
I didn't pursue it further after the last message I left on this issue. I just now tried cloning the quick-start and following the instructions in the README and generate-sources
is failing due to a ClassCastException
:
2019-10-26 15:27:23.023 ERROR JSweetConfig:149 - class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
at org.jsweet.JSweetConfig.initClassPath(JSweetConfig.java:86)
at org.jsweet.AbstractJSweetMojo.createJSweetTranspiler(AbstractJSweetMojo.java:254)
at org.jsweet.JSweetMojo.execute(JSweetMojo.java:41)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:954)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
I doubt it's worth attempting to compile against lambda again until at least the quickstart works.
Yeah, no dice. Just tried against 1.8 and there is quite a long list of internal transpiler errors.
It's a bit too verbose to paste here, but if you're interested in being able to compile a library that does type tricks of the sort lambda does, all I had to do was clone lambda master and add the jsweet plugin directive from the quick-start pom to the lambda pom and run generate-sources
. You should be able to easily see the output I see.
Thanks @jnape I will try to give a look if I find time some day. For now, the focus is on Java 11 compatibility, which should be ok soon :)
Hello!
I'm trying to transpile lambda using jsweet, but the build processing is exploding with over a hundred type errors. I'm doing some fairly advanced type acrobatics for javac in that library, so it's not surprising that it might be exposing bugs in jsweet, but it definitely seems like being able to transpile that library would build a ton of confidence that you can actually handle the full capabilities of the JLS (or at least as much as javac can).
It didn't seem helpful to log each error as a bug, but the project is open source and the following steps will show how you too can end up in the same transpilation bedlam I'm currently experiencing.
Please let me know if this is not enough information, and if not, how I can be more helpful; or, if somehow I'm doing something wrong here and the problem is actually on my side, not JSweet's.
Cheers!
Steps to reproduce
Clone the project:
$ git clone https://github.com/palatable/lambda
Add the following plugins to
pom.xml
:Run:
$ mvn verify
Expected
Transpilation completing successfully
Actual
Preceded by 153 errors of the form: