diff options
author | aclement <aclement> | 2006-01-20 09:26:04 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-01-20 09:26:04 +0000 |
commit | f51e0736ed52ca6bc3689981f53718b62471251a (patch) | |
tree | 0adf699a53a6a92c4ad3ed9dcad9b814ada0c0f8 /weaver | |
parent | 7e6cfb2bbb19a01ba9043a3e791d9128dd162e75 (diff) | |
download | aspectj-f51e0736ed52ca6bc3689981f53718b62471251a.tar.gz aspectj-f51e0736ed52ca6bc3689981f53718b62471251a.zip |
77166 - newarray joinpoint support. "-Xjoinpoints:arrayconstruction"
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/ResolvedType.java | 10 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/World.java | 14 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelWorld.java | 46 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java | 34 |
4 files changed, 94 insertions, 10 deletions
diff --git a/weaver/src/org/aspectj/weaver/ResolvedType.java b/weaver/src/org/aspectj/weaver/ResolvedType.java index ce072037f..07eb8a926 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedType.java +++ b/weaver/src/org/aspectj/weaver/ResolvedType.java @@ -1683,6 +1683,16 @@ public abstract class ResolvedType extends UnresolvedType implements AnnotatedEl } } + // Handling members for the new array join point + if (world.isJoinpointArrayConstructionEnabled() && this.isArray()) { + if (member.getKind()==Member.CONSTRUCTOR) { + ResolvedMemberImpl ret = + new ResolvedMemberImpl(Member.CONSTRUCTOR,this,Modifier.PUBLIC, + ResolvedType.VOID,"<init>",world.resolve(member.getParameterTypes())); + return ret; + } + } + // if (this.getSuperclass() != ResolvedType.OBJECT && this.getSuperclass() != null) { // return getSuperclass().lookupSyntheticMember(member); // } diff --git a/weaver/src/org/aspectj/weaver/World.java b/weaver/src/org/aspectj/weaver/World.java index b73fba107..a8193d2fa 100644 --- a/weaver/src/org/aspectj/weaver/World.java +++ b/weaver/src/org/aspectj/weaver/World.java @@ -86,6 +86,10 @@ public abstract class World implements Dump.INode { /** The level of the aspectjrt.jar the code we generate needs to run on */ private String targetAspectjRuntimeLevel = Constants.RUNTIME_LEVEL_DEFAULT; + /** Flags for the new joinpoints that are 'optional' */ + private boolean optionalJoinpoint_ArrayConstruction = false; // Command line flag: "arrayconstruction" + + /** * A list of RuntimeExceptions containing full stack information for every * type we couldn't find. @@ -660,6 +664,16 @@ public abstract class World implements Dump.INode { targetAspectjRuntimeLevel = s; } + public void setOptionalJoinpoints(String jps) { + if (jps.indexOf("arrayconstruction")!=-1) { + optionalJoinpoint_ArrayConstruction = true; + } + } + + public boolean isJoinpointArrayConstructionEnabled() { + return optionalJoinpoint_ArrayConstruction; + } + public String getTargetAspectjRuntimeLevel() { return targetAspectjRuntimeLevel; } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java index 2441176fb..634895fa8 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWorld.java @@ -28,13 +28,19 @@ import org.aspectj.apache.bcel.classfile.ClassParser; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.apache.bcel.classfile.annotation.Annotation; +import org.aspectj.apache.bcel.generic.ANEWARRAY; import org.aspectj.apache.bcel.generic.ConstantPoolGen; import org.aspectj.apache.bcel.generic.FieldInstruction; import org.aspectj.apache.bcel.generic.GETSTATIC; import org.aspectj.apache.bcel.generic.INVOKEINTERFACE; import org.aspectj.apache.bcel.generic.INVOKESPECIAL; import org.aspectj.apache.bcel.generic.INVOKESTATIC; +import org.aspectj.apache.bcel.generic.Instruction; +import org.aspectj.apache.bcel.generic.InstructionHandle; import org.aspectj.apache.bcel.generic.InvokeInstruction; +import org.aspectj.apache.bcel.generic.MULTIANEWARRAY; +import org.aspectj.apache.bcel.generic.NEWARRAY; +import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.PUTSTATIC; import org.aspectj.apache.bcel.generic.Type; import org.aspectj.apache.bcel.util.ClassLoaderRepository; @@ -380,6 +386,46 @@ public class BcelWorld extends World implements Repository { } } + + + public Member makeJoinPointSignatureForArrayConstruction(LazyClassGen cg, InstructionHandle handle) { + Instruction i = handle.getInstruction(); + ConstantPoolGen cpg = cg.getConstantPoolGen(); + Member retval = null; + + if (i instanceof ANEWARRAY) { + ANEWARRAY arrayInstruction = (ANEWARRAY)i; + ObjectType ot = arrayInstruction.getLoadClassType(cpg); + UnresolvedType ut = fromBcel(ot); + ut = UnresolvedType.makeArray(ut,1); + retval = MemberImpl.method(ut, Modifier.PUBLIC, ResolvedType.VOID, "<init>", new ResolvedType[]{ResolvedType.INT}); + + } else if (i instanceof MULTIANEWARRAY) { + MULTIANEWARRAY arrayInstruction = (MULTIANEWARRAY)i; + UnresolvedType ut = null; + short dimensions = arrayInstruction.getDimensions(); + ObjectType ot = arrayInstruction.getLoadClassType(cpg); + if (ot!=null) { + ut = fromBcel(ot); + ut = UnresolvedType.makeArray(ut,dimensions); + } else { + Type t = arrayInstruction.getType(cpg); + ut = fromBcel(t); + } + ResolvedType[] parms = new ResolvedType[dimensions]; + for (int ii=0;ii<dimensions;ii++) parms[ii] = ResolvedType.INT; + retval = MemberImpl.method(ut, Modifier.PUBLIC, ResolvedType.VOID, "<init>", parms); + + } else if (i instanceof NEWARRAY) { + NEWARRAY arrayInstruction = (NEWARRAY)i; + Type ot = arrayInstruction.getType(); + UnresolvedType ut = fromBcel(ot); + retval = MemberImpl.method(ut, Modifier.PUBLIC, ResolvedType.VOID, "<init>", new ResolvedType[]{ResolvedType.INT}); + } else { + throw new BCException("Cannot create array construction signature for this non-array instruction:"+i); + } + return retval; + } public Member makeJoinPointSignatureForMethodInvocation(LazyClassGen cg, InvokeInstruction ii) { ConstantPoolGen cpg = cg.getConstantPoolGen(); diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java index a22920a77..60d91fc4e 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java @@ -1035,16 +1035,30 @@ public final class LazyClassGen { Constants.INVOKEVIRTUAL)); } else if(sig.getKind().equals(Member.CONSTRUCTOR)) { BcelWorld w = shadow.getWorld(); - list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w)))); - list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType()))); - list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes()))); - list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterNames(w)))); - list.append(new PUSH(getConstantPoolGen(),makeString(sig.getExceptions(w)))); - list.append(fact.createInvoke(factoryType.getClassName(), - sig.getSignatureMakerName(), - new ObjectType(sig.getSignatureType()), - new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING }, - Constants.INVOKEVIRTUAL)); + if (w.isJoinpointArrayConstructionEnabled() && sig.getDeclaringType().isArray()) { + // its the magical new jp + list.append(new PUSH(getConstantPoolGen(),makeString(Modifier.PUBLIC))); + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType()))); + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes()))); + list.append(new PUSH(getConstantPoolGen(),""));//makeString("")));//sig.getParameterNames(w)))); + list.append(new PUSH(getConstantPoolGen(),""));//makeString("")));//sig.getExceptions(w)))); + list.append(fact.createInvoke(factoryType.getClassName(), + sig.getSignatureMakerName(), + new ObjectType(sig.getSignatureType()), + new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING }, + Constants.INVOKEVIRTUAL)); + } else { + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w)))); + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getDeclaringType()))); + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterTypes()))); + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getParameterNames(w)))); + list.append(new PUSH(getConstantPoolGen(),makeString(sig.getExceptions(w)))); + list.append(fact.createInvoke(factoryType.getClassName(), + sig.getSignatureMakerName(), + new ObjectType(sig.getSignatureType()), + new Type[] { Type.STRING, Type.STRING, Type.STRING, Type.STRING, Type.STRING }, + Constants.INVOKEVIRTUAL)); + } } else if(sig.getKind().equals(Member.FIELD)) { BcelWorld w = shadow.getWorld(); list.append(new PUSH(getConstantPoolGen(),makeString(sig.getModifiers(w)))); |