After upgradeing JCVM to 0.91, I'm seeing an exception due to broken
static initializer ordering in java.lang.VMClassLoader. The "bootjars"
static field is initialized on line 173, but this is after its use
(indirectly) in the static initializer that starts on line 83.

Here's a stack trace:

 java.lang.NullPointerException
   at java.lang.VMThrowable.fillInStackTrace(Native Method)
   at java.lang.Throwable.fillInStackTrace(Throwable.java:498)
   at java.lang.Throwable.<init>(Throwable.java:159)
   at java.lang.Exception.<init>(Exception.java:78)
   at java.lang.RuntimeException.<init>(RuntimeException.java:76)
   at java.lang.NullPointerException.<init>(NullPointerException.java:80)
   at java.lang.VMClassLoader.getResources(VMClassLoader.java:206)
   at java.lang.VMClassLoader.getResource(VMClassLoader.java:166)
   at java.lang.VMClassLoader.getBootPackages(VMClassLoader.java:252)
   at java.lang.VMClassLoader.<clinit>(VMClassLoader.java:76)
   at java.lang.Integer.<clinit>(Integer.java:81)
   at java.lang.String.valueOf(String.java:1756)
   at java.lang.StringBuffer.append(StringBuffer.java:530)
   at gnu.java.nio.channels.FileChannelImpl.<init>(FileChannelImpl.java:157)
   at gnu.java.nio.channels.FileChannelImpl.<clinit>(FileChannelImpl.java:91)
   at java.io.FileDescriptor.<clinit>(FileDescriptor.java:63)
   at java.lang.VMSystem.makeStandardInputStream(VMSystem.java:186)
   at java.lang.System.<clinit>(System.java)
   at java.lang.Math.<clinit>(Math.java:71)
   at java.util.WeakHashMap.hash(WeakHashMap.java:575)
   at java.util.WeakHashMap.internalGet(WeakHashMap.java:652)
   at java.util.WeakHashMap.get(WeakHashMap.java:760)
   at java.lang.VMString.intern(VMString.java:77)
   at java.lang.String.intern(String.java:1806)
   at java.lang.String.<clinit>(String.java)

Note the call to String.intern() (second line from the bottom in the
stack trace) is generated by the VM to handle creation of a String
constant. Although VM-specific, this is unrelated to the initialization
ordering problem in VMClassLoader.

This is fixed by the attached patch, which I'll commit if there are
no objections... but with that fix, I don't get much further:

Caused by java.lang.NullPointerException
   at java.lang.VMThrowable.fillInStackTrace(Native Method)
   at java.lang.Throwable.fillInStackTrace(Throwable.java:498)
   at java.lang.Throwable.<init>(Throwable.java:159)
   at java.lang.Exception.<init>(Exception.java:78)
   at java.lang.RuntimeException.<init>(RuntimeException.java:76)
   at java.lang.NullPointerException.<init>(NullPointerException.java:80)
   at java.lang.Thread.getThreadLocals(Thread.java:1032)
   at java.lang.ThreadLocal.get(ThreadLocal.java)
   at java.security.VMAccessController.pushContext(VMAccessController.java:108)
   at java.security.AccessController.doPrivileged(AccessController.java:93)
   at gnu.java.nio.charset.Provider.provider(Provider.java:237)
   at java.nio.charset.Charset.provider(Charset.java:250)
   at java.nio.charset.Charset.charsetForName(Charset.java:204)
   at java.nio.charset.Charset.forName(Charset.java:188)
   at java.lang.String.<init>(String.java:348)
   at java.util.zip.ZipFile$PartialInputStream.readString(ZipFile.java:668)
   at java.util.zip.ZipFile.readEntries(ZipFile.java:272)
   at java.util.zip.ZipFile.getEntries(ZipFile.java:357)
   at java.util.zip.ZipFile.getEntry(ZipFile.java:378)
   at java.lang.VMClassLoader.getResources(VMClassLoader.java:226)
   at java.lang.VMClassLoader.getResource(VMClassLoader.java:170)
   at java.lang.VMClassLoader.getBootPackages(VMClassLoader.java:252)
   at java.lang.VMClassLoader.<clinit>(VMClassLoader.java:79)
   at java.lang.Integer.<clinit>(Integer.java:81)
   at java.lang.String.valueOf(String.java:1756)
   at java.lang.StringBuffer.append(StringBuffer.java:530)
   at gnu.java.nio.channels.FileChannelImpl.<init>(FileChannelImpl.java:157)
   at gnu.java.nio.channels.FileChannelImpl.<clinit>(FileChannelImpl.java:91)
   at java.io.FileDescriptor.<clinit>(FileDescriptor.java:63)
   at java.lang.VMSystem.makeStandardInputStream(VMSystem.java:186)
   at java.lang.System.<clinit>(System.java)
   at java.lang.Math.<clinit>(Math.java:71)
   at java.util.WeakHashMap.hash(WeakHashMap.java:575)
   at java.util.WeakHashMap.internalGet(WeakHashMap.java:652)
   at java.util.WeakHashMap.get(WeakHashMap.java:760)
   at java.lang.VMString.intern(VMString.java:77)
   at java.lang.String.intern(String.java:1806)
   at java.lang.String.<clinit>(String.java)

I haven't investigated the second problem  yet...

I'm very curious though.. why is nobody else seeing these problems??
It doesn't seem VM-specific but maybe I'm missing something.

Thanks,
-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7530
diff -u -r1.7530 ChangeLog
--- ChangeLog   23 May 2006 12:53:20 -0000      1.7530
+++ ChangeLog   23 May 2006 14:53:19 -0000
@@ -1,3 +1,8 @@
+2006-05-23  Archie Cobbs  <[EMAIL PROTECTED]>
+
+       * vm/reference/java/lang/VMClassLoader.java: fix static initializer
+       ordering problem.
+
 2006-05-23  Audrius Meskauskas  <[EMAIL PROTECTED]>
        
        PR 27680
Index: vm/reference/java/lang/VMClassLoader.java
===================================================================
RCS file: 
/sources/classpath/classpath/vm/reference/java/lang/VMClassLoader.java,v
retrieving revision 1.37
diff -u -r1.37 VMClassLoader.java
--- vm/reference/java/lang/VMClassLoader.java   23 Apr 2006 09:52:37 -0000      
1.37
+++ vm/reference/java/lang/VMClassLoader.java   23 May 2006 14:53:24 -0000
@@ -75,6 +75,10 @@
   /** packages loaded by the bootstrap class loader */
   static final HashMap definedPackages = new HashMap();
 
+  /** jars from property java.boot.class.path */
+  static final HashMap bootjars = new HashMap();
+  
+
   /**
    * Converts the array string of native package names to
    * Packages. The packages are then put into the
@@ -168,10 +172,6 @@
       return (URL)e.nextElement();
     return null;
   }
-
-  /** jars from property java.boot.class.path */
-  static final HashMap bootjars = new HashMap();
-  
   /**
    * Helper to get a list of resources from the bootstrap class loader.
    *

Reply via email to