aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2017-09-21 10:48:59 -0700
committerAndy Clement <aclement@pivotal.io>2017-09-21 10:48:59 -0700
commit26712118bad08e60c66237e6aa2cfbd6f275cbbe (patch)
tree64531f485c94c9f6e7f1acb8506bf51cc8343cf1 /weaver
parent39b70af69b0b086f82da8ac032de5e5a5e0cdc45 (diff)
parent6d6738cfece6328027916681e67e54225531db38 (diff)
downloadaspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.tar.gz
aspectj-26712118bad08e60c66237e6aa2cfbd6f275cbbe.zip
Bring Java9 branch in line with 1.8.11 progress
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java1
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelShadow.java16
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java1
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java45
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java7
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java4
-rw-r--r--weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java5
7 files changed, 33 insertions, 46 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
index a9f214723..d22b17d12 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelAdvice.java
@@ -26,7 +26,6 @@ import org.aspectj.apache.bcel.generic.InstructionConstants;
import org.aspectj.apache.bcel.generic.InstructionFactory;
import org.aspectj.apache.bcel.generic.InstructionHandle;
import org.aspectj.apache.bcel.generic.InstructionList;
-import org.aspectj.apache.bcel.generic.InvokeDynamic;
import org.aspectj.apache.bcel.generic.LineNumberTag;
import org.aspectj.apache.bcel.generic.LocalVariableTag;
import org.aspectj.bridge.ISourceLocation;
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
index 94462d5ff..10fdbd05c 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
@@ -2586,11 +2586,11 @@ public class BcelShadow extends Shadow {
ret.append(InstructionFactory.createArrayLoad(Type.OBJECT));
ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[0]));
} else {
- int position = (hasThis()/* && pointcutBindsThis */? 1 : 0);
+ int position = (hasThis() && pointcutBindsThis)? 1 : 0;
ret.append(InstructionFactory.createLoad(objectArrayType, theObjectArrayLocalNumber));
ret.append(Utility.createConstant(fact, position));
ret.append(InstructionFactory.createArrayLoad(Type.OBJECT));
- ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[position]));
+ ret.append(Utility.createConversion(fact, Type.OBJECT, callbackMethod.getArgumentTypes()[nextArgumentToProvideForCallback]));
}
nextArgumentToProvideForCallback++;
} else {
@@ -3049,12 +3049,9 @@ public class BcelShadow extends Shadow {
/**
*
- *
* @param callbackMethod the method we will call back to when our run method gets called.
- *
* @param proceedMap A map from state position to proceed argument position. May be non covering on state position.
*/
-
private LazyMethodGen makeClosureClassAndReturnConstructor(String closureClassName, LazyMethodGen callbackMethod,
IntMap proceedMap) {
String superClassName = "org.aspectj.runtime.internal.AroundClosure";
@@ -3076,7 +3073,7 @@ public class BcelShadow extends Shadow {
closureClass.addMethodGen(constructor);
- // method
+ // Create the 'Object run(Object[])' method
LazyMethodGen runMethod = new LazyMethodGen(Modifier.PUBLIC, Type.OBJECT, "run", new Type[] { objectArrayType },
new String[] {}, closureClass);
InstructionList mbody = runMethod.getBody();
@@ -3092,12 +3089,11 @@ public class BcelShadow extends Shadow {
Type[] stateTypes = callbackMethod.getArgumentTypes();
for (int i = 0, len = stateTypes.length; i < len; i++) {
- Type stateType = stateTypes[i];
- ResolvedType stateTypeX = BcelWorld.fromBcel(stateType).resolve(world);
+ ResolvedType resolvedStateType = BcelWorld.fromBcel(stateTypes[i]).resolve(world);
if (proceedMap.hasKey(i)) {
- mbody.append(proceedVar.createConvertableArrayLoad(fact, proceedMap.get(i), stateTypeX));
+ mbody.append(proceedVar.createConvertableArrayLoad(fact, proceedMap.get(i), resolvedStateType));
} else {
- mbody.append(stateVar.createConvertableArrayLoad(fact, i, stateTypeX));
+ mbody.append(stateVar.createConvertableArrayLoad(fact, i, resolvedStateType));
}
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
index 8d5d26499..9768cb9e4 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
@@ -44,7 +44,6 @@ import org.aspectj.bridge.MessageUtil;
import org.aspectj.bridge.WeaveMessage;
import org.aspectj.bridge.context.CompilationAndWeavingContext;
import org.aspectj.bridge.context.ContextToken;
-import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.AjcMemberMaker;
import org.aspectj.weaver.AnnotationAJ;
import org.aspectj.weaver.AnnotationOnTypeMunger;
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index e3e97517a..1a66c72b3 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -215,12 +215,15 @@ public class BcelWeaver {
}
return type;
} else {
- // FIXME AV - better warning upon no such aspect from aop.xml
- RuntimeException ex = new RuntimeException("Cannot register non aspect: " + type.getName() + " , " + aspectName);
- if (trace.isTraceEnabled()) {
- trace.exit("addLibraryAspect", ex);
- }
- throw ex;
+ if (type.isMissing()) {
+ // May not be found if not visible to the classloader that can see the aop.xml during LTW
+ IMessage message = new Message("The specified aspect '"+aspectName+"' cannot be found", null, true);
+ world.getMessageHandler().handleMessage(message);
+ } else {
+ IMessage message = new Message("Cannot register '"+aspectName+"' because the type found with that name is not an aspect", null, true);
+ world.getMessageHandler().handleMessage(message);
+ }
+ return null;
}
}
@@ -694,8 +697,7 @@ public class BcelWeaver {
// if numFormals > 0 then every branch of a disjunction must bind each
// formal once and only once.
// in addition, the left and right branches of a disjunction must hold on
- // join point kinds in
- // common.
+ // join point kinds in common.
private void validateBindings(Pointcut dnfPointcut, Pointcut userPointcut, int numFormals, String[] names) {
if (numFormals == 0) {
return; // nothing to check
@@ -737,8 +739,7 @@ public class BcelWeaver {
int kindsInCommon = left.couldMatchKinds() & right.couldMatchKinds();
if (kindsInCommon != Shadow.NO_SHADOW_KINDS_BITS && couldEverMatchSameJoinPoints(left, right)) {
// we know that every branch binds every formal, so there is no
- // ambiguity
- // if each branch binds it in exactly the same way...
+ // ambiguity if each branch binds it in exactly the same way...
List<String> ambiguousNames = new ArrayList<String>();
for (int i = 0; i < numFormals; i++) {
if (leftBindings[i] == null) {
@@ -799,10 +800,9 @@ public class BcelWeaver {
validateSingleBranchRecursion(and.getLeft(), userPointcut, foundFormals, names, bindings);
validateSingleBranchRecursion(and.getRight(), userPointcut, foundFormals, names, bindings);
} else if (pc instanceof NameBindingPointcut) {
- List/* BindingTypePattern */btps = ((NameBindingPointcut) pc).getBindingTypePatterns();
- for (Iterator iter = btps.iterator(); iter.hasNext();) {
- BindingTypePattern btp = (BindingTypePattern) iter.next();
- int index = btp.getFormalIndex();
+ List<BindingTypePattern> bindingTypePatterns = ((NameBindingPointcut) pc).getBindingTypePatterns();
+ for (BindingTypePattern bindingTypePattern: bindingTypePatterns) {
+ int index = bindingTypePattern.getFormalIndex();
bindings[index] = pc;
if (foundFormals[index]) {
raiseAmbiguousBindingError(names[index], userPointcut);
@@ -810,10 +810,9 @@ public class BcelWeaver {
foundFormals[index] = true;
}
}
- List/* BindingPattern */baps = ((NameBindingPointcut) pc).getBindingAnnotationTypePatterns();
- for (Iterator iter = baps.iterator(); iter.hasNext();) {
- BindingPattern bap = (BindingPattern) iter.next();
- int index = bap.getFormalIndex();
+ List<BindingPattern> bindingAnnotationTypePatterns = ((NameBindingPointcut) pc).getBindingAnnotationTypePatterns();
+ for (BindingPattern bindingAnnotationTypePattern: bindingAnnotationTypePatterns) {
+ int index = bindingAnnotationTypePattern.getFormalIndex();
bindings[index] = pc;
if (foundFormals[index]) {
raiseAmbiguousBindingError(names[index], userPointcut);
@@ -909,13 +908,9 @@ public class BcelWeaver {
.getSourceContext().makeSourceLocation(userPointcut), null);
}
- /**
- * @param name
- * @param userPointcut
- */
- private void raiseAmbiguousBindingError(String name, Pointcut userPointcut) {
- world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AMBIGUOUS_BINDING, name), userPointcut
- .getSourceContext().makeSourceLocation(userPointcut), null);
+ private void raiseAmbiguousBindingError(String name, Pointcut pointcut) {
+ world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.AMBIGUOUS_BINDING, name), pointcut
+ .getSourceContext().makeSourceLocation(pointcut), null);
}
/**
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index 869ed5819..2655a3456 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
-import java.util.Stack;
import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.classfile.Attribute;
@@ -688,8 +687,7 @@ public final class LazyMethodGen implements Traceable {
}
}
int ecounter = 0;
- for (Iterator i = exnTable.iterator(); i.hasNext();) {
- ExceptionRange er = (ExceptionRange) i.next();
+ for (ExceptionRange er: exnTable) {
String exceptionLabel = "E" + ecounter++;
labelMap.put(Range.getRealStart(er.getHandler()), exceptionLabel);
labelMap.put(er.getHandler(), exceptionLabel);
@@ -1022,7 +1020,8 @@ public final class LazyMethodGen implements Traceable {
} else {
packBody(gen);
}
- gen.setMaxLocals();
+
+ gen.setMaxLocals(true);
gen.setMaxStack();
} else {
gen.setInstructionList(null);
diff --git a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
index 79a96c775..d02c90130 100644
--- a/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
+++ b/weaver/src/org/aspectj/weaver/bcel/UnwovenClassFile.java
@@ -71,10 +71,10 @@ public class UnwovenClassFile implements IUnwovenClassFile {
}
public void writeUnchangedBytes() throws IOException {
- writeWovenBytes(getBytes(), Collections.EMPTY_LIST);
+ writeWovenBytes(getBytes(), Collections.<ChildClass>emptyList());
}
- public void writeWovenBytes(byte[] bytes, List childClasses) throws IOException {
+ public void writeWovenBytes(byte[] bytes, List<ChildClass> childClasses) throws IOException {
writeChildClasses(childClasses);
// System.err.println("should write: " + getClassName());
diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
index 3148cbdaf..8e7f72f4f 100644
--- a/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
+++ b/weaver/testsrc/org/aspectj/weaver/bcel/ArgsWeaveTestCase.java
@@ -22,6 +22,7 @@ import org.aspectj.apache.bcel.generic.InstructionFactory;
import org.aspectj.apache.bcel.generic.InstructionHandle;
import org.aspectj.apache.bcel.generic.InstructionList;
import org.aspectj.apache.bcel.generic.Type;
+import org.aspectj.weaver.Advice;
import org.aspectj.weaver.AdviceKind;
import org.aspectj.weaver.MemberImpl;
import org.aspectj.weaver.ResolvedType;
@@ -54,8 +55,7 @@ public class ArgsWeaveTestCase extends WeaveTestCase {
}
public void testLots() throws IOException {
- List l = new ArrayList();
-
+ List<Advice> l = new ArrayList();
BcelAdvice p1 =
makeArgsMunger("before");
@@ -70,7 +70,6 @@ public class ArgsWeaveTestCase extends WeaveTestCase {
l.add(p2);
l.add(p3);
-
weaveTest("HelloWorld", "ArgsBeforeAfterHelloWorld", addLexicalOrder(l));
}