This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 103159
Collapse All | Expand All

(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/EnabledAutoloadTest.java (-24 / +26 lines)
Lines 54-59 Link Here
54
import org.netbeans.junit.Log;
54
import org.netbeans.junit.Log;
55
import org.netbeans.junit.NbModuleSuite;
55
import org.netbeans.junit.NbModuleSuite;
56
import org.netbeans.junit.NbTestCase;
56
import org.netbeans.junit.NbTestCase;
57
import org.openide.util.Mutex.ExceptionAction;
57
58
58
/**
59
/**
59
 *
60
 *
Lines 86-118 Link Here
86
    }
87
    }
87
88
88
    public void testDependOnAutoload() throws Exception {
89
    public void testDependOnAutoload() throws Exception {
89
        ModuleManager mgr = Main.getModuleSystem().getManager();
90
        final ModuleManager mgr = Main.getModuleSystem().getManager();
90
        mgr.mutexPrivileged().enterWriteAccess();
91
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
91
        try {
92
            @Override
92
            Module m1;
93
            public Void run() throws Exception {
93
            String mf = "Bundle-SymbolicName: org.require.autoload\n" +
94
                Module m1;
94
                "Bundle-Version: 33.0.3\n" +
95
                String mf = "Bundle-SymbolicName: org.require.autoload\n" +
95
                "Bundle-ManifestVersion: 2\n" +
96
                    "Bundle-Version: 33.0.3\n" +
96
                "Require-Bundle: org.openide.compat\n\n";
97
                    "Bundle-ManifestVersion: 2\n" +
97
            /*
98
                    "Require-Bundle: org.openide.compat\n\n";
98
            mf = "OpenIDE-Module: org.require.autoload\n" +
99
                /*
99
                "OpenIDE-Module-Module-Dependencies: org.openide.compat\n\n";
100
                mf = "OpenIDE-Module: org.require.autoload\n" +
100
            /**/
101
                    "OpenIDE-Module-Module-Dependencies: org.openide.compat\n\n";
101
            File jj1 = NetigsoHid.changeManifest(getWorkDir(), j1, mf);
102
                /**/
102
            m1 = mgr.create(jj1, null, false, false, false);
103
                File jj1 = NetigsoHid.changeManifest(getWorkDir(), j1, mf);
104
                m1 = mgr.create(jj1, null, false, false, false);
103
105
104
            CharSequence log = Log.enable("org.netbeans.core.modules", Level.WARNING);
106
                CharSequence log = Log.enable("org.netbeans.core.modules", Level.WARNING);
105
            mgr.enable(m1);
107
                mgr.enable(m1);
106
108
107
            assertTrue("OSGi module is now enabled", m1.isEnabled());
109
                assertTrue("OSGi module is now enabled", m1.isEnabled());
108
110
109
            Class<?> wl = m1.getClassLoader().loadClass("org.openide.util.WeakListener");
111
                Class<?> wl = m1.getClassLoader().loadClass("org.openide.util.WeakListener");
110
            assertNotNull("Weak listener found", wl);
112
                assertNotNull("Weak listener found", wl);
111
113
112
            Module compat = mgr.get("org.openide.compat");
114
                Module compat = mgr.get("org.openide.compat");
113
            assertTrue("Compat module is turned on too", compat.isEnabled());
115
                assertTrue("Compat module is turned on too", compat.isEnabled());
114
        } finally {
116
                return null;
115
            mgr.mutexPrivileged().exitWriteAccess();
117
            }
116
        }
118
        });
117
    }
119
    }
