Java can serialize functional interface's lambda into SerializedLambda by itself. Why is JobRunr using some custom parsing, for speed? Not saying they are doing something wrong, I am just curious what was the reason.
JobRunr parses the lambda through the SerializedLambda to get a Job's metadata (class, method, parameters and their values). These are all then serialized to JSON and saved in a database for later execution. It has a few but important practical benefits, such as being nicer to display in the UI or better portability by not depending on compiler details (it's important that a serialized job keep working over different deployments). We also avoid asking every argument captured by the lambda to implement Serializable (we don't need/want to serialize a bean captured by the lambda).
I'm pretty sure they (ab)use SerializedLambda already, but they also have to parse lamba bodies to discover what methods it calls, which is where ASM comes in.
Spot on u/definitelyoneof. SerializedLambda gives us the synthetic lambda$... method and captured values, and then bytecode parsing walks that lambda body to find the actual method call and parameters. On JDK 8 to 24 that is ASM; on JDK 25+ our Multi-Release JAR swaps that step over to java.lang.classfile instead.
2
u/TyGirium 9h ago
Java can serialize functional interface's lambda into SerializedLambda by itself. Why is JobRunr using some custom parsing, for speed? Not saying they are doing something wrong, I am just curious what was the reason.