package org.aspectj.ajdt.ajc;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.StringTokenizer;
-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.ajdt.internal.core.builder.AjBuildConfig;
+import org.aspectj.bridge.CountingMessageHandler;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessageHandler;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.Message;
+import org.aspectj.bridge.MessageUtil;
+import org.aspectj.bridge.SourceLocation;
+import org.aspectj.bridge.Version;
import org.aspectj.org.eclipse.jdt.core.compiler.InvalidInputException;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.Main;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+import org.aspectj.util.FileUtil;
+import org.aspectj.util.LangUtil;
+import org.aspectj.weaver.Constants;
+import org.aspectj.weaver.Dump;
+import org.aspectj.weaver.WeaverMessages;
public class BuildArgParser extends Main {
import org.aspectj.weaver.ConcreteTypeMunger;
import org.aspectj.weaver.FakeAnnotation;
import org.aspectj.weaver.ReferenceType;
+import org.aspectj.weaver.ReferenceTypeDelegate;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.TypeVariable;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.WeaverStateInfo;
import org.aspectj.weaver.World;
+import org.aspectj.weaver.bcel.BcelObjectType;
import org.aspectj.weaver.bcel.LazyClassGen;
import org.aspectj.weaver.patterns.DeclareAnnotation;
import org.aspectj.weaver.patterns.DeclareParents;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS, units[i].compilationResult.fileName);
+// units[i].scope.checkParameterizedTypes(); do this check a little later, after ITDs applied to stbs
units[i].scope.buildFieldsAndMethods();
CompilationAndWeavingContext.leavingPhase(tok);
}
weaveInterTypeDeclarations(units[i].scope, typeMungers, declareParents,declareAnnotationOnTypes);
}
}
-
+
+ for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
+ units[i].scope.checkParameterizedTypes();
+ }
+
for (int i = lastCompletedUnitIndex +1; i<=lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
for (int j = 0; j < b.length; j++) {
private boolean doDeclareParents(DeclareParents declareParents, SourceTypeBinding sourceType) {
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS, sourceType.sourceName);
- List newParents = declareParents.findMatchingNewParents(factory.fromEclipse(sourceType),false);
+ ResolvedType resolvedSourceType = factory.fromEclipse(sourceType);
+ List newParents = declareParents.findMatchingNewParents(resolvedSourceType,false);
if (!newParents.isEmpty()) {
for (Iterator i = newParents.iterator(); i.hasNext(); ) {
ResolvedType parent = (ResolvedType)i.next();
if (Modifier.isFinal(parent.getModifiers())) {
factory.showMessage(IMessage.ERROR,"cannot extend final class " + parent.getClassName(),declareParents.getSourceLocation(),null);
} else {
+ // do not actually do it if the type isn't exposed - this will correctly reported as a problem elsewhere
+ if (!resolvedSourceType.isExposedToWeaver()) return false;
AsmRelationshipProvider.getDefault().addDeclareParentsRelationship(declareParents.getSourceLocation(),factory.fromEclipse(sourceType), newParents);
addParent(sourceType, parent);
}
// BUG BUG BUG - We dont test these abits are correct, in fact we'll be very lucky if they are.
// What does that mean? It means on an incremental compile you might get away with an
// annotation that isn't allowed on a type being put on a type.
- abits = toAdd[0].resolvedType.getAnnotationTagBits();
+ if (toAdd[0].resolvedType != null) // pr184447
+ abits = toAdd[0].resolvedType.getAnnotationTagBits();
}
} else {
// much nicer, its a real SourceTypeBinding so we can stay in eclipse land
TypeDeclaration typeDecl = ((SourceTypeBinding)mbs[0].declaringClass).scope.referenceContext;
AbstractMethodDeclaration methodDecl = typeDecl.declarationOf(mbs[0]);
toAdd = methodDecl.annotations; // this is what to add
+ toAdd[0] = createAnnotationCopy(toAdd[0]);
if (toAdd[0].resolvedType!=null) // pr148536
abits = toAdd[0].resolvedType.getAnnotationTagBits();
}
// on the weaver type temporarily
ResolvedType theTargetType = factory.fromEclipse(sourceType);
TypeBinding theAnnotationType = toAdd[0].resolvedType;
- String name = new String(theAnnotationType.qualifiedPackageName())+"."+new String(theAnnotationType.sourceName());
String sig = new String(theAnnotationType.signature());
- if (theTargetType.hasAnnotation(UnresolvedType.forSignature(sig))) {
+ UnresolvedType bcelAnnotationType = UnresolvedType.forSignature(sig);
+ String name = bcelAnnotationType.getName();
+ if (theTargetType.hasAnnotation(bcelAnnotationType)) {
CompilationAndWeavingContext.leavingPhase(tok);
return false;
}
// ann.memberValuePairs = mvps;
return ann;
}
+
+ /** Create a copy of an annotation, not deep but deep enough so we don't copy across fields that will get us into trouble like 'recipient' */
+ private static Annotation createAnnotationCopy(Annotation ann) {
+ NormalAnnotation ann2 = new NormalAnnotation(ann.type,ann.sourceStart);
+ ann2.memberValuePairs = ann.memberValuePairs();
+ ann2.resolvedType = ann.resolvedType;
+ ann2.bits = ann.bits;
+ return ann2;
+// String name = annX.getTypeName();
+// TypeBinding tb = factory.makeTypeBinding(annX.getSignature());
+// String theName = annX.getSignature().getBaseName();
+// char[][] typeName = CharOperation.splitOn('.',name.replace('$','.').toCharArray()); //pr149293 - not bulletproof...
+// long[] positions = new long[typeName.length];
+// for (int i = 0; i < positions.length; i++) positions[i]=pos;
+// TypeReference annType = new QualifiedTypeReference(typeName,positions);
+// NormalAnnotation ann = new NormalAnnotation(annType,pos);
+// ann.resolvedType=tb; // yuck - is this OK in all cases?
+// // We don't need membervalues...
+//// Expression pcExpr = new StringLiteral(pointcutExpression.toCharArray(),pos,pos);
+//// MemberValuePair[] mvps = new MemberValuePair[2];
+//// mvps[0] = new MemberValuePair("value".toCharArray(),pos,pos,pcExpr);
+//// Expression argNamesExpr = new StringLiteral(argNames.toCharArray(),pos,pos);
+//// mvps[1] = new MemberValuePair("argNames".toCharArray(),pos,pos,argNamesExpr);
+//// ann.memberValuePairs = mvps;
+// return ann;
+ }
private boolean isAnnotationTargettingSomethingOtherThanAnnotationOrNormal(long abits) {
return (abits & (TagBits.AnnotationForAnnotationType | TagBits.AnnotationForType))==0;
// reportDeclareParentsMessage(WeaveMessage.WEAVEMESSAGE_DECLAREPARENTSIMPLEMENTS,sourceType,parent);
}
-
+
+ // also add it to the bcel delegate if there is one
+ if (sourceType instanceof BinaryTypeBinding) {
+ ResolvedType onType = factory.fromEclipse(sourceType);
+ ReferenceType rt = (ReferenceType)onType;
+ ReferenceTypeDelegate rtd = rt.getDelegate();
+ if (rtd instanceof BcelObjectType) {
+ ((BcelObjectType)rtd).addParent(parent);
+ }
+ }
+
}
public void warnOnAddedInterface (ResolvedType type, ResolvedType parent) {