浏览代码

Add suffix as well as prefix to googleaccess classes
This stops some part of the toolchain (TinyRemapper?) from moving the classes to the "correct" package

malte0811 4 年之前
父节点
当前提交
dcc514cb6e

+ 5 - 0
common/build.gradle

@@ -45,6 +45,11 @@ jar {
     // Move googleaccess to a directory that does not match the package to prevent accidental loads
     into('googleaccess') {
         from sourceSets.googleaccess.output
+        rename { String filename ->
+            // Add suffix to stop parts of the toolchain from moving these classes to the "correct" package
+            filename + "_manual"
+        }
+
     }
     from(sourceSets.googleimpl.output)
 }

+ 2 - 1
common/src/main/java/malte0811/ferritecore/classloading/FastImmutableMapDefiner.java

@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
 public class FastImmutableMapDefiner {
     private static final Logger LOGGER = LogManager.getLogger("FerriteCore - class definer");
     public static String GOOGLE_ACCESS_PREFIX = "/googleaccess/";
+    public static String GOOGLE_ACCESS_SUFFIX = ".class_manual";
 
     private static final LazyValue<Definer> DEFINE_CLASS = new LazyValue<>(() -> {
         try {
@@ -81,7 +82,7 @@ public class FastImmutableMapDefiner {
 
     private static void defineInAppClassloader(String name) throws Exception {
         InputStream byteInput = FastImmutableMapDefiner.class.getResourceAsStream(
-                GOOGLE_ACCESS_PREFIX + name.replace('.', '/') + ".class"
+                GOOGLE_ACCESS_PREFIX + name.replace('.', '/') + GOOGLE_ACCESS_SUFFIX
         );
         byte[] classBytes = new byte[byteInput.available()];
         final int bytesRead = byteInput.read(classBytes);

+ 1 - 0
common/src/test/java/malte0811/ferritecore/fastmap/FastMapTest.java

@@ -29,6 +29,7 @@ public class FastMapTest {
     @BeforeAll
     public static void init() {
         FastImmutableMapDefiner.GOOGLE_ACCESS_PREFIX = "/";
+        FastImmutableMapDefiner.GOOGLE_ACCESS_SUFFIX = ".class";
     }
 
     @TestFactory