118
}
120
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/IntegrationTest.java (-14 / +19 lines)
Lines 58-63 Link Here
58
import org.netbeans.junit.NbModuleSuite;
58
import org.netbeans.junit.NbModuleSuite;
59
import org.netbeans.junit.NbTestCase;
59
import org.netbeans.junit.NbTestCase;
60
import org.openide.util.Lookup;
60
import org.openide.util.Lookup;
61
import org.openide.util.Mutex.ExceptionAction;
61
import org.osgi.framework.launch.Framework;
62
import org.osgi.framework.launch.Framework;
62
63
63
/**
64
/**
Lines 100-121 Link Here
100
101
101
102
102
    public void testCheckWhichContainerIsRunning() throws Exception {
103
    public void testCheckWhichContainerIsRunning() throws Exception {
103
        ModuleManager mgr = Main.getModuleSystem().getManager();
104
        final ModuleManager mgr = Main.getModuleSystem().getManager();
104
        mgr.mutexPrivileged().enterWriteAccess();
105
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
105
        Module m1;
106
            @Override
106
        String mf = "Bundle-SymbolicName: org.foo\n" +
107
            public Void run() throws Exception {
107
            "Bundle-Version: 1.1.0\n" +
108
                Module m1;
108
            "Bundle-ManifestVersion: 2\n" +
109
                String mf = "Bundle-SymbolicName: org.foo\n" +
109
            "Export-Package: org.foo";
110
                    "Bundle-Version: 1.1.0\n" +
111
                    "Bundle-ManifestVersion: 2\n" +
112
                    "Export-Package: org.foo";
110
113
111
        LOG.info("about to enable module org.foo");
114
                LOG.info("about to enable module org.foo");
112
        File jj1 = NetigsoHid.changeManifest(getWorkDir(), j1, mf);
115
                File jj1 = NetigsoHid.changeManifest(getWorkDir(), j1, mf);
113
        m1 = mgr.create(jj1, null, false, false, false);
116
                m1 = mgr.create(jj1, null, false, false, false);
114
        mgr.enable(m1);
117
                mgr.enable(m1);
115
        LOG.info("Enabling is over");
118
                LOG.info("Enabling is over");
116
119
117
        assertTrue("OSGi module is now enabled", m1.isEnabled());
120
                assertTrue("OSGi module is now enabled", m1.isEnabled());
118
        mgr.mutexPrivileged().exitWriteAccess();
121
                return null;
122
            }
123
        });
119
124
120
        Object obj = Lookup.getDefault().lookup(NetigsoFramework.class);
125
        Object obj = Lookup.getDefault().lookup(NetigsoFramework.class);
121
        LOG.log(Level.INFO, "NetigsoFramework: {0}", obj);
126
        LOG.log(Level.INFO, "NetigsoFramework: {0}", obj);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoActivationCanAccessLayersTest.java (-13 / +15 lines)
Lines 51-56 Link Here
51
import org.netbeans.Module;
51
import org.netbeans.Module;
52
import org.netbeans.ModuleManager;
52
import org.netbeans.ModuleManager;
53
import org.netbeans.SetupHid;
53
import org.netbeans.SetupHid;
54
import org.openide.util.Mutex.ExceptionAction;
54
55
55
/**
56
/**
56
 * Can the BundleActivators access layer entries defined by other (NetBeans) modules?
57
 * Can the BundleActivators access layer entries defined by other (NetBeans) modules?
Lines 81-101 Link Here
81
    public void testActivation() throws Exception {
82
    public void testActivation() throws Exception {
82
        ModuleSystem ms = Main.getModuleSystem();
83
        ModuleSystem ms = Main.getModuleSystem();
83
        mgr = ms.getManager();
84
        mgr = ms.getManager();
84
        mgr.mutexPrivileged().enterWriteAccess();
85
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
85
        try {
86
            @Override
86
            File simpleModule = new File(jars, "activate.jar");
87
            public Void run() throws Exception {
87
            m1 = mgr.create(simpleModule, null, false, false, false);
88
                File simpleModule = new File(jars, "activate.jar");
88
            System.setProperty("activate.layer.test", "can-this-file-be-found.txt");
89
                m1 = mgr.create(simpleModule, null, false, false, false);
89
            mgr.enable(m1);
90
                System.setProperty("activate.layer.test", "can-this-file-be-found.txt");
91
                mgr.enable(m1);
90
92
91
            Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
93
                Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
92
            Object s = main.getField("start").get(null);
94
                Object s = main.getField("start").get(null);
93
            assertNotNull("Bundle started, its context provided", s);
95
                assertNotNull("Bundle started, its context provided", s);
94
96
95
            mgr.disable(m1);
97
                mgr.disable(m1);
96
        } finally {
98
                return null;
97
            mgr.mutexPrivileged().exitWriteAccess();
99
            }
98
        }
100
        });
99
    }
101
    }
100
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
102
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
101
        return createTestJAR(data, jars, name, srcdir, classpath);
103
        return createTestJAR(data, jars, name, srcdir, classpath);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoActivationOnExitTest.java (-14 / +16 lines)
Lines 51-56 Link Here
51
import org.netbeans.Module;
51
import org.netbeans.Module;
52
import org.netbeans.ModuleManager;
52
import org.netbeans.ModuleManager;
53
import org.netbeans.SetupHid;
53
import org.netbeans.SetupHid;
54
import org.openide.util.Mutex.ExceptionAction;
54
55
55
/**
56
/**
56
 * Do we correctly call the BundleActivators?
57
 * Do we correctly call the BundleActivators?
Lines 82-104 Link Here
82
    public void testDeactivationOnExit() throws Exception {
83
    public void testDeactivationOnExit() throws Exception {
83
        ModuleSystem ms = Main.getModuleSystem();
84
        ModuleSystem ms = Main.getModuleSystem();
84
        mgr = ms.getManager();
85
        mgr = ms.getManager();
85
        mgr.mutexPrivileged().enterWriteAccess();
86
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
86
        try {
87
            @Override
87
            File simpleModule = new File(jars, "activate.jar");
88
            public Void run() throws Exception {
88
            m1 = mgr.create(simpleModule, null, false, false, false);
89
                File simpleModule = new File(jars, "activate.jar");
89
            mgr.enable(m1);
90
                m1 = mgr.create(simpleModule, null, false, false, false);
91
                mgr.enable(m1);
90
92
91
            Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
93
                Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
92
            Object s = main.getField("start").get(null);
94
                Object s = main.getField("start").get(null);
93
            assertNotNull("Bundle started, its context provided", s);
95
                assertNotNull("Bundle started, its context provided", s);
94
96
95
            assertTrue("Shutdown OK", mgr.shutDown());
97
                assertTrue("Shutdown OK", mgr.shutDown());
96
98
97
            Object e = main.getField("stop").get(null);
99
                Object e = main.getField("stop").get(null);
98
            assertNotNull("Bundle stopped, its context provided", e);
100
                assertNotNull("Bundle stopped, its context provided", e);
99
        } finally {
101
                return null;
100
            mgr.mutexPrivileged().exitWriteAccess();
102
            }
101
        }
103
        });
102
    }
104
    }
103
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
105
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
104
        return createTestJAR(data, jars, name, srcdir, classpath);
106
        return createTestJAR(data, jars, name, srcdir, classpath);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoActivationTest.java (-14 / +16 lines)
Lines 51-56 Link Here
51
import org.netbeans.Module;
51
import org.netbeans.Module;
52
import org.netbeans.ModuleManager;
52
import org.netbeans.ModuleManager;
53
import org.netbeans.SetupHid;
53
import org.netbeans.SetupHid;
54
import org.openide.util.Mutex.ExceptionAction;
54
55
55
/**
56
/**
56
 * Do we correctly call the BundleActivators?
57
 * Do we correctly call the BundleActivators?
Lines 82-104 Link Here
82
    public void testActivation() throws Exception {
83
    public void testActivation() throws Exception {
83
        ModuleSystem ms = Main.getModuleSystem();
84
        ModuleSystem ms = Main.getModuleSystem();
84
        mgr = ms.getManager();
85
        mgr = ms.getManager();
85
        mgr.mutexPrivileged().enterWriteAccess();
86
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
86
        try {
87
            @Override
87
            File simpleModule = new File(jars, "activate.jar");
88
            public Void run() throws Exception {
88
            m1 = mgr.create(simpleModule, null, false, false, false);
89
                File simpleModule = new File(jars, "activate.jar");
89
            mgr.enable(m1);
90
                m1 = mgr.create(simpleModule, null, false, false, false);
91
                mgr.enable(m1);
90
92
91
            Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
93
                Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
92
            Object s = main.getField("start").get(null);
94
                Object s = main.getField("start").get(null);
93
            assertNotNull("Bundle started, its context provided", s);
95
                assertNotNull("Bundle started, its context provided", s);
94
96
95
            mgr.disable(m1);
97
                mgr.disable(m1);
96
98
97
            Object e = main.getField("stop").get(null);
99
                Object e = main.getField("stop").get(null);
98
            assertNotNull("Bundle stopped, its context provided", e);
100
                assertNotNull("Bundle stopped, its context provided", e);
99
        } finally {
101
                return null;
100
            mgr.mutexPrivileged().exitWriteAccess();
102
            }
101
        }
103
        });
102
    }
104
    }
103
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
105
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
104
        return createTestJAR(data, jars, name, srcdir, classpath);
106
        return createTestJAR(data, jars, name, srcdir, classpath);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoLayerTest.java (-24 / +26 lines)
Lines 63-68 Link Here
63
import org.netbeans.SetupHid;
63
import org.netbeans.SetupHid;
64
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
65
import org.openide.filesystems.FileUtil;
65
import org.openide.filesystems.FileUtil;
66
import org.openide.util.Mutex.ExceptionAction;
66
67
67
/**
68
/**
68
 * How does OSGi integration deals with layer registration?
69
 * How does OSGi integration deals with layer registration?
Lines 97-110 Link Here
97
98
98
            ModuleSystem ms = Main.getModuleSystem();
99
            ModuleSystem ms = Main.getModuleSystem();
99
            mgr = ms.getManager();
100
            mgr = ms.getManager();
100
            mgr.mutexPrivileged().enterWriteAccess();
101
            mgr.mutex().writeAccess(new ExceptionAction<Void>() {
101
            try {
102
                @Override
102
                File j1 = new File(jars, "simple-module.jar");
103
                public Void run() throws Exception {
103
                m1 = mgr.create(j1, null, false, false, false);
104
                    File j1 = new File(jars, "simple-module.jar");
104
                mgr.enable(Collections.<Module>singleton(m1));
105
                    m1 = mgr.create(j1, null, false, false, false);
105
            } finally {
106
                    mgr.enable(Collections.<Module>singleton(m1));
106
                mgr.mutexPrivileged().exitWriteAccess();
107
                    return null;
107
            }
108
                }
109
            });
108
        }
110
        }
109
111
110
    }
112
    }
Lines 112-134 Link Here
112
        return createTestJAR(data, jars, name, srcdir, classpath);
114
        return createTestJAR(data, jars, name, srcdir, classpath);
113
    }
115
    }
114
    public void testOSGiCanProvideLayer() throws Exception {
116
    public void testOSGiCanProvideLayer() throws Exception {
115
        mgr.mutexPrivileged().enterWriteAccess();
117
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
116
        FileObject fo;
118
            @Override
117
        try {
119
            public Void run() throws Exception {
118
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
120
                    String mfBar = "Bundle-SymbolicName: org.bar\n" +
119
                "Bundle-Version: 1.1.0\n" +
121
                        "Bundle-Version: 1.1.0\n" +
120
                "Bundle-ManifestVersion: 2\n" +
122
                        "Bundle-ManifestVersion: 2\n" +
121
                "Import-Package: org.foo\n" +
123
                        "Import-Package: org.foo\n" +
122
                "OpenIDE-Module-Layer: org/bar/layer.xml\n" +
124
                        "OpenIDE-Module-Layer: org/bar/layer.xml\n" +
123
                "\n\n";
125
                        "\n\n";
124
126
125
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
127
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
126
            Module m2 = mgr.create(j2, null, false, false, false);
128
                    Module m2 = mgr.create(j2, null, false, false, false);
127
            mgr.enable(m2);
129
                    mgr.enable(m2);
128
        } finally {
130
                return null;
129
            mgr.mutexPrivileged().exitWriteAccess();
131
            }
130
        }
132
        });
131
        fo = FileUtil.getConfigFile("TestFolder");
133
        FileObject fo = FileUtil.getConfigFile("TestFolder");
132
        assertNotNull("Folder found", fo);
134
        assertNotNull("Folder found", fo);
133
135
134
        URL u = mgr.getClassLoader().getResource("org/bar/layer.xml");
136
        URL u = mgr.getClassLoader().getResource("org/bar/layer.xml");
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoMetaInfServicesTest.java (-19 / +21 lines)
Lines 53-58 Link Here
53
import org.netbeans.ModuleManager;
53
import org.netbeans.ModuleManager;
54
import org.netbeans.SetupHid;
54
import org.netbeans.SetupHid;
55
import org.openide.util.Lookup;
55
import org.openide.util.Lookup;
56
import org.openide.util.Mutex.ExceptionAction;
56
57
57
/**
58
/**
58
 * Do we correctly handle META-INF/services in bundles?
59
 * Do we correctly handle META-INF/services in bundles?
Lines 84-111 Link Here
84
    public void testActivation() throws Exception {
85
    public void testActivation() throws Exception {
85
        ModuleSystem ms = Main.getModuleSystem();
86
        ModuleSystem ms = Main.getModuleSystem();
86
        mgr = ms.getManager();
87
        mgr = ms.getManager();
87
        mgr.mutexPrivileged().enterWriteAccess();
88
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
88
        try {
89
            @Override
89
            Callable<?> fr = Lookup.getDefault().lookup(Callable.class);
90
            public Void run() throws Exception {
90
            assertNull("No registration found yet", fr);
91
                Callable<?> fr = Lookup.getDefault().lookup(Callable.class);
92
                assertNull("No registration found yet", fr);
91
93
92
            
93
            File simpleModule = new File(jars, "activate.jar");
94
            m1 = mgr.create(simpleModule, null, false, false, false);
95
            mgr.enable(m1);
96
94
97
            Callable<?> registration = Lookup.getDefault().lookup(Callable.class);
95
                File simpleModule = new File(jars, "activate.jar");
98
            assertNotNull("Registration of Callable found", registration);
96
                m1 = mgr.create(simpleModule, null, false, false, false);
99
            Object s = registration.call();
97
                mgr.enable(m1);
100
            assertNotNull("Bundle started, its context provided", s);
101
98
102
            mgr.disable(m1);
99
                Callable<?> registration = Lookup.getDefault().lookup(Callable.class);
103
            
100
                assertNotNull("Registration of Callable found", registration);
104
            Callable<?> nr = Lookup.getDefault().lookup(Callable.class);
101
                Object s = registration.call();
105
            assertNull("No registration found anymore", nr);
102
                assertNotNull("Bundle started, its context provided", s);
106
        } finally {
103
107
            mgr.mutexPrivileged().exitWriteAccess();
104
                mgr.disable(m1);
108
        }
105
106
                Callable<?> nr = Lookup.getDefault().lookup(Callable.class);
107
                assertNull("No registration found anymore", nr);
108
                return null;
109
            }
110
        });
109
    }
111
    }
110
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
112
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
111
        return createTestJAR(data, jars, name, srcdir, classpath);
113
        return createTestJAR(data, jars, name, srcdir, classpath);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiActivationVisibleTest.java (-16 / +18 lines)
Lines 56-61 Link Here
56
import org.netbeans.ModuleManager;
56
import org.netbeans.ModuleManager;
57
import org.netbeans.SetupHid;
57
import org.netbeans.SetupHid;
58
import org.netbeans.Util;
58
import org.netbeans.Util;
59
import org.openide.util.Mutex.ExceptionAction;
59
import org.osgi.framework.Bundle;
60
import org.osgi.framework.Bundle;
60
import org.osgi.framework.BundleContext;
61
import org.osgi.framework.BundleContext;
61
62
Lines 72-80 Link Here
72
    private static File simpleBundle;
73
    private static File simpleBundle;
73
    private static File activate;
74
    private static File activate;
74
    private static Bundle toEnable;
75
    private static Bundle toEnable;
75
    private static Class directBundle;
76
    private static Class<?> directBundle;
76
    private static Class someModule;
77
    private static Class<?> someModule;
77
    private static Method loadClass;
78
    private static Method loadClass;
79
    BundleContext bc;
78
80
79
    public NetigsoOSGiActivationVisibleTest(String name) {
81
    public NetigsoOSGiActivationVisibleTest(String name) {
80
        super(name);
82
        super(name);
Lines 107-127 Link Here
107
        
109
        
108
        ModuleSystem ms = Main.getModuleSystem();
110
        ModuleSystem ms = Main.getModuleSystem();
109
        mgr = ms.getManager();
111
        mgr = ms.getManager();
110
        mgr.mutexPrivileged().enterWriteAccess();
112
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
111
        BundleContext bc;
113
            @Override
112
        try {
114
            public Void run() throws Exception {
113
            m1 = mgr.create(activate, null, false, false, false);
115
                m1 = mgr.create(activate, null, false, false, false);
114
            m2 = mgr.create(simpleBundle, null, false, autoload(), false);
116
                m2 = mgr.create(simpleBundle, null, false, autoload(), false);
115
            
116
            mgr.enable(m1);
117
117
118
            Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
118
                mgr.enable(m1);
119
            Object s = main.getField("start").get(null);
119
120
            assertNotNull("Bundle started, its context provided", s);
120
                Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
121
            bc = (BundleContext) s;
121
                Object s = main.getField("start").get(null);
122
        } finally {
122
                assertNotNull("Bundle started, its context provided", s);
123
            mgr.mutexPrivileged().exitWriteAccess();
123
                bc = (BundleContext) s;
124
        }
124
                return null;
125
            }
126
        });
125
        toEnable = null;
127
        toEnable = null;
126
        for (Bundle b : bc.getBundles()) {
128
        for (Bundle b : bc.getBundles()) {
127
            if (b.getSymbolicName().equals("org.snd.module")) {
129
            if (b.getSymbolicName().equals("org.snd.module")) {
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiCanDependTest.java (-25 / +30 lines)
Lines 49-54 Link Here
49
import org.netbeans.MockModuleInstaller;
49
import org.netbeans.MockModuleInstaller;
50
import org.netbeans.Module;
50
import org.netbeans.Module;
51
import org.netbeans.ModuleManager;
51
import org.netbeans.ModuleManager;
52
import org.openide.util.Mutex.ExceptionAction;
52
53
53
/**
54
/**
54
 *
55
 *
Lines 62-96 Link Here
62
    public void testOSGiCanDependOnNetBeans() throws Exception {
63
    public void testOSGiCanDependOnNetBeans() throws Exception {
63
        MockModuleInstaller installer = new MockModuleInstaller();
64
        MockModuleInstaller installer = new MockModuleInstaller();
64
        MockEvents ev = new MockEvents();
65
        MockEvents ev = new MockEvents();
65
        ModuleManager mgr = new ModuleManager(installer, ev);
66
        final ModuleManager mgr = new ModuleManager(installer, ev);
66
        mgr.mutexPrivileged().enterWriteAccess();
67
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
67
        HashSet<Module> both = null;
68
            @Override
68
        try {
69
            public Void run() throws Exception {
69
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
70
                HashSet<Module> both = null;
70
                "Bundle-Version: 1.1.0\n" +
71
                try {
71
                "Bundle-ManifestVersion: 2\n" +
72
                    String mfBar = "Bundle-SymbolicName: org.bar\n" +
72
                "Export-Package: org.bar\n" +
73
                        "Bundle-Version: 1.1.0\n" +
73
                "Import-Package: org.foo\n" +
74
                        "Bundle-ManifestVersion: 2\n" +
74
                "\n\n";
75
                        "Export-Package: org.bar\n" +
76
                        "Import-Package: org.foo\n" +
77
                        "\n\n";
75
78
76
            File j1 = new File(jars, "simple-module.jar");
79
                    File j1 = new File(jars, "simple-module.jar");
77
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
80
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
78
            Module m1 = mgr.create(j1, null, false, false, false);
81
                    Module m1 = mgr.create(j1, null, false, false, false);
79
            Module m2 = mgr.create(j2, null, false, false, false);
82
                    Module m2 = mgr.create(j2, null, false, false, false);
80
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
83
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
81
            mgr.enable(b);
84
                    mgr.enable(b);
82
            both = b;
85
                    both = b;
83
86
84
            Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
87
                    Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
85
            Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
88
                    Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
86
89
87
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
90
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
88
        } finally {
91
                } finally {
89
            if (both != null) {
92
                    if (both != null) {
90
                mgr.disable(both);
93
                        mgr.disable(both);
94
                    }
95
                }
96
                return null;
91
            }
97
            }
92
            mgr.mutexPrivileged().exitWriteAccess();
98
        });
93
        }
94
    }
99
    }
95
100
96
}
101
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiCanRequestNoMajorTest.java (-29 / +33 lines)
Lines 62-101 Link Here
62
    public void testOSGiCanRequireBundleOnNetBeans() throws Exception {
62
    public void testOSGiCanRequireBundleOnNetBeans() throws Exception {
63
        MockModuleInstaller installer = new MockModuleInstaller();
63
        MockModuleInstaller installer = new MockModuleInstaller();
64
        MockEvents ev = new MockEvents();
64
        MockEvents ev = new MockEvents();
65
        ModuleManager mgr = new ModuleManager(installer, ev);
65
        final ModuleManager mgr = new ModuleManager(installer, ev);
66
        mgr.mutexPrivileged().enterWriteAccess();
66
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
67
        HashSet<Module> both = null;
67
            @Override
68
        try {
68
            public Void run() throws Exception {
69
            String mfModule = "Manifest-Version: 1.0\n" +
69
                HashSet<Module> both = null;
70
                    "OpenIDE-Module: org.foo\n" +
70
                try {
71
                    "OpenIDE-Module-Name: Foo test module\n" +
71
                    String mfModule = "Manifest-Version: 1.0\n" +
72
                    "OpenIDE-Module-Specification-Version: 1.2\n\n\n";
72
                            "OpenIDE-Module: org.foo\n" +
73
                            "OpenIDE-Module-Name: Foo test module\n" +
74
                            "OpenIDE-Module-Specification-Version: 1.2\n\n\n";
73
75
74
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
76
                    String mfBar = "Bundle-SymbolicName: org.bar\n" +
75
                "Bundle-Version: 1.1.0\n" +
77
                        "Bundle-Version: 1.1.0\n" +
76
                "Bundle-ManifestVersion: 2\n" +
78
                        "Bundle-ManifestVersion: 2\n" +
77
                "Export-Package: org.bar\n" +
79
                        "Export-Package: org.bar\n" +
78
                "Require-Bundle: org.foo;bundle-version=\"[1.0,2.0)\"\n" +
80
                        "Require-Bundle: org.foo;bundle-version=\"[1.0,2.0)\"\n" +
79
                "\n\n";
81
                        "\n\n";
80
82
81
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mfModule);
83
                    File j1 = changeManifest(new File(jars, "simple-module.jar"), mfModule);
82
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
84
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
83
            Module m1 = mgr.create(j1, null, false, false, false);
85
                    Module m1 = mgr.create(j1, null, false, false, false);
84
            Module m2 = mgr.create(j2, null, false, false, false);
86
                    Module m2 = mgr.create(j2, null, false, false, false);
85
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
87
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
86
            mgr.enable(b);
88
                    mgr.enable(b);
87
            both = b;
89
                    both = b;
88
90
89
            Class<?> sprclass = m1.getClassLoader().loadClass("org.foo.Something");
91
                    Class<?> sprclass = m1.getClassLoader().loadClass("org.foo.Something");
90
            Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
92
                    Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
91
93
92
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
94
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
93
        } finally {
95
                } finally {
94
            if (both != null) {
96
                    if (both != null) {
95
                mgr.disable(both);
97
                        mgr.disable(both);
98
                    }
99
                }
100
                return null;
96
            }
101
            }
97
            mgr.mutexPrivileged().exitWriteAccess();
102
        });
98
        }
99
    }
103
    }
100
104
101
}
105
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiCanRequestTest.java (-25 / +30 lines)
Lines 63-97 Link Here
63
    public void testOSGiCanRequireBundleOnNetBeans() throws Exception {
63
    public void testOSGiCanRequireBundleOnNetBeans() throws Exception {
64
        MockModuleInstaller installer = new MockModuleInstaller();
64
        MockModuleInstaller installer = new MockModuleInstaller();
65
        MockEvents ev = new MockEvents();
65
        MockEvents ev = new MockEvents();
66
        ModuleManager mgr = new ModuleManager(installer, ev);
66
        final ModuleManager mgr = new ModuleManager(installer, ev);
67
        mgr.mutexPrivileged().enterWriteAccess();
67
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
68
        HashSet<Module> both = null;
69
        try {
70
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
71
                "Bundle-Version: 1.1.0\n" +
72
                "Bundle-ManifestVersion: 2\n" +
73
                "Export-Package: org.bar\n" +
74
                "Require-Bundle: org.foo;bundle-version=\"[100.0,102.0)\"\n" +
75
                "\n\n";
76
68
77
            File j1 = new File(jars, "simple-module.jar");
69
            @Override
78
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
70
            public Void run() throws Exception {
79
            Module m1 = mgr.create(j1, null, false, false, false);
71
                HashSet<Module> both = null;
80
            Module m2 = mgr.create(j2, null, false, false, false);
72
                try {
81
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
73
                    String mfBar = "Bundle-SymbolicName: org.bar\n" +
82
            mgr.enable(b);
74
                        "Bundle-Version: 1.1.0\n" +
83
            both = b;
75
                        "Bundle-ManifestVersion: 2\n" +
76
                        "Export-Package: org.bar\n" +
77
                        "Require-Bundle: org.foo;bundle-version=\"[100.0,102.0)\"\n" +
78
                        "\n\n";
84
79
85
            Class<?> sprclass = m1.getClassLoader().loadClass("org.foo.Something");
80
                    File j1 = new File(jars, "simple-module.jar");
86
            Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
81
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
82
                    Module m1 = mgr.create(j1, null, false, false, false);
83
                    Module m2 = mgr.create(j2, null, false, false, false);
84
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
85
                    mgr.enable(b);
86
                    both = b;
87
87
88
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
88
                    Class<?> sprclass = m1.getClassLoader().loadClass("org.foo.Something");
89
        } finally {
89
                    Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
90
            if (both != null) {
90
91
                mgr.disable(both);
91
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
92
                } finally {
93
                    if (both != null) {
94
                        mgr.disable(both);
95
                    }
96
                }
97
                return null;
92
            }
98
            }
93
            mgr.mutexPrivileged().exitWriteAccess();
99
        });
94
        }
95
    }
100
    }
96
101
97
}
102
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoOSGiFragmentTest.java (-36 / +41 lines)
Lines 63-109 Link Here
63
    public void testOSGiFragmentDependency() throws Exception {
63
    public void testOSGiFragmentDependency() throws Exception {
64
        MockModuleInstaller installer = new MockModuleInstaller();
64
        MockModuleInstaller installer = new MockModuleInstaller();
65
        MockEvents ev = new MockEvents();
65
        MockEvents ev = new MockEvents();
66
        ModuleManager mgr = new ModuleManager(installer, ev);
66
        final ModuleManager mgr = new ModuleManager(installer, ev);
67
        mgr.mutexPrivileged().enterWriteAccess();
67
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
68
        HashSet<Module> toCleanUp = null;
69
        try {
70
            String mfFoo = ""
71
                    + "Bundle-SymbolicName: org.foo\n" +
72
                "Bundle-Version: 1.1.0\n" +
73
                "Bundle-ManifestVersion: 2\n" +
74
                "Export-Package: org.foo,org.bar\n" +
75
                "\n\n";
76
            
77
            String mfBar = "Fragment-Host: org.foo\n"
78
                + "Bundle-SymbolicName: org.bar\n" +
79
                "Bundle-Version: 1.1.0\n" +
80
                "Bundle-ManifestVersion: 2\n" +
81
                "\n\n";
82
68
83
            String mfDependency = "OpenIDE-Module: org.test\n"
69
            @Override
84
                    + "OpenIDE-Module-Module-Dependencies: org.bar, org.foo\n" +
70
            public Void run() throws Exception {
85
                "\n\n";
71
                HashSet<Module> toCleanUp = null;
72
                try {
73
                    String mfFoo = ""
74
                            + "Bundle-SymbolicName: org.foo\n" +
75
                        "Bundle-Version: 1.1.0\n" +
76
                        "Bundle-ManifestVersion: 2\n" +
77
                        "Export-Package: org.foo,org.bar\n" +
78
                        "\n\n";
86
79
87
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mfFoo);
80
                    String mfBar = "Fragment-Host: org.foo\n"
88
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
81
                        + "Bundle-SymbolicName: org.bar\n" +
89
            File j3 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfDependency);
82
                        "Bundle-Version: 1.1.0\n" +
90
            Module m1 = mgr.create(j1, null, false, true, false);
83
                        "Bundle-ManifestVersion: 2\n" +
91
            Module m2 = mgr.create(j2, null, false, true, false);
84
                        "\n\n";
92
            Module m3 = mgr.create(j3, null, false, false, false);
93
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m3));
94
            mgr.enable(m3);
95
            toCleanUp = b;
96
85
97
            Class<?> sprclass = m3.getClassLoader().loadClass("org.foo.Something");
86
                    String mfDependency = "OpenIDE-Module: org.test\n"
98
            Class<?> clazz = m3.getClassLoader().loadClass("org.bar.SomethingElse");
87
                            + "OpenIDE-Module-Module-Dependencies: org.bar, org.foo\n" +
88
                        "\n\n";
99
89
100
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
90
                    File j1 = changeManifest(new File(jars, "simple-module.jar"), mfFoo);
101
        } finally {
91
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
102
            if (toCleanUp != null) {
92
                    File j3 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfDependency);
103
                mgr.disable(toCleanUp);
93
                    Module m1 = mgr.create(j1, null, false, true, false);
94
                    Module m2 = mgr.create(j2, null, false, true, false);
95
                    Module m3 = mgr.create(j3, null, false, false, false);
96
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m3));
97
                    mgr.enable(m3);
98
                    toCleanUp = b;
99
100
                    Class<?> sprclass = m3.getClassLoader().loadClass("org.foo.Something");
101
                    Class<?> clazz = m3.getClassLoader().loadClass("org.bar.SomethingElse");
102
103
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
104
                } finally {
105
                    if (toCleanUp != null) {
106
                        mgr.disable(toCleanUp);
107
                    }
108
                }
109
                return null;
104
            }
110
            }
105
            mgr.mutexPrivileged().exitWriteAccess();
111
        });
106
        }
107
    }
112
    }
108
113
109
}
114
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoReloadTest.java (-16 / +18 lines)
Lines 81-111 Link Here
81
    public void testCanReloadAModule() throws Exception {
81
    public void testCanReloadAModule() throws Exception {
82
        ModuleSystem ms = Main.getModuleSystem();
82
        ModuleSystem ms = Main.getModuleSystem();
83
        mgr = ms.getManager();
83
        mgr = ms.getManager();
84
        mgr.mutexPrivileged().enterWriteAccess();
84
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
85
        try {
86
            m1 = mgr.create(withoutA, null, false, false, false);
87
            mgr.enable(m1);
88
85
89
        } finally {
86
            @Override
90
            mgr.mutexPrivileged().exitWriteAccess();
87
            public Void run() throws Exception {
91
        }
88
                m1 = mgr.create(withoutA, null, false, false, false);
89
                mgr.enable(m1);
90
                return null;
91
            }
92
        });
92
93
93
        assertTrue("Delete is OK", withoutA.delete());
94
        assertTrue("Delete is OK", withoutA.delete());
94
        assertTrue("Rename is OK", withActivator.renameTo(withoutA));
95
        assertTrue("Rename is OK", withActivator.renameTo(withoutA));
95
96
96
        TestModuleDeployer.deployTestModule(withoutA);
97
        TestModuleDeployer.deployTestModule(withoutA);
97
        Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
98
        final Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
98
        Object s = main.getField("start").get(null);
99
        Object s = main.getField("start").get(null);
99
        assertNotNull("Bundle started, its context provided", s);
100
        assertNotNull("Bundle started, its context provided", s);
100
101
101
        mgr.mutexPrivileged().enterWriteAccess();
102
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
102
        try {
103
            @Override
103
            mgr.disable(m1);
104
            public Void run() throws Exception {
104
            Object e = main.getField("stop").get(null);
105
                mgr.disable(m1);
105
            assertNotNull("Bundle stopped, its context provided", e);
106
                Object e = main.getField("stop").get(null);
106
        } finally {
107
                assertNotNull("Bundle stopped, its context provided", e);
107
            mgr.mutexPrivileged().exitWriteAccess();
108
                return null;
108
        }
109
            }
110
        });
109
    }
111
    }
110
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
112
    private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
111
        return createTestJAR(data, jars, name, srcdir, classpath);
113
        return createTestJAR(data, jars, name, srcdir, classpath);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoServicesTest.java (-22 / +24 lines)
Lines 105-118 Link Here
105
105
106
            ModuleSystem ms = Main.getModuleSystem();
106
            ModuleSystem ms = Main.getModuleSystem();
107
            mgr = ms.getManager();
107
            mgr = ms.getManager();
108
            mgr.mutexPrivileged().enterWriteAccess();
108
            mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
109
            try {
109
110
                File j1 = new File(jars, "simple-module.jar");
110
                @Override
111
                m1 = mgr.create(j1, null, false, false, false);
111
                public Void run() throws Exception {
112
                mgr.enable(Collections.<Module>singleton(m1));
112
                    File j1 = new File(jars, "simple-module.jar");
113
            } finally {
113
                    m1 = mgr.create(j1, null, false, false, false);
114
                mgr.mutexPrivileged().exitWriteAccess();
114
                    mgr.enable(Collections.<Module>singleton(m1));
115
            }
115
                    return null;
116
                }
117
            });
116
        }
118
        }
117
119
118
    }
120
    }
Lines 120-140 Link Here
120
        return createTestJAR(data, jars, name, srcdir, classpath);
122
        return createTestJAR(data, jars, name, srcdir, classpath);
121
    }
123
    }
122
    public void testOSGiServicesVisibleInLookup() throws Exception {
124
    public void testOSGiServicesVisibleInLookup() throws Exception {
123
        mgr.mutexPrivileged().enterWriteAccess();
125
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
124
        FileObject fo;
126
            @Override
125
        try {
127
            public Void run() throws Exception {
126
            String mfBar = "Bundle-SymbolicName: org.bar\n" +
128
                String mfBar = "Bundle-SymbolicName: org.bar\n" +
127
                "Bundle-Version: 1.1.0\n" +
129
                    "Bundle-Version: 1.1.0\n" +
128
                "Bundle-ManifestVersion: 2\n" +
130
                    "Bundle-ManifestVersion: 2\n" +
129
                "Import-Package: org.foo\n" +
131
                    "Import-Package: org.foo\n" +
130
                "\n\n";
132
                    "\n\n";
131
133
132
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
134
                File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
133
            Module m2 = mgr.create(j2, null, false, false, false);
135
                Module m2 = mgr.create(j2, null, false, false, false);
134
            mgr.enable(m2);
136
                mgr.enable(m2);
135
        } finally {
137
                return null;
136
            mgr.mutexPrivileged().exitWriteAccess();
138
            }
137
        }
139
        });
138
140
139
        Bundle b = findBundle("org.bar");
141
        Bundle b = findBundle("org.bar");
140
        assertNotNull("Bundle really found", b);
142
        assertNotNull("Bundle really found", b);
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoTest.java (-126 / +147 lines)
Lines 67-239 Link Here
67
    public void testFactoryCreatesOurModules() throws Exception {
67
    public void testFactoryCreatesOurModules() throws Exception {
68
        MockModuleInstaller installer = new MockModuleInstaller();
68
        MockModuleInstaller installer = new MockModuleInstaller();
69
        MockEvents ev = new MockEvents();
69
        MockEvents ev = new MockEvents();
70
        ModuleManager mgr = new ModuleManager(installer, ev);
70
        final ModuleManager mgr = new ModuleManager(installer, ev);
71
        mgr.mutexPrivileged().enterWriteAccess();
71
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
72
        Module m2;
72
            @Override
73
        Module m1;
73
            public Void run() throws Exception {
74
        HashSet<Module> both = null;
74
                Module m2;
75
        try {
75
                Module m1;
76
            String mf = "Bundle-SymbolicName: org.foo;singleton:=true\n" +
76
                HashSet<Module> both = null;
77
                "Bundle-Version: 1.1.0\n" +
77
                try {
78
                "Bundle-ManifestVersion: 2\n" +
78
                    String mf = "Bundle-SymbolicName: org.foo;singleton:=true\n" +
79
                "Export-Package: org.foo";
79
                        "Bundle-Version: 1.1.0\n" +
80
            String mfBar =
80
                        "Bundle-ManifestVersion: 2\n" +
81
                "OpenIDE-Module: org.bar/1\n" +
81
                        "Export-Package: org.foo";
82
                "OpenIDE-Module-Name: Depends on bar test module\n" +
82
                    String mfBar =
83
                "OpenIDE-Module-Module-Dependencies: org.foo\n" +
83
                        "OpenIDE-Module: org.bar/1\n" +
84
                "some";
84
                        "OpenIDE-Module-Name: Depends on bar test module\n" +
85
                        "OpenIDE-Module-Module-Dependencies: org.foo\n" +
86
                        "some";
85
87
86
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mf);
88
                    File j1 = changeManifest(new File(jars, "simple-module.jar"), mf);
87
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
89
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
88
            m1 = mgr.create(j1, null, false, false, false);
90
                    m1 = mgr.create(j1, null, false, false, false);
89
            m2 = mgr.create(j2, null, false, false, false);
91
                    m2 = mgr.create(j2, null, false, false, false);
90
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
92
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
91
            mgr.enable(b);
93
                    mgr.enable(b);
92
            both = b;
94
                    both = b;
93
95
94
            
95
            Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
96
            Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
97
96
98
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
97
                    Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
98
                    Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
99
99
100
        } finally {
100
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
101
            if (both != null) {
101
102
                mgr.disable(both);
102
                } finally {
103
                    if (both != null) {
104
                        mgr.disable(both);
105
                    }
106
                }
107
                return null;
103
            }
108
            }
104
            mgr.mutexPrivileged().exitWriteAccess();
109
        });
105
        }
106
110
107
    }
111
    }
108
112
109
    public void testDashnames() throws Exception {
113
    public void testDashnames() throws Exception {
110
        MockModuleInstaller installer = new MockModuleInstaller();
114
        MockModuleInstaller installer = new MockModuleInstaller();
111
        MockEvents ev = new MockEvents();
115
        MockEvents ev = new MockEvents();
112
        ModuleManager mgr = new ModuleManager(installer, ev);
116
        final ModuleManager mgr = new ModuleManager(installer, ev);
113
        mgr.mutexPrivileged().enterWriteAccess();
117
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
114
        Module m2;
118
            @Override
115
        Module m1;
119
            public Void run() throws Exception {
116
        HashSet<Module> both = null;
120
                Module m2;
117
        try {
121
                Module m1;
118
            String mf = "Bundle-SymbolicName: org.foo-bar\n" +
122
                HashSet<Module> both = null;
119
                "Bundle-Version: 1.1.0\n" +
123
                try {
120
                "Bundle-ManifestVersion: 2\n" +
124
                    String mf = "Bundle-SymbolicName: org.foo-bar\n" +
121
                "Export-Package: org.foo";
125
                        "Bundle-Version: 1.1.0\n" +
122
            String mfBar =
126
                        "Bundle-ManifestVersion: 2\n" +
123
                "OpenIDE-Module: org.bar/1\n" +
127
                        "Export-Package: org.foo";
124
                "OpenIDE-Module-Name: Depends on bar test module\n" +
128
                    String mfBar =
125
                "OpenIDE-Module-Module-Dependencies: org.foo_bar\n" +
129
                        "OpenIDE-Module: org.bar/1\n" +
126
                "some";
130
                        "OpenIDE-Module-Name: Depends on bar test module\n" +
131
                        "OpenIDE-Module-Module-Dependencies: org.foo_bar\n" +
132
                        "some";
127
133
128
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mf);
134
                    File j1 = changeManifest(new File(jars, "simple-module.jar"), mf);
129
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
135
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
130
            m1 = mgr.create(j1, null, false, false, false);
136
                    m1 = mgr.create(j1, null, false, false, false);
131
            m2 = mgr.create(j2, null, false, false, false);
137
                    m2 = mgr.create(j2, null, false, false, false);
132
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
138
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
133
            mgr.enable(b);
139
                    mgr.enable(b);
134
            both = b;
140
                    both = b;
135
141
136
142
137
            Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
143
                    Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
138
            Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
144
                    Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
139
145
140
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
146
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
141
147
142
        } finally {
148
                } finally {
143
            if (both != null) {
149
                    if (both != null) {
144
                mgr.disable(both);
150
                        mgr.disable(both);
151
                    }
152
                }
153
                return null;
145
            }
154
            }
146
            mgr.mutexPrivileged().exitWriteAccess();
155
        });
147
        }
148
156
149
    }
157
    }
150
158
151
    public void testFactoryCreatesOurModulesWithDeps() throws Exception {
159
    public void testFactoryCreatesOurModulesWithDeps() throws Exception {
152
        MockModuleInstaller installer = new MockModuleInstaller();
160
        MockModuleInstaller installer = new MockModuleInstaller();
153
        MockEvents ev = new MockEvents();
161
        MockEvents ev = new MockEvents();
154
        ModuleManager mgr = new ModuleManager(installer, ev);
162
        final ModuleManager mgr = new ModuleManager(installer, ev);
155
        mgr.mutexPrivileged().enterWriteAccess();
163
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
156
        HashSet<Module> both = null;
164
            @Override
157
        try {
165
            public Void run() throws Exception {
158
            String mf = "Bundle-SymbolicName: org.foo\n" +
166
                HashSet<Module> both = null;
159
                "Bundle-Version: 1.1.0\n" +
167
                try {
160
                "Bundle-ManifestVersion: 2\n" +
168
                    String mf = "Bundle-SymbolicName: org.foo\n" +
161
                "Export-Package: org.foo";
169
                        "Bundle-Version: 1.1.0\n" +
162
            String mfBar =
170
                        "Bundle-ManifestVersion: 2\n" +
163
                "OpenIDE-Module: org.bar/1\n" +
171
                        "Export-Package: org.foo";
164
                "OpenIDE-Module-Name: Depends on bar test module\n" +
172
                    String mfBar =
165
                "OpenIDE-Module-Module-Dependencies: org.foo > 1.0\n" +
173
                        "OpenIDE-Module: org.bar/1\n" +
166
                "some";
174
                        "OpenIDE-Module-Name: Depends on bar test module\n" +
175
                        "OpenIDE-Module-Module-Dependencies: org.foo > 1.0\n" +
176
                        "some";
167
177
168
            File j1 = changeManifest(new File(jars, "simple-module.jar"), mf);
178
                    File j1 = changeManifest(new File(jars, "simple-module.jar"), mf);
169
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
179
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
170
            Module m1 = mgr.create(j1, null, false, false, false);
180
                    Module m1 = mgr.create(j1, null, false, false, false);
171
            Module m2 = mgr.create(j2, null, false, false, false);
181
                    Module m2 = mgr.create(j2, null, false, false, false);
172
            HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
182
                    HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
173
            mgr.enable(b);
183
                    mgr.enable(b);
174
            both = b;
184
                    both = b;
175
185
176
            Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
186
                    Class<?> clazz = m2.getClassLoader().loadClass("org.bar.SomethingElse");
177
            Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
187
                    Class<?> sprclass = m2.getClassLoader().loadClass("org.foo.Something");
178
188
179
            assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
189
                    assertEquals("Correct parent is used", sprclass, clazz.getSuperclass());
180
        } finally {
190
                } finally {
181
            if (both != null) {
191
                    if (both != null) {
182
                mgr.disable(both);
192
                        mgr.disable(both);
193
                    }
194
                }
195
                return null;
183
            }
196
            }
184
            mgr.mutexPrivileged().exitWriteAccess();
197
        });
185
        }
186
    }
198
    }
187
199
188
200
189
    public void testLongDepsAreShortened() throws Exception {
201
    public void testLongDepsAreShortened() throws Exception {
190
        MockModuleInstaller installer = new MockModuleInstaller();
202
        MockModuleInstaller installer = new MockModuleInstaller();
191
        MockEvents ev = new MockEvents();
203
        MockEvents ev = new MockEvents();
192
        ModuleManager mgr = new ModuleManager(installer, ev);
204
        final ModuleManager mgr = new ModuleManager(installer, ev);
193
        mgr.mutexPrivileged().enterWriteAccess();
205
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
194
        Module m2 = null;
195
        try {
196
            String mfBar =
197
                "OpenIDE-Module: org.bar/1\n" +
198
                "OpenIDE-Module-Specification-Version: 2.3.0.42.2\n" +
199
                "OpenIDE-Module-Name: Too many dots in version\n" +
200
                "OpenIDE-Module-Public-Packages: org.bar.*\n" +
201
                "some";
202
206
203
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
207
            @Override
204
            m2 = mgr.create(j2, null, false, false, false);
208
            public Void run() throws Exception {
205
            mgr.enable(m2);
209
                Module m2 = null;
206
        } finally {
210
                try {
207
            if (m2 != null) {
211
                    String mfBar =
208
                mgr.disable(m2);
212
                        "OpenIDE-Module: org.bar/1\n" +
213
                        "OpenIDE-Module-Specification-Version: 2.3.0.42.2\n" +
214
                        "OpenIDE-Module-Name: Too many dots in version\n" +
215
                        "OpenIDE-Module-Public-Packages: org.bar.*\n" +
216
                        "some";
217
218
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
219
                    m2 = mgr.create(j2, null, false, false, false);
220
                    mgr.enable(m2);
221
                } finally {
222
                    if (m2 != null) {
223
                        mgr.disable(m2);
224
                    }
225
                }
226
                return null;
209
            }
227
            }
210
            mgr.mutexPrivileged().exitWriteAccess();
228
        });
211
        }
212
    }
229
    }
213
230
214
    public void testNonNumericVersionNumberIsOK() throws Exception {
231
    public void testNonNumericVersionNumberIsOK() throws Exception {
215
        MockModuleInstaller installer = new MockModuleInstaller();
232
        MockModuleInstaller installer = new MockModuleInstaller();
216
        MockEvents ev = new MockEvents();
233
        MockEvents ev = new MockEvents();
217
        ModuleManager mgr = new ModuleManager(installer, ev);
234
        final ModuleManager mgr = new ModuleManager(installer, ev);
218
        mgr.mutexPrivileged().enterWriteAccess();
235
        mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
219
        Module m2 = null;
236
            @Override
220
        try {
237
            public Void run() throws Exception {
221
            String mfBar =
238
                Module m2 = null;
222
                "Bundle-SymbolicName: org.bar\n" +
239
                try {
223
                "Bundle-Version: 2.3.0.Prelude-rel24\n" +
240
                    String mfBar =
224
                "Export-Packages: org.bar.*\n" +
241
                        "Bundle-SymbolicName: org.bar\n" +
225
                "some";
242
                        "Bundle-Version: 2.3.0.Prelude-rel24\n" +
243
                        "Export-Packages: org.bar.*\n" +
244
                        "some";
226
245
227
            File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
246
                    File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
228
            m2 = mgr.create(j2, null, false, false, false);
247
                    m2 = mgr.create(j2, null, false, false, false);
229
            mgr.enable(m2);
248
                    mgr.enable(m2);
230
            assertEquals("2.3.0", m2.getSpecificationVersion().toString());
249
                    assertEquals("2.3.0", m2.getSpecificationVersion().toString());
231
            assertEquals("2.3.0.Prelude-rel24", m2.getImplementationVersion());
250
                    assertEquals("2.3.0.Prelude-rel24", m2.getImplementationVersion());
232
        } finally {
251
                } finally {
233
            if (m2 != null) {
252
                    if (m2 != null) {
234
                mgr.disable(m2);
253
                        mgr.disable(m2);
254
                    }
255
                }
256
                return null;
235
            }
257
            }
236
            mgr.mutexPrivileged().exitWriteAccess();
258
        });
237
        }
238
    }
259
    }
239
}
260
}
(-)a/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoUsesSwingTest.java (-10 / +11 lines)
Lines 88-103 Link Here
88
88
89
            ModuleSystem ms = Main.getModuleSystem();
89
            ModuleSystem ms = Main.getModuleSystem();
90
            mgr = ms.getManager();
90
            mgr = ms.getManager();
91
            mgr.mutexPrivileged().enterWriteAccess();
91
            mgr.mutex().writeAccess(new org.openide.util.Mutex.ExceptionAction<Void>() {
92
            try {
92
                @Override
93
                m1 = mgr.create(simpleModule, null, false, false, false);
93
                public Void run() throws Exception {
94
                mgr.enable(Collections.<Module>singleton(m1));
94
                    m1 = mgr.create(simpleModule, null, false, false, false);
95
                Class<?> c = m1.getClassLoader().loadClass("org.barwing.Main");
95
                    mgr.enable(Collections.<Module>singleton(m1));
96
                Runnable r = (Runnable)c.newInstance();
96
                    Class<?> c = m1.getClassLoader().loadClass("org.barwing.Main");
97
                r.run();
97
                    Runnable r = (Runnable)c.newInstance();
98
            } finally {
98
                    r.run();
99
                mgr.mutexPrivileged().exitWriteAccess();
99
                    return null;
100
            }
100
                }
101
            });
101
        }
102
        }
102
103
103
    }
104
    }
(-)a/core.startup/nbproject/project.xml (-1 / +1 lines)
Lines 55-61 Link Here
55
                    <compile-dependency/>
55
                    <compile-dependency/>
56
                    <run-dependency>
56
                    <run-dependency>
57
                        <release-version>1</release-version>
57
                        <release-version>1</release-version>
58
                        <specification-version>2.39</specification-version>
58
                        <specification-version>2.42</specification-version>
59
                    </run-dependency>
59
                    </run-dependency>
60
                </dependency>
60
                </dependency>
61
                <dependency>
61
                <dependency>
(-)a/core.startup/src/org/netbeans/core/startup/ConsistencyVerifier.java (-3 / +16 lines)
Lines 59-64 Link Here
59
import org.netbeans.Module;
59
import org.netbeans.Module;
60
import org.netbeans.ModuleInstaller;
60
import org.netbeans.ModuleInstaller;
61
import org.netbeans.ModuleManager;
61
import org.netbeans.ModuleManager;
62
import org.openide.util.Mutex.Action;
62
63
63
/**
64
/**
64
 * Utility class permitting you to verify that a set of modules could be enabled together.
65
 * Utility class permitting you to verify that a set of modules could be enabled together.
Lines 98-106 Link Here
98
        return findInconsistencies(modules, permittedDisabledAutoloads, true);
99
        return findInconsistencies(modules, permittedDisabledAutoloads, true);
99
    }
100
    }
100
    /* accessible to test */ static SortedMap<String,SortedSet<String>> findInconsistencies(
101
    /* accessible to test */ static SortedMap<String,SortedSet<String>> findInconsistencies(
101
            Set<Manifest> modules, Set<String> permittedDisabledAutoloads, boolean formatted) throws IllegalArgumentException {
102
            final Set<Manifest> modules, final Set<String> permittedDisabledAutoloads, final boolean formatted) throws IllegalArgumentException {
102
        ModuleManager mgr = new ModuleManager(new DummyInstaller(), new DummyEvents());
103
        final ModuleManager mgr = new ModuleManager(new DummyInstaller(), new DummyEvents());
103
        mgr.mutexPrivileged().enterWriteAccess();
104
        return mgr.mutex().writeAccess(new Action<SortedMap<String, SortedSet<String>>>() {
105
            @Override
106
            public SortedMap<String, SortedSet<String>> run() {
107
                return doFindInconsistencies(mgr, modules, permittedDisabledAutoloads, formatted);
108
            }
109
        });
110
    }
111
112
113
    private static SortedMap<String, SortedSet<String>> doFindInconsistencies(
114
        ModuleManager mgr, Set<Manifest> modules, 
115
        Set<String> permittedDisabledAutoloads, boolean formatted
116
    ) throws IllegalArgumentException {
104
        Manifest dummy = new Manifest();
117
        Manifest dummy = new Manifest();
105
        dummy.getMainAttributes().putValue("OpenIDE-Module", "__dummy__"); // NOI18N
118
        dummy.getMainAttributes().putValue("OpenIDE-Module", "__dummy__"); // NOI18N
106
        dummy.getMainAttributes().putValue("OpenIDE-Module-Provides",
119
        dummy.getMainAttributes().putValue("OpenIDE-Module-Provides",
(-)a/core.startup/src/org/netbeans/core/startup/ModuleList.java (-7 / +8 lines)
Lines 91-96 Link Here
91
import org.openide.modules.Dependency;
91
import org.openide.modules.Dependency;
92
import org.openide.modules.InstalledFileLocator;
92
import org.openide.modules.InstalledFileLocator;
93
import org.openide.modules.SpecificationVersion;
93
import org.openide.modules.SpecificationVersion;
94
import org.openide.util.Mutex.ExceptionAction;
95
import org.openide.util.MutexException;
94
import org.openide.util.Parameters;
96
import org.openide.util.Parameters;
95
import org.openide.util.RequestProcessor;
97
import org.openide.util.RequestProcessor;
96
import org.openide.util.Utilities;
98
import org.openide.util.Utilities;
Lines 1179-1188 Link Here
1179
                pendingRun = false;
1181
                pendingRun = false;
1180
            }
1182
            }
1181
            LOG.fine("ModuleList: will process outstanding external XML changes");
1183
            LOG.fine("ModuleList: will process outstanding external XML changes");
1182
            mgr.mutexPrivileged().enterWriteAccess();
1183
            try {
1184
            try {
1184
                folder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
1185
                mgr.mutex().writeAccess(new ExceptionAction<Void>() {
1185
                    public void run() throws IOException {
1186
                    @Override
1187
                    public Void run() throws Exception {
1186
                        // 1. For any dirty XML for which status exists but reloadable differs from XML: change.
1188
                        // 1. For any dirty XML for which status exists but reloadable differs from XML: change.
1187
                        // 2. For any XML for which we have no status: create & create status, as disabled.
1189
                        // 2. For any XML for which we have no status: create & create status, as disabled.
1188
                        // 3. For all dirty XML which says enabled but status says disabled: batch-enable as possible.
1190
                        // 3. For all dirty XML which says enabled but status says disabled: batch-enable as possible.
Lines 1215-1227 Link Here
1215
                            stepUpdateProps(dirtyprops);
1217
                            stepUpdateProps(dirtyprops);
1216
                            stepMarkClean();
1218
                            stepMarkClean();
1217
                        }
1219
                        }
1220
                        return null;
1218
                    }
1221
                    }
1219
                });
1222
                });
