logoalt Hacker News

exabrialyesterday at 9:45 PM2 repliesview on HN

Projects like this would be significantly funner and easier to make in Jdk25+(well technically 24+) because of the new Java classfile/bytecode API. It looks like Endive uses OW2 ASM, probably because this supports back to Jdk11. The new jdk API has a minimum target of Jdk17. OW2 ASM is significantly harder to use IMHO though.

What got me into this is I just finished a major release of Petrify (https://github.com/exabrial/petrify) that compiles ML Models to JVM Bytecode. It requires Jdk25 to do the compilation, but the compiled models can run on Jdk17+.

I'm looking for more side projects to use the classfile API on.


Replies

xxstoday at 8:34 AM

bytecode manipulation has been a thing ever since late 90s and early 2000s (e.g. BCEL, Jan, 2001), along with byte code decompilation.

Generally one must understand how bytecode signatures, all flavors of invoke, and constant pool work. After that using visor pattern or 'functional' alike stuff makes no difference whatsoever.

I have used (still using) bytecode manipulation along with custom classloaders as part of my job (albeit not on daily basis any longer). Personally, I don't consider objectweb asm hard to use in any way. and java's class file won't be funnier - perhaps it was the very project I'd not pick bcel, though.

jbaitertoday at 6:31 AM

You might want to take a look at https://www.graalvm.org/webassembly. Runs on JDK25 and has very good guest<->host interop.