DEV Community

Building a 22 Megabytes Microservice with Java, Javalin and GraalVM

Johannes Brüderl on September 27, 2018

Oracle's GraalVM allows for ahead-of-time (AOT) compilation of JVM applications. This means, instead of running a JVM process to execute your appli...
Collapse
 
5422m4n profile image
Sven Kanoldt

I really dislike that there may always be runtime errors that GraalVM can't predict at compile time (correct me if i'm wrong).

I wonder how it is possible after compilation to encounter runtime errors? As I see it the compiler does the static type checks, so at runtime there shouldn't be any surprises. Do I overlook something?

Collapse
 
birdayz profile image
Johannes Brüderl • Edited

I quote from GraalVM docs:

SubstrateVM tries to resolve these elements through a static analysis that
detects calls to the reflection API. Where the analysis fails the program
elements reflectively accessed at run time must be specified 
during native image generation in a configuration file [...]

So yeah it's best-effort only, but no guarantee to detect your stuff. Reflection is a hacky side-step to manipulate or create objects etc, so no guarantees. Javac can't give you guarantees about runtime behavior of reflection, so GraalVM can't do it as well.

Collapse
 
birdayz profile image
Johannes Brüderl

Well obviously it's horrible but it's most likely not going to ruin your business. I prefer the small Go binary tho.

 
birdayz profile image
Johannes Brüderl

I totally agree with you. The purpose of this post is that even for the people locked into Java development, there might be an option to improve this situation.