1220
                LOG.fine("ModuleList: finished processing outstanding external XML changes");
1223
                LOG.fine("ModuleList: finished processing outstanding external XML changes");
1221
            } catch (IOException ioe) {
1224
            } catch (MutexException ioe) {
1222
                LOG.log(Level.WARNING, null, ioe);
1225
                LOG.log(Level.WARNING, null, ioe.getException());
1223
            } finally {
1224
                mgr.mutexPrivileged().exitWriteAccess();
1225
            }
1226
            }
1226
        }
1227
        }
1227
        // All the steps called from the run() method to handle disk changes:
1228
        // All the steps called from the run() method to handle disk changes:
(-)a/core.startup/src/org/netbeans/core/startup/ModuleSystem.java (-157 / +184 lines)
Lines 71-76 Link Here
71
import org.openide.filesystems.FileSystem;
71
import org.openide.filesystems.FileSystem;
72
import org.openide.filesystems.FileUtil;
72
import org.openide.filesystems.FileUtil;
73
import org.openide.util.Exceptions;
73
import org.openide.util.Exceptions;
74
import org.openide.util.Mutex.Action;
75
import org.openide.util.Mutex.ExceptionAction;
76
import org.openide.util.MutexException;
74
77
75
/** Controller of the IDE's whole module system.
78
/** Controller of the IDE's whole module system.
76
 * Contains higher-level convenience methods to
79
 * Contains higher-level convenience methods to
Lines 153-168 Link Here
153
     * @return list of module-related JARs/ZIPs
156
     * @return list of module-related JARs/ZIPs
154
     */
