Checking JVMN - JVM

Native methods do not have Java bytecode. Native methods are implemented in foreign programming languages. In our model, native methods are implemented via ASM rules, hence they cannot be checked in the ASM model itself. We have to check from outside that the implementation of each native method is correct and does not change the state of the JVM in an unsafe way.

The check for a native method ensures that the virtual machine has native code for the method and knows what to do when the method is called. Since the only native methods are clone and equal, only those two methods are accepted as native.

We could check at run-time that the return value of a native method is of the return type of the method. However, such a check cannot be performed by the bytecode veri_er in the next chapters. The implementor of a native method is responsible that the method returns always values of the right type.

For example, the implementor of the native method clone of class Object must ensure that this method returns a valid reference and not a value of a primitive type.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

JVM Topics