diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-04-08 13:40:01 +0200 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2024-04-08 14:51:59 +0200 |
commit | 966326ea32f3ff0160e8d04f2b7d1b1830c62433 (patch) | |
tree | fe50ed62320ea6d047ef0c2403af99e47187e870 | |
parent | a97bb76a14c0f8d0712c9db57de81643adb1666a (diff) | |
download | aspectj-966326ea32f3ff0160e8d04f2b7d1b1830c62433.tar.gz aspectj-966326ea32f3ff0160e8d04f2b7d1b1830c62433.zip |
Revert WeavingAdaptor generated class map optimisation
This was introduced in commit 8a4aa03845 of PR #278 contribution as part
of the #279 fix. The contributor thought that the generated closure
class entries were never used, but in fact AJDT class OSGiWeavingAdaptor
relies on the presence of those entries.
To the best of my present knowledge, it looks as if this change was the
root cause of https://github.com/eclipse-aspectj/ajdt/issues/57.
Therefore, I reverted it, simultaneously refactoring Iterator::remove
usage to delete entries from the map to Collection::removeIf.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
-rw-r--r-- | loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java | 12 | ||||
-rw-r--r-- | weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java | 1 |
2 files changed, 11 insertions, 2 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 a18400e90..223008f8f 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -1008,8 +1008,16 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { * @param className a slashed classname (e.g. com/foo/Bar) */ public void flushGeneratedClassesFor(String className) { - String dottedClassName = className.replace('/', '.'); - generatedClasses.remove(dottedClassName); + try { + String dottedClassName = className.replace('/', '.'); + String dottedClassNameDollar = dottedClassName + "$"; // to pick up inner classes + generatedClasses.entrySet().removeIf(entry -> { + String generatedClassName = entry.getKey(); + return generatedClassName.equals(dottedClassName) || generatedClassName.startsWith(dottedClassNameDollar); + }); + } catch (Throwable t) { + new RuntimeException("Unexpected problem tidying up generated classes for " + className, t).printStackTrace(); + } } 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 9ee4c0962..42a4e37ee 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -939,6 +939,7 @@ 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); } |