157
     */
155
    public List<File> getModuleJars () {
158
    public List<File> getModuleJars () {
156
        mgr.mutexPrivileged().enterReadAccess();
159
        return mgr.mutex().readAccess(new Action<List<File>>() {
157
        try {
160
            @Override
158
            List<File> l = new ArrayList<File>();
161
            public List<File> run() {
159
            for (Module m: mgr.getEnabledModules()) {
162
                List<File> l = new ArrayList<File>();
160
                l.addAll(m.getAllJars());
163
                for (Module m: mgr.getEnabledModules()) {
164
                    l.addAll(m.getAllJars());
165
                }
166
                return l;
161
            }
167
            }
162
            return l;
168
        });
163
        } finally {
164
            mgr.mutexPrivileged().exitReadAccess();
165
        }
166
    }
169
    }
167
170
168
    /** We just make the modules now, restore them later
171
    /** We just make the modules now, restore them later
Lines 178-184 Link Here
178
        // Keep a list of manifest URL bases which we know we do not need to
181
        // Keep a list of manifest URL bases which we know we do not need to
179
        // parse. Some of these manifests might be signed, and if so, we do not
182
        // parse. Some of these manifests might be signed, and if so, we do not
180
        // want to touch them, as it slows down startup quite a bit.
183
        // want to touch them, as it slows down startup quite a bit.
181
        Set<File> ignoredJars = new HashSet<File>();
184
        final Set<File> ignoredJars = new HashSet<File>();
182
        String javaHome = System.getProperty("java.home"); // NOI18N
185
        String javaHome = System.getProperty("java.home"); // NOI18N
183
        if (javaHome != null) {
186
        if (javaHome != null) {
184
            File lib = new File(new File(javaHome).getParentFile(), "lib"); // NOI18N
187
            File lib = new File(new File(javaHome).getParentFile(), "lib"); // NOI18N
Lines 189-343 Link Here
189
            ignoredJars.add(new File(entry));
192
            ignoredJars.add(new File(entry));
190
        }
193
        }
191
        LOG.log(Level.FINE, "Ignored JARs: {0}", ignoredJars);
194
        LOG.log(Level.FINE, "Ignored JARs: {0}", ignoredJars);
192
            
195
        mgr.mutex().writeAccess(new Action<Void>() {
193
        mgr.mutexPrivileged().enterWriteAccess();
196
            @Override
194
        ev.log(Events.START_LOAD_BOOT_MODULES);
197
            public Void run() {
195
        try {
198
                doLoadBootModules(ignoredJars);
196
            bootModules = new HashSet<Module>(10);
199
                return null;
197
            ClassLoader loader = ModuleSystem.class.getClassLoader();
198
            Enumeration<URL> e = loader.getResources("META-INF/MANIFEST.MF"); // NOI18N
199
            ev.log(Events.PERF_TICK, "got all manifests"); // NOI18N
200
            
201
            // There will be duplicates: cf. #32576.
202
            Set<URL> checkedManifests = new HashSet<URL>();
203
            MANIFESTS:
204
            while (e.hasMoreElements()) {
205
                URL manifestUrl = e.nextElement();
206
                if (!checkedManifests.add(manifestUrl)) {
207
                    // Already seen, ignore.
208
                    continue;
209
                }
210
                URL jarURL = FileUtil.getArchiveFile(manifestUrl);
211
                if (jarURL != null && jarURL.getProtocol().equals("file") &&
212
                        /* #121777 */ jarURL.getPath().startsWith("/")) {
213
                    LOG.log(Level.FINE, "Considering JAR: {0}", jarURL);
214
                try {
215
                        if (ignoredJars.contains(new File(jarURL.toURI()))) {
216
                        LOG.log(Level.FINE, "ignoring JDK/JRE manifest: {0}", manifestUrl);
217
                        continue MANIFESTS;
218
                    }
219
                } catch (URISyntaxException x) {
220
                    Exceptions.printStackTrace(x);
221
                }
222
                }
223
                LOG.log(Level.FINE, "Checking boot manifest: {0}", manifestUrl);
224
                
225
                InputStream is;
226
                try {
227
                    is = manifestUrl.openStream();
228
                } catch (IOException ioe) {
229
                    // Debugging for e.g. #32493 - which JAR was guilty?
230
                    Exceptions.attachMessage(ioe, "URL: " + manifestUrl); // NOI18N
231
                    throw ioe;
232
                }
233
                try {
234
                    Manifest mani = new Manifest(is);
235
                    Attributes attr = mani.getMainAttributes();
236
                    if (attr.getValue("OpenIDE-Module") == null) { // NOI18N
237
                        // Not a module.
238
                        continue;
239
                    }
240
                    bootModules.add(mgr.createFixed(mani, manifestUrl, loader));
241
                } finally {
242
                    is.close();
243
                }
244
            }
200
            }
245
            if (list == null) {
201
        });
246
                // Plain calling us, we have to install now.
247
                // Do it the simple way.
248
                mgr.enable(bootModules);
249
            }
250
            ev.log(Events.PERF_TICK, "added all classpath modules"); // NOI18N
251
	    
252
        } catch (IOException ioe) {
253
            // Note: includes also InvalidException's for malformed this and that.
254
            // Probably if a bootstrap module is corrupt we are in pretty bad shape
255
            // anyway, so don't bother trying to be fancy and install just some of
256
            // them etc.
257
            LOG.log(Level.WARNING, null, ioe);
258
        } catch (DuplicateException de) {
259
            LOG.log(Level.WARNING, null, de);
260
        } finally {
261
            // Not 100% accurate in this case:
262
            ev.log(Events.FINISH_LOAD_BOOT_MODULES);
263
            mgr.mutexPrivileged().exitWriteAccess();
264
        }
265
    }
202
    }
266
    
267
    /** Refreshes the list of modules. Used from autoupdate.services.
268
     * @since 1.28
269
     */
270
    public final void refresh() {
271
        list.moduleListChanged();
272
    }
273
    
274
    /** Read disk settings and determine what the known modules are.
275
     */
276
    public void readList() {
277
        ev.log(Events.PERF_START, "ModuleSystem.readList"); // NOI18N
278
        mgr.mutexPrivileged().enterWriteAccess();
279
        try {
280
            list.readInitial();
281
        } finally {
282
            mgr.mutexPrivileged().exitWriteAccess();
283
        }
284
	ev.log(Events.PERF_END, "ModuleSystem.readList"); // NOI18N
285
    }
286
    
287
    /** Install read modules.
288
     */
289
    public void restore() {
290
	ev.log(Events.PERF_START, "ModuleSystem.restore"); // NOI18N
291
        mgr.mutexPrivileged().enterWriteAccess();
292
        try {
293
            Set<Module> toTrigger = new HashSet<Module>(bootModules/*Collections.EMPTY_SET*/);
294
            list.trigger(toTrigger);
295
            mgr.releaseModuleManifests();
296
        } finally {
297
            mgr.mutexPrivileged().exitWriteAccess();
298
        }
299
	ev.log(Events.PERF_END, "ModuleSystem.restore"); // NOI18N	
300
    }
