[英]Are all the “Magic” methods on the JVM marked as Native?
By "Magic" I mean the methods which have semantics which are not expressed in pure Java. “魔术”是指具有语义的方法,这些语法不是用纯Java表达的。
I know all native
methods are magic, in that their implementation is provided by the underlying runtime and not by Java bytecodes. 我知道所有
native
方法都很神奇,因为它们的实现是由底层运行时提供的,而不是由Java字节码提供的。
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? 所有魔法方法都是
native
,还是有一些神奇的方法显然是用纯Java实现的,但是有一些JVM特殊外壳的额外帮助?
The use case is that I want to modify the semantics of Java by instrumenting its bytecodes. 用例是我想通过检测其字节码来修改Java的语义。 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. native
的都很明显,但我想知道是否有任何无标记的魔术方法我需要注意和特殊情况。
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.
看看内部方法 - 这些方法是JIT已知的,它在编译方法时使用手动实现,并包括大量调用的方法,如String.indexOf, Integer.numberOfLeadingZeros等。
Take a look at here , under Intrinsics, for some details and how to determine which methods are intrinsified on your JVM. 在Intrinsics下查看这里的一些细节以及如何确定哪些方法在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.
我不确定注入字节码是否会关闭内部化,但是有一个DisableIntrinsic XX选项可用于禁用选定的内在函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.