Note: This item only applies to JNBridgePro version 6.1 and later.
Situation: In Java-to-.NET projects, if you are using by-value proxies and a SecurityException is thrown.
The issue has to do with the use by JNBridgePro of certain reflection calls that may throw exceptions if the proper security policies have not been set in your Java Runtime Environment (JRE). The problem particularly manifests itself when by-value proxies are passed in Java-to-.NET projects, and a passed proxy class has protected fields whose values are being passed. Note that the default security managers with most JREs will not cause this exception to be thrown, so it is unlikely that you will see it. If you do see this exception, you have two options for addressing it:
1) You can set your JRE’s java.policy file to grant permissions for the operations that cause the problem. In particular, add the following lines:
grant codebase “file://location of jnbcore.jar_goes_here”
permission java.lang.RuntimePermission “*”, “accessDeclaredMembers”;
Once this change is made, the exception will be thrown, and everything will work properly.
2) If you cannot change the Java security policy, or you do not care about the values of protected fields being passed, simply set the following properly in your Java-side configuration file:
When this property is set to false, the exception will not be thrown, and the values will not be passed for protected fields (that is, the values that are passed are default values such as 0 (zero), null, or the empty string, depending on the type of the field). Note that if a setting for javaSide.throwSecurityException is left out of the Java-side configuration, its default value, true, will be used, and the SecurityException will be thrown.