diff options
author | Uri Simchoni <urisimchoni@gmail.com> | 2024-02-05 08:34:35 +0200 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-02-08 12:17:55 +0700 |
commit | 8e98580a22a207c77a6c3816e3a36eab9782c7e9 (patch) | |
tree | f8c4fa72299228b8bd64b7d5ee01b3e3ef3e468c | |
parent | 82da6700027abcd575e4a372e1d55e841f17e89f (diff) | |
download | aspectj-8e98580a22a207c77a6c3816e3a36eab9782c7e9.tar.gz aspectj-8e98580a22a207c77a6c3816e3a36eab9782c7e9.zip |
Store only weaved class names in the generatedClasses map
The generatedClasses map contained both keys of woven classes that had
generated classes associated with them, and the keys of the generated
classes themselves. It seems like this map is never consulted for the
generated class key - the generated class is generated from within the
context of woven class loading / retransformation, and thus no transform
event is generated for it by the JVM. Because of that, we do not need to
guard against re-weaving it. Other uses of generatedClasses map are for
full/empty tests, where the woven class key is sufficient. This change
simplifies deletion of a class because we do not have to look for its
associated generated classes.
Relates to #279.
-rw-r--r-- | loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java | 17 | ||||
-rw-r--r-- | weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java | 1 |
2 files changed, 2 insertions, 16 deletions
diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 9d478633f..d0484f6b4 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -1008,21 +1008,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { * @param className a slashed classname (e.g. com/foo/Bar) */ public void flushGeneratedClassesFor(String className) { - try { - String dottedClassName = className.replace('/', '.'); - String dottedClassNameDollar = dottedClassName+"$"; // to pickup inner classes - Iterator<Map.Entry<String, IUnwovenClassFile>> iter = generatedClasses.entrySet().iterator(); - while (iter.hasNext()) { - Entry<String, IUnwovenClassFile> next = iter.next(); - String existingGeneratedName = next.getKey(); - if (existingGeneratedName.equals(dottedClassName) || - existingGeneratedName.startsWith(dottedClassNameDollar)) { - iter.remove(); - } - } - } catch (Throwable t) { - new RuntimeException("Unexpected problem tidying up generated classes for "+className,t).printStackTrace(); - } + String dottedClassName = className.replace('/', '.'); + generatedClasses.remove(dottedClassName); } private static final Object lock = new Object(); 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 966143fc1..ee9c82dd8 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -936,7 +936,6 @@ public class WeavingAdaptor implements IMessageContext { lacache.addGeneratedClassesNames(wovenClass.getClassName(), wovenClass.getBytes(), result.getClassName()); } - generatedClasses.put(className, result); generatedClasses.put(wovenClass.getClassName(), wovenClass); generatedClassHandler.acceptClass(className, null, resultBytes); } |