Skip to content

Commit

Permalink
Factor out some anonymous IWeaveRequestor classes to inner classes
Browse files Browse the repository at this point in the history
Drive-by cosmetics in the context of #279.

Signed-off-by: Alexander Kriegisch <[email protected]>
  • Loading branch information
kriegaex committed Feb 8, 2024
1 parent faa36ca commit 6117924
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 60 deletions.
43 changes: 20 additions & 23 deletions weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,29 +972,7 @@ public Iterator<UnwovenClassFile> getClassFileIterator() {
}

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*/
Expand All @@ -1003,6 +981,25 @@ public void weaveCompleted() {
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.
Expand Down
72 changes: 35 additions & 37 deletions weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -916,52 +916,50 @@ public Iterator<UnwovenClassFile> getClassFileIterator() {
}

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
}
}
}

Expand Down

0 comments on commit 6117924

Please sign in to comment.