Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> only the part of the JRE and external libraries that the app really uses

Just curious, how the reflection and dynamic class loading things work when generating an executable?



The native image generator performs a closed-world static analysis over your application, the JDK, and any supplied libraries to determine what's actually in use. In cases of ambiguity, it must be conservative and include all candidate classes. Since the output is a native binary without the JVM (and subsequently, without a Java bytecode interpreter), there's no way to dynamically load classes. Reflection is handled by registering classes during the image generation process, I believe. Static MethodHandles neatly avoid any issues as well, if you can work with that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: