cincheo / jsweet

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

JSweet transpiler is throwing Null Pointer exception #590

Closed xeccgtt closed 3 years ago

xeccgtt commented 4 years ago

We placed a copy of our code in the the JSweet Quickstart Maven directory hierarchy. We then used maven to generate_sources. We did this as an easy way for us to get started with JSweet.
Version of JSWeet:
JSweet transpiler version 3.0.0-RC2 (build date: 2020-04-04 11:49:41) org.jsweet:jsweet-core:jar:6.0.2:compile

The transpiler is throwing a NullPointer exception when it tries to compile our Java code. Please see the stack trace at the end. Our class Map extends another class called ExtendedApplet. ExtendededApplet extends java.applet.Applet and implements ComponentListener

The line in the Map.java where the transpiler is failing is public String getParameter ( String name)

There are two more NULL pointer exceptions generated by the transpiral. We only included information on the first. There were three Null Pointer exceptions before the the transpiral failed.

[INFO] JSweet transpiler version 3.0.0-RC2 (build date: 2020-04-04 11:49:41) [INFO] dependencies=[Dependency {groupId=org.jsweet, artifactId=jsweet-core, version=6.0.2, type=jar}, Dependency {groupId=org.jsweet.candies, artifactId=jquery, version=1.10.0-20170726, type=jar}] [INFO] candies detection: add project dependency Dependency {groupId=org.jsweet, artifactId=jsweet-core, version=6.0.2, type=jar} => org.jsweet:jsweet-core:jar:6.0.2:compile [INFO] candies detection: add project dependency Dependency {groupId=org.jsweet.candies, artifactId=jquery, version=1.10.0-20170726, type=jar} => org.jsweet.candies:jquery:jar:1.10.0-20170726:compile [INFO] all candies artifacts: [org.jsweet:jsweet-core:jar:6.0.2:compile (1; enabled), org.jsweet.candies:jquery:jar:1.10.0-20170726:compile (1; enabled)] [INFO] candies jars: [USER_ID.m2\repository\org\jsweet\jsweet-core\6.0.2\jsweet-core-6.0.2.jar, USER_ID.m2\repository\org\jsweet\candies\jquery\1.10.0-20170726\jquery-1.10.0-20170726.jar] [INFO] classpath from maven: USER_ID.m2\repository\org\jsweet\jsweet-core\6.0.2\jsweet-core-6.0.2.jar;USER_ID.m2\repository\org\jsweet\candies\jquery\1.10.0-20170726\jquery-1.10.0-20170726.jar [INFO] jsOut: M:\CODE\jsweet\jsweet-quickstart-esp-applet\target\js [INFO] bundle: null [INFO] tsOut: M:\CODE\jsweet\jsweet-quickstart-esp-applet\target\ts [INFO] tsOnly: null [INFO] tsserver: null [INFO] declarations: null [INFO] ignoreDefinitions: null [INFO] declarationOutDir: null [INFO] candiesJsOutDir: M:\CODE\jsweet\jsweet-quickstart-esp-applet\webapp [INFO] ecmaTargetVersion: ES6 [INFO] moduleKind: none [INFO] sourceMap: null [INFO] sourceRoot: null [INFO] verbose: true [INFO] veryVerbose: null [INFO] jdkHome: C:\Program Files\Java\jdk-11.0.6 [INFO] factoryClassName: null [INFO] ignoredProblems: null [INFO] extraSystemPath: null 2020-05-18 12:02:23.023 INFO JSweetTranspiler:389 - no configuration file found at M:\CODE\jsweet\jsweet-quickstart-esp-applet\jsweetconfig.json 2020-05-18 12:02:23.023 INFO JSweetTranspiler:494 - creating transpiler version 3.0.0-RC2 (build date: 2020-04-04 11:49:41)

2020-05-18 11:58:13.013 ERROR output:55 - internal transpiler error at DIRECTORY_PATH\Map.java(315) dumping transpiler's strack trace: [JCMethodDecl] public String getParameter(Str... (DIRECTORY_PATH\Map.java(315,5)) [JCClassDecl] public class Map extends Exten... (DIRECTORY_PATH\Map.java(41,1)) ... (DIRECTORY_PATH\Map.java(22,1)) java.lang.NullPointerException at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:2175) at org.jsweet.transpiler.Java2TypeScriptTranslator.visitMethod(Java2TypeScriptTranslator.java:2239) 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.AbstractJSweetMojo.transpile(AbstractJSweetMojo.java:606) at org.jsweet.JSweetMojo.execute(JSweetMojo.java:43) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) 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:956) 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) 2020-05-18 11:58:13.013 INFO JSweetTranspiler:903 - output file: com\optsw\esp\Map.ts 2020-05-18 11:58:13.013 INFO JSweetTranspiler:928 - created DIRECTORY_PATH\target\ts\DIRECTORY_PATH\Map.ts

lgrignon commented 4 years ago

Hello, it's hard to tell why it fails without the source code. Anyway I got that you are using Java Applet which is a particular Java API (using UI). I don't know how much your code base rely on complex Java APIs or other third party libraries, but you could try using JSweet 2.3.x with J4TS (which is a Java runtime for JS), you may be luckier

xeccgtt commented 4 years ago

What Maven dependencies do I need? The pom has the following in it. We also need to to use jdk .18.

            <properties>
                            <jsweet.transpiler.version>3.0.0-RC2</jsweet.transpiler.version>
                            <jsweet.core.version>6.0.2</jsweet.core.version>
                            <java.version.release>8</java.version.release>
                            <java.version>1.${java.version.release}</java.version>
                            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            </properties>

