Are all "magic" methods on the JVM marked as Native?

By "Magic" I mean methods that have semantics that are not expressed in pure Java.

I know that all native methods are magic, because their implementation is provided by the underlying runtime, not Java bytecodes.

Is the converse true? Are all magic methods native , or are there some magic methods that are apparently implemented in pure Java, but with some additional help from some JVM-specific packages?

A use case is that I want to change the semantics of Java using my bytecodes. All these magical methods are special cases that I will refer to one way or another. native all obvious, but I was wondering if there are any unmarked magic methods that I have to follow, and a special case for.

+6
source share
2 answers

Unfortunately, there are "magic" methods outside of their own methods. Take a look at the internal methods - these methods are known by JIT, which uses manual implementations to compile the method and includes strongly called methods such as String.indexOf, Integer.numberOfLeadingZeros , etc.

Take a look at the Intrinsics section here for some details and how to determine which methods are built into your JVM. I'm not sure if bytecode injection will disable intrisification, but there is a DisableIntrinsic XX option that you can use to disable selected functions.

+5
source

You may find that many details are already processed in AspectJ . I would look at it before doing manual bytecode manipulation.

0
source

All Articles