301
    
302
    /** Shut down the system: ask modules to shut down.
303
     * Some of them may refuse.
304
     */
305
    public boolean shutDown(final Runnable midHook) {
306
        mgr.mutexPrivileged().enterWriteAccess();
307
        boolean res;
308
        Runnable both = new Runnable() {
309
            @Override
310
            public void run() {
311
                midHook.run();
312
                Stamps.getModulesJARs().shutdown();
313
            }
314
        };
315
        try {
316
            res = mgr.shutDown(both);
317
        } finally {
318
            mgr.mutexPrivileged().exitWriteAccess();
319
        }
320
        return res;
321
    }
322
    
323
    /** Load a module in test (reloadable) mode.
324
     * If there is an existing module with a different JAR, get
325
     * rid of it and load this one instead.
326
     * If it is already installed, disable it and reenable it
327
     * to reload its contents.
328
     * If other modules depend on it, disable them first and
329
     * then (try to) enable them again later.
330
     */
331
    final void deployTestModule(File jar) throws IOException {
332
        if (! jar.isAbsolute()) throw new IOException("Absolute paths only please"); // NOI18N
333
203
334
        // Check to see if Javeleon is enabled. If so,
204
    private void doDeployTestModule(File jar) throws IOException, IllegalArgumentException {
335
        // let Javeleon handle the module reloading.
336
        if (JaveleonModule.isJaveleonPresent && JaveleonModuleReloader.getDefault().reloadJaveleonModule(jar, mgr, installer, ev)) {
337
            return;
338
        }
339
        
340
        mgr.mutexPrivileged().enterWriteAccess();
341
        ev.log(Events.START_DEPLOY_TEST_MODULE, jar);
205
        ev.log(Events.START_DEPLOY_TEST_MODULE, jar);
342
        // For now, just print to stderr directly; could also go thru Events.
206
        // For now, just print to stderr directly; could also go thru Events.
343
        // No need for I18N, module developers are expected to know English
207
        // No need for I18N, module developers are expected to know English
Lines 412-418 Link Here
412
            System.err.println("Done."); // NOI18N
276
            System.err.println("Done."); // NOI18N
413
        } finally {
277
        } finally {
414
            ev.log(Events.FINISH_DEPLOY_TEST_MODULE, jar);
278
            ev.log(Events.FINISH_DEPLOY_TEST_MODULE, jar);
415
            mgr.mutexPrivileged().exitWriteAccess();
279
        }
280
    }
281
282
    private void doLoadBootModules(Set<File> ignoredJars) throws IllegalArgumentException {
283
        ev.log(Events.START_LOAD_BOOT_MODULES);
284
        try {
285
            bootModules = new HashSet<Module>(10);
286
            ClassLoader loader = ModuleSystem.class.getClassLoader();
287
            Enumeration<URL> e = loader.getResources("META-INF/MANIFEST.MF"); // NOI18N
288
            ev.log(Events.PERF_TICK, "got all manifests"); // NOI18N
289
            
290
            // There will be duplicates: cf. #32576.
291
            Set<URL> checkedManifests = new HashSet<URL>();
292
            MANIFESTS:
293
            while (e.hasMoreElements()) {
294
                URL manifestUrl = e.nextElement();
295
                if (!checkedManifests.add(manifestUrl)) {
296
                    // Already seen, ignore.
297
                    continue;
298
                }
299
                URL jarURL = FileUtil.getArchiveFile(manifestUrl);
300
                if (jarURL != null && jarURL.getProtocol().equals("file") &&
301
                        /* #121777 */ jarURL.getPath().startsWith("/")) {
302
                    LOG.log(Level.FINE, "Considering JAR: {0}", jarURL);
303
                try {
304
                        if (ignoredJars.contains(new File(jarURL.toURI()))) {
305
                        LOG.log(Level.FINE, "ignoring JDK/JRE manifest: {0}", manifestUrl);
306
                        continue MANIFESTS;
307
                    }
308
                } catch (URISyntaxException x) {
309
                    Exceptions.printStackTrace(x);
310
                }
311
                }
312
                LOG.log(Level.FINE, "Checking boot manifest: {0}", manifestUrl);
313
                
314
                InputStream is;
315
                try {
316
                    is = manifestUrl.openStream();
317
                } catch (IOException ioe) {
318
                    // Debugging for e.g. #32493 - which JAR was guilty?
319
                    Exceptions.attachMessage(ioe, "URL: " + manifestUrl); // NOI18N
320
                    throw ioe;
321
                }
322
                try {
323
                    Manifest mani = new Manifest(is);
324
                    Attributes attr = mani.getMainAttributes();
325
                    if (attr.getValue("OpenIDE-Module") == null) { // NOI18N
326
                        // Not a module.
327
                        continue;
328
                    }
329
                    bootModules.add(mgr.createFixed(mani, manifestUrl, loader));
330
                } finally {
331
                    is.close();
332
                }
333
            }
334
            if (list == null) {
335
                // Plain calling us, we have to install now.
336
                // Do it the simple way.
337
                mgr.enable(bootModules);
338
            }
339
            ev.log(Events.PERF_TICK, "added all classpath modules"); // NOI18N
340
        
341
        } catch (IOException ioe) {
342
            // Note: includes also InvalidException's for malformed this and that.
343
            // Probably if a bootstrap module is corrupt we are in pretty bad shape
344
            // anyway, so don't bother trying to be fancy and install just some of
345
            // them etc.
346
            LOG.log(Level.WARNING, null, ioe);
347
        } catch (DuplicateException de) {
348
            LOG.log(Level.WARNING, null, de);
349
        } finally {
350
            // Not 100% accurate in this case:
351
            ev.log(Events.FINISH_LOAD_BOOT_MODULES);
352
        }
353
    }
354
    
355
    /** Refreshes the list of modules. Used from autoupdate.services.
356
     * @since 1.28
357
     */
358
    public final void refresh() {
359
        list.moduleListChanged();
360
    }
361
    
362
    /** Read disk settings and determine what the known modules are.
363
     */
364
    public void readList() {
365
        ev.log(Events.PERF_START, "ModuleSystem.readList"); // NOI18N
366
        mgr.mutex().writeAccess(new Runnable() {
367
            @Override
368
            public void run() {
369
                list.readInitial();
370
            }
371
        });
372
    	ev.log(Events.PERF_END, "ModuleSystem.readList"); // NOI18N
373
    }
374
    
375
    /** Install read modules.
376
     */
377
    public void restore() {
378
	ev.log(Events.PERF_START, "ModuleSystem.restore"); // NOI18N
379
        mgr.mutex().writeAccess(new Runnable() {
380
            @Override
381
            public void run() {
382
                Set<Module> toTrigger = new HashSet<Module>(bootModules/*Collections.EMPTY_SET*/);
383
                list.trigger(toTrigger);
384
                mgr.releaseModuleManifests();
385
            }
386
        });
387
    	ev.log(Events.PERF_END, "ModuleSystem.restore"); // NOI18N	
388
    }
389
    
390
    /** Shut down the system: ask modules to shut down.
391
     * Some of them may refuse.
392
     */
393
    public boolean shutDown(final Runnable midHook) {
394
        class ActionImpl implements Runnable {
395
            boolean second;
396
            boolean res;
397
            
398
            public ActionImpl() {
399
            }
400
401
            @Override
402
            public void run() {
403
                if (second) {
404
                    midHook.run();
405
                    Stamps.getModulesJARs().shutdown();
406
                } else {
407
                    second = true;
408
                    res = mgr.shutDown(this);
409
                }
410
            }
411
        }
412
        ActionImpl impl = new ActionImpl();
413
        return impl.res;
414
    }
415
    
416
    /** Load a module in test (reloadable) mode.
417
     * If there is an existing module with a different JAR, get
418
     * rid of it and load this one instead.
419
     * If it is already installed, disable it and reenable it
420
     * to reload its contents.
421
     * If other modules depend on it, disable them first and
422
     * then (try to) enable them again later.
423
     */
424
    final void deployTestModule(final File jar) throws IOException {
425
        try {
426
            if (! jar.isAbsolute()) throw new IOException("Absolute paths only please"); // NOI18N
427
428
            // Check to see if Javeleon is enabled. If so,
429
            // let Javeleon handle the module reloading.
430
            if (JaveleonModule.isJaveleonPresent && JaveleonModuleReloader.getDefault().reloadJaveleonModule(jar, mgr, installer, ev)) {
431
                return;
432
            }
433
            
434
            mgr.mutex().writeAccess(new ExceptionAction<Void>() {
435
                @Override
436
                public Void run() throws IOException {
437
                    doDeployTestModule(jar);
438
                    return null;
439
                }
440
            });
441
        } catch (MutexException ex) {
442
            throw (IOException)ex.getException();
416
        }
443
        }
417
    }
444
    }
418
    /** Make sure some module is disabled.
445
    /** Make sure some module is disabled.
(-)a/core.startup/src/org/netbeans/core/startup/NbInstaller.java (-2 / +13 lines)
Lines 67-72 Link Here
67
import java.util.StringTokenizer;
67
import java.util.StringTokenizer;
68
import java.util.TreeMap;
68
import java.util.TreeMap;
69
import java.util.TreeSet;
69
import java.util.TreeSet;
70
import java.util.concurrent.Executor;
70
import java.util.jar.Attributes;
71
import java.util.jar.Attributes;
71
import java.util.jar.JarEntry;
72
import java.util.jar.JarEntry;
72
import java.util.jar.JarFile;
73
import java.util.jar.JarFile;
Lines 92-98 Link Here
92
import org.openide.util.NbCollections;
93
import org.openide.util.NbCollections;
93
import org.openide.util.SharedClassObject;
94
import org.openide.util.SharedClassObject;
94
import org.openide.util.NbBundle;
95
import org.openide.util.NbBundle;
95
import org.openide.util.Utilities;
96
import org.openide.util.lookup.InstanceContent;
96
import org.openide.util.lookup.InstanceContent;
97
import org.xml.sax.SAXException;
97
import org.xml.sax.SAXException;
98
98
Lines 103-109 Link Here
103
 * messages and the like.
103
 * messages and the like.
104
 * @author Jesse Glick, Jan Pokorsky, Jaroslav Tulach, et al.
104
 * @author Jesse Glick, Jan Pokorsky, Jaroslav Tulach, et al.
105
 */
105
 */
106
final class NbInstaller extends ModuleInstaller {
106
final class NbInstaller extends ModuleInstaller implements Executor {
107
107
108
    private static final Logger LOG = Logger.getLogger(NbInstaller.class.getName());
108
    private static final Logger LOG = Logger.getLogger(NbInstaller.class.getName());
109
109
Lines 484-489 Link Here
484
    }
484
    }
485
    
485
    
486
    private final InstanceContent.Convertor<ManifestSection,Object> convertor = new Convertor();
486
    private final InstanceContent.Convertor<ManifestSection,Object> convertor = new Convertor();
487
488
    @Override
489
    public void execute(Runnable command) {
490
        FileUtil.runAtomicAction(command);
491
    }
492
493
    @Override
494
    protected Executor executor() {
495
        return this;
496
    }
497
    
