I am facing a challenge where I need to convert Java code into JavaScript while preserving all method, variable and parameter names. Is it possible to achieve this using the GWT compiler or any other tool available in the market? I attempted compiling the Java code with optimizations turned off, but the method names ended up being mangled. If the GWT compiler cannot handle this task, is there another tool that can do it?
Update
The Java code only relies on GWT emulated classes, making it feasible for the GWT compiler to process.
Update 2
For instance, the Java method :
public String method()
was transformed into this JavaScript function :
function com_client_T_$method__Lcom_client_T_2Ljava_lang_String_2()
with the compilation options :
-style DETAILED
-optimize 0
-draftCompile
Unfortunately, it seems like the names cannot be preserved. Is there a way to control how they get altered?
Clarification
Imagine having a sorting algorithm written in Java that you want to convert into JavaScript without changing the method name, or at least altering it predictably for seamless conversion between the two languages. This would enable you to reuse code across different applications effortlessly even if updates are made to the original Java version. Can this be done with tools like GWT compiler?
Conclusion
The response to the main query is NO. While some method names may be preserved, their functionality cannot be maintained. The scattered nature of method calls within the generated file makes them unsuitable for use in a JavaScript library, which defeats the purpose of the initial objective.