< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page




 148   return false;
 149 }
 150 
 151 // called to verify that k is a member of this nest
 152 bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const {
 153   if (_nest_members == NULL || _nest_members == Universe::the_empty_short_array()) {
 154     if (log_is_enabled(Trace, class, nestmates)) {
 155       ResourceMark rm(THREAD);
 156       log_trace(class, nestmates)("Checked nest membership of %s in non-nest-host class %s",
 157                                   k->external_name(), this->external_name());
 158     }
 159     return false;
 160   }
 161 
 162   if (log_is_enabled(Trace, class, nestmates)) {
 163     ResourceMark rm(THREAD);
 164     log_trace(class, nestmates)("Checking nest membership of %s in %s",
 165                                 k->external_name(), this->external_name());
 166   }
 167 
 168   // Check names first and if they match then check actual klass. This avoids
 169   // resolving anything unnecessarily.
 170   for (int i = 0; i < _nest_members->length(); i++) {
 171     int cp_index = _nest_members->at(i);








 172     Symbol* name = _constants->klass_name_at(cp_index);
 173     if (name == k->name()) {
 174       log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
 175 
 176       // names match so check actual klass - this may trigger class loading if
 177       // it doesn't match (but that should be impossible)
 178       Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
 179       if (k2 == k) {
 180         log_trace(class, nestmates)("- class is listed as a nest member");
 181         return true;
 182       } else {

 183         // same name but different klass!
 184         log_trace(class, nestmates)(" - klass comparison failed!");
 185         // can't have different classes for the same name, so we're done
 186         return false;

 187       }
 188     }
 189   }
 190   log_trace(class, nestmates)("- class is NOT a nest member!");
 191   return false;
 192 }
 193 
 194 // Return nest-host class, resolving, validating and saving it if needed.
 195 // In cases where this is called from a thread that can not do classloading
 196 // (such as a native JIT thread) then we simply return NULL, which in turn
 197 // causes the access check to return false. Such code will retry the access
 198 // from a more suitable environment later.
 199 InstanceKlass* InstanceKlass::nest_host(Symbol* validationException, TRAPS) {
 200   InstanceKlass* nest_host_k = _nest_host;
 201   if (nest_host_k == NULL) {
 202     // need to resolve and save our nest-host class. This could be attempted
 203     // concurrently but as the result is idempotent and we don't use the class
 204     // then we do not need any synchronization beyond what is implicitly used
 205     // during class loading.
 206     if (_nest_host_index != 0) { // we have a real nest_host




 148   return false;
 149 }
 150 
 151 // called to verify that k is a member of this nest
 152 bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const {
 153   if (_nest_members == NULL || _nest_members == Universe::the_empty_short_array()) {
 154     if (log_is_enabled(Trace, class, nestmates)) {
 155       ResourceMark rm(THREAD);
 156       log_trace(class, nestmates)("Checked nest membership of %s in non-nest-host class %s",
 157                                   k->external_name(), this->external_name());
 158     }
 159     return false;
 160   }
 161 
 162   if (log_is_enabled(Trace, class, nestmates)) {
 163     ResourceMark rm(THREAD);
 164     log_trace(class, nestmates)("Checking nest membership of %s in %s",
 165                                 k->external_name(), this->external_name());
 166   }
 167 
 168   // Check for a resolved cp entry , else fall back to a name check.
 169   // We don't want to resolve any class other than the one being checked.
 170   for (int i = 0; i < _nest_members->length(); i++) {
 171     int cp_index = _nest_members->at(i);
 172     if (_constants->tag_at(cp_index).value() == JVM_CONSTANT_Class) {
 173       Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
 174       if (k2 == k) {
 175         log_trace(class, nestmates)("- class is listed at nest_members[%d] => cp[%d]", i, cp_index);
 176         return true;
 177       }
 178     }
 179     else {
 180       Symbol* name = _constants->klass_name_at(cp_index);
 181       if (name == k->name()) {
 182         log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
 183 
 184         // names match so check actual klass - this may trigger class loading if
 185         // it doesn't match (but that should be impossible)
 186         Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
 187         if (k2 == k) {
 188           log_trace(class, nestmates)("- class is listed as a nest member");
 189           return true;
 190         }
 191         else {
 192           // same name but different klass!
 193           log_trace(class, nestmates)(" - klass comparison failed!");
 194           // can't have two names the same, so we're done
 195           return false;
 196         }
 197       }
 198     }
 199   }
 200   log_trace(class, nestmates)("- class is NOT a nest member!");
 201   return false;
 202 }
 203 
 204 // Return nest-host class, resolving, validating and saving it if needed.
 205 // In cases where this is called from a thread that can not do classloading
 206 // (such as a native JIT thread) then we simply return NULL, which in turn
 207 // causes the access check to return false. Such code will retry the access
 208 // from a more suitable environment later.
 209 InstanceKlass* InstanceKlass::nest_host(Symbol* validationException, TRAPS) {
 210   InstanceKlass* nest_host_k = _nest_host;
 211   if (nest_host_k == NULL) {
 212     // need to resolve and save our nest-host class. This could be attempted
 213     // concurrently but as the result is idempotent and we don't use the class
 214     // then we do not need any synchronization beyond what is implicitly used
 215     // during class loading.
 216     if (_nest_host_index != 0) { // we have a real nest_host


< prev index next >