The Artima Developer Community
Sponsored Link

Chapter 8 of Inside the Java Virtual Machine
The Linking Model
by Bill Venners

<<  Page 6 of 20  >>

Advertisement

Resolution of CONSTANT_Fieldref_info Entries

To resolve a constant pool entry of type CONSTANT_Fieldref_info, the virtual machine must first resolve the CONSTANT_Class_info entry specified in the class_index item. Therefore, any error that can be thrown because of the resolution of a CONSTANT_Class_info can be thrown during the resolution of a CONSTANT_Fieldref_info. If resolution of the CONSTANT_Class_info entry succeeds, the virtual machine searches for the indicated field in the type and its supertypes. If it finds the indicated field, the virtual machine checks to make sure the current class has permission to access the field.

If resolution to the CONSTANT_Class_info completes successfully, the virtual machine performs the field lookup process using these steps:

  1. The virtual machine checks the referenced type for a field of the specified name and type. If the virtual machine discovers such a field, that field is the result of the successful field lookup.
  2. Otherwise, the virtual machine checks any interfaces directly implemented or extended by the type, and recursively, any superinterfaces of interfaces directly implemented or extended by the type, for a field of the specified name and type. If the virtual machine discovers such a field, that field is the result of the successful field lookup.
  3. Otherwise, if the type has a direct superclass, the virtual machine checks the type's direct superclass, and recursively all the superclasses of the type, for a field of the specified name and type. If the virtual machine discovers such a field, that field is the result of the successful field lookup.
  4. Otherwise, field lookup fails.

If the virtual machine discovers there is no field with the proper name and type in the referenced class or any of its supertypes (if field lookup failed), the virtual machine throws NoSuchFieldError. Otherwise, if the field lookup succeeds, but the current class doesn't have permission to access the field, the virtual machine throws IllegalAccessError.

Otherwise, the virtual machine marks the entry as resolved and places a direct reference to the field in the data for the constant pool entry.

<<  Page 6 of 20  >>


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use