Eclipse 3.0 deprecation removal
diff --git a/plugins/org.eclipse.jem.proxy/plugin.xml b/plugins/org.eclipse.jem.proxy/plugin.xml index 1b298eb..2ab3d62 100644 --- a/plugins/org.eclipse.jem.proxy/plugin.xml +++ b/plugins/org.eclipse.jem.proxy/plugin.xml
@@ -53,7 +53,9 @@ delegate="org.eclipse.jem.internal.proxy.remote.LocalProxyLaunchDelegate" category="org.eclipse.jem.proxy" modes="run" - id="org.eclipse.jem.proxy.LocalProxyLaunchConfigurationType"> + id="org.eclipse.jem.proxy.LocalProxyLaunchConfigurationType" + sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector" + sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"> </launchConfigurationType> </extension>
diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java index 1e84f21..e06842b 100644 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java +++ b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/IConfigurationContributionController.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: IConfigurationContributionController.java,v $ - * $Revision: 1.4 $ $Date: 2004/05/24 15:57:24 $ + * $Revision: 1.5 $ $Date: 2004/06/02 15:57:12 $ */ import org.eclipse.core.resources.IProject; @@ -103,38 +103,7 @@ * @since 1.0.0 */ public void contributeClasspath(String[] classpaths, int typeFlag); - - /** - * Add a file/folder from a plugin in the running Eclipse to the classpath. The type flag tells where to add it. - * In development mode it will find the bin class files instead if proxy.jars is setup correctly. - * <p> - * If nlsLocalize is <code>true</code>, then it will also search through the fragments in this manner: - * (Note: if <code>false</code> it will still search in the fragments, but it will only return the first file found that matches. - * <p> - * To find the files in the fragments that are in the runtime path (i.e. libraries), it will need to use a suffix, - * This is because the JDT will get confused if a runtime jar in a fragment has the same name - * as a runtime jar in the main plugin. So we will use the following search pattern: - * - * 1) Find in the plugin and all of the fragments those that match the name exactly - * 2) Find in all of the fragments, in their runtime path (<library> stmt), those that match the name - * but have a suffix the same as the uniqueid of the fragment (preceeded by a period). This is so that it can be easily - * found but yet be unique in the entire list of fragments. For example if looking for "runtime/xyz.jar" - * and we have fragment "a.b.c.d.frag", then in the runtime path we will look for the file - * "runtime/xyz.a.b.c.d.frag.jar". - * <p> - * If the files in the fragments are not in the fragments library path then it can have the same name as in the plugin. - * <p> - * This is useful for nls where the nls for the filename will be in one or more of the fragments of the plugin. - * - * @param pluginDescriptor The plugin descriptor it can be found in. - * @param relativePath Path to file/folder relative to bundle root. If it is <code>APPEND_JAVA_LIBRARY_PATH</code>, it should be folder and nlsLocalize will be ignored. - * @param typeFlag One of <code>APPEND_USER_CLASSPATH</code>, <code>APPEND_BOOT_CLASSPATH</code>, <code>PREPEND_BOOT_CLASSPATH</code>, or <code>APPEND_JAVA_LIBRARY_PATH</code>. - * @param nlsLocalize The usual value should be <code>false</code>. Use <code>true</code> if should look through fragments to gather them all as described in this methods description. - * @deprecated use contributeClasspath(Bundle, String, int, boolean) instead. - * @since 1.0.0 - */ - public void contributeClasspath(org.eclipse.core.runtime.IPluginDescriptor plugin, String relativePath, int typeFlag, boolean nlsLocalize); - + /** * Add a file/folder from a plugin in the running Eclipse to the classpath. The type flag tells where to add it. * In development mode it will find the bin class files instead if proxy.jars is setup correctly.
diff --git a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java index 262b9eb..cb2f4fa 100644 --- a/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java +++ b/plugins/org.eclipse.jem.proxy/proxy/org/eclipse/jem/internal/proxy/core/ProxyPlugin.java
@@ -11,7 +11,7 @@ *******************************************************************************/ /* * $RCSfile: ProxyPlugin.java,v $ - * $Revision: 1.21 $ $Date: 2004/06/01 23:51:45 $ + * $Revision: 1.22 $ $Date: 2004/06/02 15:57:12 $ */ @@ -91,20 +91,6 @@ return logger; } - - /** - * This is just helper for when have a Plugin. Use one bundle when have a bundle. - * - * @param plugin - * @param fileNameWithinPlugin - * @return - * @see ProxyPlugin#localizeFromBundle(Bundle, String) - * @since 1.0.0 - */ - public String localizeFromPlugin(Plugin plugin, String fileNameWithinPlugin) { - return localizeFromBundle(plugin.getBundle(), fileNameWithinPlugin); - } - /** * * @param pluginDescriptor @@ -198,18 +184,6 @@ /** - * - * @param pluginDescriptor - * @param filenameWithinPlugin - * @return - * @deprecated see urlLocalizeFromPluginDescriptorAndFragments(Bundle, String) instead. - * @since 1.0.0 - */ - public URL[] urlLocalizeFromPluginDescriptorAndFragments(IPluginDescriptor pluginDescriptor, String filenameWithinPlugin) { - return urlLocalizeFromBundleAndFragments(Platform.getBundle(pluginDescriptor.getUniqueIdentifier()), filenameWithinPlugin); - } - - /** * Like <code>localizeFromBundleAndFragments</code> except it returns URL's instead. * @param bundle * @param filenameWithinBundle @@ -274,21 +248,6 @@ private static final IPath PROXYJARS_PATH = new Path("proxy.jars"); /** - * @see ProxyPlugin#localizeFromPluginDescriptor(IPluginDescriptor, String) - * - * This is just a helper to return a url instead. - * - * @param pluginDescriptor - * @param filenameWithinPlugin - * @return - * @deprecated use urlLocalizeFromPluginDescriptor(Bundle, String) instead. - * @since 1.0.0 - */ - public URL urlLocalizeFromPluginDescriptor(IPluginDescriptor pluginDescriptor, String filenameWithinPlugin) { - return urlLocalizeFromBundle(Platform.getBundle(pluginDescriptor.getUniqueIdentifier()), filenameWithinPlugin); - } - - /** * @see ProxyPlugin#localizeFromBundle(Bundle, String) * * This is just a helper to return a url instead. @@ -304,21 +263,6 @@ } /** - * @see ProxyPlugin#localizeFromPluginDescriptor(IPluginDescriptor, String) - * - * This is just a helper to return a url instead. - * - * @param pluginDescriptor - * @param filenameWithinPlugin - * @return - * @deprecated use urlLocalizeFromPluginDescriptor(Bundle, IPath) instead. - * @since 1.0.0 - */ - public URL urlLocalizeFromPluginDescriptor(IPluginDescriptor pluginDescriptor, IPath filenameWithinPlugin) { - return urlLocalizeFromBundle(Platform.getBundle(pluginDescriptor.getUniqueIdentifier()), filenameWithinPlugin); - } - - /** * @see ProxyPlugin#localizeFromBundle(bundle, String) * * This is just a helper to return a url instead. @@ -429,16 +373,51 @@ return result; } - private static List getPrereqs(Bundle bundle, Map prereqsMap) { - List dependents = (List) prereqsMap.get(bundle); - if (dependents == null) { - dependents = getPrereqs(bundle); - prereqsMap.put(bundle, dependents); - } - return dependents; + /** + * Get all of the prereqs for this bundle, all of the way down to the root. + * They will be in top-down depth-first order. There won't be duplicates. They will show up + * only once the first time they are found. + * + * @param bundle + * @return list of all pre-reqs. + * + * @since 1.0.0 + */ + public static List getAllPrereqs(Bundle bundle) { + List prereqs = new ArrayList(); + getAllPrereqs(bundle, prereqs, new HashMap()); + return prereqs; } - private static List getPrereqs(Bundle bundle) { + private static void getAllPrereqs(Bundle bundle, List prereqs, Map prereqsMap) { + List prs = getPrereqs(bundle, prereqsMap); + for (int i = 0; i < prs.size(); i++) { + Bundle pre = (Bundle) prs.get(i); + if (prereqsMap.containsKey(pre)) + continue; // Already processed this one once. + prereqs.add(pre); // Add to the list of pre-reqs accumulated so far. + getAllPrereqs(pre, prereqs, prereqsMap); + } + } + + private static List getPrereqs(Bundle bundle, Map prereqsMap) { + List prereqs = (List) prereqsMap.get(bundle); + if (prereqs == null) { + prereqs = getPrereqs(bundle); + prereqsMap.put(bundle, prereqs); + } + return prereqs; + } + + /** + * Get the immediate pre-req'ed bundles for this bundle. + * + * @param bundle + * @return the prereq'ed bundles. + * + * @since 1.0.0 + */ + public static List getPrereqs(Bundle bundle) { List requires = null; try { String requiresList = (String) bundle.getHeaders().get(Constants.REQUIRE_BUNDLE);
diff --git a/plugins/org.eclipse.jem.proxy/proxyRemote/org/eclipse/jem/internal/proxy/remote/LocalFileConfigurationContributorController.java b/plugins/org.eclipse.jem.proxy/proxyRemote/org/eclipse/jem/internal/proxy/remote/LocalFileConfigurationContributorController.java index 1b21f43..7d793b0 100644 --- a/plugins/org.eclipse.jem.proxy/proxyRemote/org/eclipse/jem/internal/proxy/remote/LocalFileConfigurationContributorController.java +++ b/plugins/org.eclipse.jem.proxy/proxyRemote/org/eclipse/jem/internal/proxy/remote/LocalFileConfigurationContributorController.java
@@ -10,7 +10,7 @@ *******************************************************************************/ /* * $RCSfile: LocalFileConfigurationContributorController.java,v $ - * $Revision: 1.4 $ $Date: 2004/05/24 15:57:24 $ + * $Revision: 1.5 $ $Date: 2004/06/02 15:57:12 $ */ package org.eclipse.jem.internal.proxy.remote; @@ -18,7 +18,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.core.*; import org.eclipse.jdt.launching.IRuntimeClasspathEntry; import org.eclipse.jdt.launching.JavaRuntime; @@ -206,14 +205,6 @@ else contributeClasspath(ProxyPlugin.getPlugin().localizeFromBundleAndFragments(bundle, relativePath), typeFlag); } - - /* (non-Javadoc) - * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionController#contributeClasspath(org.eclipse.core.runtime.Plugin, java.lang.String, int, boolean) - * - */ - public void contributeClasspath(org.eclipse.core.runtime.IPluginDescriptor pluginDescriptor, String relativePath, int typeFlag, boolean nlsLocalize) { - contributeClasspath(Platform.getBundle(pluginDescriptor.getUniqueIdentifier()), relativePath, typeFlag, nlsLocalize); - } /* (non-Javadoc) * @see org.eclipse.jem.internal.proxy.core.IConfigurationContributionController#contributeClasspath(java.lang.String[], int)
diff --git a/plugins/org.eclipse.jem.proxy/proxyide/org/eclipse/jem/internal/proxy/ide/IDEProxyFactoryRegistry.java b/plugins/org.eclipse.jem.proxy/proxyide/org/eclipse/jem/internal/proxy/ide/IDEProxyFactoryRegistry.java index c942d35..84e2865 100644 --- a/plugins/org.eclipse.jem.proxy/proxyide/org/eclipse/jem/internal/proxy/ide/IDEProxyFactoryRegistry.java +++ b/plugins/org.eclipse.jem.proxy/proxyide/org/eclipse/jem/internal/proxy/ide/IDEProxyFactoryRegistry.java
@@ -11,14 +11,14 @@ *******************************************************************************/ /* * $RCSfile: IDEProxyFactoryRegistry.java,v $ - * $Revision: 1.2 $ $Date: 2004/02/03 23:18:36 $ + * $Revision: 1.3 $ $Date: 2004/06/02 15:57:12 $ */ import java.net.URL; import java.net.URLClassLoader; -import org.eclipse.core.runtime.IPluginRegistry; import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; import org.eclipse.jem.internal.proxy.core.*; /** @@ -33,6 +33,42 @@ protected String fName; protected ClassLoader fClassLoader; protected IDECallbackRegistry fCallbackRegistry; + + /* + * Special classloader that firsts tries to load from bundle then tries from url paths so + * that bundle is treated as being at the head of the url paths. + * + * @since 1.0.0 + */ + private static class IDESpecialClassLoader extends URLClassLoader { + + private Bundle bundle; + /** + * @param urls + * + * @since 1.0.0 + */ + public IDESpecialClassLoader(URL[] urls, Bundle bundle) { + super(urls); + this.bundle = bundle; + } + + /* (non-Javadoc) + * @see java.lang.ClassLoader#findClass(java.lang.String) + */ + protected Class findClass(String name) throws ClassNotFoundException { + Class c = bundle.loadClass(name); + return c != null ? c : super.findClass(name); + } + + /* (non-Javadoc) + * @see java.lang.ClassLoader#findResource(java.lang.String) + */ + public URL findResource(String name) { + URL r = bundle.getResource(name); + return r != null ? r : super.findResource(name); + } +} /** * Create a special loader that has the plugin classloader of the passed in plugin @@ -40,15 +76,9 @@ * needed by IDE Proxy to work. */ public static ClassLoader createSpecialLoader(String pluginName, URL[] otherURLs) { - IPluginRegistry registry = Platform.getPluginRegistry(); - // Get the class loader from the plugin. This is because Class.forName - // does not work in Eclipse - ClassLoader loader = null; - if (pluginName != null && registry.getPluginDescriptor(pluginName) != null ) { - loader = registry.getPluginDescriptor(pluginName).getPluginClassLoader(); - } + Bundle bundle = Platform.getBundle(pluginName); - URL[] mustHaveUrls = ProxyPlugin.getPlugin().urlLocalizeFromPluginDescriptorAndFragments(ProxyPlugin.getPlugin().getDescriptor(), "vm/remotevm.jar"); //$NON-NLS-1$ + URL[] mustHaveUrls = ProxyPlugin.getPlugin().urlLocalizeFromBundleAndFragments(ProxyPlugin.getPlugin().getBundle(), "vm/remotevm.jar"); //$NON-NLS-1$ URL[] urls = null; if (otherURLs != null) { @@ -58,10 +88,7 @@ } else urls = mustHaveUrls; - loader = loader != null ? - new URLClassLoader(urls, loader) : new URLClassLoader(urls); - - return loader; + return bundle != null ? new IDESpecialClassLoader(urls, bundle) : new URLClassLoader(urls); } public IDEProxyFactoryRegistry(String aName, ClassLoader loader) {
diff --git a/plugins/org.eclipse.jem.ui/ui/org/eclipse/jem/internal/ui/proxy/remote/LocalLaunchTabGroup.java b/plugins/org.eclipse.jem.ui/ui/org/eclipse/jem/internal/ui/proxy/remote/LocalLaunchTabGroup.java index f520690..9267c5d 100644 --- a/plugins/org.eclipse.jem.ui/ui/org/eclipse/jem/internal/ui/proxy/remote/LocalLaunchTabGroup.java +++ b/plugins/org.eclipse.jem.ui/ui/org/eclipse/jem/internal/ui/proxy/remote/LocalLaunchTabGroup.java
@@ -9,11 +9,12 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ /* - * $RCSfile: LocalLaunchTabGroup.java,v $ $Revision: 1.2 $ $Date: 2004/05/24 23:23:43 $ + * $RCSfile: LocalLaunchTabGroup.java,v $ $Revision: 1.3 $ $Date: 2004/06/02 15:57:18 $ */ package org.eclipse.jem.internal.ui.proxy.remote; import org.eclipse.debug.ui.*; +import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; import org.eclipse.jdt.debug.ui.launchConfigurations.*; /** @@ -39,7 +40,7 @@ new JavaArgumentsTab(), new JavaJRETab(), new JavaClasspathTab(), - new JavaSourceLookupTab(), // TODO Need to see why SourceLookupTab didn't work. Until then use this. + new SourceLookupTab(), // TODO Need to see why SourceLookupTab didn't work. Until then use this. new EnvironmentTab(), new CommonTab()}; setTabs(tabs);