From: Louis Grignon notifications@github.com Sent: Monday, May 18, 2020 1:03 PM To: cincheo/jsweet jsweet@noreply.github.com Cc: Stark, Albert J albert.stark@bnymellon.com; Author author@noreply.github.com Subject: Re: [cincheo/jsweet] JSweet transpiler is throwing Null Pointer exception (#590)

Hello, it's hard to tell why it fails without the source code. Anyway I got that you are using Java Applet which is a particular Java API (using UI). I don't know how much your code base rely on complex Java APIs or other third party libraries, but you could try using JSweet 2.3.x with J4TS (which is a Java runtime for JS), you may be luckier

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://clicktime.symantec.com/34UbNr147ZjqpnAJpNxNhh67Vc?u=https%3A%2F%2Fgithub.com%2Fcincheo%2Fjsweet%2Fissues%2F590%23issuecomment-630314890, or unsubscribehttps://clicktime.symantec.com/3JMK78UDyPbDbsYVQvQeWtq7Vc?u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFY4KDXE4CGUN2OQBNW5OULRSFS4XANCNFSM4NEHI3XQ.

The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.

Please refer to https://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities. We take our data protection and privacy responsibilities seriously and our privacy notice explains how we collect, use and share personal information in the course of our business activities. It can be accessed at the privacy section of www.bnymellon.com.

xeccgtt commented 4 years ago

Hi I tried to use 2.3.7 and I am see many errors like this:

· 2020-05-18 15:11:44.044 ERROR output:55 - cannot find namespace 'java' at SIRECTORY_PATH\Arrow.java(86)

Any Idea on how to resolve this

            <properties>
                            <jsweet.transpiler.version>2.3.7</jsweet.transpiler.version>
                            <jsweet.core.version>6.0.2</jsweet.core.version>
                            <java.version.release>8</java.version.release>
                            <java.version>1.${java.version.release}</java.version>
                            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            </properties>

From: Louis Grignon notifications@github.com Sent: Monday, May 18, 2020 1:03 PM To: cincheo/jsweet jsweet@noreply.github.com Cc: Stark, Albert J albert.stark@bnymellon.com; Author author@noreply.github.com Subject: Re: [cincheo/jsweet] JSweet transpiler is throwing Null Pointer exception (#590)

Hello, it's hard to tell why it fails without the source code. Anyway I got that you are using Java Applet which is a particular Java API (using UI). I don't know how much your code base rely on complex Java APIs or other third party libraries, but you could try using JSweet 2.3.x with J4TS (which is a Java runtime for JS), you may be luckier

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://clicktime.symantec.com/34UbNr147ZjqpnAJpNxNhh67Vc?u=https%3A%2F%2Fgithub.com%2Fcincheo%2Fjsweet%2Fissues%2F590%23issuecomment-630314890, or unsubscribehttps://clicktime.symantec.com/3JMK78UDyPbDbsYVQvQeWtq7Vc?u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFY4KDXE4CGUN2OQBNW5OULRSFS4XANCNFSM4NEHI3XQ.

The information contained in this e-mail, and any attachment, is confidential and is intended solely for the use of the intended recipient. Access, copying or re-use of the e-mail or any attachment, or any information contained therein, by any other person is not authorized. If you are not the intended recipient please return the e-mail to the sender and delete it from your computer. Although we attempt to sweep e-mail and attachments for viruses, we do not guarantee that either are virus-free and accept no liability for any damage sustained as a result of viruses.

Please refer to https://disclaimer.bnymellon.com/eu.htm for certain disclosures relating to European legal entities. We take our data protection and privacy responsibilities seriously and our privacy notice explains how we collect, use and share personal information in the course of our business activities. It can be accessed at the privacy section of www.bnymellon.com.

lgrignon commented 4 years ago

Please try using https://github.com/j4ts/j4ts

Chances are you are using a lot of specific Java APIs which may be available in j4ts

This doc may also help you: https://github.com/cincheo/jsweet/blob/master/doc/jsweet-language-specifications.md#getting-more-java-apis

xeccgtt commented 4 years ago

I added this dependency to my pom

org.jsweet j4ts 0.6.0

We are using awt code in the applet. we are getting errors like this one. We added the dependecies below and that did not resolve the issue. Are there other dependencies we need.
ERROR output:55 - namespace 'java.awt' has no exported member 'event' at DIRECTORY_PATH\TextApplet.java(332)

    <dependency>
        <groupId>org.jsweet.candies.j4ts</groupId>
        <artifactId>j4ts-awtgeom</artifactId>
        <version>1.8.132-20170726</version>
    </dependency>
    <dependency>
        <groupId>org.jsweet.candies.j4ts</groupId>
        <artifactId>j4ts-swingundo</artifactId>
        <version>1.8.132-20170726</version>
    </dependency>
    <dependency>
        <groupId>org.jsweet.candies.j4ts</groupId>
        <artifactId>j4ts-batik-svgpathparser</artifactId>
        <version>1.10.0-20170726</version>
    </dependency>
rfvbgt54 commented 4 years ago

@xeccgtt I'm sorry to interrupt you. I'm also in trouble with a similar error. Have you found any solution?

lgrignon commented 4 years ago

@rfvbgt54 could you please explain what is specifically your problem so we can tell if it's exactly the same problem or not? Thanks in advance

rfvbgt54 commented 4 years ago

@lgrignon could you check the following issues I worte? https://github.com/cincheo/jsweet/issues/598 https://github.com/cincheo/jsweet/issues/599

lgrignon commented 4 years ago

@xeccgtt did you manage to make it work?