Skip to content

Commit f0f9b8a

Browse files
committed
Fixed alot of minor things.
1 parent 8acb454 commit f0f9b8a

4 files changed

Lines changed: 4 additions & 31 deletions

File tree

src/main/java/org/mangorage/mangobotlaunch/launch/LoadedModule.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,18 @@
33
import java.io.IOException;
44
import java.lang.module.ModuleReader;
55
import java.lang.module.ModuleReference;
6-
import java.net.MalformedURLException;
76
import java.net.URI;
8-
import java.security.CodeSigner;
9-
import java.security.CodeSource;
107
import java.util.ArrayList;
118
import java.util.List;
129
import java.util.Optional;
13-
import java.util.stream.Stream;
1410

1511
public final class LoadedModule {
1612
private final List<LoadedModule> children = new ArrayList<>();
1713

1814
private final ModuleReference moduleReference;
19-
private final CodeSource codeSource;
2015

2116
LoadedModule(ModuleReference moduleReference) {
2217
this.moduleReference = moduleReference;
23-
try {
24-
this.codeSource = new CodeSource(moduleReference.location().get().toURL(), (CodeSigner[]) null);
25-
} catch (MalformedURLException e) {
26-
throw new IllegalStateException(e);
27-
}
2818
}
2919

3020
ModuleReference getModuleReference() {
@@ -39,10 +29,6 @@ ModuleReader getModuleReader() {
3929
}
4030
}
4131

42-
CodeSource getCodeSource() {
43-
return codeSource;
44-
}
45-
4632
void addChild(LoadedModule module) {
4733
this.children.add(module);
4834
}

src/main/java/org/mangorage/mangobotlaunch/launch/MangoBotLaunchTarget.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
import org.mangorage.bootstrap.api.launch.ILaunchTarget;
66
import org.mangorage.bootstrap.api.launch.ILaunchTargetEntrypoint;
77
import org.mangorage.mangobotlaunch.util.Util;
8-
9-
import java.io.IOException;
108
import java.lang.module.Configuration;
119
import java.lang.module.ModuleFinder;
12-
import java.nio.file.Files;
1310
import java.nio.file.Path;
14-
import java.nio.file.StandardCopyOption;
1511
import java.util.ArrayList;
1612
import java.util.Comparator;
1713
import java.util.HashMap;

src/main/java/org/mangorage/mangobotlaunch/launch/MangoLoaderImpl.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
import java.lang.module.ResolvedModule;
1313
import java.net.URL;
1414
import java.nio.ByteBuffer;
15-
import java.security.SecureClassLoader;
1615
import java.util.*;
1716
import java.util.concurrent.ConcurrentHashMap;
1817

19-
public final class MangoLoaderImpl extends SecureClassLoader implements IMangoLoader {
18+
public final class MangoLoaderImpl extends ClassLoader implements IMangoLoader {
2019

2120
static {
2221
ClassLoader.registerAsParallelCapable();
@@ -40,11 +39,6 @@ private void initializeModules(Set<ResolvedModule> modules) {
4039
}
4140

4241
void load(final ModuleLayer moduleLayer, final ModuleLayer.Controller controller) {
43-
loadModuleConfiguration(moduleLayer, controller);
44-
loadTransformers();
45-
}
46-
47-
private void loadModuleConfiguration(final ModuleLayer moduleLayer, final ModuleLayer.Controller controller) {
4842
var moduleLayerImpl = new ModuleLayerImpl(moduleLayer, controller);
4943
ServiceLoader.load(IModuleConfigurator.class)
5044
.stream()
@@ -58,9 +52,7 @@ private void loadModuleConfiguration(final ModuleLayer moduleLayer, final Module
5852
.forEach(module::addChild)
5953
);
6054
});
61-
}
6255

63-
private void loadTransformers() {
6456
ServiceLoader.load(IClassTransformer.class)
6557
.stream()
6658
.map(ServiceLoader.Provider::get)
@@ -108,7 +100,7 @@ protected Enumeration<URL> findResources(String name) throws IOException {
108100
return Collections.enumeration(findResourcesAsList(name));
109101
}
110102

111-
private List<URL> findResourcesAsList(String name) throws IOException {
103+
private List<URL> findResourcesAsList(String name){
112104
String pn = toPackageName(name);
113105
LoadedModule module = localPackageToModule.get(pn);
114106
if (module != null) {
@@ -198,11 +190,11 @@ private Class<?> defineClass(String cn, LoadedModule loadedModule) {
198190
byte[] modifiedClassBytes = transformers.transform(cn, classBytes);
199191

200192
if (modifiedClassBytes != null) {
201-
Class<?> clz = defineClass(cn, modifiedClassBytes, 0, modifiedClassBytes.length, loadedModule.getCodeSource());
193+
Class<?> clz = defineClass(cn, modifiedClassBytes, 0, modifiedClassBytes.length);
202194
transformers.add(cn, clz);
203195
return clz;
204196
}
205-
return defineClass(cn, classBytes, 0, classBytes.length, loadedModule.getCodeSource());
197+
return defineClass(cn, classBytes, 0, classBytes.length);
206198
} catch (IOException ioe) {
207199
return null;
208200
}

src/main/java/org/mangorage/mangobotlaunch/util/Util.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.File;
44
import java.lang.module.ModuleFinder;
55
import java.lang.module.ModuleReference;
6-
import java.lang.reflect.Method;
76
import java.nio.file.Path;
87
import java.util.HashSet;
98
import java.util.Set;

0 commit comments

Comments
 (0)