United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6958668 repeated uncommon trapping for new of klass which is being initialized
JDK-6958668 : repeated uncommon trapping for new of klass which is being initialized

Details
Type:
Bug
Submit Date:
2010-06-04
Status:
Closed
Updated Date:
2013-06-19
Project Name:
JDK
Resolved Date:
2011-03-08
Component:
hotspot
OS:
solaris_9
Sub-Component:
compiler
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
hs19
Fixed Versions:
hs19 (b04)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
That doesn't make much sense unless klass initialization hasn't been
completed yet.  Could all these copy calls be being made from a class
initializer?  This test case has the recompilation behaviour you're
seeing.

public class abs {
  public Object copy() {
      return new abs();
  }

  static {
      for (int i = 0; i < 10000000; i++) {
          abs qc = new abs();
          Object o = qc.copy();
      }
  }

  public static void main(String[] args) {
  }
}

The rules for dealing with classes that are in the being_initialized
state are somewhat complicated since only the initializing thread is
allowed to instantiate instances of that class while it's being
initialized.  Other threads must block so a dynamic check is required
before executing the new.  C2 just falls back to the interpreter through an uncommon trap with reason uninitialized which throws out the code and may end up recompiling.  It should really just emit a guarded new so you only end up with on extra uncommon trap once the init completes.

                                    

Comments
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/3941674cc7fa
                                     
2010-07-13
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-gc/hotspot/rev/3941674cc7fa
                                     
2010-07-21



Hardware and Software, Engineered to Work Together