PR libgcj/25265 second part: Throw NoSuchFieldError for missing fields

Bryce McKinlay mckinlay@redhat.com
Wed Dec 7 23:28:00 GMT 2005


Andrew Haley wrote:
> This is the second part of the patch, the part that defers throwing a
> NoSuchFieldError until we try to use a missing field.
>
> Unfortunately, this really requires us to insert some
> compiler-generated code.  On the plus side, this is only necessary
> when accessing fields that beling to some other class, and in
> Object-Oriented programming we really aren't supposed to do that sort
> of thing.  So it doesn't matter.  ;-)
>   

Accessing fields across public class boundaries frowned upon, but I 
don't think it is unusual in some other cases. eg: It seems reasonably 
common to access fields directly when:

- the field accesses are between nested classes
- the fields are in a superclass

Classpath, for example, has many examples of the first type in 
particular. Of course, I don't see any better way to fix this, but it 
would be interesting to see what effect (if any) this change has on 
Dacapo/SpecJVM scores.

Bryce



More information about the Java-patches mailing list