fixed Windows classloading - test on MacOS

This commit is contained in:
BetaSteward 2011-05-08 12:36:05 -04:00
parent 6cda7ea076
commit 1558e37abd

View file

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