Constant Folding of Reflective Calls via Static Analysis of Java Bytecode

Constant Folding of Reflective Calls via Static Analysis of Java Bytecode

06 December 2024

Ahead-of-time (AOT) compilation of Java applications to native executables provides faster application startup and comparable peak performance to the traditional just-in-time (JIT) compilation approach of a Java Virtual Machine. This makes AOT compilation especially attractive for short-lived cloud microservices. GraalVM enables AOT compilation by utilizing the closed world assumption, which states that all classes the application can access during its execution must be known at compile time. This limits dynamic Java features, such as class loading and introspection through the reflection API. To get around those limitations, GraalVM employs a static analysis of IR graphs for the cases where the arguments of reflective calls are known in compile time. However, different compiler optimizations can happen before the static analysis and thus can alter its precision and require excess user-provided reflection metadata. We discuss the problems that can arise due to the dependence of GraalVM static analysis on previous compiler optimizations and the difficulty of defining its formal specification in terms of Java source code. We propose an alternative approach, based on static analysis of Java bytecode, which avoids optimization dependencies and enables formal specifications. This results in an improved user experience by reducing ambiguity and the amount of reflection metadata that needs to be provided.


Venue : The fourteenth Symposium "Mathematics and Applications" 2024 https://simpozijum.matf.bg.ac.rs/home.html

File Name : MATFSymposioum24_Constant_Folding_of_Reflective_Calls_via_Static_Analysis_of_Java_Bytecode-1.pdf



  • What’s New