cincheo / jsweet

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

Version 3.0.0-RC3: method inheritence combined with multiple method signatures bug #597

Closed AntoineJonard closed 4 years ago

AntoineJonard commented 4 years ago

We are having an issue with method inheritence combined with multiple method signatures. The very simple and common Java code below shows the issue : JavaSuperClass defines one method with 2 signatures while JavaClass overloads one of these signatures.

It leads to Null Exception Error with no other explanations which is itself an issue.

We are guessing that’s something to do with the way JSweet handles “complex overloading”, creating a method that wraps the whole thing. This method sounds to be final

How could we make it work the Java way : we don’t care about optional parameters of JS. Any annotation or so ?

As this issue seems to be a conceptual issue, a special § in the language specs would help.

Code :

` package quickstart;

public class JavaSuperClass{ public JavaSuperClass(){ super(); }

public int fct(){
    return 0;
}

public int fct(boolean arg){
    return 0;
}

} `

and i redefine only one of the method in a sub class:

` package quickstart;

public class JavaClass extends JavaSuperClass{ public JavaClass(){ }

public int fct(){
    return 0;
}

} `

i get this error when i start to transpile with mvn generate-sources :

2020-06-05 12:06:18.018 ERROR output:55 - internal transpiler error at C:\Users\Utilisateur\jsweet-quickstart\src\main\java\quickstart\JavaClass.java(7) dumping transpiler's strack trace: ... (C:\Users\Utilisateur\jsweet-quickstart\src\main\java\quickstart\JavaClass.java(7,9)) [JCClassDecl] public class JavaClass extends... (C:\Users\Utilisateur\jsweet-quickstart\src\main\java\quickstart\JavaClass.java(3,1)) ... (C:\Users\Utilisateur\jsweet-quickstart\src\main\java\quickstart\JavaClass.java(1,1)) java.lang.NullPointerException

renaudpawlak commented 4 years ago

Umm. In theory it should work with no problems. Maybe a regression... which version of JSweet are you using? (See pom.xml)

AntoineJonard commented 4 years ago

It should be 6.2.0, I attach the pom.xml if you want to see more. pom.txt

renaudpawlak commented 4 years ago

Nope. You are using 3.0.0-RC3. So I guess it is a bug for that version. If you want to make it work on a stable release, use JDK 8 and replace JSweet version with 2.3.8 for instance and it should work.

In any case this is a version 3 specific bug. Not a limitation of JSweet.

AntoineJonard commented 4 years ago

Thanks for the reply, by modifying jdk and JSweet Version it worked.