Skip to content

Commit 436bf4d

Browse files
committed
Clean up JoinPointImpl, e.g. use list instead of stack
Fixes eclipse-aspectj#128. Signed-off-by: Alexander Kriegisch <[email protected]>
1 parent 1584914 commit 436bf4d

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

runtime/src/main/java/org/aspectj/runtime/reflect/JoinPointImpl.java

+10-19
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
package org.aspectj.runtime.reflect;
1515

16-
import java.util.Stack;
17-
1816
import org.aspectj.lang.JoinPoint;
1917
import org.aspectj.lang.ProceedingJoinPoint;
2018
import org.aspectj.lang.Signature;
2119
import org.aspectj.lang.reflect.SourceLocation;
2220
import org.aspectj.runtime.internal.AroundClosure;
2321

22+
import java.util.ArrayList;
23+
import java.util.List;
24+
2425
class JoinPointImpl implements ProceedingJoinPoint {
2526
static class StaticPartImpl implements JoinPoint.StaticPart {
2627
String kind;
@@ -137,32 +138,27 @@ public final String toLongString() {
137138
}
138139

139140
// To proceed we need a closure to proceed on. Generated code
140-
// will either be using arc or arcs but not both. arcs being non-null
141-
// indicates it is in use (even if an empty stack)
141+
// will either be using arc or arcs but not both.
142142
private AroundClosure arc = null;
143-
private final Stack<AroundClosure> arcs = new Stack<>();
144-
private int currentArcIndex = -1;
143+
private final List<AroundClosure> arcs = new ArrayList<>();
144+
private int currentArcIndex = -1;
145145

146146
public void set$AroundClosure(AroundClosure arc) {
147147
this.arc = arc;
148148
}
149149

150-
public synchronized void stack$AroundClosure(AroundClosure arc) {
150+
public synchronized void stack$AroundClosure(AroundClosure arc) {
151151
// If input parameter arc is null this is the 'unlink' call from AroundClosure
152152
if (arc != null) {
153-
this.arcs.push(arc);
153+
this.arcs.add(arc);
154154
currentArcIndex++;
155155
}
156156
}
157157

158158
public synchronized Object proceed() throws Throwable {
159159
// when called from a before advice, but be a no-op
160160
if (currentArcIndex < 0) {
161-
if (arc == null) {
162-
return null;
163-
} else {
164-
return arc.run(arc.getState());
165-
}
161+
return arc == null ? null : arc.run(arc.getState());
166162
} else {
167163
final AroundClosure ac = arcs.get(currentArcIndex--);
168164
final Object result = ac.run(ac.getState());
@@ -173,12 +169,7 @@ public synchronized Object proceed() throws Throwable {
173169

174170
public synchronized Object proceed(Object[] adviceBindings) throws Throwable {
175171
// when called from a before advice, but be a no-op
176-
AroundClosure ac = null;
177-
if (currentArcIndex < 0) {
178-
ac = arc;
179-
} else {
180-
ac = arcs.get(currentArcIndex);
181-
}
172+
AroundClosure ac = currentArcIndex < 0 ? arc : arcs.get(currentArcIndex);
182173

183174
if (ac == null) {
184175
return null;

0 commit comments

Comments
 (0)