Now the defaults are: + org.aspectj.apache.bcel.useSingleRepositoryInstance (default: false) + org.aspectj.apache.bcel.useUnavailableClassesCache (default: false) + org.aspectj.apache.bcel.ignoreCacheClearRequests (default: false) I.e. the new caching optimisations are opt-in instead of opt-out as originally designed. This might change in the future, but for now without any additional tests and experience with the new feature let us be conservative and make the build green first. I also added a few more code review findings concerning backward compatibility, which was less than 100% even with all three flags deactivated. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>tags/V1_9_8
//Cache not found classes as well to prevent unnecessary file I/O operations | //Cache not found classes as well to prevent unnecessary file I/O operations | ||||
public static final boolean useUnavailableClassesCache = | public static final boolean useUnavailableClassesCache = | ||||
System.getProperty("org.aspectj.apache.bcel.useUnavailableClassesCache", "true").equalsIgnoreCase("true"); | |||||
System.getProperty("org.aspectj.apache.bcel.useUnavailableClassesCache", "false").equalsIgnoreCase("true"); | |||||
//Ignore cache clear requests to not build up the cache over and over again | //Ignore cache clear requests to not build up the cache over and over again | ||||
public static final boolean ignoreCacheClearRequests = | public static final boolean ignoreCacheClearRequests = | ||||
System.getProperty("org.aspectj.apache.bcel.ignoreCacheClearRequests", "true").equalsIgnoreCase("true"); | |||||
System.getProperty("org.aspectj.apache.bcel.ignoreCacheClearRequests", "false").equalsIgnoreCase("true"); | |||||
//Second cache for the unavailable classes | //Second cache for the unavailable classes | ||||
private static Set<String> unavailableClasses = new HashSet<String>(); | private static Set<String> unavailableClasses = new HashSet<String>(); | ||||
classesLoadedCount++; | classesLoadedCount++; | ||||
return clazz; | return clazz; | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
unavailableClasses.add(className); | |||||
if (useUnavailableClassesCache) { | |||||
unavailableClasses.add(className); | |||||
} | |||||
throw new ClassNotFoundException(e.toString()); | throw new ClassNotFoundException(e.toString()); | ||||
} | } | ||||
} | } |
//Use single instance of Repository and ClassLoader | //Use single instance of Repository and ClassLoader | ||||
public static final boolean useSingleInstances = | public static final boolean useSingleInstances = | ||||
System.getProperty("org.aspectj.apache.bcel.useSingleRepositoryInstance", "true").equalsIgnoreCase("true"); | |||||
System.getProperty("org.aspectj.apache.bcel.useSingleRepositoryInstance", "false").equalsIgnoreCase("true"); | |||||
static { | static { | ||||
try { | try { | ||||
if (useSingleInstances && staticBcelRepository == null) | if (useSingleInstances && staticBcelRepository == null) | ||||
staticBcelRepository = new ClassLoaderRepository(getClassLoader()); | staticBcelRepository = new ClassLoaderRepository(getClassLoader()); | ||||
else | else | ||||
this.bcelRepository = new ClassLoaderRepository(getClassLoader()); | |||||
this.bcelRepository = new ClassLoaderRepository(classLoaderRef); | |||||
} | } | ||||
else { | else { | ||||
if (useSingleInstances && staticBcelRepository == null) | if (useSingleInstances && staticBcelRepository == null) | ||||
staticBcelRepository = new NonCachingClassLoaderRepository(getClassLoader()); | staticBcelRepository = new NonCachingClassLoaderRepository(getClassLoader()); | ||||
else | else | ||||
this.bcelRepository = new NonCachingClassLoaderRepository(getClassLoader()); | |||||
this.bcelRepository = new NonCachingClassLoaderRepository(classLoaderRef); | |||||
} | } | ||||
} | } | ||||