From bd2803502422028cb07fb79349acbbb23de1dee4 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sat, 31 Oct 2015 13:47:45 -0400 Subject: [PATCH] Don't load classes when we're checking for them This causes a ton of lag and doesn't seem to ever work Addresses #124 --- .../reflect/compiler/StructureCompiler.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java index 80234722..ccaab3c1 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java @@ -146,7 +146,9 @@ public final class StructureCompiler { private static String SUPER_CLASS = "com/comphenix/protocol/reflect/StructureModifier"; private static String COMPILED_CLASS = PACKAGE_NAME + "/CompiledStructureModifier"; private static String FIELD_EXCEPTION_CLASS = "com/comphenix/protocol/reflect/FieldAccessException"; - + + public static boolean attemptClassLoad = false; + /** * Construct a structure compiler. * @param loader - main class loader. @@ -163,18 +165,24 @@ public final class StructureCompiler { */ public boolean lookupClassLoader(StructureModifier source) { StructureKey key = new StructureKey(source); - + // See if there's a need to lookup the class name if (compiledCache.containsKey(key)) { return true; } - + + if (! attemptClassLoad) { + return false; + } + + // This causes a ton of lag and doesn't seem to work + try { String className = getCompiledName(source); - + // This class might have been generated before. Try to load it. Class before = loader.loadClass(PACKAGE_NAME.replace('/', '.') + "." + className); - + if (before != null) { compiledCache.put(key, before); return true; @@ -182,7 +190,7 @@ public final class StructureCompiler { } catch (ClassNotFoundException e) { // That's ok. } - + // We need to compile the class return false; }