487
    private final class Convertor implements InstanceContent.Convertor<ManifestSection,Object> { // or <ManifestSection,SharedClassObject>?
498
    private final class Convertor implements InstanceContent.Convertor<ManifestSection,Object> { // or <ManifestSection,SharedClassObject>?
488
        Convertor() {}
499
        Convertor() {}
489
        public Object convert(ManifestSection s) {
500
        public Object convert(ManifestSection s) {
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/ModuleFormatSatisfiedTest.java (-12 / +14 lines)
Lines 54-59 Link Here
54
import java.util.jar.Manifest;
54
import java.util.jar.Manifest;
55
import org.netbeans.Module;
55
import org.netbeans.Module;
56
import org.netbeans.ModuleManager;
56
import org.netbeans.ModuleManager;
57
import org.openide.util.Mutex.ExceptionAction;
57
58
58
/** Checks whether a modules are provided with ModuleFormat1 token.
59
/** Checks whether a modules are provided with ModuleFormat1 token.
59
 *
60
 *
Lines 89-107 Link Here
89
        
90
        
90
        final MockEvents ev = new MockEvents();
91
        final MockEvents ev = new MockEvents();
91
        NbInstaller installer = new NbInstaller(ev);
92
        NbInstaller installer = new NbInstaller(ev);
92
        ModuleManager mgr = new ModuleManager(installer, ev);
93
        final ModuleManager mgr = new ModuleManager(installer, ev);
93
        installer.registerManager(mgr);
94
        installer.registerManager(mgr);
94
        mgr.mutexPrivileged().enterWriteAccess();
95
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
95
        try {
96
            @Override
96
            addOpenideModules(mgr);
97
            public Void run() throws Exception {
97
            Module m1 = mgr.create(moduleJarFile, null, false, false, false);
98
                addOpenideModules(mgr);
98
            assertEquals(Collections.EMPTY_SET, m1.getProblems());
99
                Module m1 = mgr.create(moduleJarFile, null, false, false, false);
99
            mgr.enable(m1);
100
                assertEquals(Collections.EMPTY_SET, m1.getProblems());
100
            mgr.disable(m1);
101
                mgr.enable(m1);
101
            mgr.delete(m1);
102
                mgr.disable(m1);
102
        } finally {
103
                mgr.delete(m1);
103
            mgr.mutexPrivileged().exitWriteAccess();
104
                return null;
104
        }
105
            }
106
        });
105
    }
107
    }
106
108
107
    static void addOpenideModules (ModuleManager mgr) throws Exception {
109
    static void addOpenideModules (ModuleManager mgr) throws Exception {
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListDontDeleteDisabledModulesTest.java (-9 / +11 lines)
Lines 53-58 Link Here
53
import org.netbeans.MockModuleInstaller;
53
import org.netbeans.MockModuleInstaller;
54
import org.netbeans.SetupHid;
54
import org.netbeans.SetupHid;
55
import org.openide.filesystems.*;
55
import org.openide.filesystems.*;
56
import org.openide.util.Mutex.ExceptionAction;
56
import org.openide.util.test.MockLookup;
57
import org.openide.util.test.MockLookup;
57
58
58
/** 
59
/** 
Lines 127-141 Link Here
127
        FileObject configFo = FileUtil.getConfigFile("Modules/org-foo.xml");
128
        FileObject configFo = FileUtil.getConfigFile("Modules/org-foo.xml");
128
        assertNotNull("Config file exists", configFo);
129
        assertNotNull("Config file exists", configFo);
129
130
130
        mgr.mutexPrivileged().enterWriteAccess();
131
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
131
        try {
132
            @Override
132
            assertEquals(Collections.emptySet(), list.readInitial());
133
            public Void run() throws Exception {
133
            assertEquals(Collections.emptySet(), mgr.getModules());
134
                assertEquals(Collections.emptySet(), list.readInitial());
134
            list.trigger(Collections.<Module>emptySet());
135
                assertEquals(Collections.emptySet(), mgr.getModules());
135
            assertEquals(Collections.emptySet(), mgr.getModules());
136
                list.trigger(Collections.<Module>emptySet());
136
        } finally {
137
                assertEquals(Collections.emptySet(), mgr.getModules());
137
            mgr.mutexPrivileged().exitWriteAccess();
138
                return null;
138
        }
139
            }
140
        });
139
141
140
        assertTrue("Old config file is still OK", configFo.isValid());
142
        assertTrue("Old config file is still OK", configFo.isValid());
141
        FileObject configFo2 = FileUtil.getConfigFile("Modules/org-foo.xml");
143
        FileObject configFo2 = FileUtil.getConfigFile("Modules/org-foo.xml");
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/ModuleListTest.java (-48 / +54 lines)
Lines 71-76 Link Here
71
import org.openide.filesystems.FileUtil;
71
import org.openide.filesystems.FileUtil;
72
import org.openide.filesystems.LocalFileSystem;
72
import org.openide.filesystems.LocalFileSystem;
73
import org.openide.modules.InstalledFileLocator;
73
import org.openide.modules.InstalledFileLocator;
74
import org.openide.util.Mutex.ExceptionAction;
74
import org.openide.util.test.MockLookup;
75
import org.openide.util.test.MockLookup;
75
76
76
/** Test the functions of the module list, i.e. finding modules on
77
/** Test the functions of the module list, i.e. finding modules on
Lines 138-155 Link Here
138
     * Make sure a class from one can depend on a class from another.
139
     * Make sure a class from one can depend on a class from another.
139
     */
140
     */
140
    public void testScanAndTwiddle() throws Exception {
141
    public void testScanAndTwiddle() throws Exception {
141
        mgr.mutexPrivileged().enterWriteAccess();
142
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
142
        try {
143
            @Override
143
            // XXX try to read an actual initial list too...
144
            public Void run() throws Exception {
144
            assertEquals(Collections.emptySet(), list.readInitial());
145
                // XXX try to read an actual initial list too...
145
            Set<Module> modules = new HashSet<Module>();
146
                assertEquals(Collections.emptySet(), list.readInitial());
146
            modules.add(makeModule("simple-module.jar"));
147
                Set<Module> modules = new HashSet<Module>();
147
            modules.add(makeModule("depends-on-simple-module.jar"));
148
                modules.add(makeModule("simple-module.jar"));
148
            list.trigger(modules);
149
                modules.add(makeModule("depends-on-simple-module.jar"));
149
            assertEquals(modules, mgr.getEnabledModules());
150
                list.trigger(modules);
150
        } finally {
151
                assertEquals(modules, mgr.getEnabledModules());
151
            mgr.mutexPrivileged().exitWriteAccess();
152
                return null;
152
        }
153
            }
154
        });
153
        FileObject[] xml = modulesfolder.getChildren();
155
        FileObject[] xml = modulesfolder.getChildren();
154
        assertEquals(2, xml.length);
156
        assertEquals(2, xml.length);
155
        FileObject foo, bar;
157
        FileObject foo, bar;
Lines 168-183 Link Here
168
        // Checking that changes in memory will rewrite XML:
170
        // Checking that changes in memory will rewrite XML:
169
        LoggedFileListener listener = new LoggedFileListener();
171
        LoggedFileListener listener = new LoggedFileListener();
170
        modulesfolder.addFileChangeListener(listener);
172
        modulesfolder.addFileChangeListener(listener);
171
        mgr.mutexPrivileged().enterWriteAccess();
173
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
172
        try {
174
            @Override
173
            Module m1 = mgr.get("org.foo");
175
            public Void run() throws Exception {
174
            assertNotNull(m1);
176
                Module m1 = mgr.get("org.foo");
175
            Module m2 = mgr.get("org.bar");
177
                assertNotNull(m1);
176
            assertNotNull(m2);
178
                Module m2 = mgr.get("org.bar");
177
            mgr.disable(new HashSet<Module>(Arrays.asList(m1, m2)));
179
                assertNotNull(m2);
178
        } finally {
180
                mgr.disable(new HashSet<Module>(Arrays.asList(m1, m2)));
179
            mgr.mutexPrivileged().exitWriteAccess();
181
                return null;
180
        }
182
            }
183
        });
181
        // We expect it to have marked both as disabled now:
184
        // We expect it to have marked both as disabled now:
182
        listener.waitForChange("Modules/org-foo.xml");
185
        listener.waitForChange("Modules/org-foo.xml");
183
        listener.waitForChange("Modules/org-bar.xml");
186
        listener.waitForChange("Modules/org-bar.xml");
Lines 216-229 Link Here
216
        MockEvents ev = new MockEvents();
219
        MockEvents ev = new MockEvents();
217
        ModuleManager mgr2 = new ModuleManager(installer, ev);
220
        ModuleManager mgr2 = new ModuleManager(installer, ev);
218
        assertNotNull(mf);
221
        assertNotNull(mf);
219
        ModuleList list2 = new ModuleList(mgr2, mf, ev);
222
        final ModuleList list2 = new ModuleList(mgr2, mf, ev);
220
        mgr2.mutexPrivileged().enterWriteAccess();
221
        CharSequence log = Log.enable("org.netbeans.core.startup.ModuleList", Level.FINEST);
223
        CharSequence log = Log.enable("org.netbeans.core.startup.ModuleList", Level.FINEST);
222
        try {
224
        mgr2.mutex().writeAccess(new ExceptionAction<Void>() {
223
            list2.readInitial();
225
            @Override
224
        } finally {
226
            public Void run() throws Exception {
225
            mgr2.mutexPrivileged().exitWriteAccess();
227
                list2.readInitial();
226
        }
228
                return null;
229
            }
230
        });
227
        if (log.toString().indexOf("no cache") >= 0) {
231
        if (log.toString().indexOf("no cache") >= 0) {
228
            fail("Everything shall be read from cache:\n" + log);
232
            fail("Everything shall be read from cache:\n" + log);
229
        }
233
        }
Lines 250-264 Link Here
250
     * Written to help test #27106.
254
     * Written to help test #27106.
251
     */
255
     */
252
    public void testAddNewModuleViaXML() throws Exception {
256
    public void testAddNewModuleViaXML() throws Exception {
253
        mgr.mutexPrivileged().enterWriteAccess();
257
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
254
        try {
258
            @Override
255
            assertEquals(Collections.emptySet(), list.readInitial());
259
            public Void run() throws Exception {
256
            assertEquals(Collections.emptySet(), mgr.getModules());
260
                assertEquals(Collections.emptySet(), list.readInitial());
257
            list.trigger(Collections.<Module>emptySet());
261
                assertEquals(Collections.emptySet(), mgr.getModules());
258
            assertEquals(Collections.emptySet(), mgr.getModules());
262
                list.trigger(Collections.<Module>emptySet());
259
        } finally {
263
                assertEquals(Collections.emptySet(), mgr.getModules());
260
            mgr.mutexPrivileged().exitWriteAccess();
264
                return null;
261
        }
265
            }
266
        });
262
        LoggedPCListener listener = new LoggedPCListener();
267
        LoggedPCListener listener = new LoggedPCListener();
263
        mgr.addPropertyChangeListener(listener);
268
        mgr.addPropertyChangeListener(listener);
264
        modulesfolder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
269
        modulesfolder.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
Lines 269-284 Link Here
269
            }
274
            }
270
        });
275
        });
271
        assertTrue("PROP_MODULES fired", listener.waitForChange(mgr, ModuleManager.PROP_MODULES));
276
        assertTrue("PROP_MODULES fired", listener.waitForChange(mgr, ModuleManager.PROP_MODULES));
272
        mgr.mutexPrivileged().enterReadAccess();
277
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
273
        try {
278
            @Override
274
            Set modules = mgr.getEnabledModules();
279
            public Void run() throws Exception {
275
            assertEquals(1, modules.size());
280
                Set modules = mgr.getEnabledModules();
276
            Module m = (Module)modules.iterator().next();
281
                assertEquals(1, modules.size());
277
            assertEquals("org.foo", m.getCodeNameBase());
282
                Module m = (Module)modules.iterator().next();
278
            assertTrue(m.isEnabled());
283
                assertEquals("org.foo", m.getCodeNameBase());
279
        } finally {
284
                assertTrue(m.isEnabled());
280
            mgr.mutexPrivileged().exitReadAccess();
285
                return null;
281
        }
286
            }
287
        });
282
    }
288
    }
283
    
289
    
284
    // XXX try to read a nonempty initial list
