1 19 20 package org.netbeans; 21 22 import org.netbeans.junit.NbTestCase; 23 import org.openide.ErrorManager; 24 import org.openide.util.Lookup; 25 import org.openide.util.RequestProcessor; 26 import org.openide.util.lookup.AbstractLookup; 27 28 32 public class Deadlock64710Test extends NbTestCase { 33 private Lkp lookup; 34 35 public Deadlock64710Test(String name) { 36 super(name); 37 } 38 39 protected void setUp() throws Exception { 40 System.setProperty("org.openide.util.Lookup", "org.netbeans.Deadlock64710Test$Lkp"); 41 42 Lookup l = Lookup.getDefault(); 43 44 ErrorManager.getDefault(); 45 46 if (! (l instanceof Lkp)) { 47 fail("From lookup: " + l); 48 } 49 50 lookup = (Lkp)l; 51 52 53 String c = "org.openide.util.Cancellable"; 54 55 lookup.query = new JarClassLoaderTest.OneClassLoader ( 56 "cancel loader", getClass().getClassLoader(), getClass().getClassLoader().getParent(), c 57 ); 58 lookup.another = new JarClassLoaderTest.OneClassLoader ( 59 "another loader", getClass().getClassLoader(), getClass().getClassLoader().getParent(), c 60 ); 61 62 } 63 64 public void testProxyClassLoaderAsksForLookup() throws Exception { 65 lookup.lookup(Module.class); 66 } 67 68 public static final class Lkp extends AbstractLookup implements Runnable { 69 ProxyClassLoader query, another; 70 ProxyClassLoader toAdd; 71 72 public Lkp () { 73 this (new org.openide.util.lookup.InstanceContent ()); 74 } 75 76 private Lkp (org.openide.util.lookup.InstanceContent ic) { 77 super (ic); 78 } 79 80 protected synchronized void beforeLookup(org.openide.util.Lookup.Template template) { 81 if (query != null) { 82 ProxyClassLoader p = query; 83 toAdd = p; 84 try { 86 synchronized (this) { 87 RequestProcessor.getDefault().post(this); 88 wait(200); 89 } 90 p.loadClass("java.lang.String", false); 91 } catch (Exception ex) { 92 fail(ex.getMessage()); 93 } 94 return; 95 } 96 97 } 98 99 public void run() { 100 toAdd.append(new ClassLoader [] { another }); 101 } 102 103 104 } 105 106 } 107 | Popular Tags |