13
13
14
14
package org .aspectj .runtime .reflect ;
15
15
16
- import java .util .Stack ;
17
-
18
16
import org .aspectj .lang .JoinPoint ;
19
17
import org .aspectj .lang .ProceedingJoinPoint ;
20
18
import org .aspectj .lang .Signature ;
21
19
import org .aspectj .lang .reflect .SourceLocation ;
22
20
import org .aspectj .runtime .internal .AroundClosure ;
23
21
22
+ import java .util .ArrayList ;
23
+ import java .util .List ;
24
+
24
25
class JoinPointImpl implements ProceedingJoinPoint {
25
26
static class StaticPartImpl implements JoinPoint .StaticPart {
26
27
String kind ;
@@ -137,32 +138,27 @@ public final String toLongString() {
137
138
}
138
139
139
140
// 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.
142
142
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 ;
145
145
146
146
public void set$AroundClosure (AroundClosure arc ) {
147
147
this .arc = arc ;
148
148
}
149
149
150
- public synchronized void stack$AroundClosure (AroundClosure arc ) {
150
+ public synchronized void stack$AroundClosure (AroundClosure arc ) {
151
151
// If input parameter arc is null this is the 'unlink' call from AroundClosure
152
152
if (arc != null ) {
153
- this .arcs .push (arc );
153
+ this .arcs .add (arc );
154
154
currentArcIndex ++;
155
155
}
156
156
}
157
157
158
158
public synchronized Object proceed () throws Throwable {
159
159
// when called from a before advice, but be a no-op
160
160
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 ());
166
162
} else {
167
163
final AroundClosure ac = arcs .get (currentArcIndex --);
168
164
final Object result = ac .run (ac .getState ());
@@ -173,12 +169,7 @@ public synchronized Object proceed() throws Throwable {
173
169
174
170
public synchronized Object proceed (Object [] adviceBindings ) throws Throwable {
175
171
// 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 );
182
173
183
174
if (ac == null ) {
184
175
return null ;
0 commit comments