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
// '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;
* 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);
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
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.
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);
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"
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;
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");
public void testAnnotationPatternMatchingOnTypes() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
ResolvedTypeX rtx = loadType("AnnotatedClass");
initAnnotationTypePatterns();
}
public void testAnnotationPatternMatchingOnMethods() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
ResolvedTypeX rtx = loadType("AnnotatedClass");
ResolvedMember aMethod = rtx.getDeclaredMethods()[1];
}
public void testAnnotationPatternMatchingOnFields() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
ResolvedTypeX rtx = loadType("AnnotatedClass");
ResolvedMember aField = rtx.getDeclaredFields()[0];
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;
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");
}
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);
}
public void testBindingAnnotationPatternMatching() {
- if (is15VMOrGreater) {
+ if (LangUtil.is15VMOrGreater()) {
PatternParser p = new PatternParser("foo");
AnnotationTypePattern ap = p.parseAnnotationNameOrVarTypePattern();
try {
}
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);
// }
//
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);