The manual and specification of JNI programmers says this in "10.9 Violating Access Control Rules":
"JNI does not apply restrictions on access to the class, fields and methods that can be expressed at the level of the Java programming language using modifiers such as private and final. You can write your own code to access or change the field of an object, even if it is done at the level The Java programming language will IllegalAccessException . JNI validity was a conscious design decision, given that native code can access and change any memory location on the heap anyway. "
So, the answers to your questions:
Can it call a private method?
Yes.
if it is YES, then only in the same class or any other classes?
Any class.
if he can cause others, then is this a problem that could be dangerous? that is, he violated the rules.
The rationale for designers in order not to try to provide normal Java access rules is clearly stated in the text above. Yes, this is potentially dangerous, but any use of the JNI is potentially dangerous.
source share