jsweet
jsweet copied to clipboard
Creating a class in java.util.function : methods name lost
in a java candy, there is a file named FunctionClassTest.java
package java.util.function;
public class FunctionClassTest<T> {
public static <T> FunctionClassTest<T> myMethod1(java.util.Comparator<? super T> comparator) {
return null;
}
public static <T> FunctionClassTest<T> myMethod2(java.util.Comparator<? super T> comparator) {
return null;
}
}
in bundle.ts of candy, it will be
/* Generated from Java with JSweet 3.2.0 -SNAPSHOT http://www.jsweet.org */
namespace java.util.__function {
export class FunctionClassTest<T> {
public static <T>(comparator: any): () => T {
return <any>(((funcInst: any) => { if (funcInst == null || typeof funcInst == 'function') { return funcInst } return () => (funcInst['<init>'] ? funcInst['<init>'] : funcInst) .call(funcInst)})(null));
}
public static <T>(comparator: any): () => T {
return <any>(((funcInst: any) => { if (funcInst == null || typeof funcInst == 'function') { return funcInst } return () => (funcInst['<init>'] ? funcInst['<init>'] : funcInst) .call(funcInst)})(null));
}
}
FunctionClassTest["__class"] = "java.util.function.FunctionClassTest";
}
the methods myMethod1 and myMethod2 lost. because no methods name, bundle.ts can't be compiled to javascript
Thanks for your bug report.
I guess this is because it is located in the special package java.util.function
Can you confirm it works if you change package?
Thanks, @lgrignon yes, it works if I change the package name to java.util.__function for this file. however, if I refactor it to java.util.__function for all classes under JDK, the error still exists.
Hello @tonysmarthome
Is it still the same error?
I understood that renaming package works.
Hi @lgrignon , sorry for late reply. I create a repo for it if you don't mind. https://github.com/tonysmarthome/j4ts-funtions you can see the bundle.ts file. the errors still exist. if I refactor java.util.function to java.util.___function (not __function), there some errors disappear, but the default method in interfaces still can't be handled. I guess it might because transpiler refactors all "funtion" to "__funtion" but ignores the package name.