From 1ca58eb3031b322bb998edc13f7cd26a3df9e347 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 21 Apr 2019 01:11:55 +0200 Subject: [PATCH 1/2] Fix CONRAD.getClasses when running with pyconrad On pyconrad, the thread that runs CONRAD GUI gets detached from JVM. Therefore, `Thread.currentThread().getContextClassLoader()` returns `null`. We can solve this problem by patching a private member from pyconrad. --- src/edu/stanford/rsl/conrad/utils/CONRAD.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/edu/stanford/rsl/conrad/utils/CONRAD.java b/src/edu/stanford/rsl/conrad/utils/CONRAD.java index 44a8679a..34d9d0c0 100644 --- a/src/edu/stanford/rsl/conrad/utils/CONRAD.java +++ b/src/edu/stanford/rsl/conrad/utils/CONRAD.java @@ -45,6 +45,7 @@ public abstract class CONRAD { public static boolean useGarbageCollection; public static final String EOL = System.getProperty("line.separator"); public static final long INPUT_QUEUE_DELAY = 0; + private static ClassLoader classLoaderForPyconrad = null; /// Regular ClassLoader doesnot work with pyconrad since Thread is detached from JVM /** * This flag can be used to control debug outputs. * 0: No Debug output @@ -272,6 +273,8 @@ private synchronized static ArrayList getInstancesFromConradFromClasspat private static ArrayList> getClasses(String packageName) throws ClassNotFoundException, IOException { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null ) + classLoader = CONRAD.classLoaderForPyconrad; assert classLoader != null; String path = packageName.replace('.', '/'); Enumeration resources = classLoader.getResources(path); From eef2a99d3a453125ffad7dcd07230c0126900882 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Tue, 9 Jul 2019 14:42:32 +0200 Subject: [PATCH 2/2] Make member classLoaderForPyconrad public (necessary for new pyconrad version) --- src/edu/stanford/rsl/conrad/utils/CONRAD.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edu/stanford/rsl/conrad/utils/CONRAD.java b/src/edu/stanford/rsl/conrad/utils/CONRAD.java index 34d9d0c0..f1af7ead 100644 --- a/src/edu/stanford/rsl/conrad/utils/CONRAD.java +++ b/src/edu/stanford/rsl/conrad/utils/CONRAD.java @@ -45,7 +45,7 @@ public abstract class CONRAD { public static boolean useGarbageCollection; public static final String EOL = System.getProperty("line.separator"); public static final long INPUT_QUEUE_DELAY = 0; - private static ClassLoader classLoaderForPyconrad = null; /// Regular ClassLoader doesnot work with pyconrad since Thread is detached from JVM + public static ClassLoader classLoaderForPyconrad = null; /// Regular ClassLoader doesnot work with pyconrad since Thread is detached from JVM /** * This flag can be used to control debug outputs. * 0: No Debug output