How to debug class loading

Hi, I'm dropping in here from github (https://github.com/leaningtech/cheerpj-meta/issues/195). I'm trying to run the kotlin compiler in a browser (https://github.com/F43nd1r/kotlin-compiler-cheerpj) - however this leads to "Bad class file cj3.js:1:420827" on the console with no further info. How can I debug here to see where the issue might be?
GitHub
Issues · leaningtech/cheerpj-meta
Run Java 8 applications, libraries, applets, Java Web Start, and Oracle Forms on the web without legacy plugins. - Issues · leaningtech/cheerpj-meta
GitHub
GitHub - F43nd1r/kotlin-compiler-cheerpj
Contribute to F43nd1r/kotlin-compiler-cheerpj development by creating an account on GitHub.
apignotti
apignotti•24d ago
The bad class file message is most likely caused by an internal bug where non-class data is being parsed as a class. What version of CJ are your using?
F43nd1r
F43nd1r•24d ago
https://cjrtnc.leaningtech.com/3_20240416_465/cj3loader.js
apignotti
apignotti•24d ago
We had success running kotlin code, including the kotlin compiler in the past For a specific version, but it's a codebase that tends to do extremely complicated manipulations It's quite possible the fix will be easy, just upload test complete HTML test case to a publicly accessible URL so that we can take a look For reference: https://discord.com/channels/988743885121548329/1178768677479403671/1178781364561129612 about our previous experiments with kotlin
F43nd1r
F43nd1r•24d ago
GitHub
kotlin-compiler-cheerpj/src/main/serve/index.html at master · F43nd...
Contribute to F43nd1r/kotlin-compiler-cheerpj development by creating an account on GitHub.
apignotti
apignotti•24d ago
Can you deploy a ready-made page already integrated with CJ? For us is time consuming to get sources to build, and we never need the source anyway
F43nd1r
F43nd1r•24d ago
Oh, that is an interesting approach - I was trying to get the embedded compiler running instead of the standalone I'll set up gh pages, give me a minute https://f43nd1r.github.io/kotlin-compiler-cheerpj/ there you go Note that currently everything happens only on the console, nothing visible on the page
apignotti
apignotti•24d ago
No description
apignotti
apignotti•24d ago
That's what I get, it does not seem to be what you previously mentioned
F43nd1r
F43nd1r•24d ago
Oh, typical web development fun: only happens in firefox, chrome shows what you posted Continuing with chrome, I got to a stacktrace:
Stacktrace: java.lang.Error: java.lang.ArrayIndexOutOfBoundsException
at java.lang.Error.<init>(Unknown Source)
at org.jetbrains.kotlin.com.intellij.util.containers.ConcurrentLongObjectHashMap.<clinit>(Unknown Source)
at org.jetbrains.kotlin.com.intellij.util.containers.ContainerUtil.createConcurrentLongObjectMap(Unknown Source)
[...]
at kotlin.script.experimental.host.BasicScriptingHost.eval(Unknown Source)
at com.faendir.KotlinCompiler.eval(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at .(Unknown Source)
at java.lang.invoke.LambdaForm$DMH.invokeVirtual_LL_J(Unknown Source)
at .(Unknown Source)
... 31 more
Stacktrace: java.lang.Error: java.lang.ArrayIndexOutOfBoundsException
at java.lang.Error.<init>(Unknown Source)
at org.jetbrains.kotlin.com.intellij.util.containers.ConcurrentLongObjectHashMap.<clinit>(Unknown Source)
at org.jetbrains.kotlin.com.intellij.util.containers.ContainerUtil.createConcurrentLongObjectMap(Unknown Source)
[...]
at kotlin.script.experimental.host.BasicScriptingHost.eval(Unknown Source)
at com.faendir.KotlinCompiler.eval(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at .(Unknown Source)
at java.lang.invoke.LambdaForm$DMH.invokeVirtual_LL_J(Unknown Source)
at .(Unknown Source)
... 31 more
Looking at the source of ConcurrentLongObjectHashMap, the kotlin compiler seems to be accessing com.sun.misc.Unsafe using reflection here. Hard to tell which call exactly with no line numbers. I assume I can't turn on line numbers in cheerpj somewhere?
apignotti
apignotti•24d ago
Debugging information is not supported at this time
F43nd1r
F43nd1r•24d ago
Alright, I thought evaluating some kotlin would've been an impressive demo of cheerpj. Probably a bit too ambitious - at least I'm out of my depth here. I can see the kotlin compiler tries to figure out the memory layout of certain classes, I assume that's the part which is just different enough on cheerpj to not work out, but I have no idea how to debug or fix any of it. Thanks for the help either way 🙂
apignotti
apignotti•24d ago
Give me a few hours before giving up As a matter of fact, the Firefox issue is already fixed locally
F43nd1r
F43nd1r•24d ago
oh, that's cool. Sure if you continue on your side I'll happily follow along!
apignotti
apignotti•23d ago
I've fixed a few minor issues and this is the output I get right now, which is the same I see when running with native Java 8
No description
apignotti
apignotti•23d ago
Please try again with the following build: https://cjrtnc.leaningtech.com/3_20240425_466/cj3loader.js
F43nd1r
F43nd1r•23d ago
yeah that's because my hello world isn't actually valid kotlin code 😂 I updated the demo with the new build and a bit of UI - https://f43nd1r.github.io/kotlin-compiler-cheerpj/ Not the fastest in the world, but it works! Impressive how you got that fixed so fast
Want results from more Discord servers?
Add your server
More Posts
WASM-less compilingIs there a way to compile Cheerp code into a single JS target without any extra WASM support when itCheerPJ not showing anythingThere is a class file in my code named AbstractPageBean which returns 404 when I run the page using Runtime class extendingHow does a one extend existing JS class in Cheerp? JS example: ```js class ExtendedClass extends ECalling JS object member functions from WasmThe pong tutorial (https://labs.leaningtech.com/cheerp/tutorials/pong) shows how to handle interactiHow to start CheerojI hadn't learned any java. How to use Cheerpj step by step?Options for running Java versions more recent than Java 8I'm a doctoral researcher, and part of my tasks is providing technical support for grading student pCheerpJ missing functionality of original Jar fileI am trying to get my java swing projects in the browser, but the program is not working fully (it wI'd like to run NASA's Rocket Modeler on my laptop.I see from the NASA webpage https://www1.grc.nasa.gov/wp-content/plugins/cheerpj-integration/lib/appAccessing Java class / object attributes in CheerpJ based PWAI'm new to CheerpJ and I am working on creating a React Native module for ImageJ.js (CheerpJ translaInt ConversionThere is a function in Java, that calls a native function with string argument, like `setContentViewState of the C++ modules supportWhen the new C++ modules are expected to be supported?Cheerpj hangs after "Jar is loaded,main is starting"I am trying to use cheerpj to run my Java Swing app in a browser. I can run the example SwingSet3.jaStretch to Fit Height IssueRunning a basic application in the example html provided on the CheerpJ website. My html code is efProblems with CheerpjHello, I am trying to get my Java app running in CheerPJ - I was successful in creating a simple "HeCache Results for Faster Startup?Hello new user here. Performing initial research into potential commercial application usage. 1) AmUnknownHostException happened when the Java application connect to serverUnknownHostException happened when the Java application connect to server. The host name is the sameHTTP server returned compressed partial data. That should not happen. CheerpJ cannot run.Browser shows error "HTTP server returned compressed partial data. That should not happen. CheerpJ cAccesing the standard out and standard error stream from the Java processHow do I from javascript access the output streams from the started Java process?Any plan on adding internet access without Tailscale?Hi there ! Do you plan on adding internet access without the need to install Tailscale etc, that wour[((0 + c) | 0)] is not a function when instantiating objectHello, thank you all for developing CheerpJ, it is an impressive tool! I am playing around with tryi