Possible fix for MacOS classloader issue.

This commit is contained in:
magenoxx 2011-05-06 13:01:32 +04:00
parent 1fef6e6bb4
commit 57e2b94205

View file

@ -157,7 +157,7 @@ public abstract class ExpansionSet implements Serializable {
private List<Card> getCardClassesForPackage(String packageName) {
ClassLoader classLoader = this.getClass().getClassLoader();
assert classLoader != null;
String path = packageName.replace('.', '/');
String path = packageName.replace(".", File.separator);
Enumeration<URL> resources = null;
try {
resources = classLoader.getResources(path);
@ -185,9 +185,10 @@ public abstract class ExpansionSet implements Serializable {
if (jarPath.contains("!")) {
jarPath = jarPath.substring(0, jarPath.lastIndexOf('!'));
}
if (jarPath.startsWith("file:/")) {
String filePathElement = "file:" + File.separator;
if (jarPath.startsWith(filePathElement)) {
try {
jarPath = URLDecoder.decode(jarPath.substring(jarPath.indexOf("file:/") + "file:/".length()), "UTF-8");
jarPath = URLDecoder.decode(jarPath.substring(jarPath.indexOf(filePathElement) + filePathElement.length()), "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.fatal("Error decoding file - " + jarPath, e);
}
@ -257,7 +258,7 @@ public abstract class ExpansionSet implements Serializable {
break;
}
if ((jarEntry.getName().startsWith(packageName)) && (jarEntry.getName().endsWith(".class"))) {
String clazz = jarEntry.getName().replaceAll("/", "\\.").replace(".class", "");
String clazz = jarEntry.getName().replaceAll(File.separator, "\\.").replace(".class", "");
Class c = cl.loadClass(clazz);
if (CardImpl.class.isAssignableFrom(c)) {
classes.add(c);