diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-02-08 11:58:49 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-02-08 12:17:55 +0700 |
commit | dbce4ca387fec90afb2f8044cdc48d0d4682edff (patch) | |
tree | 644e7641ce671618f47cdc28c9dfd414ef19396c /weaver/src/main | |
parent | 8e98580a22a207c77a6c3816e3a36eab9782c7e9 (diff) | |
download | aspectj-dbce4ca387fec90afb2f8044cdc48d0d4682edff.tar.gz aspectj-dbce4ca387fec90afb2f8044cdc48d0d4682edff.zip |
Factor out some anonymous IWeaveRequestor classes to inner classes
Drive-by cosmetics in the context of #279.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'weaver/src/main')
-rw-r--r-- | weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java | 43 | ||||
-rw-r--r-- | weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java | 72 |
2 files changed, 55 insertions, 60 deletions
diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java index d4f47cbe7..1df4e060f 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java @@ -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. diff --git a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java index ee9c82dd8..1617cb22b 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -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 + } } } |