]> source.dussan.org Git - aspectj.git/commitdiff
Optimize class loading - make backward compatible with legacy behaviour
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Fri, 7 May 2021 10:14:34 +0000 (17:14 +0700)
committerAndy Clement <aclement@pivotal.io>
Thu, 13 Jan 2022 23:07:40 +0000 (15:07 -0800)
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>
bcel-builder/src/main/java/org/aspectj/apache/bcel/util/ClassLoaderRepository.java
weaver/src/main/java/org/aspectj/weaver/reflect/Java15AnnotationFinder.java

index cdc072b5c03b5bb5efe50523d2aa9c1245e03618..e8d8f309e402a18460485f57313127794193abc7 100644 (file)
@@ -98,10 +98,10 @@ public class ClassLoaderRepository implements Repository {
 
        //Cache not found classes as well to prevent unnecessary file I/O operations
        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
        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
        private static Set<String> unavailableClasses = new HashSet<String>();
@@ -349,7 +349,9 @@ public class ClassLoaderRepository implements Repository {
                        classesLoadedCount++;
                        return clazz;
                } catch (IOException e) {
-                       unavailableClasses.add(className);
+                       if (useUnavailableClassesCache) {
+                               unavailableClasses.add(className);
+                       }
                        throw new ClassNotFoundException(e.toString());
                }
        }
index ef437b724d14726dc28e150e8608ced5001a366b..e0e1af8d2ff370b80307d45a3d83e8cf0cbad8db 100644 (file)
@@ -51,7 +51,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
 
        //Use single instance of Repository and ClassLoader
        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 {
                try {
@@ -77,13 +77,13 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder {
                        if (useSingleInstances && staticBcelRepository == null)
                                staticBcelRepository = new ClassLoaderRepository(getClassLoader());
                        else
-                               this.bcelRepository = new ClassLoaderRepository(getClassLoader());
+                               this.bcelRepository = new ClassLoaderRepository(classLoaderRef);
                }
                else {
                        if (useSingleInstances && staticBcelRepository == null)
                                staticBcelRepository = new NonCachingClassLoaderRepository(getClassLoader());
                        else
-                               this.bcelRepository = new NonCachingClassLoaderRepository(getClassLoader());
+                               this.bcelRepository = new NonCachingClassLoaderRepository(classLoaderRef);
                }
        }