Finding the declaring class of a _Jv_Field

Tom Tromey tromey@cygnus.com
Mon Oct 30 15:58:00 GMT 2000


>>>>> "Mark" == Mark Wielaard <mark@klomp.org> writes:

Mark>  - Checks that the currently executing method has access to the
Mark>  referenced method or field."

Mark> But does not specify 'has access to'.

I'm sure this means access in terms of private/protected/public.

Mark> I would conclude that the description of putfield and putstatic
Mark> is not strict enough but that almost all JVMs currently
Mark> implement what it says and that the Microsoft VM is (the only)
Mark> correct JVM when it throws the IllegalAccessError.

Mark> It is interesting to know if that is indeed how one should
Mark> interpret the spec because it makes it easier to implement final
Mark> field checking in gij and it indicates that one may do some
Mark> optimalisations on final fields because they really are not
Mark> suppost to change ever.

A long time ago I did some work on java.lang.System.  I found that
some versions of the JDK (the newer ones) did in fact reassign the
final fields `in', `out', and `err'.

That is why I implemented the setIn/setOut/setErr methods the way that
I did.  ISTR that gcj wouldn't accept a direct reassignment from Java
so I did it in C++ (eww).

Before I ran these tests I had more complex machinery in System.java
(I had a private subclass of PrintStream that let you reassign the
underlying stream).  However, experimentation (and an email discussion
with Per) convinced me that this wasn't required.

It sucks that this isn't well specified.  Maybe the only thing to do
is file a bug report with Sun and hope that they respond to it
someday.

Tom


More information about the Java mailing list