Skip to content

Commit

Permalink
Fixed the weirdest bug on OpenJDK, preventing some classes from loadi…
Browse files Browse the repository at this point in the history
…ng seemingly randomly
  • Loading branch information
Hugobros3 committed Nov 2, 2017
1 parent b30996a commit 7dc329d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ public ForeignCodeClassLoader(Mod responsibleMod, ClassLoader parentLoader, Coll

try
{
Class<?> loadedClass = this.findClass(className);
//OpenJDK weirdness: Unlike Oracle's implementation, OpenJDK loads the referenced classes when it loads one
//meaning when I call findClass() on every .class I end up with duplicate findClass() calls, and it doesn't like it very much

//The fix is easy: call findLoadedClass() first and check we're not duplicating the request
Class<?> alreadyLoadedClass = this.findLoadedClass(className);
Class<?> loadedClass = alreadyLoadedClass != null ? alreadyLoadedClass : this.findClass(className);
classes.put(className, loadedClass);
}
catch (ClassNotFoundException e1)
Expand All @@ -71,6 +76,7 @@ public ForeignCodeClassLoader(Mod responsibleMod, ClassLoader parentLoader, Coll
}
catch(LinkageError le)
{
System.out.println("This should not happen!");
//Don't care
}
//classes.add(className);
Expand Down
2 changes: 1 addition & 1 deletion debug-client.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
java -d64 -Xmx1200M -Xdebug -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Xrunjdwp:transport=dt_socket,address=7724,server=y,suspend=n -jar client/build/libs/chunkstories.jar --dir="."
java -d64 -Xmx1200M -Xdebug -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Xrunjdwp:transport=dt_socket,address=7724,server=y,suspend=n -jar client/build/libs/chunkstories.jar --dir="." --core="../chunkstories-core/res/"

0 comments on commit 7dc329d

Please sign in to comment.