290
    // XXX try to read a nonempty initial list
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbBootDelegationTest.java (-24 / +29 lines)
Lines 46-51 Link Here
46
import java.util.Collections;
46
import java.util.Collections;
47
import org.netbeans.Module;
47
import org.netbeans.Module;
48
import org.netbeans.ModuleManager;
48
import org.netbeans.ModuleManager;
49
import org.openide.util.Mutex.ExceptionAction;
49
50
50
/**
51
/**
51
 *
52
 *
Lines 58-88 Link Here
58
    }
59
    }
59
    
60
    
60
    public void testNetBeansBootDelegation() throws Exception {
61
    public void testNetBeansBootDelegation() throws Exception {
61
        ModuleManager mgr = Main.getModuleSystem().getManager();
62
        final ModuleManager mgr = Main.getModuleSystem().getManager();
62
        mgr.mutexPrivileged().enterWriteAccess();
63
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
63
        System.setProperty("netbeans.bootdelegation", "javax.swing, javax.naming.*");
64
            @Override
64
        try {
65
            public Void run() throws Exception {
65
            Module m1 = mgr.create(new File(jars, "simple-module.jar"), null, false, false, false);
66
                System.setProperty("netbeans.bootdelegation", "javax.swing, javax.naming.*");
66
            mgr.enable(Collections.singleton(m1));
67
                try {
67
            final ClassLoader ldr = m1.getClassLoader();
68
                    Module m1 = mgr.create(new File(jars, "simple-module.jar"), null, false, false, false);
68
            Class<?> jtree = Class.forName("javax.swing.JTree", true, ldr);
69
                    mgr.enable(Collections.singleton(m1));
69
            assertNotNull("JTree found", jtree);
70
                    final ClassLoader ldr = m1.getClassLoader();
70
            String tableModel = "javax.swing.table.TableModel";
71
                    Class<?> jtree = Class.forName("javax.swing.JTree", true, ldr);
71
            try {
72
                    assertNotNull("JTree found", jtree);
72
                Class<?> model = Class.forName(tableModel, true, ldr);
73
                    String tableModel = "javax.swing.table.TableModel";
73
                fail("Model shall not be accessible: " + model);
74
                    try {
74
            } catch (ClassNotFoundException ex) {
75
                        Class<?> model = Class.forName(tableModel, true, ldr);
75
                // OK
76
                        fail("Model shall not be accessible: " + model);
76
                assertNotNull("The class exists on boot path", ClassLoader.getSystemClassLoader().loadClass(tableModel));
77
                    } catch (ClassNotFoundException ex) {
78
                        // OK
79
                        assertNotNull("The class exists on boot path", ClassLoader.getSystemClassLoader().loadClass(tableModel));
80
                    }
81
                    Class<?> list = Class.forName("java.util.ArrayList", true, ldr);
82
                    assertNotNull("java packages are always accessible", list);
83
                    Class<?> naming = Class.forName("javax.naming.event.EventContext", true, ldr);
84
                    assertNotNull("naming is recursively visible", naming);
85
                } finally {
86
                    System.getProperties().remove("netbeans.bootdelegation");
87
                }
88
                return null;
77
            }
89
            }
78
            Class<?> list = Class.forName("java.util.ArrayList", true, ldr);
90
        });
79
            assertNotNull("java packages are always accessible", list);
80
            Class<?> naming = Class.forName("javax.naming.event.EventContext", true, ldr);
81
            assertNotNull("naming is recursively visible", naming);
82
        } finally {
83
            System.getProperties().remove("netbeans.bootdelegation");
84
            mgr.mutexPrivileged().exitWriteAccess();
85
        }
86
    }
91
    }
87
92
88
93
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbInstallerHideClasspathPackagesTest.java (-42 / +44 lines)
Lines 55-60 Link Here
55
import org.netbeans.Events;
55
import org.netbeans.Events;
56
import org.netbeans.Module;
56
import org.netbeans.Module;
57
import org.netbeans.ModuleManager;
57
import org.netbeans.ModuleManager;
58
import org.openide.util.Mutex.ExceptionAction;
58
59
59
/**
60
/**
60
 * Checks that OpenIDE-Module-Hide-Classpath-Packages works.
61
 * Checks that OpenIDE-Module-Hide-Classpath-Packages works.
Lines 66-72 Link Here
66
    }
67
    }
67
68
68
    public void testHideClasspathPackages() throws Exception {
69
    public void testHideClasspathPackages() throws Exception {
69
        File m1j = new File(getWorkDir(), "m1.jar");
70
        final File m1j = new File(getWorkDir(), "m1.jar");
70
        Map<String,String> contents = new  HashMap<String,String>();
71
        Map<String,String> contents = new  HashMap<String,String>();
71
        contents.put("javax/net/SocketFactory.class", "ignored");
72
        contents.put("javax/net/SocketFactory.class", "ignored");
72
        contents.put("javax/swing/JPanel.class", "overrides");
73
        contents.put("javax/swing/JPanel.class", "overrides");
Lines 77-83 Link Here
77
        mani.put("OpenIDE-Module", "m1");
78
        mani.put("OpenIDE-Module", "m1");
78
        mani.put("OpenIDE-Module-Hide-Classpath-Packages", "javax.swing.**, javax.naming.*");
79
        mani.put("OpenIDE-Module-Hide-Classpath-Packages", "javax.swing.**, javax.naming.*");
79
        createJar(m1j, contents, mani);
80
        createJar(m1j, contents, mani);
80
        File m2j = new File(getWorkDir(), "m2.jar");
81
        final File m2j = new File(getWorkDir(), "m2.jar");
81
        mani = new HashMap<String,String>();
82
        mani = new HashMap<String,String>();
82
        mani.put("OpenIDE-Module", "m2");
83
        mani.put("OpenIDE-Module", "m2");
83
        mani.put("OpenIDE-Module-Module-Dependencies", "m1");
84
        mani.put("OpenIDE-Module-Module-Dependencies", "m1");
Lines 85-134 Link Here
85
        mani.put("OpenIDE-Module-Layer", "m2/layer.xml");
86
        mani.put("OpenIDE-Module-Layer", "m2/layer.xml");
86
        mani.put("OpenIDE-Module-Package-Dependencies", "javax.management[Descriptor]");
87
        mani.put("OpenIDE-Module-Package-Dependencies", "javax.management[Descriptor]");
87
        createJar(m2j, Collections.singletonMap("m2/layer.xml", "<filesystem/>"), mani);
88
        createJar(m2j, Collections.singletonMap("m2/layer.xml", "<filesystem/>"), mani);
88
        File m3j = new File(getWorkDir(), "m3.jar");
89
        final File m3j = new File(getWorkDir(), "m3.jar");
89
        createJar(m3j, Collections.<String,String>emptyMap(), Collections.singletonMap("OpenIDE-Module", "m3"));
90
        createJar(m3j, Collections.<String,String>emptyMap(), Collections.singletonMap("OpenIDE-Module", "m3"));
90
        Events ev = new MockEvents();
91
        Events ev = new MockEvents();
91
        NbInstaller inst = new NbInstaller(ev);
92
        NbInstaller inst = new NbInstaller(ev);
92
        ModuleManager mgr = new ModuleManager(inst, ev);
93
        final ModuleManager mgr = new ModuleManager(inst, ev);
93
        inst.registerManager(mgr);
94
        inst.registerManager(mgr);
94
        mgr.mutexPrivileged().enterWriteAccess();
95
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
95
        try {
96
            @Override
96
            Module m1 = mgr.create(m1j, null, false, false, false);
97
            public Void run() throws Exception {
97
            Module m2 = mgr.create(m2j, null, false, false, false);
98
                Module m1 = mgr.create(m1j, null, false, false, false);
98
            Module m3 = mgr.create(m3j, null, false, false, false);
99
                Module m2 = mgr.create(m2j, null, false, false, false);
99
            mgr.enable(new HashSet<Module>(Arrays.asList(m1, m2, m3)));
100
                Module m3 = mgr.create(m3j, null, false, false, false);
100
            ModuleManagerTest.assertDoesNotOverride(m1, "javax.net.SocketFactory");
101
                mgr.enable(new HashSet<Module>(Arrays.asList(m1, m2, m3)));
101
            ModuleManagerTest.assertOverrides(m1, "javax.swing.JPanel");
102
                ModuleManagerTest.assertDoesNotOverride(m1, "javax.net.SocketFactory");
102
            ModuleManagerTest.assertOverrides(m1, "javax.swing.text.Document");
103
                ModuleManagerTest.assertOverrides(m1, "javax.swing.JPanel");
103
            ModuleManagerTest.assertOverrides(m1, "javax.naming.Context");
104
                ModuleManagerTest.assertOverrides(m1, "javax.swing.text.Document");
104
            ModuleManagerTest.assertDoesNotOverride(m1, "javax.naming.spi.Resolver");
105
                ModuleManagerTest.assertOverrides(m1, "javax.naming.Context");
105
            ModuleManagerTest.assertDoesNotOverride(m2, "javax.net.SocketFactory");
106
                ModuleManagerTest.assertDoesNotOverride(m1, "javax.naming.spi.Resolver");
106
            ModuleManagerTest.assertOverrides(m2, "javax.swing.JPanel");
107
                ModuleManagerTest.assertDoesNotOverride(m2, "javax.net.SocketFactory");
107
            ModuleManagerTest.assertOverrides(m2, "javax.swing.text.Document");
108
                ModuleManagerTest.assertOverrides(m2, "javax.swing.JPanel");
108
            ModuleManagerTest.assertOverrides(m2, "javax.naming.Context");
109
                ModuleManagerTest.assertOverrides(m2, "javax.swing.text.Document");
109
            ModuleManagerTest.assertDoesNotOverride(m2, "javax.naming.spi.Resolver");
110
                ModuleManagerTest.assertOverrides(m2, "javax.naming.Context");
110
            ModuleManagerTest.assertDoesNotOverride(m3, "javax.net.SocketFactory");
111
                ModuleManagerTest.assertDoesNotOverride(m2, "javax.naming.spi.Resolver");
111
            ModuleManagerTest.assertDoesNotOverride(m3, "javax.swing.JPanel");
112
                ModuleManagerTest.assertDoesNotOverride(m3, "javax.net.SocketFactory");
112
            ModuleManagerTest.assertDoesNotOverride(m3, "javax.swing.text.Document");
113
                ModuleManagerTest.assertDoesNotOverride(m3, "javax.swing.JPanel");
113
            ModuleManagerTest.assertDoesNotOverride(m3, "javax.naming.Context");
114
                ModuleManagerTest.assertDoesNotOverride(m3, "javax.swing.text.Document");
114
            ModuleManagerTest.assertDoesNotOverride(m3, "javax.naming.spi.Resolver");
115
                ModuleManagerTest.assertDoesNotOverride(m3, "javax.naming.Context");
115
            // #159586: masked JRE classes should not be accessible from SCL either.
116
                ModuleManagerTest.assertDoesNotOverride(m3, "javax.naming.spi.Resolver");
116
            ClassLoader scl = mgr.getClassLoader();
117
                // #159586: masked JRE classes should not be accessible from SCL either.
117
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.net.SocketFactory");
118
                ClassLoader scl = mgr.getClassLoader();
118
            ModuleManagerTest.assertOverrides(scl, "system class loader", "javax.swing.JPanel");
119
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.net.SocketFactory");
119
            ModuleManagerTest.assertOverrides(scl, "system class loader", "javax.swing.text.Document");
120
                ModuleManagerTest.assertOverrides(scl, "system class loader", "javax.swing.JPanel");
120
            ModuleManagerTest.assertOverrides(scl, "system class loader", "javax.naming.Context");
121
                ModuleManagerTest.assertOverrides(scl, "system class loader", "javax.swing.text.Document");
121
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.naming.spi.Resolver");
122
                ModuleManagerTest.assertOverrides(scl, "system class loader", "javax.naming.Context");
122
            mgr.disable(new HashSet<Module>(Arrays.asList(m1, m2, m3)));
123
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.naming.spi.Resolver");
123
            scl = mgr.getClassLoader();
124
                mgr.disable(new HashSet<Module>(Arrays.asList(m1, m2, m3)));
124
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.net.SocketFactory");
125
                scl = mgr.getClassLoader();
125
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.swing.JPanel");
126
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.net.SocketFactory");
126
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.swing.text.Document");
127
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.swing.JPanel");
127
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.naming.Context");
128
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.swing.text.Document");
128
            ModuleManagerTest.assertDoesNotOverride(scl, "javax.naming.spi.Resolver");
129
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.naming.Context");
129
        } finally {
130
                ModuleManagerTest.assertDoesNotOverride(scl, "javax.naming.spi.Resolver");
130
            mgr.mutexPrivileged().exitWriteAccess();
131
                return null;
131
        }
132
            }
133
        });
132
    }
134
    }
133
135
134
    @Override
136
    @Override
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbInstallerTest2.java (-20 / +22 lines)
Lines 51-56 Link Here
51
import org.netbeans.Module;
51
import org.netbeans.Module;
52
import org.netbeans.ModuleManager;
52
import org.netbeans.ModuleManager;
53
import org.openide.filesystems.FileUtil;
53
import org.openide.filesystems.FileUtil;
54
import org.openide.util.Mutex.ExceptionAction;
54
55
55
/** Test the NetBeans module installer implementation.
56
/** Test the NetBeans module installer implementation.
56
 * Broken into pieces to ensure each runs in its own VM.
57
 * Broken into pieces to ensure each runs in its own VM.
Lines 72-99 Link Here
72
        Main.getModuleSystem (); // init module system
73
        Main.getModuleSystem (); // init module system
73
        final MockEvents ev = new MockEvents();
74
        final MockEvents ev = new MockEvents();
74
        NbInstaller installer = new NbInstaller(ev);
75
        NbInstaller installer = new NbInstaller(ev);
75
        ModuleManager mgr = new ModuleManager(installer, ev);
76
        final ModuleManager mgr = new ModuleManager(installer, ev);
76
        installer.registerManager(mgr);
77
        installer.registerManager(mgr);
77
        mgr.mutexPrivileged().enterWriteAccess();
78
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
78
        try {
79
            @Override
79
            Locale orig = Locale.getDefault();
80
            public Void run() throws Exception {
80
            Locale.setDefault(new Locale("cs", "CZ"));
81
                Locale orig = Locale.getDefault();
81
            try {
82
                Locale.setDefault(new Locale("cs", "CZ"));
82
                Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
83
                try {
83
                assertEquals(Collections.EMPTY_SET, m1.getProblems());
84
                    Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
84
                assertEquals(null, slurp("foo/file1.txt"));
85
                    assertEquals(Collections.EMPTY_SET, m1.getProblems());
85
                mgr.enable(m1);
86
                    assertEquals(null, slurp("foo/file1.txt"));
86
                assertEquals("prekladany obsah", slurp("foo/file1.txt"));
87
                    mgr.enable(m1);
87
                assertEquals("base contents", slurp("foo/file2.txt"));
88
                    assertEquals("prekladany obsah", slurp("foo/file1.txt"));
88
                assertEquals("someval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
89
                    assertEquals("base contents", slurp("foo/file2.txt"));
89
                mgr.disable(m1);
90
                    assertEquals("someval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
90
                mgr.delete(m1);
91
                    mgr.disable(m1);
91
            } finally {
92
                    mgr.delete(m1);
92
                Locale.setDefault(orig);
93
                } finally {
94
                    Locale.setDefault(orig);
95
                }
96
                return null;
93
            }
97
            }
94
        } finally {
98
        });
95
            mgr.mutexPrivileged().exitWriteAccess();
96
        }
97
    }
99
    }
98
100
99
}
101
}
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbInstallerTest3.java (-18 / +20 lines)
Lines 49-54 Link Here
49
import java.util.Collections;
49
import java.util.Collections;
50
import org.netbeans.Module;
50
import org.netbeans.Module;
51
import org.netbeans.ModuleManager;
51
import org.netbeans.ModuleManager;
52
import org.openide.util.Mutex.ExceptionAction;
52
import org.openide.util.NbBundle;
53
import org.openide.util.NbBundle;
53
54
54
/** Test the NetBeans module installer implementation.
55
/** Test the NetBeans module installer implementation.
Lines 66-91 Link Here
66
        Main.getModuleSystem ();
67
        Main.getModuleSystem ();
67
        final MockEvents ev = new MockEvents();
68
        final MockEvents ev = new MockEvents();
68
        NbInstaller installer = new NbInstaller(ev);
69
        NbInstaller installer = new NbInstaller(ev);
69
        ModuleManager mgr = new ModuleManager(installer, ev);
70
        final ModuleManager mgr = new ModuleManager(installer, ev);
70
        installer.registerManager(mgr);
71
        installer.registerManager(mgr);
71
        mgr.mutexPrivileged().enterWriteAccess();
72
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
72
        try {
73
            @Override
73
            String orig = NbBundle.getBranding();
74
            public Void run() throws Exception {
74
            NbBundle.setBranding("foo");
75
                String orig = NbBundle.getBranding();
75
            try {
76
                NbBundle.setBranding("foo");
76
                Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
77
                try {
77
                assertEquals(Collections.EMPTY_SET, m1.getProblems());
78
                    Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
78
                mgr.enable(m1);
79
                    assertEquals(Collections.EMPTY_SET, m1.getProblems());
79
                assertEquals("special contents", slurp("foo/file1.txt"));
80
                    mgr.enable(m1);
80
                assertEquals(null, slurp("foo/file2.txt"));
81
                    assertEquals("special contents", slurp("foo/file1.txt"));
81
                mgr.disable(m1);
82
                    assertEquals(null, slurp("foo/file2.txt"));
82
                mgr.delete(m1);
83
                    mgr.disable(m1);
83
            } finally {
84
                    mgr.delete(m1);
84
                NbBundle.setBranding(orig);
85
                } finally {
86
                    NbBundle.setBranding(orig);
87
                }
88
                return null;
85
            }
89
            }
86
        } finally {
90
        });
87
            mgr.mutexPrivileged().exitWriteAccess();
88
        }
89
    }
91
    }
90
    
92
    
91
}
93
}
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbInstallerTest4.java (-26 / +28 lines)
Lines 54-59 Link Here
54
import org.netbeans.ModuleManager;
54
import org.netbeans.ModuleManager;
55
import org.netbeans.Stamps;
55
import org.netbeans.Stamps;
56
import org.openide.filesystems.FileUtil;
56
import org.openide.filesystems.FileUtil;
57
import org.openide.util.Mutex.ExceptionAction;
57
58
58
/** Test the NetBeans module installer implementation.
59
/** Test the NetBeans module installer implementation.
59
 * Broken into pieces to ensure each runs in its own VM.
60
 * Broken into pieces to ensure each runs in its own VM.
Lines 72-104 Link Here
72
        Main.getModuleSystem (); // init module system
73
        Main.getModuleSystem (); // init module system
73
        final MockEvents ev = new MockEvents();
74
        final MockEvents ev = new MockEvents();
74
        NbInstaller installer = new NbInstaller(ev);
75
        NbInstaller installer = new NbInstaller(ev);
75
        ModuleManager mgr = new ModuleManager(installer, ev);
76
        final ModuleManager mgr = new ModuleManager(installer, ev);
76
        installer.registerManager(mgr);
77
        installer.registerManager(mgr);
77
        mgr.mutexPrivileged().enterWriteAccess();
78
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
78
        try {
79
            @Override
79
            Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
80
            public Void run() throws Exception {
80
            Module m2 = mgr.create(new File(jars, "override-layer-mod.jar"), null, false, false, false);
81
                Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
81
            assertEquals(Collections.EMPTY_SET, m2.getProblems());
82
                Module m2 = mgr.create(new File(jars, "override-layer-mod.jar"), null, false, false, false);
82
            assertEquals(null, slurp("foo/file1.txt"));
83
                assertEquals(Collections.EMPTY_SET, m2.getProblems());
83
            assertEquals(null, slurp("foo/file3.txt"));
84
                assertEquals(null, slurp("foo/file1.txt"));
84
            assertEquals(null, slurp("foo/file4.txt"));
85
                assertEquals(null, slurp("foo/file3.txt"));
85
            Set<Module> m1m2 = new HashSet<Module>(Arrays.asList(m1, m2));
86
                assertEquals(null, slurp("foo/file4.txt"));
86
            mgr.enable(m1m2);
87
                Set<Module> m1m2 = new HashSet<Module>(Arrays.asList(m1, m2));
87
            
88
                mgr.enable(m1m2);
88
            Stamps.getModulesJARs().flush(0);
89
89
            Stamps.getModulesJARs().shutdown();
90
                Stamps.getModulesJARs().flush(0);
90
            
91
                Stamps.getModulesJARs().shutdown();
91
            assertEquals("base contents", slurp("foo/file1.txt"));
92
92
            assertEquals("customized contents", slurp("foo/file3.txt"));
93
                assertEquals("base contents", slurp("foo/file1.txt"));
93
            assertEquals(null, slurp("foo/file4.txt"));
94
                assertEquals("customized contents", slurp("foo/file3.txt"));
94
            assertEquals("someotherval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
95
                assertEquals(null, slurp("foo/file4.txt"));
95
            mgr.disable(m1m2);
96
                assertEquals("someotherval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
96
            assertEquals(null, slurp("foo/file1.txt"));
97
                mgr.disable(m1m2);
97
            mgr.delete(m2);
98
                assertEquals(null, slurp("foo/file1.txt"));
98
            mgr.delete(m1);
99
                mgr.delete(m2);
99
        } finally {
100
                mgr.delete(m1);
100
            mgr.mutexPrivileged().exitWriteAccess();
101
                return null;
101
        }
102
            }
103
        });
102
    }
104
    }
103
105
104
}
106
}
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbInstallerTest5.java (-29 / +31 lines)
Lines 50-55 Link Here
50
import org.netbeans.Module;
50
import org.netbeans.Module;
51
import org.netbeans.ModuleManager;
51
import org.netbeans.ModuleManager;
52
import org.openide.filesystems.FileUtil;
52
import org.openide.filesystems.FileUtil;
53
import org.openide.util.Mutex.ExceptionAction;
53
54
54
/** Test the NetBeans module installer implementation.
55
/** Test the NetBeans module installer implementation.
55
 * Broken into pieces to ensure each runs in its own VM.
56
 * Broken into pieces to ensure each runs in its own VM.
Lines 71-106 Link Here
71
                .lookup(org.openide.modules.ModuleInfo.class)); // TEMP
72
                .lookup(org.openide.modules.ModuleInfo.class)); // TEMP
72
        final MockEvents ev = new MockEvents();
73
        final MockEvents ev = new MockEvents();
73
        NbInstaller installer = new NbInstaller(ev);
74
        NbInstaller installer = new NbInstaller(ev);
74
        ModuleManager mgr = new ModuleManager(installer, ev);
75
        final ModuleManager mgr = new ModuleManager(installer, ev);
75
        installer.registerManager(mgr);
76
        installer.registerManager(mgr);
76
        mgr.mutexPrivileged().enterWriteAccess();
77
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
77
        try {
78
            @Override
78
            Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
79
            public Void run() throws Exception {
79
            Module m2 = mgr.create(new File(jars, "override-layer-mod.jar"), null, false, false, false);
80
                Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
80
            
81
                Module m2 = mgr.create(new File(jars, "override-layer-mod.jar"), null, false, false, false);
81
            assertEquals(Collections.EMPTY_SET, m2.getProblems());
82
82
            assertEquals(null, slurp("foo/file1.txt"));
83
                assertEquals(Collections.EMPTY_SET, m2.getProblems());
83
            assertEquals(null, slurp("foo/file3.txt"));
84
                assertEquals(null, slurp("foo/file1.txt"));
84
            assertEquals(null, slurp("foo/file4.txt"));
85
                assertEquals(null, slurp("foo/file3.txt"));
85
            mgr.enable(m1);
86
                assertEquals(null, slurp("foo/file4.txt"));
86
            assertEquals("base contents", slurp("foo/file1.txt"));
87
                mgr.enable(m1);
87
            assertEquals("base contents", slurp("foo/file3.txt"));
88
                assertEquals("base contents", slurp("foo/file1.txt"));
88
            assertEquals("base contents", slurp("foo/file4.txt"));
89
                assertEquals("base contents", slurp("foo/file3.txt"));
89
            assertEquals("someval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
90
                assertEquals("base contents", slurp("foo/file4.txt"));
90
            mgr.enable(m2);
91
                assertEquals("someval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
91
            assertEquals("base contents", slurp("foo/file1.txt"));
92
                mgr.enable(m2);
92
            assertEquals(null, slurp("foo/file4.txt"));
93
                assertEquals("base contents", slurp("foo/file1.txt"));
93
            assertEquals("customized contents", slurp("foo/file3.txt"));
94
                assertEquals(null, slurp("foo/file4.txt"));
94
            assertEquals("someotherval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
95
                assertEquals("customized contents", slurp("foo/file3.txt"));
95
            mgr.disable(m2);
96
                assertEquals("someotherval", FileUtil.getConfigFile("foo/file5.txt").getAttribute("myattr"));
96
            assertEquals("base contents", slurp("foo/file3.txt"));
97
                mgr.disable(m2);
97
            mgr.disable(m1);
98
                assertEquals("base contents", slurp("foo/file3.txt"));
98
            assertEquals(null, slurp("foo/file3.txt"));
99
                mgr.disable(m1);
99
            mgr.delete(m2);
100
                assertEquals(null, slurp("foo/file3.txt"));
100
            mgr.delete(m1);
101
                mgr.delete(m2);
101
        } finally {
102
                mgr.delete(m1);
102
            mgr.mutexPrivileged().exitWriteAccess();
103
                return null;
103
        }
104
            }
105
        });
104
    }
106
    }
105
107
106
}
108
}
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/NbInstallerTest8.java (-16 / +18 lines)
Lines 53-58 Link Here
53
import org.netbeans.ModuleManager;
53
import org.netbeans.ModuleManager;
54
import junit.textui.TestRunner;
54
import junit.textui.TestRunner;
55
import org.netbeans.junit.NbTestSuite;
55
import org.netbeans.junit.NbTestSuite;
56
import org.openide.util.Mutex.ExceptionAction;
56
57
57
/** Test the NetBeans module installer implementation.
58
/** Test the NetBeans module installer implementation.
58
 * Broken into pieces to ensure each runs in its own VM.
59
 * Broken into pieces to ensure each runs in its own VM.
Lines 89-110 Link Here
89
     */
90
     */
