From a8c1caa33da4f62b452f18a3304116cbfdcab4d0 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 5 May 2009 23:41:20 +0000 Subject: [PATCH] 275032: test and fix: itd of no-arg constructor should overwrite a generated default constructor --- .../lookup/EclipseAnnotationConvertor.java | 3 +++ .../compiler/lookup/EclipseResolvedMember.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java index 3aed8f22b..d0088e164 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java @@ -15,6 +15,7 @@ import org.aspectj.apache.bcel.classfile.annotation.ElementValueGen; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ArrayInitializer; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MemberValuePair; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.NormalAnnotation; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; @@ -100,6 +101,8 @@ public class EclipseAnnotationConvertor { annotationAJ.addNameValuePair(new AnnotationNameValuePair(new String( singleMemberAnnotation.memberValuePairs()[0].name), av)); } + } else if (annotation instanceof MarkerAnnotation) { + MarkerAnnotation markerAnnotation = (MarkerAnnotation) annotation; } else { // this is a marker annotation (no member value pairs) throw new MissingImplementationException( diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java index 365373c5a..463ecc5eb 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseResolvedMember.java @@ -26,6 +26,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.impl.IntConstant; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Binding; 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.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; @@ -52,6 +53,7 @@ public class EclipseResolvedMember extends ResolvedMemberImpl { private ResolvedType[] cachedAnnotationTypes; private EclipseFactory eclipseFactory; + public EclipseResolvedMember(MethodBinding binding, MemberKind memberKind, ResolvedType realDeclaringType, int modifiers, UnresolvedType rettype, String name, UnresolvedType[] paramtypes, UnresolvedType[] extypes, EclipseFactory eclipseFactory) { @@ -235,4 +237,19 @@ public class EclipseResolvedMember extends ResolvedMemberImpl { return null; } + /** + * Return true if this is the default constructor. The default constructor + * is the one generated if there isn't one in the source. Eclipse + * helpfully uses a bit to indicate the default constructor. + * + * @return true if this is the default constructor. + */ + public boolean isDefaultConstructor() { + if (!(realBinding instanceof MethodBinding)) { + return false; + } + MethodBinding mb = (MethodBinding) realBinding; + return mb.isConstructor() && ((mb.modifiers & ExtraCompilerModifiers.AccIsDefaultConstructor) != 0); + } + } -- 2.39.5