title: ImageIO hangs when referred inside an OSGI Application Mac OS X - Java 1.7
body: <p>I am using Java 1.7 on Mac OS X 10.7.5 . It hangs the moment execution touches any ImageIO API.</p>
  
  <pre><code>import javax.imageio.ImageIO;
  
  import org.eclipse.equinox.app.IApplication;
  import org.eclipse.equinox.app.IApplicationContext;
  
  public class ImageMain implements IApplication {
  
      @Override
      public Object start(IApplicationContext context) throws Exception {
  
          ImageIO.getCacheDirectory();
  
           return IApplication.EXIT_OK; 
      }
  
      @Override
      public void stop() {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p><strong>jstack output :</strong></p>
  
  <blockquote>
    <p>013-12-03 11:37:57
        Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode):</p>
  
  <pre><code>"Attach Listener" daemon prio=5 tid=0x00007fbada8c5000 nid=0x8a23 waiting on condition [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "Worker-JM" prio=5 tid=0x00007fbadb941000 nid=0x6007 in Object.wait() [0x0000000116ee6000]
     java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x00000007f85bf428&gt; (a java.util.ArrayList)
    at org.eclipse.core.internal.jobs.InternalWorker.run(InternalWorker.java:58)
    - locked &lt;0x00000007f85bf428&gt; (a java.util.ArrayList)
  
  "Start Level Event Dispatcher" daemon prio=5 tid=0x00007fbadb92c800 nid=0x5d03 in Object.wait()
  </code></pre>
    
    <p>[0x0000000115bbf000]
           java.lang.Thread.State: WAITING (on object monitor)
          at java.lang.Object.wait(Native Method)
          - waiting on &lt;0x00000007f96b2838> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
          at java.lang.Object.wait(Object.java:503)
          at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:400)
          - locked &lt;0x00000007f96b2838> (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
          at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:336)</p>
  
  <pre><code>"State Saver" prio=5 tid=0x00007fbadb895800 nid=0x5b03 in Object.wait() [0x0000000115ab7000]
     java.lang.Thread.State: RUNNABLE
    at sun.awt.AppContext$2.run(AppContext.java:271)
    at sun.awt.AppContext$2.run(AppContext.java:260)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.AppContext.initMainAppContext(AppContext.java:260)
    at sun.awt.AppContext.access$200(AppContext.java:133)
    at sun.awt.AppContext$3.run(AppContext.java:314)
    at sun.awt.AppContext$3.run(AppContext.java:298)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.AppContext.getAppContext(AppContext.java:297)
    at sun.awt.AppContext$6.getContext(AppContext.java:841)
    at sun.misc.SharedSecrets.getJavaAWTAccess(SharedSecrets.java:200)
    at java.util.TimeZone.getDefaultInAppContext(TimeZone.java:730)
    at java.util.TimeZone.getDefaultRef(TimeZone.java:620)
    at java.util.Date.normalize(Date.java:1193)
    at java.util.Date.toString(Date.java:1027)
    at java.util.Properties.store0(Properties.java:823)
    at java.util.Properties.store(Properties.java:812)
    at org.eclipse.osgi.storagemanager.StorageManager.save(StorageManager.java:551)
    at org.eclipse.osgi.storagemanager.StorageManager.update(StorageManager.java:310)
    at org.eclipse.osgi.storagemanager.StorageManager.closeOutputStream(StorageManager.java:903)
    at org.eclipse.osgi.storagemanager.ManagedOutputStream.close(ManagedOutputStream.java:52)
    at java.io.FilterOutputStream.close(FilterOutputStream.java:160)
    at java.io.FilterOutputStream.close(FilterOutputStream.java:160)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage.saveBundleDatas(BaseStorage.java:598)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage.saveAllData(BaseStorage.java:461)
    at org.eclipse.osgi.internal.baseadaptor.BaseStorage$StateSaver.run(BaseStorage.java:1306)
    - locked &lt;0x00000007f96b8c48&gt; (a org.eclipse.osgi.internal.resolver.SystemState)
    at java.lang.Thread.run(Thread.java:724)
  
  "Framework Event Dispatcher" daemon prio=5 tid=0x00007fbadb948000 nid=0x5903 in Object.wait() [0x00000001159b6000]
     java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x00000007f96b2520&gt; (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
    at java.lang.Object.wait(Object.java:503)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.getNextEvent(EventManager.java:400)
    - locked &lt;0x00000007f96b2520&gt; (a org.eclipse.osgi.framework.eventmgr.EventManager$EventThread)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:336)
  
  "State Data Manager" daemon prio=5 tid=0x00007fbadb828000 nid=0x5703 waiting for monitor entry [0x00000001158b3000]
     java.lang.Thread.State: BLOCKED (on object monitor)
    at org.eclipse.osgi.internal.baseadaptor.StateManager.run(StateManager.java:303)
    - waiting to lock &lt;0x00000007f96b8c48&gt; (a org.eclipse.osgi.internal.resolver.SystemState)
    at java.lang.Thread.run(Thread.java:724)
  
  "Framework Active Thread" prio=5 tid=0x00007fbadb05b800 nid=0x5503 in Object.wait() [0x00000001157b0000]
     java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x00000007f96b7310&gt; (a org.eclipse.osgi.framework.internal.core.Framework)
    at org.eclipse.osgi.framework.internal.core.Framework.run(Framework.java:1862)
    - locked &lt;0x00000007f96b7310&gt; (a org.eclipse.osgi.framework.internal.core.Framework)
    at java.lang.Thread.run(Thread.java:724)
  
  "Service Thread" daemon prio=5 tid=0x00007fbad9806000 nid=0x4f03 runnable [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "C2 CompilerThread1" daemon prio=5 tid=0x00007fbadc001800 nid=0x4d03 waiting on condition [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "C2 CompilerThread0" daemon prio=5 tid=0x00007fbadb829800 nid=0x4b03 waiting on condition [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "JDWP Command Reader" daemon prio=5 tid=0x00007fbadd002000 nid=0x4903 runnable [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "JDWP Event Helper Thread" daemon prio=5 tid=0x00007fbadd000000 nid=0x4703 runnable [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "JDWP Transport Listener: dt_socket" daemon prio=5 tid=0x00007fbadb828800 nid=0x4503 runnable [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "Signal Dispatcher" daemon prio=5 tid=0x00007fbadb81a000 nid=0x4303 runnable [0x0000000000000000]
     java.lang.Thread.State: RUNNABLE
  
  "Finalizer" daemon prio=5 tid=0x00007fbadb803000 nid=0x3a03 in Object.wait() [0x0000000114b56000]
     java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x00000007f96e30b0&gt; (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
    - locked &lt;0x00000007f96e30b0&gt; (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:189)
  
  "Reference Handler" daemon prio=5 tid=0x00007fbadb800800 nid=0x3803 in Object.wait() [0x0000000114a53000]
     java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x00000007f96e2af8&gt; (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:503)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
    - locked &lt;0x00000007f96e2af8&gt; (a java.lang.ref.Reference$Lock)
  
  "main" prio=5 tid=0x00007fbad9041000 nid=0x707 runnable [0x00007fff6ccd1000]
     java.lang.Thread.State: RUNNABLE
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
    - locked &lt;0x00000007f96e20e0&gt; (a java.util.Vector)
    - locked &lt;0x00000007f96a0ad8&gt; (a java.util.Vector)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1843)
    at java.lang.Runtime.load0(Runtime.java:795)
    - locked &lt;0x00000007f9727830&gt; (a java.lang.Runtime)
    at java.lang.System.load(System.java:1061)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1957)
    - locked &lt;0x00000007f96e20e0&gt; (a java.util.Vector)
    - locked &lt;0x00000007f96a0ad8&gt; (a java.util.Vector)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1882)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
    at java.lang.Runtime.loadLibrary0(Runtime.java:849)
    - locked &lt;0x00000007f9727830&gt; (a java.lang.Runtime)
    at java.lang.System.loadLibrary(System.java:1087)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:67)
    at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:47)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1646)
    at java.awt.Toolkit.&lt;clinit&gt;(Toolkit.java:1668)
    at sun.awt.AppContext$2.run(AppContext.java:271)
    at sun.awt.AppContext$2.run(AppContext.java:260)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.AppContext.initMainAppContext(AppContext.java:260)
    at sun.awt.AppContext.access$200(AppContext.java:133)
    at sun.awt.AppContext$3.run(AppContext.java:314)
    at sun.awt.AppContext$3.run(AppContext.java:298)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.AppContext.getAppContext(AppContext.java:297)
    at javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:154)
    at javax.imageio.ImageIO.&lt;clinit&gt;(ImageIO.java:65)
    at com.sap.ImageTest.ImageMain.start(ImageMain.java:13)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
  
  "VM Thread" prio=5 tid=0x00007fbad908e000 nid=0x3603 runnable 
  
  "GC task thread#0 (ParallelGC)" prio=5 tid=0x00007fbad904d000 nid=0x2603 runnable 
  
  "GC task thread#1 (ParallelGC)" prio=5 tid=0x00007fbad904d800 nid=0x2803 runnable 
  
  "GC task thread#2 (ParallelGC)" prio=5 tid=0x00007fbad904e000 nid=0x2a03 runnable 
  
  "GC task thread#3 (ParallelGC)" prio=5 tid=0x00007fbad904e800 nid=0x2c03 runnable 
  
  "GC task thread#4 (ParallelGC)" prio=5 tid=0x00007fbad904f800 nid=0x2e03 runnable 
  
  "GC task thread#5 (ParallelGC)" prio=5 tid=0x00007fbad9050000 nid=0x3003 runnable 
  
  "GC task thread#6 (ParallelGC)" prio=5 tid=0x00007fbad9050800 nid=0x3203 runnable 
  
  "GC task thread#7 (ParallelGC)" prio=5 tid=0x00007fbad9051000 nid=0x3403 runnable 
  
  "VM Periodic Task Thread" prio=5 tid=0x00007fbada801000 nid=0x5103 waiting on condition 
  
  JNI global references: 2810
  </code></pre>
  </blockquote>