Comparison of Java and .NET reflection mechanisms for dynamic module loading: a performance benchmark study
Abstract
This paper presents an experimental performance analysis of dynamic module loading via reflection on the Java Virtual Machine (JVM) and the .NET Common Language Runtime (CLR). Three cold-loading benchmark scenarios are defined and executed with N=1000 post-warm-up iterations each: (A) Java URLClassLoader (non-modular JAR), (B) Java JPMS ModuleLayer (modular JAR), and (C) .NET AssemblyLoadContext. Each iteration measures four consecutive phases: module loading, type resolution, instance creation, and method invocation. After JIT warm-up (W=50 iterations) and IQR-based outlier removal, .NET AssemblyLoadContext achieves the lowest total mean time of 0.419 +- 0.104 ms, whereas Java JPMS incurs the highest mean of 1.299 +- 0.532 ms driven primarily by ModuleLayer construction (5.2x overhead vs. URLClassLoader). .NET type resolution is 20.9x faster than Java URLClassLoader (0.030 ms vs. 0.626 ms). Non-parametric statistical analysis (Mann–Whitney U, Cohen’s d: 0.66–2.26) confirms that all pairwise differences are highly significant (p<0.001). Cached-reflection baselines show that both platforms reduce to sub-10 us once class/assembly metadata is reused.