]> source.dussan.org Git - aspectj.git/commit
BcelTypeMunger.mungeMethodDelegate: only use 'synchronized' when necessary
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 7 Jan 2023 09:36:08 +0000 (10:36 +0100)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 7 Jan 2023 13:07:27 +0000 (14:07 +0100)
commitc8b9568a8577d2af0f1449eec729784b0dcaa484
treec7af67ed62acd67c72843c6451dd116e61c1d112
parent438eb9301014ffb63bbcbae4df684a2907ac91d5
BcelTypeMunger.mungeMethodDelegate: only use 'synchronized' when necessary

Relates to #198. Now, we create a delegate method body which basically
looks as follows:

public void methodOne() {
  if (this.ajc$instance$MyAspect$MyMixin == null) {
    synchronized(this) {
      if (this.ajc$instance$MyAspect$MyMixin == null) {
        this.ajc$instance$MyAspect$MyMixin = MyAspect.aspectOf().createImplementation(this);
      }
    }
  }
  this.ajc$instance$MyAspect$MyMixin.methodOne();
}

The idea for the outer null check is from @aclement, see
https://github.com/eclipse/org.aspectj/pull/205#issuecomment-1371556080.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
tests/features164/declareMixin/CaseEConcurrent.java
weaver/src/main/java/org/aspectj/weaver/bcel/BcelTypeMunger.java