aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorAlexander Kriegisch <Alexander@Kriegisch.name>2021-03-13 15:07:07 +0700
committerAlexander Kriegisch <Alexander@Kriegisch.name>2021-03-13 15:07:07 +0700
commitcd83adc724c3779cc688405cc475ca5bd1e13bfe (patch)
tree89f60af210f8e497d8d77e1dd2d74b85fb6c75cb /weaver
parent07af5d416e94791eb92ae1123e87394e8d22ad80 (diff)
downloadaspectj-cd83adc724c3779cc688405cc475ca5bd1e13bfe.tar.gz
aspectj-cd83adc724c3779cc688405cc475ca5bd1e13bfe.zip
Make MoveInstructionsWeaveTestCase.testFancyHello pass when run twice
Reset counter, just in case this test runs multiple times in one JVM. This can happen e.g. due to "run all tests" in IntelliJ IDEA, which directly runs this test class and als WeaverModuleTests, both of which implement junit.framework.TestCase. In that case, during the second run the counter would start at a higher base count, making the 2nd test run fail. Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/test/java/org/aspectj/weaver/bcel/MoveInstructionsWeaveTestCase.java23
1 files changed, 14 insertions, 9 deletions
diff --git a/weaver/src/test/java/org/aspectj/weaver/bcel/MoveInstructionsWeaveTestCase.java b/weaver/src/test/java/org/aspectj/weaver/bcel/MoveInstructionsWeaveTestCase.java
index bd7c2ae65..da3e9f79e 100644
--- a/weaver/src/test/java/org/aspectj/weaver/bcel/MoveInstructionsWeaveTestCase.java
+++ b/weaver/src/test/java/org/aspectj/weaver/bcel/MoveInstructionsWeaveTestCase.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver.bcel;
@@ -55,6 +55,11 @@ public class MoveInstructionsWeaveTestCase extends WeaveTestCase {
static int counter = 0;
public void testFancyHello() throws IOException {
+ // Reset counter, just in case this test runs multiple times in one JVM. This can happen e.g. due to "run all tests"
+ // in IntelliJ IDEA, which directly runs this test class and als WeaverModuleTests, both of which implement
+ // junit.framework.TestCase. In that case, during the second run the counter would start at a higher base count,
+ // making the 2nd test run fail.
+ counter = 0;
BcelAdvice p = new BcelAdvice(null, makePointcutAll(), null, 0, -1, -1, null, null) {
public void specializeOn(Shadow s) {
super.specializeOn(s);
@@ -63,7 +68,7 @@ public class MoveInstructionsWeaveTestCase extends WeaveTestCase {
public boolean implementOn(Shadow s) {
BcelShadow shadow = (BcelShadow) s;
- LazyMethodGen newMethod =
+ LazyMethodGen newMethod =
shadow.extractShadowInstructionsIntoNewMethod(NameMangler.getExtractableName(shadow
.getSignature())
+ "_extracted" + counter++, 0, this.getSourceLocation(), new ArrayList(),shadow.getEnclosingClass().isInterface());