mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 00:15:35 +00:00
fix bootstrap addon class referencing from addons
This commit is contained in:
parent
ffc884384c
commit
83baf377e0
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* This file is part of Terra.
|
||||
*
|
||||
* Terra is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Terra is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addon;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
|
||||
public class AddonClassLoader extends URLClassLoader {
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
public AddonClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
||||
|
||||
public BootstrapAddonLoader() { }
|
||||
|
||||
private BootstrapBaseAddon<?> loadAddon(Path addonPath, ClassLoader parent) {
|
||||
private BootstrapBaseAddon<?> loadAddon(Path addonPath, BootstrapAddonClassLoader parent) {
|
||||
logger.debug("Loading bootstrap addon from JAR {}", addonPath);
|
||||
try(JarFile jar = new JarFile(addonPath.toFile())) {
|
||||
String entry = jar.getManifest().getMainAttributes().getValue("Terra-Bootstrap-Addon-Entry-Point");
|
||||
@ -55,10 +55,8 @@ public class BootstrapAddonLoader implements BootstrapBaseAddon<BootstrapBaseAdd
|
||||
|
||||
//noinspection NestedTryStatement
|
||||
try {
|
||||
@SuppressWarnings({ "resource", "IOResourceOpenedButNotSafelyClosed" })
|
||||
AddonClassLoader loader = new AddonClassLoader(new URL[]{ addonPath.toUri().toURL() }, parent);
|
||||
|
||||
Object addonObject = loader.loadClass(entry).getConstructor().newInstance();
|
||||
parent.addURL(addonPath.toUri().toURL());
|
||||
Object addonObject = parent.loadClass(entry).getConstructor().newInstance();
|
||||
|
||||
if(!(addonObject instanceof BootstrapBaseAddon<?> addon)) {
|
||||
throw new AddonLoadException(
|
||||
|
Loading…
x
Reference in New Issue
Block a user