[zeromq-dev] Java binding
gonzalo diethelm
gdiethelm at dcv.cl
Mon Feb 22 15:50:26 CET 2010
> > I don't know if the fact that you can call through JNI a private
class
> > member function from member functions in another class within the
same
> > package, is documented to always work in Java, but it SEEMS we could
> > declare these functions private.
>
> Little digging on the web got me this:
>
> http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
>
> As far as I understand the text, private member shouldn't be
accessible
> from another class in the package. The fact that it works with JNI may
> be just an artifact and we shouldn't use it IMO.
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.
--
Gonzalo Diethelm
-----------------------------------------
Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena.
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje.
"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law.
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message.
More information about the zeromq-dev
mailing list