Skip to content

Commit

Permalink
Revert WeavingAdaptor generated class map optimisation
Browse files Browse the repository at this point in the history
This was introduced in commit 8a4aa03 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 eclipse-aspectj/ajdt#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>
  • Loading branch information
kriegaex committed Apr 8, 2024
1 parent a97bb76 commit 966326e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -1008,8 +1008,16 @@ public void flushGeneratedClasses() {
* @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();
Expand Down
Expand Up @@ -939,6 +939,7 @@ public void acceptResult(IUnwovenClassFile result) {
lacache.addGeneratedClassesNames(wovenClass.getClassName(), wovenClass.getBytes(), result.getClassName());
}

generatedClasses.put(className, result);
generatedClasses.put(wovenClass.getClassName(), wovenClass);
generatedClassHandler.acceptClass(className, null, resultBytes);
}
Expand Down

0 comments on commit 966326e

Please sign in to comment.