From: aclement Date: Thu, 17 Jan 2008 00:27:56 +0000 (+0000) Subject: AspectJ6: picking up compiler interface changes X-Git-Tag: V1_6_0M1~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=82798ce1343827def3993c82d295bcdae0f93335;p=aspectj.git AspectJ6: picking up compiler interface changes --- diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java index cc53512a8..95ef3856b 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjConstructorDeclaration.java @@ -17,6 +17,7 @@ import org.aspectj.weaver.AjAttribute; import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; /** * Root class for all ConstructorDeclaration objects created by the parser. @@ -43,7 +44,7 @@ public class AjConstructorDeclaration extends ConstructorDeclaration { } protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) { - if (!classFile.codeStream.generateLineNumberAttributes) return; + if ((classFile.codeStream.generateAttributes & ClassFileConstants.ATTR_LINES)==0) return; int[] separators = compilationResult().lineSeparatorPositions; int declarationStartLine = 1; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index f49ffeb07..16edc567a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -27,6 +27,7 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseTypeMunger; import org.aspectj.ajdt.internal.compiler.lookup.HelperInterfaceBinding; import org.aspectj.ajdt.internal.compiler.lookup.InlineAccessFieldBinding; import org.aspectj.ajdt.internal.compiler.lookup.PrivilegedHandler; +import org.aspectj.apache.bcel.classfile.Signature.BaseTypeSignature; import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; @@ -34,11 +35,12 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Clinit; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; +import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.BranchLabel; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Label; import org.aspectj.org.eclipse.jdt.internal.compiler.env.IGenericType; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BaseTypes; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; @@ -49,6 +51,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBin import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SyntheticFieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.AjcMemberMaker; @@ -103,7 +106,7 @@ public class AspectDeclaration extends TypeDeclaration { } public boolean isAbstract() { - return (modifiers & AccAbstract) != 0; + return (modifiers & ClassFileConstants.AccAbstract) != 0; } public void resolve() { @@ -247,21 +250,22 @@ public class AspectDeclaration extends TypeDeclaration { if (!isAbstract()) { - initFailureField = factory.makeFieldBinding(AjcMemberMaker.initFailureCauseField(typeX)); - binding.addField(initFailureField); + initFailureField = factory.createSyntheticFieldBinding(binding,AjcMemberMaker.initFailureCauseField(typeX)); +// binding.addSyntheticField((SyntheticFieldBinding)initFailureField); + //initFailureField = factory.makeFieldBinding(AjcMemberMaker.initFailureCauseField(typeX)); + //binding.addField(initFailureField); if (perClause == null) { // we've already produced an error for this } else if (perClause.getKind() == PerClause.SINGLETON) { - binding.addField(factory.makeFieldBinding(AjcMemberMaker.perSingletonField( - typeX))); + factory.createSyntheticFieldBinding(binding, AjcMemberMaker.perSingletonField(typeX)); +//CUSTARD binding.addField(factory.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX))); +//CUSTARD methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, false, true, initFailureField); } else if (perClause.getKind() == PerClause.PERCFLOW) { - binding.addField( - factory.makeFieldBinding( - AjcMemberMaker.perCflowField( - typeX))); + factory.createSyntheticFieldBinding(binding, AjcMemberMaker.perCflowField(typeX)); +//CUSTARD binding.addField(factory.makeFieldBinding(AjcMemberMaker.perCflowField(typeX))); methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, true, false, null); } else if (perClause.getKind() == PerClause.PEROBJECT) { // binding.addField( @@ -269,8 +273,9 @@ public class AspectDeclaration extends TypeDeclaration { // AjcMemberMaker.perCflowField( // typeX))); } else if (perClause.getKind() == PerClause.PERTYPEWITHIN) { + factory.createSyntheticFieldBinding(binding, AjcMemberMaker.perTypeWithinWithinTypeField(typeX,typeX)); //PTWIMPL Add field for storing typename in aspect for which the aspect instance exists - binding.addField(factory.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX,typeX))); +// binding.addField(factory.makeFieldBinding(AjcMemberMaker.perTypeWithinWithinTypeField(typeX,typeX))); } else { throw new RuntimeException("unimplemented"); } @@ -433,11 +438,12 @@ public class AspectDeclaration extends TypeDeclaration { gen.generate(codeStream); // body ends here if (codeStream.pcToSourceMapSize==0) codeStream.recordPositionsFrom(0,1); - boolean b = codeStream.generateLocalVariableTableAttributes; // pr148693 - if (codeStream.maxLocals==0) - codeStream.generateLocalVariableTableAttributes=false; + boolean b = ((codeStream.generateAttributes & ClassFileConstants.ATTR_VARS)!=0?true:false); // pr148693 + if (codeStream.maxLocals==0) { + codeStream.generateAttributes &= ~ClassFileConstants.ATTR_VARS; + } classFile.completeCodeAttribute(codeAttributeOffset); - codeStream.generateLocalVariableTableAttributes=b; + if (b) codeStream.generateAttributes |= ClassFileConstants.ATTR_VARS; attributeNumber++; classFile.completeMethodInfo(methodAttributeOffset, attributeNumber); @@ -498,7 +504,7 @@ public class AspectDeclaration extends TypeDeclaration { codeStream.dup(); codeStream.invokespecial( new MethodBinding(0, "".toCharArray(), - BaseTypes.VoidBinding, new TypeBinding[0], + TypeBinding.VOID, new TypeBinding[0], new ReferenceBinding[0], binding)); @@ -566,10 +572,10 @@ public class AspectDeclaration extends TypeDeclaration { final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope); generateMethod(classFile, aspectOfMethod, new BodyGenerator() { public void generate(CodeStream codeStream) { - - Label instanceFound = new Label(codeStream); + BranchLabel instanceFound = new BranchLabel(codeStream); ExceptionLabel anythingGoesWrong = new ExceptionLabel(codeStream,world.makeTypeBinding(UnresolvedType.JAVA_LANG_EXCEPTION)); + anythingGoesWrong.placeStart(); codeStream.aload_0(); codeStream.invokestatic(world.makeMethodBindingForCall(AjcMemberMaker.perTypeWithinGetInstance(typeX))); codeStream.astore_1(); @@ -609,8 +615,8 @@ public class AspectDeclaration extends TypeDeclaration { generateMethod(classFile, aspectOfMethod, new BodyGenerator() { public void generate(CodeStream codeStream) { // body starts here - Label wrongType = new Label(codeStream); - Label popWrongType = new Label(codeStream); + BranchLabel wrongType = new BranchLabel(codeStream); + BranchLabel popWrongType = new BranchLabel(codeStream); codeStream.aload_0(); codeStream.instance_of(interfaceType); codeStream.ifeq(wrongType); @@ -645,7 +651,7 @@ public class AspectDeclaration extends TypeDeclaration { generateMethod(classFile, hasAspectMethod, new BodyGenerator() { public void generate(CodeStream codeStream) { // body starts here - Label wrongType = new Label(codeStream); + BranchLabel wrongType = new BranchLabel(codeStream); codeStream.aload_0(); codeStream.instance_of(interfaceType); codeStream.ifeq(wrongType); @@ -670,8 +676,8 @@ public class AspectDeclaration extends TypeDeclaration { generateMethod(classFile, hasAspectMethod, new BodyGenerator() { public void generate(CodeStream codeStream) { ExceptionLabel goneBang = new ExceptionLabel(codeStream,world.makeTypeBinding(UnresolvedType.JAVA_LANG_EXCEPTION)); - Label noInstanceExists = new Label(codeStream); - Label leave = new Label(codeStream); + BranchLabel noInstanceExists = new BranchLabel(codeStream); + BranchLabel leave = new BranchLabel(codeStream); goneBang.placeStart(); codeStream.aload_0(); codeStream.invokestatic(world.makeMethodBinding(AjcMemberMaker.perTypeWithinGetInstance(typeX))); @@ -699,7 +705,7 @@ public class AspectDeclaration extends TypeDeclaration { new BodyGenerator() { public void generate(CodeStream codeStream) { // body starts here - Label wrongType = new Label(codeStream); + BranchLabel wrongType = new BranchLabel(codeStream); codeStream.aload_0(); codeStream.instance_of(interfaceType); codeStream.ifeq(wrongType); //XXX this case might call for screaming @@ -716,7 +722,7 @@ public class AspectDeclaration extends TypeDeclaration { codeStream.dup(); codeStream.invokespecial( new MethodBinding(0, "".toCharArray(), - BaseTypes.VoidBinding, new TypeBinding[0], + TypeBinding.VOID, new TypeBinding[0], new ReferenceBinding[0], binding)); codeStream.invokeinterface(world.makeMethodBindingForCall( AjcMemberMaker.perObjectInterfaceSet(typeX))); @@ -801,7 +807,7 @@ public class AspectDeclaration extends TypeDeclaration { codeStream.new_(world.makeTypeBinding(typeX)); codeStream.dup(); codeStream.invokespecial(new MethodBinding(0, "".toCharArray(), - BaseTypes.VoidBinding, new TypeBinding[0], + TypeBinding.VOID, new TypeBinding[0], new ReferenceBinding[0], binding)); codeStream.astore_1(); codeStream.aload_1(); @@ -849,7 +855,7 @@ public class AspectDeclaration extends TypeDeclaration { // body starts here (see end of each line for what it is doing!) FieldBinding fb = world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX)); codeStream.getstatic(fb); // GETSTATIC - Label isNonNull = new Label(codeStream); + BranchLabel isNonNull = new BranchLabel(codeStream); codeStream.ifnonnull(isNonNull); // IFNONNULL codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); // NEW codeStream.dup(); // DUP @@ -872,7 +878,7 @@ public class AspectDeclaration extends TypeDeclaration { // body starts here codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perSingletonField( typeX))); - Label isNull = new Label(codeStream); + BranchLabel isNull = new BranchLabel(codeStream); codeStream.ifnull(isNull); codeStream.iconst_1(); codeStream.ireturn(); @@ -897,7 +903,7 @@ public class AspectDeclaration extends TypeDeclaration { codeStream.dup(); codeStream.invokespecial( new MethodBinding(0, "".toCharArray(), - BaseTypes.VoidBinding, new TypeBinding[0], + TypeBinding.VOID, new TypeBinding[0], new ReferenceBinding[0], binding)); codeStream.putstatic( @@ -1158,7 +1164,7 @@ public class AspectDeclaration extends TypeDeclaration { superclass.print(0, output); } if (superInterfaces != null && superInterfaces.length > 0) { - output.append((kind() == IGenericType.INTERFACE_DECL) ? " extends " : " implements ");//$NON-NLS-2$ //$NON-NLS-1$ + output.append((TypeDeclaration.kind(this.modifiers) == TypeDeclaration.INTERFACE_DECL) ? " extends " : " implements ");//$NON-NLS-2$ //$NON-NLS-1$ for (int i = 0; i < superInterfaces.length; i++) { if (i > 0) output.append( ", "); //$NON-NLS-1$ superInterfaces[i].print(0, output); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/Proceed.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/Proceed.java index 77244f8da..cb682c0f9 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/Proceed.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/Proceed.java @@ -16,13 +16,21 @@ package org.aspectj.ajdt.internal.compiler.ast; import org.aspectj.weaver.AdviceKind; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CastExpression; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MessageSend; +import org.aspectj.org.eclipse.jdt.internal.compiler.impl.Constant; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; @@ -70,7 +78,7 @@ public class Proceed extends MessageSend { return super.resolveType(scope); } - constant = NotAConstant; + constant = Constant.NotAConstant; binding = codegenBinding = aroundDecl.proceedMethodBinding; this.actualReceiverType = binding.declaringClass; @@ -105,11 +113,57 @@ public class Proceed extends MessageSend { boolean argsContainCast = false; for (int i=0; i= 0;) +// pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type +// this.binding = +// this.receiver.isImplicitThis() +// ? scope.getImplicitMethod(this.selector, pseudoArgs, this) +// : scope.findMethod((ReferenceBinding) this.actualReceiverType, this.selector, pseudoArgs, this); +// if (this.binding != null && !this.binding.isValidBinding()) { +// MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; +// // record the closest match, for clients who may still need hint about possible method match +// if (closestMatch != null) { +// if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method +// // shouldn't return generic method outside its context, rather convert it to raw method (175409) +// closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null); +// } +// this.binding = closestMatch; +// MethodBinding closestMatchOriginal = closestMatch.original(); +// if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) { +// // ignore cases where method is used from within inside itself (e.g. direct recursions) +// closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; +// } +// } +// } +// } +// return null; +// } +// } +// - checkInvocationArguments(scope,null,this.actualReceiverType,binding, - this.arguments,binding.parameters,argsContainCast,this); + // checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this); for (int i=0, len=arguments.length; i < len; i++) { Expression arg = arguments[i]; TypeBinding argType = arg.resolveType(scope); @@ -120,7 +174,8 @@ public class Proceed extends MessageSend { } } } - + checkInvocationArguments(scope,null,this.actualReceiverType,binding, + this.arguments,binding.parameters,argsContainCast,this); return binding.returnType; }