Java Reflection Isn't Slow

Hm, I thought the compiler/bytecode verifier would take care of all type checking.

This turned out to be a surprisingly high cost on the GC end of things. Once I made the method caching optimization I mentioned in my original post I ran it through VisualVM to get a feel for garbage creation, and my simple little benchmark loop was beating the GC mercilessly because I was creating two arrays per opcode dispatch - an array of parameters to pass to the method and an array of the parameter types to verify method signatures before calling. Caching and reusing those arrays made the interpreter garbage-free. The caching made no difference to performance over creating new arrays (wouldn’t expect that to be measurable) but now I have a nice steady and gradual allocation slope as the immutable integer objects are created in the benchmark’s while-loop.