aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2018-02-28 11:53:14 -0800
committerAndy Clement <aclement@pivotal.io>2018-03-09 17:18:45 -0800
commit7d47cba01043c93bab95b59e66b727580351e85f (patch)
tree07a7fed0235f2d0e3b9221ebf097e5c24d16aaf0 /org.aspectj.matcher
parent6b620ba3aa4b0c9d29560dfa42f8c67dcafb1229 (diff)
downloadaspectj-7d47cba01043c93bab95b59e66b727580351e85f.tar.gz
aspectj-7d47cba01043c93bab95b59e66b727580351e85f.zip
Bug#531694: generate more optional thisJoinPoint construction code
This commit introduces some new methods into the runtime Factory class and modifies code generation to use them (and to use the form of the LDC bytecode that loads class constants).
Diffstat (limited to 'org.aspectj.matcher')
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/Constants.java1
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/RuntimeVersion.java47
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/World.java16
3 files changed, 56 insertions, 8 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/Constants.java b/org.aspectj.matcher/src/org/aspectj/weaver/Constants.java
index 4b99a32ab..bdbde3853 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/Constants.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/Constants.java
@@ -22,6 +22,7 @@ public interface Constants {
public final static String RUNTIME_LEVEL_12 = "1.2";
public final static String RUNTIME_LEVEL_15 = "1.5";
+ public final static String RUNTIME_LEVEL_19 = "1.9";
// Default for 1.5.0
public final static String RUNTIME_LEVEL_DEFAULT = RUNTIME_LEVEL_15;
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/RuntimeVersion.java b/org.aspectj.matcher/src/org/aspectj/weaver/RuntimeVersion.java
new file mode 100644
index 000000000..0cf90a9a2
--- /dev/null
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/RuntimeVersion.java
@@ -0,0 +1,47 @@
+/* *******************************************************************
+ * Copyright (c) 2018 Contributors
+ * 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
+ * ******************************************************************/
+package org.aspectj.weaver;
+
+/**
+ * Captures important runtime versions. Typically new versions are added here if something
+ * changes in the runtime and the code generation may be able to do something different
+ * (more optimal) for a later runtime.
+ *
+ * @author Andy Clement
+ */
+public enum RuntimeVersion {
+
+ V1_2("1.2"), V1_5("1.5"), V1_6_10("1.6.10"), V1_9("1.9");
+
+ private String[] aliases = null;
+
+ RuntimeVersion(String... aliases) {
+ this.aliases = aliases;
+ }
+
+ public static RuntimeVersion getVersionFor(String version) {
+ for (RuntimeVersion candidateVersion: values()) {
+ if (candidateVersion.name().equals(version)) {
+ return candidateVersion;
+ }
+ if (candidateVersion.aliases != null) {
+ for (String alias: candidateVersion.aliases) {
+ if (alias.equals(version)) {
+ return candidateVersion;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isThisVersionOrLater(RuntimeVersion version) {
+ return this.compareTo(version) >= 0;
+ }
+}
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java
index 19d61f5be..644f232ac 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java
@@ -110,8 +110,9 @@ public abstract class World implements Dump.INode {
private boolean incrementalCompileCouldFollow = false;
/** The level of the aspectjrt.jar the code we generate needs to run on */
- private String targetAspectjRuntimeLevel = Constants.RUNTIME_LEVEL_DEFAULT;
-
+ public static final RuntimeVersion RUNTIME_LEVEL_DEFAULT = RuntimeVersion.V1_5;
+ private RuntimeVersion targetAspectjRuntimeLevel = RUNTIME_LEVEL_DEFAULT;
+
/** Flags for the new joinpoints that are 'optional': -Xjoinpoints:arrayconstruction -Xjoinpoints:synchronization */
private boolean optionalJoinpoint_ArrayConstruction = false;
private boolean optionalJoinpoint_Synchronization = false;
@@ -202,6 +203,7 @@ public abstract class World implements Dump.INode {
/**
* Dump processing when a fatal error occurs
*/
+ @Override
public void accept(Dump.IVisitor visitor) {
// visitor.visitObject("Extra configuration:");
// visitor.visitList(extraConfiguration.);
@@ -982,7 +984,7 @@ public abstract class World implements Dump.INode {
}
public void setTargetAspectjRuntimeLevel(String s) {
- targetAspectjRuntimeLevel = s;
+ targetAspectjRuntimeLevel = RuntimeVersion.getVersionFor(s);
}
public void setOptionalJoinpoints(String jps) {
@@ -1005,20 +1007,18 @@ public abstract class World implements Dump.INode {
return optionalJoinpoint_Synchronization;
}
- public String getTargetAspectjRuntimeLevel() {
+ public RuntimeVersion getTargetAspectjRuntimeLevel() {
return targetAspectjRuntimeLevel;
}
- // OPTIMIZE are users falling foul of not supplying -1.5 and so targetting
- // the old runtime?
+ // OPTIMIZE are users falling foul of not supplying -1.5 and so targetting the old runtime?
public boolean isTargettingAspectJRuntime12() {
boolean b = false; // pr116679
if (!isInJava5Mode()) {
b = true;
} else {
- b = getTargetAspectjRuntimeLevel().equals(org.aspectj.weaver.Constants.RUNTIME_LEVEL_12);
+ b = (getTargetAspectjRuntimeLevel() == RuntimeVersion.V1_2);
}
- // System.err.println("Asked if targetting runtime 1.2 , returning: "+b);
return b;
}