Skip to content

Commit

Permalink
fix shade in cli being broken, make module's cached by classloader
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Aug 1, 2024
1 parent 6b89a42 commit b5a31bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import xyz.wagyourtail.jvmdg.version.Ref;
import xyz.wagyourtail.jvmdg.version.Stub;

import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;

public class J_L_Class {
private static final Map<ClassLoader, J_L_Module> moduleCache = Collections.synchronizedMap(new WeakHashMap<>());

@Stub(ref = @Ref("Ljava/lang/Class;"))
public static Class<?> forName(J_L_Module module, String name) throws ClassNotFoundException {
Expand All @@ -13,7 +18,13 @@ public static Class<?> forName(J_L_Module module, String name) throws ClassNotFo

@Stub
public static J_L_Module getModule(Class<?> clazz) {
return new J_L_Module(clazz.getClassLoader());
ClassLoader loader = clazz.getClassLoader();
J_L_Module module = moduleCache.get(loader);
if (module == null) {
module = new J_L_Module(loader);
moduleCache.put(loader, module);
}
return module;
}

@Stub
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/xyz/wagyourtail/jvmdg/compile/ApiShader.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public static void shadeApis(Flags flags, List<String> prefix, List<Path> inputR
Set<Path> downgradedApiPath = resolveDowngradedApi(flags, downgradedApi);
List<FileSystem> apiFs = new ArrayList<>();
try {
for (File file : downgradedApi) {
apiFs.add(Utils.openZipFileSystem(file.toPath(), false));
for (Path file : downgradedApiPath) {
apiFs.add(Utils.openZipFileSystem(file, false));
}
List<Path> apiRoots = new ArrayList<>();
for (FileSystem fs : apiFs) {
Expand Down

0 comments on commit b5a31bd

Please sign in to comment.