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.
Manifest-Version: 1.0
OpenIDE-Module: org.openide.util.lookup
OpenIDE-Module-Localizing-Bundle: org/openide/util/lookup/Bundle.properties
OpenIDE-Module-Specification-Version: 8.30
OpenIDE-Module-Specification-Version: 8.31
public class GlobalLookup {
private static final ThreadLocal<Lookup> CURRENT = new ThreadLocal<Lookup>();
/**
* The true system Lookup, the main, holy and only.
*/
private static volatile Lookup systemLookup;
private GlobalLookup() {
}
@SuppressWarnings("AssignmentToMethodParameter")
public static boolean execute(Lookup defaultLookup, Runnable r) {
if (defaultLookup == null) {
defaultLookup = systemLookup;
Lookup prev = CURRENT.get();
if (prev == defaultLookup) {
return false;
public static Lookup current() {
return CURRENT.get();
public static void setSystemLookup(Lookup lkp) {
systemLookup = lkp;
if (lkp != null) {
return lkp;
} else {
return defaultLookup;
LOG.log(Level.FINER, "About to initialize Lookup@{0}.getDefault() by {1}",
new Object[] { Lookup.class.getClassLoader(), Thread.currentThread() }
if (className != null) {
Object o = Class.forName(className, true, l).newInstance();
defaultLookup = (Lookup)o;
// set the global global Lookuo
GlobalLookup.setSystemLookup(defaultLookup);
LOG.log(Level.FINE, "Default lookup initialized {0}", defaultLookup);
// for testing purposes, tests may setup a class implementing both interfaces
if (o instanceof Lookup.Provider) {
if (o == null) {
o = SharedClassObjectBridge.newInstance(c);
Object other = CACHE.findInstance(c);
if (other != null) {
return object = other;
CACHE.storeInstance(o);