90
    public void testEarlyModuleInfoLookup() throws Exception {
91
    public void testEarlyModuleInfoLookup() throws Exception {
91
        // Ought to load these modules:
92
        // Ought to load these modules:
92
        ModuleManager mgr = Main.getModuleSystem().getManager();
93
        final ModuleManager mgr = Main.getModuleSystem().getManager();
93
        mgr.mutexPrivileged().enterWriteAccess();
94
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
94
        try {
95
            @Override
95
            Module m = mgr.get("lookformyself");
96
            public Void run() throws Exception {
96
            assertNull(m);
97
                Module m = mgr.get("lookformyself");
97
            m = mgr.create(moduleJar, new ModuleHistory(moduleJar.getAbsolutePath()), false, false, false);
98
                assertNull(m);
98
            assertEquals("look-for-myself.jar can be enabled", Collections.EMPTY_SET, m.getProblems());
99
                m = mgr.create(moduleJar, new ModuleHistory(moduleJar.getAbsolutePath()), false, false, false);
99
            mgr.enable(m);
100
                assertEquals("look-for-myself.jar can be enabled", Collections.EMPTY_SET, m.getProblems());
100
            Class<?> c = m.getClassLoader().loadClass("lookformyself.Loder");
101
                mgr.enable(m);
101
            Method meth = c.getMethod("foundNow");
102
                Class<?> c = m.getClassLoader().loadClass("lookformyself.Loder");
102
            assertTrue("ModuleInfo is found after startup", (Boolean) meth.invoke(null));
103
                Method meth = c.getMethod("foundNow");
103
            Field f = c.getField("foundEarly");
104
                assertTrue("ModuleInfo is found after startup", (Boolean) meth.invoke(null));
104
            assertTrue("ModuleInfo is found during dataloader section initialization", (Boolean) f.get(null));
105
                Field f = c.getField("foundEarly");
105
        } finally {
106
                assertTrue("ModuleInfo is found during dataloader section initialization", (Boolean) f.get(null));
106
            mgr.mutexPrivileged().exitWriteAccess();
107
                return null;
107
        }
108
            }
109
        });
108
    }
110
    }
109
    
111
    
110
}
112
}
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/PlatformDependencySatisfiedTest.java (-15 / +17 lines)
Lines 55-60 Link Here
55
import java.util.jar.Manifest;
55
import java.util.jar.Manifest;
56
import org.netbeans.Module;
56
import org.netbeans.Module;
57
import org.netbeans.ModuleManager;
57
import org.netbeans.ModuleManager;
58
import org.openide.util.Mutex.ExceptionAction;
58
import org.openide.util.Utilities;
59
import org.openide.util.Utilities;
59
60
60
/** Checks whether a module with generated
61
/** Checks whether a module with generated
Lines 175-181 Link Here
175
        assertEnableModule("org.openide.modules.os.OS2", true);
176
        assertEnableModule("org.openide.modules.os.OS2", true);
176
    }
177
    }
177
    
178
    
178
    private void assertEnableModule(String req, boolean enable) throws Exception {
179
    private void assertEnableModule(String req, final boolean enable) throws Exception {
179
        Manifest man = new Manifest ();
180
        Manifest man = new Manifest ();
180
        man.getMainAttributes ().putValue ("Manifest-Version", "1.0");
181
        man.getMainAttributes ().putValue ("Manifest-Version", "1.0");
181
        man.getMainAttributes ().putValue ("OpenIDE-Module", "org.test.PlatformDependency/1");
182
        man.getMainAttributes ().putValue ("OpenIDE-Module", "org.test.PlatformDependency/1");
Lines 189-211 Link Here
189
        
190
        
190
        final MockEvents ev = new MockEvents();
191
        final MockEvents ev = new MockEvents();
191
        NbInstaller installer = new NbInstaller(ev);
192
        NbInstaller installer = new NbInstaller(ev);
192
        ModuleManager mgr = new ModuleManager(installer, ev);
193
        final ModuleManager mgr = new ModuleManager(installer, ev);
193
        ModuleFormatSatisfiedTest.addOpenideModules(mgr);
194
        ModuleFormatSatisfiedTest.addOpenideModules(mgr);
194
        installer.registerManager(mgr);
195
        installer.registerManager(mgr);
195
        mgr.mutexPrivileged().enterWriteAccess();
196
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
196
        try {
197
            @Override
197
            Module m1 = mgr.create(moduleJarFile, null, false, false, false);
198
            public Void run() throws Exception {
198
            if (enable) {
199
                Module m1 = mgr.create(moduleJarFile, null, false, false, false);
199
                assertEquals(Collections.EMPTY_SET, m1.getProblems());
200
                if (enable) {
200
                mgr.enable(m1);
201
                    assertEquals(Collections.EMPTY_SET, m1.getProblems());
201
                mgr.disable(m1);
202
                    mgr.enable(m1);
202
            } else {
203
                    mgr.disable(m1);
203
                assertFalse("We should not be able to enable the module", m1.getProblems().isEmpty());
204
                } else {
205
                    assertFalse("We should not be able to enable the module", m1.getProblems().isEmpty());
206
                }
207
                mgr.delete(m1);
208
                return null;
204
            }
209
            }
205
            mgr.delete(m1);
210
        });
206
        } finally {
207
            mgr.mutexPrivileged().exitWriteAccess();
208
        }
209
    }
211
    }
210
212
211
}
213
}
(-)a/core.startup/test/unit/src/org/netbeans/core/startup/layers/SystemFileSystemTest.java (-54 / +84 lines)
Lines 60-65 Link Here
60
import org.netbeans.core.startup.MainLookup;
60
import org.netbeans.core.startup.MainLookup;
61
import org.netbeans.SetupHid;
61
import org.netbeans.SetupHid;
62
import org.openide.filesystems.FileAttributeEvent;
62
import org.openide.filesystems.FileAttributeEvent;
63
import org.openide.filesystems.FileChangeAdapter;
63
import org.openide.filesystems.FileChangeListener;
64
import org.openide.filesystems.FileChangeListener;
64
import org.openide.filesystems.FileEvent;
65
import org.openide.filesystems.FileEvent;
65
import org.openide.filesystems.FileObject;
66
import org.openide.filesystems.FileObject;
Lines 68-73 Link Here
68
import org.openide.filesystems.FileUtil;
69
import org.openide.filesystems.FileUtil;
69
import org.openide.modules.ModuleInfo;
70
import org.openide.modules.ModuleInfo;
70
import org.openide.util.Lookup;
71
import org.openide.util.Lookup;
72
import org.openide.util.Mutex.ExceptionAction;
71
import org.openide.util.lookup.InstanceContent;
73
import org.openide.util.lookup.InstanceContent;
72
74
73
/** Test layering of filesystems installed via lookup.
75
/** Test layering of filesystems installed via lookup.
Lines 194-261 Link Here
194
    }
196
    }
195
    
197
    
196
    public void testPreferenceOfLayersNowDynamicSystemsCanHideWhatComesFromLayers() throws Exception {
198
    public void testPreferenceOfLayersNowDynamicSystemsCanHideWhatComesFromLayers() throws Exception {
197
        ModuleManager mgr = Main.getModuleSystem ().getManager();
199
        final ModuleManager mgr = Main.getModuleSystem ().getManager();
198
        mgr.mutexPrivileged().enterWriteAccess();
200
        final FileObject[] glob = { null };
199
        Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
201
        mgr.mutex().writeAccess(new ExceptionAction<Void>() {
200
        FileObject global;
202
            @Override
201
        try {
203
            public Void run() throws Exception {
202
            assertEquals(Collections.EMPTY_SET, m1.getProblems());
204
                Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
203
            mgr.enable(m1);
205
                FileObject global;
204
            global = FileUtil.getConfigFile("foo/file2.txt");
206
                try {
205
            assertNotNull("File Object installed: " + global, global);
207
                    assertEquals(Collections.EMPTY_SET, m1.getProblems());
206
            assertEquals("base contents", read(global));
208
                    mgr.enable(m1);
207
            
209
                    global = FileUtil.getConfigFile("foo/file2.txt");
208
            FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath());
210
                    glob[0] = global;
209
            fo1.setAttribute("one", 1);
211
                    assertNotNull("File Object installed: " + global, global);
210
            write(fo1, "fileone");
212
                    assertEquals("base contents", read(global));
211
213
212
            FileObject fo2 = FileUtil.createData(fs2.getRoot(), global.getPath());
214
                    FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath());
213
            fo2.setAttribute("two", 2);
215
                    fo1.setAttribute("one", 1);
214
            write(fo2, "two");
216
                    write(fo1, "fileone");
215
217
216
            events.clear();
218
                    FileObject fo2 = FileUtil.createData(fs2.getRoot(), global.getPath());
219
                    fo2.setAttribute("two", 2);
220
                    write(fo2, "two");
217
221
218
            MainLookup.register(fs1, this);
222
                    events.clear();
219
            MainLookup.register(fs2, this);
223
220
            
224
                    MainLookup.register(fs1, SystemFileSystemTest.this);
221
            Iterator<? extends FileSystem> it = Lookup.getDefault().lookupAll(FileSystem.class).iterator();
225
                    MainLookup.register(fs2, SystemFileSystemTest.this);
222
            assertTrue("At least One", it.hasNext());
226
223
            assertEquals("first is fs1", fs1, it.next());
227
                    Iterator<? extends FileSystem> it = Lookup.getDefault().lookupAll(FileSystem.class).iterator();
224
            assertTrue("At least two ", it.hasNext());
228
                    assertTrue("At least One", it.hasNext());
225
            assertEquals("first is fs2", fs2, it.next());
229
                    assertEquals("first is fs1", fs1, it.next());
226
            
230
                    assertTrue("At least two ", it.hasNext());
227
            assertEquals("fileone", read(global));
231
                    assertEquals("first is fs2", fs2, it.next());
228
        } finally {
232
229
            mgr.disable(m1);
233
                    assertEquals("fileone", read(global));
230
            mgr.delete(m1);
234
                } finally {
231
            mgr.mutexPrivileged().exitWriteAccess();
235
                    mgr.disable(m1);
232
        }
236
                    mgr.delete(m1);
233
        assertTrue("Still valid", global.isValid());
237
                }
234
        assertEquals("fileone", read(global));
238
                return null;
239
            }
240
        });
241
        assertTrue("Still valid", glob[0].isValid());
242
        assertEquals("fileone", read(glob[0]));
235
    }
243
    }
236
    
244
    
237
    public void testCanHideFilesFromModules() throws Exception {
245
    public void testCanHideFilesFromModules() throws Exception {
238
        ModuleManager mgr = Main.getModuleSystem ().getManager();
246
        final ModuleManager mgr = Main.getModuleSystem ().getManager();
239
        mgr.mutexPrivileged().enterWriteAccess();
240
        Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
241
        try {
242
            assertEquals(Collections.EMPTY_SET, m1.getProblems());
243
            mgr.enable(m1);
244
            FileObject global = FileUtil.getConfigFile("foo/file2.txt");
245
            assertNotNull("File Object installed: " + global, global);
246
            assertEquals("base contents", read(global));
247
            
248
            FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath() + "_hidden");
249
247
250
            events.clear();
251
            MainLookup.register(fs1, this);
252
248
253
            assertNull("No longer findable", global.getFileSystem().findResource(global.getPath()));
249
        class L extends FileChangeAdapter {
254
            assertFalse("Is not valid anymore", global.isValid());
250
            int cnt;
255
        } finally {
251
256
            mgr.disable(m1);
252
            @Override
257
            mgr.delete(m1);
253
            public void fileDeleted(FileEvent fe) {
258
            mgr.mutexPrivileged().exitWriteAccess();
254
                assertFalse("Don't hold mutex", mgr.mutex().isReadAccess());
255
                assertFalse("Don't hold write mutex", mgr.mutex().isWriteAccess());
256
                cnt++;
257
            }
258
        }
259
        final L listener = new L();
260
        
261
        mgr.mutex().writeAccess(new ExceptionAction<Exception>() {
262
            @Override
263
            public Exception run() throws Exception {
264
                Module m1 = mgr.create(new File(jars, "base-layer-mod.jar"), null, false, false, false);
265
                try {
266
                    assertEquals(Collections.EMPTY_SET, m1.getProblems());
267
                    mgr.enable(m1);
268
                    FileObject global = FileUtil.getConfigFile("foo/file2.txt");
269
                    assertNotNull("File Object installed: " + global, global);
270
                    assertEquals("base contents", read(global));
271
                    global.getParent().addFileChangeListener(listener);
272
273
                    FileObject fo1 = FileUtil.createData(fs1.getRoot(), global.getPath() + "_hidden");
274
275
                    events.clear();
276
                    MainLookup.register(fs1, SystemFileSystemTest.this);
277
278
                    assertNull("No longer findable", global.getFileSystem().findResource(global.getPath()));
279
                    assertFalse("Is not valid anymore", global.isValid());
280
                } finally {
281
                    mgr.disable(m1);
282
                    mgr.delete(m1);
283
                }
284
                return null;
285
            }
286
        });
287
        if (listener.cnt == 0) {
288
            fail("File change should have been notified: " + listener.cnt);
259
        }
289
        }
260
    }
290
    }
261
    
291
    
(-)a/o.n.bootstrap/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.bootstrap/1
2
OpenIDE-Module: org.netbeans.bootstrap/1
3
OpenIDE-Module-Specification-Version: 2.41
3
OpenIDE-Module-Specification-Version: 2.42
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
6
6
(-)a/o.n.bootstrap/src/org/netbeans/ModuleInstaller.java (+11 lines)
Lines 48-53 Link Here
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.util.List;
49
import java.util.List;
50
import java.util.Set;
50
import java.util.Set;
51
import java.util.concurrent.Executor;
51
import java.util.jar.JarFile;
52
import java.util.jar.JarFile;
52
import java.util.jar.Manifest;
53
import java.util.jar.Manifest;
53
import org.openide.modules.Dependency;
54
import org.openide.modules.Dependency;
Lines 224-227 Link Here
224
        return null;
225
        return null;
225
    }
226
    }
226
227
228
    /** Executor to wrap operations in {@link ModuleManager#mutex()} to. 
229
     * Created to delay events about changes in filesystem until all other
230
     * attributes of enabled/disabled modules are ready.
231
     * 
232
     * @return by default <code>null</code>
233
     * @since 2.42
234
     */
235
    protected Executor executor() {
236
        return null;
237
    }
227
}
238
}
(-)a/o.n.bootstrap/src/org/netbeans/ModuleManager.java (-3 / +8 lines)
Lines 69-74 Link Here
69
import java.util.Set;
69
import java.util.Set;
70
import java.util.StringTokenizer;
70
import java.util.StringTokenizer;
71
import java.util.TreeSet;
71
import java.util.TreeSet;
72
import java.util.concurrent.Executor;
72
import java.util.jar.Manifest;
73
import java.util.jar.Manifest;
73
import java.util.logging.Level;
74
import java.util.logging.Level;
74
import org.openide.LifecycleManager;
75
import org.openide.LifecycleManager;
Lines 128-133 Link Here
128
     */
129
     */
129
    public ModuleManager(ModuleInstaller installer, Events ev) {
130
    public ModuleManager(ModuleInstaller installer, Events ev) {
130
        this.installer = installer;
131
        this.installer = installer;
132
        final Executor executor = installer.executor();
133
        this.MUTEX = executor != null ?
134
            new Mutex(MUTEX_PRIVILEGED, executor) :
135
            new Mutex(MUTEX_PRIVILEGED);
131
        this.ev = ev;
136
        this.ev = ev;
132
        String patches = System.getProperty("netbeans.systemclassloader.patches");
137
        String patches = System.getProperty("netbeans.systemclassloader.patches");
133
        if (patches != null) {
138
        if (patches != null) {
Lines 171-177 Link Here
171
    }
176
    }
172
177
173
    private final Mutex.Privileged MUTEX_PRIVILEGED = new Mutex.Privileged();
178
    private final Mutex.Privileged MUTEX_PRIVILEGED = new Mutex.Privileged();
174
    private final Mutex MUTEX = new Mutex(MUTEX_PRIVILEGED);
179
    private final Mutex MUTEX;
180
    
175
    /** Get a locking mutex for this module installer.
181
    /** Get a locking mutex for this module installer.
176
     * All calls other than adding or removing property change
182
     * All calls other than adding or removing property change
177
     * listeners, or getting the module lookup, called on this
183
     * listeners, or getting the module lookup, called on this
Lines 196-204 Link Here
196
        return MUTEX;
202
        return MUTEX;
197
    }
203
    }
198
    /** Classes in this package can, if careful, use the privileged form.
204
    /** Classes in this package can, if careful, use the privileged form.
199
     * @since JST-PENDING this had to be made public as the package is now split in two
200
     */
205
     */
201
    public final Mutex.Privileged mutexPrivileged() {
206
    final Mutex.Privileged mutexPrivileged() {
202
        return MUTEX_PRIVILEGED;
207
        return MUTEX_PRIVILEGED;
203
    }
208
    }
204
    // [PENDING] with improved API for Mutex, could throw
209
    // [PENDING] with improved API for Mutex, could throw

Return to bug 103159