Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.reflections won't work #36

Closed
hexadecimal233 opened this issue Aug 11, 2023 · 2 comments
Closed

org.reflections won't work #36

hexadecimal233 opened this issue Aug 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@hexadecimal233
Copy link

hexadecimal233 commented Aug 11, 2023

Describe the bug

org.reflections won't work

Steps to reproduce

  1. Install this mod: MC-Reflections-1.0-SNAPSHOT.jar.zip (Code)
  2. Run using connector
  3. Error pops up in console. Reflections won't work.

Expected

A "Hello world" will be printed to console.

Logs


[11Aug2023 22:50:24.150] [Render thread/WARN] [org.reflections.Reflections/]: could not create Vfs.Dir from url. ignoring the exception and continuing
org.reflections.ReflectionsException: Could not open url connection
	at org.reflections.vfs.JarInputDir$1.<init>(JarInputDir.java:31) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at org.reflections.vfs.JarInputDir.lambda$getFiles$0(JarInputDir.java:28) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at org.reflections.Reflections.lambda$scan$2(Reflections.java:177) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
	at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1707) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
	at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290) ~[?:?]
	at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754) ~[?:?]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
	at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:686) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:159) ~[?:?]
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:173) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233) ~[?:?]
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:765) ~[?:?]
	at org.reflections.Reflections.scan(Reflections.java:173) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at org.reflections.Reflections.<init>(Reflections.java:126) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at org.reflections.Reflections.<init>(Reflections.java:159) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at org.reflections.Reflections.<init>(Reflections.java:151) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	at me.chirin.mcreflections.ReflectTest.init(ReflectTest.java:14) ~[MC-Reflections-1.0-SNAPSHOT_mapped_srg_1.20.1.jar%23176!/:?]
	at me.chirin.mcreflections.MCReflections.onInitialize(MCReflections.java:8) ~[MC-Reflections-1.0-SNAPSHOT_mapped_srg_1.20.1.jar%23176!/:?]
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[Connector-1.0.0-beta.3+1.20.1-full.jar%23158!/:?]
	at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35) ~[Connector-1.0.0-beta.3+1.20.1-full.jar%23158!/:?]
	at dev.su5ed.sinytra.connector.mod.ConnectorLoader.load(ConnectorLoader.java:52) ~[Connector-1.0.0-beta.3+1.20.1-mod.jar%23161!/:?]
	at net.minecraft.client.Minecraft.handler$zzf000$earlyInit(Minecraft.java:2930) ~[client-1.20.1-20230612.114412-srg.jar%23163!/:?]
	at net.minecraft.client.Minecraft.<init>(Minecraft.java:424) ~[client-1.20.1-20230612.114412-srg.jar%23163!/:?]
	at net.minecraft.client.main.Main.main(Main.java:182) ~[minecraft-1.20.1-client.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111) ~[fmlloader-1.20.1-47.1.43.jar:?]
	at net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99) ~[fmlloader-1.20.1-47.1.43.jar:?]
	at net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25) ~[fmlloader-1.20.1-47.1.43.jar:?]
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:108) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:78) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-10.0.9.jar:?]
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) ~[bootstraplauncher-1.1.2.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at io.github.zekerzhayard.forgewrapper.installer.Main.main(Main.java:57) ~[?:?]
	at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:88) ~[?:?]
	at org.prismlauncher.EntryPoint.listen(EntryPoint.java:126) ~[?:?]
	at org.prismlauncher.EntryPoint.main(EntryPoint.java:71) ~[?:?]
Caused by: java.nio.file.NoSuchFileException: /
	at jdk.nio.zipfs.ZipFileSystem.newByteChannel(ZipFileSystem.java:974) ~[jdk.zipfs:?]
	at jdk.nio.zipfs.ZipPath.newByteChannel(ZipPath.java:864) ~[jdk.zipfs:?]
	at jdk.nio.zipfs.ZipFileSystemProvider.newByteChannel(ZipFileSystemProvider.java:238) ~[jdk.zipfs:?]
	at java.nio.file.Files.newByteChannel(Files.java:380) ~[?:?]
	at java.nio.file.Files.newByteChannel(Files.java:432) ~[?:?]
	at cpw.mods.niofs.union.UnionFileSystem.byteChannel(UnionFileSystem.java:348) ~[securejarhandler-2.1.10.jar:?]
	at java.util.Optional.map(Optional.java:260) ~[?:?]
	at cpw.mods.niofs.union.UnionFileSystem.newReadByteChannel(UnionFileSystem.java:339) ~[securejarhandler-2.1.10.jar:?]
	at cpw.mods.niofs.union.UnionFileSystemProvider.newByteChannel(UnionFileSystemProvider.java:149) ~[securejarhandler-2.1.10.jar:?]
	at java.nio.file.Files.newByteChannel(Files.java:380) ~[?:?]
	at java.nio.file.Files.newByteChannel(Files.java:432) ~[?:?]
	at java.nio.file.Files.readAllBytes(Files.java:3288) ~[?:?]
	at cpw.mods.niofs.union.UnionFileSystem.buildInputStream(UnionFileSystem.java:70) ~[securejarhandler-2.1.10.jar:?]
	at cpw.mods.niofs.union.UnionPath.buildInputStream(UnionPath.java:331) ~[securejarhandler-2.1.10.jar:?]
	at cpw.mods.cl.UnionURLStreamHandler.lambda$inputStreamFunction$0(UnionURLStreamHandler.java:25) ~[securejarhandler-2.1.10.jar:?]
	at cpw.mods.cl.ModularURLHandler$FunctionURLConnection.getInputStream(ModularURLHandler.java:65) ~[securejarhandler-2.1.10.jar:?]
	at org.reflections.vfs.JarInputDir$1.<init>(JarInputDir.java:30) ~[MC-Reflections-1.0-SNAPSHOT$reflections-0.10.2_mapped_srg_1.20.1.jar%23177!/:?]
	... 49 more
[11Aug2023 22:50:24.156] [Render thread/INFO] [org.reflections.Reflections/]: Reflections took 15 ms to scan 1 urls, producing 0 keys and 0 values

Additional context

No response

@hexadecimal233 hexadecimal233 added the bug Something isn't working label Aug 11, 2023
@Su5eD
Copy link
Member

Su5eD commented Aug 25, 2023

The issue here seems to be caused by the Reflections library trying to open an input stream on the root URL of a jar, which the union file system doesn't support. It could a bug / unimplemented feature, as trying the same on a real directory path works fine.

All resource location URIs in Forge use the union file system by default, so to get it to work you'd need to explicitly pass in one that points to the outer file system.

@Su5eD
Copy link
Member

Su5eD commented Aug 26, 2023

I fixed Forgified Fabric Loader to provide the real file path from the ModOrigin inside the mod container, achieving parity with upstream. You can now use that to get the file URI to pass into reflections. Hopefully that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants