quilt-loader icon indicating copy to clipboard operation
quilt-loader copied to clipboard

code source location incompatibilites with quilt-loader 0.18.1-beta+

Open 0-x-2-2 opened this issue 1 year ago • 2 comments

    public static URI getURI(final Class<?> clazz) throws URISyntaxException {
        return clazz.getProtectionDomain().getCodeSource().getLocation().toURI();
    }

    public static Path getPath(final Class<?> clazz) throws URISyntaxException {
        final URI uri = getURI(clazz);
        System.out.println("URI: " + uri);
        return Paths.get(getURI(clazz));
    }
final byte[] bytes = Files.newInputStream(getPath(Example.class)).readAllBytes();
System.out.println("length: " + bytes.length);
URI: quilt.mfs://example.jar.i0:0/
java.nio.file.FileSystemException: Cannot open an InputStream on a directory!
	at org.quiltmc.loader.impl.filesystem.QuiltMemoryFileSystemProvider.newInputStream(QuiltMemoryFileSystemProvider.java:169)
	at java.base/java.nio.file.Files.newInputStream(Files.java:160)

This isn't the only usage of code source URIs that no longer works with the latest quilt loader betas but I don't have any stack traces for the other incompatibilities yet.

If you know a better way to find the location of a jar file containing a class file that works on quilt, fabric, forge (legacylauncher and modlauncher), paper, and sponge that would be just as good as a solution inside of the quilt itself.

0-x-2-2 avatar Dec 09 '22 02:12 0-x-2-2