tags:

views:

58

answers:

2

Is there any chance for the the violation of java security policy through java native interface. Which are the main areas we have to use JNI

+1  A: 

Yes, once you invoke native code through JNI it can do pretty much anything the current user is allowed to do - e.g. delete all their files. The Java system cannot police anything that native code does.

You don't have to use JNI for anything - it's typically used for e.g. low-level access (e.g. critical error handling for a removable drive) or to access a C API which doesn't have a pure-Java equivalent.

Vinay Sajip
+2  A: 

Java's Security policies simply do not apply to native code called via JNI, so obviously the native code can violate them at will.

As for what JNI us used for, these days it's mainly to call OS-specific APIs or interface with existing non-Java code. Improving performance used to be a frequently-cited reason, but considering the state of VMs and JIT compilers today, that almost never makes sense.

Michael Borgwardt