diff options
| author | cbrun | 2015-04-01 12:30:52 +0000 |
|---|---|---|
| committer | cbrun | 2015-04-01 12:51:39 +0000 |
| commit | 0dc80429ca6441c5d8ed394d35db58dd99ecc3ed (patch) | |
| tree | 75ae856c98205251a8ba620f7517aaec6faed447 | |
| parent | 42e2eeba1f01807245db88e33cab22eeb9f812e1 (diff) | |
| download | org.eclipse.sirius-0dc80429ca6441c5d8ed394d35db58dd99ecc3ed.tar.gz org.eclipse.sirius-0dc80429ca6441c5d8ed394d35db58dd99ecc3ed.tar.xz org.eclipse.sirius-0dc80429ca6441c5d8ed394d35db58dd99ecc3ed.zip | |
[460947] call URLClassLoader.close() reflectively to support Java6
Bug: 460947
Change-Id: I17bb0d42ae2497b02493ce1099800edaac08e858
Signed-off-by: Cedric Brun <cedric.brun@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/utils/WorkspaceClassLoading.java | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/utils/WorkspaceClassLoading.java b/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/utils/WorkspaceClassLoading.java index 55daa1ed7a..41f15e4db7 100644 --- a/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/utils/WorkspaceClassLoading.java +++ b/plugins/org.eclipse.sirius.editor/src-gen/org/eclipse/sirius/editor/utils/WorkspaceClassLoading.java @@ -12,6 +12,8 @@ package org.eclipse.sirius.editor.utils; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; @@ -76,7 +78,7 @@ import com.google.common.collect.Sets; * <li>if you have in your workspace some projects which are actually used by * Sirius and which might pass instances to the query implementation, things * *will* go wrong as this utility will search first in the workspace.</li> - * <li>you can't use the generated model interfaces</li> + * <li>you can't use the generated model interfaces</li> * </ul> * * @author cedric @@ -130,11 +132,7 @@ public class WorkspaceClassLoading extends BundleClassLoading { for (String projectName : changed) { URLClassLoader old = projectsToClassLoader.get(projectName); if (old != null) { - try { - old.close(); - } catch (IOException e) { - SiriusEditorPlugin.INSTANCE.log(e); - } + closeClassLoader(old); } projectsToClassLoader.remove(projectName); } @@ -530,15 +528,33 @@ public class WorkspaceClassLoading extends BundleClassLoading { ResourcesPlugin.getWorkspace().removeResourceChangeListener(workspaceListener); } for (URLClassLoader loader : projectsToClassLoader.values()) { - try { - loader.close(); - } catch (IOException e) { - SiriusEditorPlugin.INSTANCE.log(e); - } + closeClassLoader(loader); } projectsToClassLoader.clear(); } + private void closeClassLoader(URLClassLoader old) { + /* + * we invoke the "URLClassLoader.close()" method reflectively as it has + * only been introduced with Java 7. + */ + try { + Method closeMethod = URLClassLoader.class.getMethod("close", new Class<?>[0]); + closeMethod.invoke(old, new Object[0]); + } catch (NoSuchMethodException e) { + /* + * Java pre-7 + */ + } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { + } catch (InvocationTargetException e) { + /* + * the close() call triggered an exception + */ + SiriusEditorPlugin.INSTANCE.log(e.getCause()); + } + } + @Override public void setClasspathChangeCallback(ClasspathChangeCallback listener) { IWorkspaceRoot root = EcorePlugin.getWorkspaceRoot(); |
