AlmuraDev/Libigot — pull request #5 by agaricusb (2013-02-16 04:44:29+00:00)
Title: Fix invalid non-hierarchical codesource URL

Fixes the getCodeSource() location on plugin classes. Test case:

try {
System.out.println("codeSource URI="+getClass().getProtectionDomain().getCodeSource().getLocation().toURI());
System.out.println(" file = ="+new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()));
System.out.println("new canonical file = ="+(new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI())).getCanonicalFile());
} catch (Throwable t) {
System.out.println("codeSource URI exception="+t);
t.printStackTrace();
}

On libigot-1.4.7-R1.1-SNAPSHOT.jar build 30, this fails with:

20:22:55 [INFO] codeSource URI=jar:file:/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar!/agaricus/plugins/IncompatiblePlugin/SamplePlugin.class
20:22:55 [INFO] codeSource URI exception=java.lang.IllegalArgumentException: URI is not hierarchical
20:22:55 [SEVERE] java.lang.IllegalArgumentException: URI is not hierarchical
20:22:55 [SEVERE] at java.io.File.(File.java:392)
20:22:55 [SEVERE] at agaricus.plugins.IncompatiblePlugin.SamplePlugin.onEnable(SamplePlugin.java:62)
20:22:55 [SEVERE] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
20:22:55 [SEVERE] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:375)
20:22:55 [SEVERE] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:383)
20:22:55 [SEVERE] at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:308)
20:22:55 [SEVERE] at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:290)
20:22:55 [SEVERE] at net.minecraft.server.MinecraftServer.j(MinecraftServer.java:327)
20:22:55 [SEVERE] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:306)
20:22:55 [SEVERE] at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:265)
20:22:55 [SEVERE] at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:149)
20:22:55 [SEVERE] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:405)
20:22:55 [SEVERE] at net.minecraft.server.ThreadServerApplication.run(SourceFile:849)

With craftbukkit-1.4.7-R1.0.jar, works as expected:
20:25:13 [INFO] codeSource URI=file:/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar
20:25:13 [INFO] file = =/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar
20:25:13 [INFO] new canonical file = =/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar

and with this patch:
20:31:25 [INFO] codeSource URI=file:/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar
20:31:25 [INFO] file = =/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar
20:31:25 [INFO] new canonical file = =/Users/admin/minecraft/1.4.x/test-server/plugins/bukkit-sample-plugin-0.5.jar

Already fixed this in MCPC+ https://github.com/MinecraftPortCentral/MCPC-Plus/issues/75 to support Residence (we have a similar remapping classloader for vanilla compatibility), but figured you guys might want this fix for Libigot, too. Other plugins may also be fixed with this change, although Residence is the only one I know of.