diff options
5 files changed, 38 insertions, 7 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index e254922bd..538057f97 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -55,6 +55,7 @@ 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.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.weaver.AbstractReferenceTypeDelegate; @@ -68,6 +69,7 @@ import org.aspectj.weaver.BCException; import org.aspectj.weaver.EnumAnnotationValue; import org.aspectj.weaver.ReferenceType; import org.aspectj.weaver.ResolvedMember; +import org.aspectj.weaver.ResolvedMemberImpl; import org.aspectj.weaver.ResolvedPointcutDefinition; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.StandardAnnotation; @@ -245,7 +247,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { List<ResolvedMember> declaredMethods = new ArrayList<ResolvedMember>(); List<ResolvedMember> declaredFields = new ArrayList<ResolvedMember>(); - binding.methods(); // the important side-effect of this call is to make + MethodBinding[] ms = binding.methods(); // the important side-effect of this call is to make // sure bindings are completed AbstractMethodDeclaration[] methods = declaration.methods; if (methods != null) { @@ -306,6 +308,28 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { } } } + + if (isEnum()) { + // The bindings for the eclipse binding will include values/valueof + for (int m=0,len=ms.length;m<len;m++) { + MethodBinding mb = ms[m]; + if ((mb instanceof SyntheticMethodBinding) && mb.isStatic()) { // cannot use .isSynthetic() because it isn't truly synthetic + if (CharOperation.equals(mb.selector,valuesCharArray) && mb.parameters.length==0 && mb.returnType.isArrayType() && ((ArrayBinding)mb.returnType).leafComponentType()==binding) { + // static <EnumType>[] values() + ResolvedMember valuesMember = factory.makeResolvedMember(mb); + valuesMember.setSourceContext(new EclipseSourceContext(unit.compilationResult, 0)); + valuesMember.setPosition(0, 0); + declaredMethods.add(valuesMember); + } else if (CharOperation.equals(mb.selector,valueOfCharArray) && mb.parameters.length==1 && CharOperation.equals(mb.parameters[0].signature(),jlString) && mb.returnType==binding) { + // static <EnumType> valueOf(String) + ResolvedMember valueOfMember = factory.makeResolvedMember(mb); + valueOfMember.setSourceContext(new EclipseSourceContext(unit.compilationResult, 0)); + valueOfMember.setPosition(0, 0); + declaredMethods.add(valueOfMember); + } + } + } + } FieldBinding[] fields = binding.fields(); for (int i = 0, len = fields.length; i < len; i++) { @@ -317,6 +341,11 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { this.declaredMethods = declaredMethods.toArray(new ResolvedMember[declaredMethods.size()]); this.declaredFields = declaredFields.toArray(new ResolvedMember[declaredFields.size()]); } + + private final static char[] valuesCharArray = "values".toCharArray(); + private final static char[] valueOfCharArray = "valueOf".toCharArray(); + private final static char[] jlString = "Ljava/lang/String;".toCharArray(); + private ResolvedPointcutDefinition makeResolvedPointcutDefinition(AbstractMethodDeclaration md) { if (md.binding == null) { diff --git a/tests/bugs171/pr387568/Code.java b/tests/bugs171/pr387568/Code.java index 99d248803..8b86a3a68 100644 --- a/tests/bugs171/pr387568/Code.java +++ b/tests/bugs171/pr387568/Code.java @@ -1,12 +1,13 @@ import java.lang.annotation.*; - class AAA { public void m() { Color[] cs = Color.values(); + Color c = Color.valueOf("R"); } } +@Anno aspect Foo { after(): @annotation(Anno) {} } @@ -14,4 +15,3 @@ aspect Foo { @Retention(RetentionPolicy.RUNTIME) @interface Anno {} -enum Color {R,G,B;} diff --git a/tests/bugs171/pr387568/Color.java b/tests/bugs171/pr387568/Color.java new file mode 100644 index 000000000..39d74a8fb --- /dev/null +++ b/tests/bugs171/pr387568/Color.java @@ -0,0 +1,2 @@ + +enum Color {R,G,B;} diff --git a/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java index baebd2518..39f2884fd 100644 --- a/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java @@ -21,9 +21,9 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Ajc171Tests extends org.aspectj.testing.XMLBasedAjcTestCase { -// public void testUnresolvableEnum_pr387568() { -// runTest("unresolvable enum"); -// } + public void testUnresolvableEnum_pr387568() { + runTest("unresolvable enum"); + } public void testAbstractItds_pr386049() { runTest("itd abstract"); diff --git a/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml b/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml index 6e19b7b83..7f6a372d8 100644 --- a/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml +++ b/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml @@ -3,7 +3,7 @@ <suite> <ajc-test dir="bugs171/pr387568" title="unresolvable enum"> - <compile files="Code.java" options="-1.5"/> + <compile files="Color.java Code.java" options="-1.5"/> <!-- <run class="de.scrum_master.galileo.filter.JsoupFilter"> <stdout> |