Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2006-01-18 16:51:26 -0500
committerDJ Houghton2006-01-18 16:51:26 -0500
commitbb2a8409433c464b408eb69754eaf859828dd8d1 (patch)
treece5da87ed807c96e8336947b25a96184ec3c526c
parent259b422f97fd62d73d1217ac7755ae004e2584ca (diff)
downloadrt.equinox.bundles-bb2a8409433c464b408eb69754eaf859828dd8d1.tar.gz
rt.equinox.bundles-bb2a8409433c464b408eb69754eaf859828dd8d1.tar.xz
rt.equinox.bundles-bb2a8409433c464b408eb69754eaf859828dd8d1.zip
Bug 110994 - Can't garbage collect a Plugin that uses PluginPreferences
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java12
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java4
2 files changed, 10 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java
index 60a89f6d..2fb36d0e 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/DefaultPreferences.java
@@ -11,6 +11,7 @@
package org.eclipse.core.internal.preferences;
import java.io.*;
+import java.lang.ref.WeakReference;
import java.net.URL;
import java.util.*;
import org.eclipse.core.internal.runtime.RuntimeLog;
@@ -44,7 +45,8 @@ public class DefaultPreferences extends EclipsePreferences {
// cached values
private String qualifier;
private int segmentCount;
- private Object plugin;
+ private WeakReference pluginReference;
+
public static String pluginCustomizationFile = null;
@@ -57,14 +59,14 @@ public class DefaultPreferences extends EclipsePreferences {
private DefaultPreferences(EclipsePreferences parent, String name, Object context) {
this(parent, name);
- this.plugin = context;
+ this.pluginReference = new WeakReference(context);
}
private DefaultPreferences(EclipsePreferences parent, String name) {
super(parent, name);
if (parent instanceof DefaultPreferences)
- this.plugin = ((DefaultPreferences) parent).plugin;
+ this.pluginReference = ((DefaultPreferences) parent).pluginReference;
// cache the segment count
String path = absolutePath();
@@ -207,9 +209,11 @@ public class DefaultPreferences extends EclipsePreferences {
return;
// Do legacy plugin preference initialization
+ Object plugin = pluginReference.get();
ILegacyPreferences initService = PreferencesOSGiUtils.getDefault().getLegacyPreferences();
if (initService != null)
- initService.init(plugin, name());
+ plugin = initService.init(plugin, name());
+ pluginReference = new WeakReference(plugin);
}
/*
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java
index 7c03e185..9c4ce658 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/ILegacyPreferences.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,5 +25,5 @@ public interface ILegacyPreferences {
*
* @see Plugin#initializeDefaultPluginPreferences
*/
- public void init(Object object, String name);
+ public Object init(Object object, String name);
}

Back to the top