leaningtech / cheerpj-meta

Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins.
https://labs.leaningtech.com/cheerpj
434 stars 21 forks source link

Error while compiling jar #153

Closed pfreon closed 5 months ago

pfreon commented 1 year ago

Hi, Similar issues were already addressed in " Error while compiling jar #42" and in "Error when adding to String #65", which are now closed. I took into account the solution proposed but still face the same problem although I used JDK version 8 instead of the last releases (17-18): compiling fr/ird/climprod/AppelNavigateur.class ... Failure compiling fr/ird/climprod/AppelNavigateur.class command: /usr/local/cheerpj_2.3/bin/cheerpj -llvm -llvm-exceptions -cp /tmp/tmp47k1_xta/rt.jar.dir/ fr/ird/climprod/AppelNavigateur.class Loading class fr/ird/climprod/AppelNavigateur and dependencies Could not open class java/lang/invoke/StringConcatFactory Unsupported LLVM generation for opcode ba In function displayURL cheerpj: CheerpJCompilerMethod.cpp:2349: uint32_t CheerpJCompiler::compileOpcode(std::ostream&, const ClassFile*, CheerpJCompiler::BasicBlock&, uint32_t, uint32_t, bool, const std::set&, uint16_t, bool): Assertion `false' failed.

The function displayURL within class fr/ird/climprod/AppelNavigateur is as follows: static public void displayURL(String url) { boolean windows = isWindowsPlatform(); String cmd = null; try { if (windows) { // cmd = 'rundll32 url.dll,FileProtocolHandler http://...' cmd = WIN_PATH + " " + WIN_FLAG + " " + url; System.out.println("cmd Windows = " + cmd); Process p = Runtime.getRuntime().exec(cmd); } else { if (isMacPlatform()){ cmd = "open " + url; System.out.println("cmdmacOS = " + cmd); Process p = Runtime.getRuntime().exec(cmd); } else{ // Under Unix, Netscape has to be running for the "-remote" // command to work. So, we try sending the command and //check for an exit value. If the exit command is 0, // it worked, otherwise we need to start the browser. // cmd = 'netscape -remote openURL(http://www.javaworld.com/)' cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + "file://" + url + ")"; System.out.println("cmd Linux exitCode 0 Browser open = " + cmd); Process p = Runtime.getRuntime().exec(cmd); try { // wait for exit code -- if it's 0, command worked, // otherwise we need to start the browser up. int exitCode = p.waitFor(); System.out.println("exitCode " + exitCode); if (exitCode != 0) { // Command failed, start up the browser // cmd = 'netscape http://www.javaworld.com/' cmd = UNIX_PATH + " " + "(" + "file://" + url + ")"; System.out.println("cmd Linux exitCode different from 0, Browser closed = " + cmd); p = Runtime.getRuntime().exec(cmd); } } catch (InterruptedException x) { System.err.println("Error bringing up browser,cmd='" + cmd + "'"); System.err.println("Caught: " + x); } } } } catch(IOException x) { // couldn't exec browser System.err.println("Could not invoke browser, command=" + cmd); System.err.println("Caught: " + x); } } Please help...

marsicplusplus commented 1 year ago

Hi @pfreon. Could you paste the entire error? Is the compilation failing or is it reverting to the legacy compiler?

If it is failing completely and you are using JDK8, could you provide us with a reproducible example?

pfreon commented 1 year ago

Hi Lorenzo, Thank you for you answer. I apologize for the delay but I am still on leave.

First, let me please introduce myself shortly. I am a scientist with some skills in html and java (plus R, C++ and Fortran) but I am not a geek and I have no skill in Python nor in Javascript.

I ran cheerpjfy.py from the console terminal of a computer working under Linux KDE and also from another one working under MS-Windows 10 where only the JKD8 version was installed.

After this change of computer the previous error disappeared and I suppose that this is due to the fact that the .jar I used on the linux computer was compiled with JDK18. Although cheerpjfy.py was run after uninstalling JDK18 and installing JDK8, the previous error appeared.

Now there are not anymore errors resulting from the launch cheerpjfy.py and the .jar.js file was built as expected.

Then I ran the following html file on my Firefox browser:

<!DOCTYPE html>

CLIMPRODCheerpJ

As a result, the browser open a new frame entitled first "CheerpJ is initializing", then "CheerpJ runtime ready" , then "jar is loaded, main is starting" but the frame remains empty.

Opening the Firefox debugger I can see the following error: "CheerpJ is initializing loader.js:2976:11 unreachable code after return statement loader.js:4:183 unreachable code after return statement loader.js:4:741 Uncaught (in promise) "

In order for you to be able to reproduce this error, I sent you separately by e-mail the .jar file I used.

Thank you for your help.

marsicplusplus commented 1 year ago

Hi @pfreon

I didn't get any email. Please send it to lorenzo@leaningtech.com

marsicplusplus commented 1 year ago

Hi @pfreon I was able to replicate the issue and we are currently looking into it.

If in the meanwhile you would like to run your app you can skip the compilation process and let the Just-In-Time compiler do its work. The application works this way.

Best, Lorenzo

pfreon commented 1 year ago

Hi Lorenzo, Once more thank you for your help. I was not familiar with JIT but learnt about it. I manage to run successfully (no compilation error) in JIT mode after installing NET Pyjion on my computer and launching the command "python -m pyjion cheerpjfy.py Climprod5.3_32bits.jar from my terminal. But please let me know if there is a more straightforward method to use JIT.

As a result I manage to run the software directly from my Internet browser. Nonetheless I did not manage to repeat the operation. Although "Uncaught (in promise) fr.ird.climprod.AppelNavigateur" error did not pop up anymore, there are still the warnings "unreachable code after return statement loader.js:4:183 unreachable code after return statement loader.js:4:741" and the browser is stuck at the window "jar is loaded, main is starting" with an empty frame. Please help. Best Pierre

marsicplusplus commented 1 year ago

Hi @pfreon

I am not sure of what you did, but what I meant was... do not compile at all :)

There is something going wrong in the compilation phase and we are looking into it, but when not compiling ahead of time the application starts.

When CheerpJ cannot find the compiled jar.js file it will start compiling it on the fly on the client machine.

This is obviously not a solution, but a workaround while we try to figure out why the compiled version fails.

Best, Lorenzo

pfreon commented 1 year ago

Hi Lorenzo, I'm with you now. I can now run CheerpJ successfully from my machine in JIT mode simply after removing the jar.js file. I'm waiting for a final solution from your side. Best Pierre

pfreon commented 1 year ago

Hi Lorenzo, Did you manage to solve the issue? Best Pierre

pfreon commented 1 year ago

Hi Lorenzo,

pfreon commented 1 year ago

No news regarding my help request since October 2022. Please tell me if there is still some hope or if you gave up. Best regards Pierre

pfreon commented 1 year ago

Hi. No body there anymore? Carlo, Stefano, Lorenzo or Alessandro, please answer me, even if it is to tell me that there is no way to help me. Thanks Pierre

alexp-sssup commented 1 year ago

We are currently focusing our work on a new architecture for CheerpJ 3.0 that will require no compilation to jar.js at all.

As such we are not currently scheduling any work on fixing compilation issues with the old architecture (CheerpJ 2.x)

We will close this bug after CheerpJ 3.0 has been released and the correct execution validated.

pfreon commented 1 year ago

Thank you so much for your prompt answer, Alessandro. Any idea of how long this will take? Is it a question of weeks, months, quarters?

alexp-sssup commented 1 year ago

It is a matter of months. We plan to release later in the year, but we do not have a definite release date yet.

pfreon commented 8 months ago

Hi Alessandro and colleagues, I hope that the community will benefit from the new architecture for CheerpJ 3.0 before the end of this year. Is it thinkable to use ChatGPT or other IAs to help in the code writing of CheerpJ 3.0 ?

bates64 commented 8 months ago

Yes, as with other libraries, AI tools could help you use them. Note that ChatGPT in particular has a "knowledge cutoff," where it won't know about CheerpJ 3's API because it released after the knowledge cutoff date. You may have better luck with Copilot or Cursor in that case.

alexp-sssup commented 5 months ago

As part of the new CheerpJ 3.0 architecture there is no need to precompile jar.js files at all.

CheerpJ can now run JAR files completely on this fly. Closing this bug as obsolete.