-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fabric runtime remapper and tests
- Loading branch information
1 parent
ccc84ba
commit f4b9dec
Showing
9 changed files
with
184 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
testplugin/loom/src/main/java/dev/lukebemish/opensesame/test/java/loom/FakeKnot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package dev.lukebemish.opensesame.test.java.loom; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.loader.impl.launch.FabricLauncherBase; | ||
|
||
import java.io.InputStream; | ||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.jar.Manifest; | ||
|
||
class FakeKnot extends FabricLauncherBase { | ||
private static volatile boolean INITIALIZED = false; | ||
synchronized static void init() { | ||
if (!INITIALIZED){ | ||
INITIALIZED = true; | ||
new FakeKnot(); | ||
} | ||
} | ||
|
||
@Override | ||
public void addToClassPath(Path path, String... allowedPrefixes) {} | ||
|
||
@Override | ||
public void setAllowedPrefixes(Path path, String... prefixes) {} | ||
|
||
@Override | ||
public void setValidParentClassPath(Collection<Path> paths) {} | ||
|
||
@Override | ||
public EnvType getEnvironmentType() { | ||
return EnvType.SERVER; | ||
} | ||
|
||
@Override | ||
public boolean isClassLoaded(String name) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Class<?> loadIntoTarget(String name) throws ClassNotFoundException { | ||
throw new ClassNotFoundException("FakeKnot is not Knot"); | ||
} | ||
|
||
@Override | ||
public InputStream getResourceAsStream(String name) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public ClassLoader getTargetClassLoader() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public byte[] getClassByteArray(String name, boolean runTransformers) { | ||
return new byte[0]; | ||
} | ||
|
||
@Override | ||
public Manifest getManifest(Path originPath) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isDevelopment() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getEntrypoint() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getTargetNamespace() { | ||
return "named"; | ||
} | ||
|
||
@Override | ||
public List<Path> getClassPath() { | ||
return List.of(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
testtargets/src/test/java/dev/lukebemish/opensesame/test/java/Open/TestModules.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dev.lukebemish.opensesame.test.java.Open; | ||
|
||
import dev.lukebemish.opensesame.annotations.Open; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
@Tag("modules") | ||
public class TestModules { | ||
@Open( | ||
name = "hiddenByModules", | ||
targetName = "dev.lukebemish.opensesame.test.target.hidden.Hidden", | ||
type = Open.Type.STATIC, | ||
unsafe = true | ||
) | ||
private static String hiddenByModules() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Open( | ||
name = "hiddenByModulesPrivate", | ||
targetName = "dev.lukebemish.opensesame.test.target.hidden.Hidden", | ||
type = Open.Type.STATIC, | ||
unsafe = true | ||
) | ||
private static String hiddenByModulesPrivate() { | ||
throw new RuntimeException(); | ||
} | ||
|
||
@Test | ||
void testModuleBreaking() { | ||
assertEquals("hiddenByModules", hiddenByModules()); | ||
assertEquals("hiddenByModulesPrivate", hiddenByModulesPrivate()); | ||
assertThrows(IllegalAccessException.class, () -> { | ||
Class<?> hidden = Class.forName("dev.lukebemish.opensesame.test.target.hidden.Hidden"); | ||
hidden.getDeclaredMethod("hiddenByModules").invoke(null); | ||
}); | ||
} | ||
} |