summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java17
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java12
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java3
-rw-r--r--util/src/org/aspectj/util/LangUtil.java18
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java20
-rw-r--r--weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java22
6 files changed, 33 insertions, 59 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java b/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java
index 2ea90022a..525e91e52 100644
--- a/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java
+++ b/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java
@@ -24,7 +24,9 @@ import java.util.Set;
import org.aspectj.ajde.internal.CompilerAdapter;
import org.aspectj.bridge.IMessage;
+import org.aspectj.tools.ajc.AjcTestCase;
import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
/**
* Weaving messages are complicated things. There are multiple places where weaving
@@ -68,19 +70,6 @@ public class ShowWeaveMessagesTestCase extends AjdeTestCase {
// 'expected weaving messages' files.
regenerate = false;
}
-
- private static boolean is13VMOrGreater = true;
- private static boolean is14VMOrGreater = true;
- private static boolean is15VMOrGreater = false;
-
- static {
- String vm = System.getProperty("java.vm.version");
- if (vm.startsWith("1.3")) {
- is14VMOrGreater = false;
- } else if (vm.startsWith("1.5")) {
- is15VMOrGreater = true;
- }
- }
private CompilerAdapter compilerAdapter;
@@ -175,7 +164,7 @@ public class ShowWeaveMessagesTestCase extends AjdeTestCase {
* Weave 'declare @type, @constructor, @method and @field' and check the weave messages that come out.
*/
public void testWeaveMessagesDeclareAnnotation() {
- if (!is15VMOrGreater) return; // annotation classes won't be about pre 15
+ if (!LangUtil.is15VMOrGreater()) return; // annotation classes won't be about pre 15
if (debugTests) System.out.println("\ntestWeaveMessagesDeclareAnnotation: Building with Six.lst");
compilerAdapter = new CompilerAdapter();
compilerAdapter.showInfoMessages(true);
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
index c4cace3b3..41bb20bc3 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java
@@ -52,18 +52,6 @@ public class AjcTestCase extends TestCase {
private RunResult lastRunResult;
- protected static boolean is13VMOrGreater = true;
- protected static boolean is14VMOrGreater = true;
- protected static boolean is15VMOrGreater = false;
-
- static {
- String vm = System.getProperty("java.vm.version");
- if (vm.startsWith("1.3")) {
- is14VMOrGreater = false;
- } else if (vm.startsWith("1.5")) {
- is15VMOrGreater = true;
- }
- }
/**
* The Ajc (compiler) instance used for thet test. Created afresh
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index b84ee076e..4bae9cf4c 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -23,6 +23,7 @@ import org.aspectj.apache.bcel.util.ClassPath;
import org.aspectj.apache.bcel.util.SyntheticRepository;
import org.aspectj.asm.AsmManager;
import org.aspectj.testing.XMLBasedAjcTestCase;
+import org.aspectj.util.LangUtil;
/**
* These are tests that will run on Java 1.4 and use the old harness format for test specification.
@@ -115,7 +116,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void testBadASMforEnums() throws IOException {
runTest("bad asm for enums");
- if (System.getProperty("java.vm.version").startsWith("1.5")) {
+ if (LangUtil.is15VMOrGreater()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(baos);
AsmManager.dumptree(pw,AsmManager.getDefault().getHierarchy().getRoot(),0);
diff --git a/util/src/org/aspectj/util/LangUtil.java b/util/src/org/aspectj/util/LangUtil.java
index ce339e0a1..9d3103011 100644
--- a/util/src/org/aspectj/util/LangUtil.java
+++ b/util/src/org/aspectj/util/LangUtil.java
@@ -86,6 +86,24 @@ public class LangUtil {
return false;
}
}
+
+ private static boolean is13VMOrGreater = true;
+ private static boolean is14VMOrGreater = true;
+ private static boolean is15VMOrGreater = false;
+
+ static {
+ String vm = System.getProperty("java.runtime.version");
+ if (vm==null) vm = System.getProperty("java.vm.version");
+ if (vm.startsWith("1.3")) {
+ is14VMOrGreater = false;
+ } else if (vm.startsWith("1.5")) {
+ is15VMOrGreater = true;
+ }
+ }
+
+ public static boolean is13VMOrGreater() { return is13VMOrGreater;}
+ public static boolean is14VMOrGreater() { return is14VMOrGreater;}
+ public static boolean is15VMOrGreater() { return is15VMOrGreater;}
/**
* Shorthand for "if null, throw IllegalArgumentException"
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
index 35c191bbb..37506ad48 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternMatchingTestCase.java
@@ -20,6 +20,7 @@ import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IMessage.Kind;
+import org.aspectj.util.LangUtil;
import org.aspectj.weaver.BcweaverTests;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedTypeX;
@@ -61,19 +62,6 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
private BcelWorld world;
private AnnotationTypePattern fooTP,simpleAnnotationTP;
- private static boolean is13VMOrGreater = true;
- private static boolean is14VMOrGreater = true;
- private static boolean is15VMOrGreater = false;
-
- static {
- String vm = System.getProperty("java.vm.version");
- if (vm.startsWith("1.3")) {
- is14VMOrGreater = false;
- } else if (vm.startsWith("1.5")) {
- is15VMOrGreater = true;
- }
- }
-
private ResolvedTypeX loadType(String name) {
if (world == null) {
world = new BcelWorld(BcweaverTests.TESTDATA_PATH + "/testcode.jar");
@@ -93,7 +81,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
public void testAnnotationPatternMatchingOnTypes() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
ResolvedTypeX rtx = loadType("AnnotatedClass");
initAnnotationTypePatterns();
@@ -170,7 +158,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
}
public void testAnnotationPatternMatchingOnMethods() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
ResolvedTypeX rtx = loadType("AnnotatedClass");
ResolvedMember aMethod = rtx.getDeclaredMethods()[1];
@@ -188,7 +176,7 @@ public class AnnotationPatternMatchingTestCase extends TestCase {
}
public void testAnnotationPatternMatchingOnFields() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
ResolvedTypeX rtx = loadType("AnnotatedClass");
ResolvedMember aField = rtx.getDeclaredFields()[0];
diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
index 02f0e274e..7697b43d7 100644
--- a/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/patterns/AnnotationPatternTestCase.java
@@ -10,6 +10,7 @@
package org.aspectj.weaver.patterns;
import org.aspectj.bridge.AbortException;
+import org.aspectj.util.LangUtil;
import org.aspectj.weaver.AnnotatedElement;
import org.aspectj.weaver.ResolvedTypeX;
import org.aspectj.weaver.BcweaverTests;
@@ -20,18 +21,7 @@ import junit.framework.TestCase;
public class AnnotationPatternTestCase extends TestCase {
- private static boolean is13VMOrGreater = true;
- private static boolean is14VMOrGreater = true;
- private static boolean is15VMOrGreater = false;
-
- static {
- String vm = System.getProperty("java.vm.version");
- if (vm.startsWith("1.3")) {
- is14VMOrGreater = false;
- } else if (vm.startsWith("1.5")) {
- is15VMOrGreater = true;
- }
- }
+
public void testParseSimpleAnnotationPattern() {
PatternParser p = new PatternParser("@Foo");
@@ -254,7 +244,7 @@ public class AnnotationPatternTestCase extends TestCase {
}
public void testExactAnnotationPatternMatching() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
PatternParser p = new PatternParser("@Foo");
AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
@@ -266,7 +256,7 @@ public class AnnotationPatternTestCase extends TestCase {
}
public void testBindingAnnotationPatternMatching() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
PatternParser p = new PatternParser("foo");
AnnotationTypePattern ap = p.parseAnnotationNameOrVarTypePattern();
try {
@@ -283,7 +273,7 @@ public class AnnotationPatternTestCase extends TestCase {
}
public void testAndAnnotationPatternMatching() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
PatternParser p = new PatternParser("@Foo @Boo");
AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);
@@ -313,7 +303,7 @@ public class AnnotationPatternTestCase extends TestCase {
// }
//
public void testNotAnnotationPatternMatching() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
PatternParser p = new PatternParser("!@Foo");
AnnotationTypePattern ap = p.maybeParseAnnotationPattern();
ap = ap.resolveBindings(makeSimpleScope(),new Bindings(3),true);