(This came up while reviewing the nestmates stuff.  I'm sending it in its
own thread, FTR.)

Here's a question to mull over for the future.  It belongs in the "strict VM"
bucket of ideas, which I have occasionally spoken about.

There is a lot of (IMO needless) complexity in the JVM dealing with
a symbolic reference from a class D to a protected member C.m/I.m
of a super C/I outside of D's package.  I think such references can
and should be normalized specifically to D's immediate super, whether
that is C or not.  Could we do this?  I think it would simplify JVMS 5.4.4,
at a point where it is rather opaque.

This is the language I'm talking about:

> • R is protected and is declared in a class C, and D is either a subclass of 
> C or C itself. Furthermore, if R is not static, then the symbolic reference 
> to R must contain a symbolic reference to a class T, such that T is either a 
> subclass of D, a superclass of D, or D itself.
> 
> During verification, it was also required that, even if T is a superclass of 
> D, the target reference of a protected instance field access or method 
> invocation must be an instance of D or a subclass of D (4.10.1.8).


We could replace it by this:

> • R is protected and is declared in a class C *not in the same run-time 
> package as D*, and D is *a subclass of C*. Furthermore the symbolic reference 
> to R must contain a symbolic reference to *the immediate superclass of D*.
> 

> During verification, it was also required that the target reference of a 
> protected instance field access or method invocation must be an instance of D 
> or a subclass of D (4.10.1.8).


The existing complexities are due IMO to historical mis-steps (as
recognized in hindsight) in the way symbolic references were formulated.
This is the ancient 1.0 time frame, before we invented ACC_SUPER
and when miranda methods were a new thing.  We've come a ways
since then; perhaps we can make use of our knowledge.

— John

Reply via email to