aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-11-29 13:21:24 +0000
committeraclement <aclement>2005-11-29 13:21:24 +0000
commit385d9ef905eb07bdd37fd25887ad0a8e69e06f45 (patch)
tree2e9b41bb67df4ca35c4edc2eccd61e23f1f7dca5
parentb6980f2f7b2697e41b454a16d3a7bd1e0135aa8d (diff)
downloadaspectj-385d9ef905eb07bdd37fd25887ad0a8e69e06f45.tar.gz
aspectj-385d9ef905eb07bdd37fd25887ad0a8e69e06f45.zip
code for 116679: targetting a 1.2.1 runtime
-rw-r--r--lib/aspectj/lib/aspectjrt121.jarbin0 -> 41534 bytes
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java9
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties2
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java8
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java1
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java4
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java1
-rw-r--r--tests/bugs150/pr111667/A.java13
-rw-r--r--tests/bugs150/pr111667/X.java3
-rw-r--r--tests/bugs150/pr111667/Y.java4
-rw-r--r--tests/compatibility/Simple.java21
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ajc150.xml10
-rw-r--r--weaver/src/org/aspectj/weaver/Constants.java6
-rw-r--r--weaver/src/org/aspectj/weaver/World.java11
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java10
16 files changed, 104 insertions, 1 deletions
diff --git a/lib/aspectj/lib/aspectjrt121.jar b/lib/aspectj/lib/aspectjrt121.jar
new file mode 100644
index 000000000..ee43ae3a5
--- /dev/null
+++ b/lib/aspectj/lib/aspectjrt121.jar
Binary files differ
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
index 9db08913d..2f4eea60e 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
@@ -20,6 +20,7 @@ import java.util.*;
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;
@@ -637,6 +638,14 @@ public class BuildArgParser extends Main {
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");
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
index a297978ec..3feed9b3d 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
@@ -131,6 +131,8 @@ xoption.usage = {0} non-standard options:\n\
\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):
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
index 505b80844..25200a327 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
@@ -571,4 +571,12 @@ public class AjBuildConfig {
public boolean getBehaveInJava5Way() {
return options.behaveInJava5Way;
}
+
+ public void setTargetAspectjRuntimeLevel(String level) {
+ options.targetAspectjRuntimeLevel = level;
+ }
+
+ public String getTargetAspectjRuntimeLevel() {
+ return options.targetAspectjRuntimeLevel;
+ }
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
index 63ad260af..0cbb761db 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java
@@ -608,6 +608,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc
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());
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java
index 7481b4ffc..d5f04d885 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java
@@ -17,6 +17,7 @@ import java.util.Map;
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;
/**
@@ -73,6 +74,9 @@ public class AjCompilerOptions extends CompilerOptions {
// 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;
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java
index 8bfa9b9d6..84371f08a 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java
@@ -156,6 +156,7 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
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);
diff --git a/tests/bugs150/pr111667/A.java b/tests/bugs150/pr111667/A.java
new file mode 100644
index 000000000..431af1ba1
--- /dev/null
+++ b/tests/bugs150/pr111667/A.java
@@ -0,0 +1,13 @@
+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() {}
+}
+
diff --git a/tests/bugs150/pr111667/X.java b/tests/bugs150/pr111667/X.java
new file mode 100644
index 000000000..232adb7e4
--- /dev/null
+++ b/tests/bugs150/pr111667/X.java
@@ -0,0 +1,3 @@
+public aspect X {
+ before():execution(* m1()) {}
+}
diff --git a/tests/bugs150/pr111667/Y.java b/tests/bugs150/pr111667/Y.java
new file mode 100644
index 000000000..8ed31b5f1
--- /dev/null
+++ b/tests/bugs150/pr111667/Y.java
@@ -0,0 +1,4 @@
+public aspect Y {
+
+ before():execution(* m1()) {}
+}
diff --git a/tests/compatibility/Simple.java b/tests/compatibility/Simple.java
new file mode 100644
index 000000000..72fec1886
--- /dev/null
+++ b/tests/compatibility/Simple.java
@@ -0,0 +1,21 @@
+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);
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
index 282e04c8b..c692b30d9 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
@@ -48,6 +48,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
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");}
@@ -79,6 +80,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
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");}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
index bc6d6d009..fc6457043 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml
@@ -86,6 +86,11 @@
<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"/>
@@ -108,6 +113,11 @@
<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">
diff --git a/weaver/src/org/aspectj/weaver/Constants.java b/weaver/src/org/aspectj/weaver/Constants.java
index e51bf96c2..9962f893c 100644
--- a/weaver/src/org/aspectj/weaver/Constants.java
+++ b/weaver/src/org/aspectj/weaver/Constants.java
@@ -21,4 +21,10 @@ public interface Constants {
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;
}
diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java
index 31db56be9..3f1bd7faf 100644
--- a/weaver/src/org/aspectj/weaver/World.java
+++ b/weaver/src/org/aspectj/weaver/World.java
@@ -79,6 +79,9 @@ public abstract class World implements Dump.INode {
/** 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.
@@ -644,6 +647,14 @@ public abstract class World implements Dump.INode {
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
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
index f97eacbdf..806b4e82c 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
@@ -999,7 +999,14 @@ public final class LazyClassGen {
// 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))));
@@ -1079,6 +1086,7 @@ public final class LazyClassGen {
new Type[] { Type.STRING },
Constants.INVOKEVIRTUAL));
}
+
//XXX should load source location from shadow
list.append(Utility.createConstant(fact, shadow.getSourceLine()));