src/share/vm/oops/instanceKlass.cpp

changeset 7290
90257dfad6e3
parent 7191
7dca5ed0e13d
child 7325
3c87c13918fb
     1.1 --- a/src/share/vm/oops/instanceKlass.cpp	Fri Oct 24 03:03:59 2014 +0000
     1.2 +++ b/src/share/vm/oops/instanceKlass.cpp	Fri Oct 24 12:29:08 2014 -0700
     1.3 @@ -780,6 +780,41 @@
     1.4    }
     1.5  }
     1.6  
     1.7 +// Eagerly initialize superinterfaces that declare default methods (concrete instance: any access)
     1.8 +void InstanceKlass::initialize_super_interfaces(instanceKlassHandle this_oop, TRAPS) {
     1.9 +  if (this_oop->has_default_methods()) {
    1.10 +    for (int i = 0; i < this_oop->local_interfaces()->length(); ++i) {
    1.11 +      Klass* iface = this_oop->local_interfaces()->at(i);
    1.12 +      InstanceKlass* ik = InstanceKlass::cast(iface);
    1.13 +      if (ik->should_be_initialized()) {
    1.14 +        if (ik->has_default_methods()) {
    1.15 +          ik->initialize_super_interfaces(ik, THREAD);
    1.16 +        }
    1.17 +        // Only initialize() interfaces that "declare" concrete methods.
    1.18 +        // has_default_methods drives searching superinterfaces since it
    1.19 +        // means has_default_methods in its superinterface hierarchy
    1.20 +        if (!HAS_PENDING_EXCEPTION && ik->declares_default_methods()) {
    1.21 +          ik->initialize(THREAD);
    1.22 +        }
    1.23 +        if (HAS_PENDING_EXCEPTION) {
    1.24 +          Handle e(THREAD, PENDING_EXCEPTION);
    1.25 +          CLEAR_PENDING_EXCEPTION;
    1.26 +          {
    1.27 +            EXCEPTION_MARK;
    1.28 +            // Locks object, set state, and notify all waiting threads
    1.29 +            this_oop->set_initialization_state_and_notify(
    1.30 +                initialization_error, THREAD);
    1.31 +
    1.32 +            // ignore any exception thrown, superclass initialization error is
    1.33 +            // thrown below
    1.34 +            CLEAR_PENDING_EXCEPTION;
    1.35 +          }
    1.36 +          THROW_OOP(e());
    1.37 +        }
    1.38 +      }
    1.39 +    }
    1.40 +  }
    1.41 +}
    1.42  
    1.43  void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) {
    1.44    // Make sure klass is linked (verified) before initialization
    1.45 @@ -859,33 +894,11 @@
    1.46      }
    1.47    }
    1.48  
    1.49 +  // Recursively initialize any superinterfaces that declare default methods
    1.50 +  // Only need to recurse if has_default_methods which includes declaring and
    1.51 +  // inheriting default methods
    1.52    if (this_oop->has_default_methods()) {
    1.53 -    // Step 7.5: initialize any interfaces which have default methods
    1.54 -    for (int i = 0; i < this_oop->local_interfaces()->length(); ++i) {
    1.55 -      Klass* iface = this_oop->local_interfaces()->at(i);
    1.56 -      InstanceKlass* ik = InstanceKlass::cast(iface);
    1.57 -      if (ik->has_default_methods() && ik->should_be_initialized()) {
    1.58 -        ik->initialize(THREAD);
    1.59 -
    1.60 -        if (HAS_PENDING_EXCEPTION) {
    1.61 -          Handle e(THREAD, PENDING_EXCEPTION);
    1.62 -          CLEAR_PENDING_EXCEPTION;
    1.63 -          {
    1.64 -            EXCEPTION_MARK;
    1.65 -            // Locks object, set state, and notify all waiting threads
    1.66 -            this_oop->set_initialization_state_and_notify(
    1.67 -                initialization_error, THREAD);
    1.68 -
    1.69 -            // ignore any exception thrown, superclass initialization error is
    1.70 -            // thrown below
    1.71 -            CLEAR_PENDING_EXCEPTION;
    1.72 -          }
    1.73 -          DTRACE_CLASSINIT_PROBE_WAIT(
    1.74 -              super__failed, InstanceKlass::cast(this_oop()), -1, wait);
    1.75 -          THROW_OOP(e());
    1.76 -        }
    1.77 -      }
    1.78 -    }
    1.79 +    this_oop->initialize_super_interfaces(this_oop, CHECK);
    1.80    }
    1.81  
    1.82    // Step 8

mercurial