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 16265
Collapse All | Expand All

(-)core/src/org/netbeans/core/NbTopManager.java (-1 / +2 lines)
Lines 755-761 Link Here
755
    public ClassLoader systemClassLoader () {
755
    public ClassLoader systemClassLoader () {
756
        ModuleSystem ms = getModuleSystem();
756
        ModuleSystem ms = getModuleSystem();
757
        if (ms != null) {
757
        if (ms != null) {
758
            return ms.getManager().getClassLoader();
758
            // #16265: do not go straight to ModuleManager
759
            return ms.getSystemClassLoader();
759
        } else {
760
        } else {
760
            // This can be called very early: if lookup asks for ClassLoader.
761
            // This can be called very early: if lookup asks for ClassLoader.
761
            // For now, just give the startup classloader.
762
            // For now, just give the startup classloader.
(-)core/src/org/netbeans/core/modules/ModuleSystem.java (-14 / +33 lines)
Lines 114-144 Link Here
114
    /** Get the system classloader, for use from NbTopManager.
114
    /** Get the system classloader, for use from NbTopManager.
115
     * When it changes, NbTopManager will likewise be notified.
115
     * When it changes, NbTopManager will likewise be notified.
116
     */
116
     */
117
    public ClassLoader getSystemClassLoader() {
117
    public synchronized ClassLoader getSystemClassLoader() {
118
        if (! addedClassLoaderListener) {
118
        if (systemClassLoader == null) {
119
            addedClassLoaderListener = true;
119
            // First time this has been called. Set to dummy and change later.
120
            systemClassLoader = ModuleSystem.class.getClassLoader();
121
            // Check for future changes.
120
            class ListenerFirer implements PropertyChangeListener, Runnable {
122
            class ListenerFirer implements PropertyChangeListener, Runnable {
123
                // do not fire too frequently:
124
                private boolean needToChange = true;
121
                public void propertyChange(PropertyChangeEvent ev) {
125
                public void propertyChange(PropertyChangeEvent ev) {
122
                    if (ModuleManager.PROP_CLASS_LOADER.equals(ev.getPropertyName())) {
126
                    if (ModuleManager.PROP_CLASS_LOADER.equals(ev.getPropertyName())) {
123
                        // Exit read mutex first for safety.
127
                        // Get the new one in a write mutex.
128
                        needToChange = true;
124
                        RequestProcessor.postRequest(ListenerFirer.this);
129
                        RequestProcessor.postRequest(ListenerFirer.this);
125
                    }
130
                    }
126
                }
131
                }
127
                public void run() {
132
                public void run() {
128
                    NbTopManager.get().fireSystemClassLoaderChange();
133
                    if (needToChange) {
129
                    Util.err.log("fired change in system classloader");
134
                        needToChange = false;
135
                        // We got the change, now in write mutex get the new one.
136
                        ClassLoader nue;
137
                        mgr.mutexPrivileged().enterWriteAccess();
138
                        try {
139
                            nue = mgr.getClassLoader();
140
                        } finally {
141
                            mgr.mutexPrivileged().exitWriteAccess();
142
                        }
143
                        synchronized (ModuleSystem.this) {
144
                            systemClassLoader = nue;
145
                        }
146
                        NbTopManager.get().fireSystemClassLoaderChange();
147
                        Util.err.log("fired change in system classloader");
148
                    }
130
                }
149
                }
131
            }
150
            }
132
            mgr.addPropertyChangeListener(new ListenerFirer());
151
            ListenerFirer lf = new ListenerFirer();
133
        }
152
            mgr.addPropertyChangeListener(lf);
134
        mgr.mutexPrivileged().enterWriteAccess();
153
            // Also change ASAP to the real thing.
135
        try {
154
            RequestProcessor.postRequest(lf);
136
            return mgr.getClassLoader();
137
        } finally {
138
            mgr.mutexPrivileged().exitWriteAccess();
139
        }
155
        }
156
        return systemClassLoader;
140
    }
157
    }
141
    private boolean addedClassLoaderListener = false;
158
    // #16265: keep a local copy so that every call does not have to
159
    // enter the write mutex.
160
    private ClassLoader systemClassLoader = null;
142
    
161
    
143
    /** Produce a list of JAR files including all installed modules,
162
    /** Produce a list of JAR files including all installed modules,
144
     * their extensions, and enabled locale variants of both.
163
     * their extensions, and enabled locale variants of both.

Return to bug 16265