import org.aspectj.ajdt.internal.core.builder.*;
import org.aspectj.bridge.*;
import org.aspectj.util.*;
+import org.aspectj.weaver.Constants;
import org.aspectj.weaver.Dump;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.org.eclipse.jdt.core.compiler.InvalidInputException;
buildConfig.setProceedOnError(true);
} else if (new File(arg).isDirectory()) {
showError("dir arg not permitted: " + arg);
+ } else if (arg.startsWith("-Xajruntimetarget")) {
+ if (arg.endsWith(":1.2")) {
+ buildConfig.setTargetAspectjRuntimeLevel(Constants.RUNTIME_LEVEL_12);
+ } else if (arg.endsWith(":1.5")) {
+ buildConfig.setTargetAspectjRuntimeLevel(Constants.RUNTIME_LEVEL_15);
+ } else {
+ showError("-Xajruntimetarget:<level> only supports a target level of 1.2 or 1.5");
+ }
} else if (arg.equals("-1.5")) {
buildConfig.setBehaveInJava5Way(true);
unparsedArgs.add("-1.5");
\t-XserializableAspects allows aspects to implement serializable\n\
\t-XnoWeave compile classes but do not weave. Deprecated, use\n\
\t reweavable instead.\n\
+\t-Xajruntimelevel:<level> allows code to be generated that targets\n\
+\t a 1.2 or a 1.5 level AspectJ runtime (default 1.5)\n\
\t-XhasMember allow hasmethod() and hasfield type patterns in\n\
\t declare parents and declare @type\n
## options not documented above (per ..ajdt.ajc.BuildArgParser.java):
public boolean getBehaveInJava5Way() {
return options.behaveInJava5Way;
}
+
+ public void setTargetAspectjRuntimeLevel(String level) {
+ options.targetAspectjRuntimeLevel = level;
+ }
+
+ public String getTargetAspectjRuntimeLevel() {
+ return options.targetAspectjRuntimeLevel;
+ }
}
cp.addAll(buildConfig.getClasspath());
BcelWorld bcelWorld = new BcelWorld(cp, handler, null);
bcelWorld.setBehaveInJava5Way(buildConfig.getBehaveInJava5Way());
+ bcelWorld.setTargetAspectjRuntimeLevel(buildConfig.getTargetAspectjRuntimeLevel());
bcelWorld.setXnoInline(buildConfig.isXnoInline());
bcelWorld.setXlazyTjp(buildConfig.isXlazyTjp());
bcelWorld.setXHasMemberSupportEnabled(buildConfig.isXHasMemberEnabled());
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.aspectj.weaver.Constants;
/**
// If true - autoboxing behaves differently ...
public boolean behaveInJava5Way = false;
+ // Specifies the level of the aspectjrt.jar we are targetting
+ public String targetAspectjRuntimeLevel = Constants.RUNTIME_LEVEL_DEFAULT;
+
// these next four not exposed by IDEs
public boolean generateModel = false;
public boolean generateJavaDocsInModel = false;
cpManager = new EclipseClassPathManager(nameEnvironment);
myBcelWorld = new BcelWorld(cpManager,new UnhandledMessageHandler(getProject()),null /*(xrefHandler)*/);
myBcelWorld.setBehaveInJava5Way(options.behaveInJava5Way);
+ myBcelWorld.setTargetAspectjRuntimeLevel(options.targetAspectjRuntimeLevel);
myBcelWorld.setXnoInline(options.xNoInline);
myBcelWorld.setXlazyTjp(options.xLazyThisJoinPoint);
myBcelWorld.setXHasMemberSupportEnabled(options.xHasMember);
--- /dev/null
+public class A{
+ public static void main(String []argv) {
+ A a = new A();
+ a.m1();
+ a.m2();
+ a.m3();
+ }
+
+ public void m1() {}
+ public void m2() {}
+ public void m3() {}
+}
+
--- /dev/null
+public aspect X {
+ before():execution(* m1()) {}
+}
--- /dev/null
+public aspect Y {
+
+ before():execution(* m1()) {}
+}
--- /dev/null
+public class Simple {
+ public static void main(String []argv) {
+ new Simple().a();
+ }
+
+ public void a() {}
+}
+
+aspect X {
+ before():execution(* a(..)) {
+ System.err.println(thisJoinPoint);
+ System.err.println(thisJoinPointStaticPart);
+ System.err.println(thisEnclosingJoinPointStaticPart);
+ }
+
+ before():execution(Simple.new(..)) {
+ System.err.println(thisJoinPoint);
+ System.err.println(thisEnclosingJoinPointStaticPart);
+ System.err.println(thisJoinPointStaticPart);
+ }
+}
public void testCunningDeclareParents_pr92311() { runTest("cunning declare parents");}
public void testGenericITDsAndAbstractMethodError_pr102357() { runTest("generic itds and abstract method error");}
*/
+ public void testGeneratingCodeForAnOldRuntime_pr116679() { runTest("generating code for a 1.2.1 runtime");}
public void testAtDeclareParents_pr117681() { runTest("at declare parents");}
public void testPrivilegeProblem_pr87525() { runTest("privilege problem with switch");}
public void testVarargsITD_pr110906() { runTest("ITD varargs problem");}
public void testBadRenderer_pr86903() { runTest("bcelrenderer bad");}
+ //public void testLintForAdviceSorting_pr111667() { runTest("lint for advice sorting");}
public void testIncompatibleClassChangeError_pr113630_1() {runTest("IncompatibleClassChangeError - errorscenario");}
public void testIncompatibleClassChangeError_pr113630_2() {runTest("IncompatibleClassChangeError - workingscenario");}
<run class="Test"/>
</ajc-test>
+ <ajc-test dir="bugs150/pr111667" pr="111667" title="lint for advice sorting">
+ <compile files="A.java,X.java,Y.java" options="-1.5">
+ </compile>
+ </ajc-test>
+
<ajc-test dir="bugs150/pr117296" pr="117296" title="self bounding generic types">
<compile files="PropertySupport.java" options="-1.5"/>
<run class="PropertySupport"/>
<run class="ReflectOnAjcCompiledPointcuts" classpath="../lib/bcel/bcel.jar"/>
</ajc-test>
+ <ajc-test dir="compatibility" title="generating code for a 1.2.1 runtime">
+ <compile files="Simple.java" options="-Xajruntimetarget:1.2"></compile>
+ <run class="Simple" classpath="../lib/aspectj/lib/aspectjrt121.jar"/>
+ </ajc-test>
+
<ajc-test dir="java5/reflection" pr="114322" title="reflection on abstract ITDs (Billing example)">
<compile files="ReflectBilling.java,Billing.aj" options="-1.5"/>
<run class="ReflectBilling">
public final static int ACC_BRIDGE = 0x0040;
public final static int ACC_VARARGS = 0x0080;
+
+ public final static String RUNTIME_LEVEL_12 = "1.2";
+ public final static String RUNTIME_LEVEL_15 = "1.5";
+
+ // Default for 1.5.0
+ public final static String RUNTIME_LEVEL_DEFAULT = RUNTIME_LEVEL_15;
}
/** When behaving in a Java 5 way autoboxing is considered */
private boolean behaveInJava5Way = false;
+ /** The level of the aspectjrt.jar the code we generate needs to run on */
+ private String targetAspectjRuntimeLevel = Constants.RUNTIME_LEVEL_DEFAULT;
+
/**
* A list of RuntimeExceptions containing full stack information for every
* type we couldn't find.
return behaveInJava5Way;
}
+ public void setTargetAspectjRuntimeLevel(String s) {
+ targetAspectjRuntimeLevel = s;
+ }
+
+ public String getTargetAspectjRuntimeLevel() {
+ return targetAspectjRuntimeLevel;
+ }
+
/*
* Map of types in the world, with soft links to expendable ones.
* An expendable type is a reference type that is not exposed to the weaver (ie
// create the signature
list.append(InstructionFactory.createLoad(factoryType, 0));
- if (sig.getKind().equals(Member.METHOD)) {
+ if (world.getTargetAspectjRuntimeLevel().equals(org.aspectj.weaver.Constants.RUNTIME_LEVEL_12)) {
+ list.append(new PUSH(getConstantPoolGen(), sig.getSignatureString(shadow.getWorld())));
+ list.append(fact.createInvoke(factoryType.getClassName(),
+ sig.getSignatureMakerName(),
+ new ObjectType(sig.getSignatureType()),
+ new Type[] { Type.STRING },
+ Constants.INVOKEVIRTUAL));
+ } else if (sig.getKind().equals(Member.METHOD)) {
BcelWorld w = shadow.getWorld();
// For methods, push the parts of the signature on.
list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w))));
new Type[] { Type.STRING },
Constants.INVOKEVIRTUAL));
}
+
//XXX should load source location from shadow
list.append(Utility.createConstant(fact, shadow.getSourceLine()));