Skip to content

Commit 3176709

Browse files
committed
Make error message more explicit when initializing Mod in SCL
1 parent 56cc89c commit 3176709

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

common/src/main/java/com/fox2code/foxloader/loader/ModContainer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,13 @@ void loadLanguageTo(String lang, Properties target) {
262262
private Mod initializeMod(String clsName) throws ReflectiveOperationException {
263263
if (clsName == null) return null;
264264
Mod mod;
265-
Class<? extends Mod> cls = Class.forName(clsName, false,
266-
FoxLauncher.getFoxClassLoader()).asSubclass(Mod.class);
265+
Class<?> cls0 = Class.forName(clsName, false, FoxLauncher.getFoxClassLoader());
266+
if (cls0.getClassLoader() == FoxLauncher.class.getClassLoader()) {
267+
// This would have previously made a vague "ClassCastException" in "cls0.asSubclass(Mod.class)"
268+
throw new ReflectiveOperationException("Class \"" + clsName +
269+
"\" exist on system class loader, and therefore cannot be properly loaded.");
270+
}
271+
Class<? extends Mod> cls = cls0.asSubclass(Mod.class);
267272
try {
268273
tmp = this;
269274
mod = cls.newInstance();

0 commit comments

Comments
 (0)