Open AlexGeller1 opened 2 years ago
JSweet 3's strategy for J4TS was to avoid overriding core packages since it's restricted and actually not necessary. Switching to a j4ts.awt package, with a @Name("java.awt") would work I think. The only important thing is to provide the proper .js and .d.ts in src/main/resources/META-INF/resources/webjars/${project.artifactId}/${project.version}/
JSweet 3's strategy for J4TS was to avoid overriding core packages since it's restricted and actually not necessary.
If it is not necessary then of course I will not do it. But how then do I compile code that has references to java.awt.Color for example?
java.awt.Color is part of core Java classes, so Java compilation will pass, and you have to embed your j4ts.d.ts and j4ts.js (or any other def & runtime implementation) in a project's candy to make ts2js transpilation pass and the projet to run.
Is there any additional information that could help you?
Is there any additional information that could help you?
Yes, I want to implement java.awt.Color in Java (not in TypeScript or JavaScript) since there is absolutely no need for native code in the implementation of this class and for many more classes from the java.awt package. Even Graphics2D is a purely abstract class without any browser dependencies in the original implementation. Is that possible (to implement these classes in Java) and if yes, how. Ideally we also want to implement those classes in a lazy fashion because there are so many and we don't use all of them and we don't call all methods from these classes and so there is no technical need for the implementations to be complete. Ideally I would like to implement java.awt.Color for example without the method Color.HSBtoRGB() if the code that I am porting never calls this method. We need a pragmatic and easy way to compile existing code that uses some core library functionality. Prior to version 3.1.0 this path existed. Correct me if I am wrong, I am currently under the impression that your approach to the implementation of core classes is, that they are implemented in TypeScript or there is some non standard or complicated way (I haven't yet evaluated your proposal for this so that I might be wrong on this) to implement them in Java. But the original core libraries themselves are written for the largest part in pure Java without native calls so that for us it would be nice if there were an easy way to do the same thing and write a class like java.awt.Color in Java.
That's totally possible, that's what we do.
As I mentionned earlier, I would put my Java classes in a my.awt package, with a @Name("java.awt")
on the package-info, and it should do the trick to be transpiled to a proper .d.ts and .js, to be bundled in a candy.
Steps to reproduce: