< prev index next >

hotspot/src/share/vm/interpreter/linkResolver.cpp

Print this page
rev 10524 : vwithfield class/field access


 904   }
 905 
 906   if (!link_info.check_access())
 907     // Access checking may be turned off when calling from within the VM.
 908     return;
 909 
 910   // check access
 911   KlassHandle current_klass = link_info.current_klass();
 912   check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);
 913 
 914   // check for errors
 915   if (is_static != fd.is_static()) {
 916     ResourceMark rm(THREAD);
 917     char msg[200];
 918     jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string());
 919     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
 920   }
 921 
 922   // Final fields can only be accessed from its own class.
 923   if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) {
















 924     THROW(vmSymbols::java_lang_IllegalAccessError());
 925   }
 926 
 927   // initialize resolved_klass if necessary
 928   // note 1: the klass which declared the field must be initialized (i.e, sel_klass)
 929   //         according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
 930   //
 931   // note 2: we don't want to force initialization if we are just checking
 932   //         if the field access is legal; e.g., during compilation
 933   if (is_static && initialize_class) {
 934     sel_klass->initialize(CHECK);
 935   }
 936 
 937   if (sel_klass() != current_klass()) {
 938     check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK);
 939   }
 940 
 941   // return information. note that the klass is set to the actual klass containing the
 942   // field, otherwise access of static fields in superclasses will not work.
 943 }




 904   }
 905 
 906   if (!link_info.check_access())
 907     // Access checking may be turned off when calling from within the VM.
 908     return;
 909 
 910   // check access
 911   KlassHandle current_klass = link_info.current_klass();
 912   check_field_accessability(current_klass, resolved_klass, sel_klass, fd, CHECK);
 913 
 914   // check for errors
 915   if (is_static != fd.is_static()) {
 916     ResourceMark rm(THREAD);
 917     char msg[200];
 918     jio_snprintf(msg, sizeof(msg), "Expected %s field %s.%s", is_static ? "static" : "non-static", resolved_klass()->external_name(), fd.name()->as_C_string());
 919     THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), msg);
 920   }
 921 
 922   // Final fields can only be accessed from its own class.
 923   if (is_put && fd.access_flags().is_final() && sel_klass() != current_klass()) {
 924 #define MVT_FINAL_ACCESS_FROM_VCC_HOST
 925 #ifdef  MVT_FINAL_ACCESS_FROM_VCC_HOST
 926     /*
 927      * Minimal Value Types hole to allow vwithfield opcode, final field access from
 928      * Value Capable class (VCC) hosting anonymous class to Derived Value Type class (DVT)
 929      */
 930     if (byte == Bytecodes::_vwithfield) {
 931       assert(sel_klass()->is_value(), "Expected Value Type");
 932       if (current_klass->is_instance_klass() && InstanceKlass::cast(current_klass())->is_anonymous()) {
 933         Klass* host_class = InstanceKlass::cast(current_klass())->host_klass(); // Is host VCC of DVT ?
 934         if (host_class->is_instance_klass() && InstanceKlass::cast(host_class)->derive_value_type_klass() == sel_klass()) {
 935           return;
 936         }
 937       }
 938     }
 939 #endif
 940     THROW(vmSymbols::java_lang_IllegalAccessError());
 941   }
 942 
 943   // initialize resolved_klass if necessary
 944   // note 1: the klass which declared the field must be initialized (i.e, sel_klass)
 945   //         according to the newest JVM spec (5.5, p.170) - was bug (gri 7/28/99)
 946   //
 947   // note 2: we don't want to force initialization if we are just checking
 948   //         if the field access is legal; e.g., during compilation
 949   if (is_static && initialize_class) {
 950     sel_klass->initialize(CHECK);
 951   }
 952 
 953   if (sel_klass() != current_klass()) {
 954     check_field_loader_constraints(field, sig, current_klass, sel_klass, CHECK);
 955   }
 956 
 957   // return information. note that the klass is set to the actual klass containing the
 958   // field, otherwise access of static fields in superclasses will not work.
 959 }


< prev index next >