By "Magic" I mean the methods which have semantics which are not expressed in pure Java.
I know all native
methods are magic, in that their implementation is provided by the underlying runtime and not by Java bytecodes.
Is the reverse true? Are all magic methods native
, or are there some magic methods apparently implemented in pure Java, but with some extra help from some JVM-special-casing?
The use case is that I want to modify the semantics of Java by instrumenting its bytecodes. All these magic methods are special cases which I will have to handle some way or another. The native
ones are all obvious, but I was wondering if there are any unmarked magic methods I have to watch out and special case for.
Unfortunately there are "magic" methods outside of native methods. Take a look at intrinsic methods - these methods are known to the JIT, which uses hand rolled implementations when a method is compiled, and include heavily called methods such as String.indexOf, Integer.numberOfLeadingZeros, etc.
Take a look at here, under Intrinsics, for some details and how to determine which methods are intrinsified on your JVM. I'm not sure if injecting bytecode will turn off intrisification, but there is a DisableIntrinsic XX option you can use to disable selected intrinsics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With