[zeromq-dev] Java binding

Martin Sustrik sustrik at 250bpm.com
Mon Feb 22 16:00:22 CET 2010


gonzalo diethelm wrote:

> And I found this gem, at sun.com. It seems we can go ahead, declare
> these two methods private and enjoy ourselves...
> 
> 
> http://java.sun.com/docs/books/jni/html/pitfalls.html
> 
> 10.9 Violating Access Control Rules
> 
> The JNI does not enforce class, field, and method access control
> restrictions that can be expressed at the Java programming language
> level through the use of modifiers such as private and final. It is
> possible to write native code to access or modify fields of an object
> even though doing so at the Java programming language level would lead
> to an IllegalAccessException. JNI's permissiveness was a conscious
> design decision, given that native code can access and modify any memory
> location in the heap anyway.
> 
> Native code that bypasses source-language-level access checks may have
> undesirable effects on program execution. For example, an inconsistency
> may be created if a native method modifies a final field after a
> just-in-time (JIT) compiler has inlined accesses to the field.
> Similarly, native methods should not modify immutable objects such as
> fields in instances of java.lang.String or java.lang.Integer. Doing so
> may lead to breakage of invariants in the Java platform implementation.

Ok, so it looks like it'll work the same way with any Java 
implementation. Please, modify the code to use private of 
package-private (you choose), then make a diff and send it to the 
mailing list stating that it's submitted under MIT license. I'll push it 
into the trunk.

Martin





More information about the zeromq-dev mailing list