< prev index next >

src/hotspot/share/oops/instanceKlass.cpp

Print this page

        

@@ -234,49 +234,41 @@
   InstanceKlass* nest_host_k = _nest_host;
   if (nest_host_k != NULL) {
     return nest_host_k;
   }
 
-  const bool doLog = log_is_enabled(Trace, class, nestmates);
+  ResourceMark rm(THREAD);
 
   // need to resolve and save our nest-host class.
   if (_nest_host_index != 0) { // we have a real nest_host
     // Before trying to resolve check if we're in a suitable context
     if (!THREAD->can_call_java() && !_constants->tag_at(_nest_host_index).is_klass()) {
-      if (doLog) {
-        ResourceMark rm(THREAD);
         log_trace(class, nestmates)("Rejected resolution of nest-host of %s in unsuitable thread",
                                     this->external_name());
-      }
       return NULL; // sentinel to say "try again from a different context"
     }
 
-    if (doLog) {
-      ResourceMark rm(THREAD);
       log_trace(class, nestmates)("Resolving nest-host of %s using cp entry for %s",
                                   this->external_name(),
                                   _constants->klass_name_at(_nest_host_index)->as_C_string());
-    }
 
     Klass* k = _constants->klass_at(_nest_host_index, THREAD);
     if (HAS_PENDING_EXCEPTION) {
       if (PENDING_EXCEPTION->is_a(SystemDictionary::VirtualMachineError_klass())) {
         return NULL; // propagate VMEs
       }
-      ResourceMark rm(THREAD);
       stringStream ss;
       char* target_host_class = _constants->klass_name_at(_nest_host_index)->as_C_string();
       ss.print("Nest host resolution of %s with host %s failed: ",
                this->external_name(), target_host_class);
       java_lang_Throwable::print(PENDING_EXCEPTION, &ss);
       _nest_host_res_error = ss.as_string(true /* on C-heap */);
       // ensure we see _nest_host_res_error is set if _nest_host is non-NULL
       OrderAccess::storestore();
       CLEAR_PENDING_EXCEPTION;
-      if (doLog) {
+
         log_trace(class, nestmates)("%s", _nest_host_res_error);
-      }
     } else {
       // A valid nest-host is an instance class in the current package that lists this
       // class as a nest member. If any of these conditions are not met the class is
       // its own nest-host.
       const char* error = NULL;

@@ -290,15 +282,13 @@
           bool is_member = nest_host_k->has_nest_member(this, THREAD);
           // exception is rare, perhaps impossible
           if (!HAS_PENDING_EXCEPTION) {
             if (is_member) {
               _nest_host = nest_host_k; // save resolved nest-host value
-              if (doLog) {
-                ResourceMark rm(THREAD);
+
                 log_trace(class, nestmates)("Resolved nest-host of %s to %s",
                                             this->external_name(), k->external_name());
-              }
               return nest_host_k;
             } else {
               error = "current type is not listed as a nest member";
             }
           } else {

@@ -317,11 +307,10 @@
         error = "types are in different packages";
       }
 
       // something went wrong, so record what and log it
       {
-        ResourceMark rm(THREAD);
         stringStream ss;
         ss.print("Type %s (loader: %s) is not a nest member of type %s (loader: %s): %s",
                  this->external_name(),
                  this->class_loader_data()->loader_name_and_id(),
                  k->external_name(),

@@ -329,22 +318,17 @@
                  error);
         _nest_host_res_error = ss.as_string(true /* on C-heap */);
         // ensure we see _nest_host_res_error is set if _nest_host is non-NULL
         OrderAccess::storestore();
 
-        if (doLog) {
           log_trace(class, nestmates)("%s", _nest_host_res_error);
         }
       }
-    }
   } else {
-    if (doLog) {
-      ResourceMark rm(THREAD);
       log_trace(class, nestmates)("Type %s is not part of a nest: setting nest-host to self",
                                   this->external_name());
     }
-  }
 
   // Either not in an explicit nest, or else an error occurred, so
   // the nest-host is set to `this`. Any thread that sees this assignment
   // will also see any setting of _nest_host_res_error, if applicable.
   return (_nest_host = this);

@@ -409,18 +393,15 @@
     return false;
   }
 
   bool access = (cur_host == k_nest_host);
 
-  if (log_is_enabled(Trace, class, nestmates)) {
     ResourceMark rm(THREAD);
     log_trace(class, nestmates)("Class %s does %shave nestmate access to %s",
                                 this->external_name(),
                                 access ? "" : "NOT ",
                                 k->external_name());
-  }
-
   return access;
 }
 
 InstanceKlass* InstanceKlass::allocate_instance_klass(const ClassFileParser& parser, TRAPS) {
   bool is_hidden_or_anonymous = parser.is_hidden() || parser.is_unsafe_anonymous();
< prev index next >