]> source.dussan.org Git - aspectj.git/commitdiff
Factor out some anonymous IWeaveRequestor classes to inner classes
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Thu, 8 Feb 2024 04:58:49 +0000 (11:58 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Thu, 8 Feb 2024 05:17:55 +0000 (12:17 +0700)
Drive-by cosmetics in the context of #279.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java

index d4f47cbe75dd35fe6bde44a6aea1eae2764252e3..1df4e060f1b07388d814e6d35521674297bf4074 100644 (file)
@@ -972,29 +972,7 @@ public class BcelWeaver {
                        }
 
                        public IWeaveRequestor getRequestor() {
-                               return new IWeaveRequestor() {
-                                       public void acceptResult(IUnwovenClassFile result) {
-                                               try {
-                                                       writeZipEntry(result.getFilename(), result.getBytes());
-                                               } catch (IOException ex) {
-                                               }
-                                       }
-
-                                       public void processingReweavableState() {
-                                       }
-
-                                       public void addingTypeMungers() {
-                                       }
-
-                                       public void weavingAspects() {
-                                       }
-
-                                       public void weavingClasses() {
-                                       }
-
-                                       public void weaveCompleted() {
-                                       }
-                               };
+                               return new WeaveRequestor();
                        }
                });
                // /* BUG 40943*/
@@ -1003,6 +981,25 @@ public class BcelWeaver {
                return c;
        }
 
+       private class WeaveRequestor implements IWeaveRequestor {
+               public void acceptResult(IUnwovenClassFile result) {
+                       try {
+                               writeZipEntry(result.getFilename(), result.getBytes());
+                       } catch (IOException ex) {
+                       }
+               }
+
+               public void processingReweavableState() {}
+
+               public void addingTypeMungers() {}
+
+               public void weavingAspects() {}
+
+               public void weavingClasses() {}
+
+               public void weaveCompleted() {}
+       }
+
        private Set<IProgramElement> candidatesForRemoval = null;
 
        // variation of "weave" that sources class files from an external source.
index ee9c82dd8e4b050c56a6d3336a70cca3e8e6f999..1617cb22b85091e782ee20c079dad10a8213617b 100644 (file)
@@ -916,52 +916,50 @@ public class WeavingAdaptor implements IMessageContext {
                }
 
                public IWeaveRequestor getRequestor() {
-                       return new IWeaveRequestor() {
-
-                               public void acceptResult(IUnwovenClassFile result) {
-                                       if (wovenClass == null) {
-                                               wovenClass = result;
-                                               String name = result.getClassName();
-                                               if (shouldDump(name.replace('/', '.'), false)) {
-                                                       dump(name, result.getBytes(), false);
-                                               }
-                                       } else {
-                                               // Classes generated by weaver e.g. around closure advice
-                                               String className = result.getClassName();
-                                               byte[]  resultBytes = result.getBytes();
-
-                                               if (SimpleCacheFactory.isEnabled()) {
-                                                       SimpleCache lacache=SimpleCacheFactory.createSimpleCache();
-                                                       lacache.put(result.getClassName(), wovenClass.getBytes(), result.getBytes());
-                                                       lacache.addGeneratedClassesNames(wovenClass.getClassName(), wovenClass.getBytes(), result.getClassName());
-                                               }
+                       return new WeaveRequestor();
+               }
 
-                                               generatedClasses.put(wovenClass.getClassName(), wovenClass);
-                                               generatedClassHandler.acceptClass(className, null, resultBytes);
+               private class WeaveRequestor implements IWeaveRequestor {
+                       @Override
+                       public void acceptResult(IUnwovenClassFile result) {
+                               if (wovenClass == null) {
+                                       wovenClass = result;
+                                       String name = result.getClassName();
+                                       if (shouldDump(name.replace('/', '.'), false)) {
+                                               dump(name, result.getBytes(), false);
+                                       }
+                               } else {
+                                       // Classes generated by weaver e.g. around closure advice
+                                       String className = result.getClassName();
+                                       byte[]  resultBytes = result.getBytes();
+
+                                       if (SimpleCacheFactory.isEnabled()) {
+                                               SimpleCache lacache=SimpleCacheFactory.createSimpleCache();
+                                               lacache.put(result.getClassName(), wovenClass.getBytes(), result.getBytes());
+                                               lacache.addGeneratedClassesNames(wovenClass.getClassName(), wovenClass.getBytes(), result.getClassName());
                                        }
-                               }
 
-                               public void processingReweavableState() {
+                                       generatedClasses.put(wovenClass.getClassName(), wovenClass);
+                                       generatedClassHandler.acceptClass(className, null, resultBytes);
                                }
+                       }
 
-                               public void addingTypeMungers() {
-                               }
+                       public void processingReweavableState() {}
 
-                               public void weavingAspects() {
-                               }
+                       public void addingTypeMungers() {}
 
-                               public void weavingClasses() {
-                               }
+                       public void weavingAspects() {}
 
-                               public void weaveCompleted() {
-                                       // ResolvedType.resetPrimitives();
-                                       if (delegateForCurrentClass != null) {
-                                               delegateForCurrentClass.weavingCompleted();
-                                       }
-                                       // ResolvedType.resetPrimitives();
-                                       // bcelWorld.discardType(typeBeingProcessed.getResolvedTypeX()); // work in progress
+                       public void weavingClasses() {}
+
+                       public void weaveCompleted() {
+                               // ResolvedType.resetPrimitives();
+                               if (delegateForCurrentClass != null) {
+                                       delegateForCurrentClass.weavingCompleted();
                                }
-                       };
+                               // ResolvedType.resetPrimitives();
+                               // bcelWorld.discardType(typeBeingProcessed.getResolvedTypeX()); // work in progress
+                       }
                }
        }