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.
16 Replies
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?
https://cjrtnc.leaningtech.com/3_20240416_465/cj3loader.js
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
I linked it in the OP - the html would be here https://github.com/F43nd1r/kotlin-compiler-cheerpj/blob/master/src/main/serve/index.html
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.
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
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
That's what I get, it does not seem to be what you previously mentioned
Oh, typical web development fun: only happens in firefox, chrome shows what you posted
Continuing with chrome, I got to a stacktrace:
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?Debugging information is not supported at this time
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 🙂
Give me a few hours before giving up
As a matter of fact, the Firefox issue is already fixed locally
oh, that's cool. Sure if you continue on your side I'll happily follow along!
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
Please try again with the following build: https://cjrtnc.leaningtech.com/3_20240425_466/cj3loader.js
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