### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java,v retrieving revision 1.3 diff -u -r1.3 DefaultValuePairBinding.java --- dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java 26 Mar 2007 17:30:24 -0000 1.3 +++ dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java 21 Jul 2010 16:33:37 -0000 @@ -26,6 +26,12 @@ super(null, resolver); this.method = binding; this.value = MemberValuePairBinding.buildDOMValue(binding.getDefaultValue(), resolver); + if (binding.returnType != null && binding.returnType.isArrayType()) { + if (!this.value.getClass().isArray()) { + // wrap into an array + this.value = new Object[] { this.value }; + } + } } public IMethodBinding getMethodBinding() { Index: dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java,v retrieving revision 1.8 diff -u -r1.8 MemberValuePairBinding.java --- dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java 7 Mar 2009 00:59:00 -0000 1.8 +++ dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java 21 Jul 2010 16:33:37 -0000 @@ -139,6 +139,10 @@ this.value = buildDOMValue(this.internalPair.getValue(), this.bindingResolver); if (this.value == null) this.value = NoValue; + IMethodBinding methodBinding = getMethodBinding(); + if (methodBinding.getReturnType().isArray() && !this.value.getClass().isArray()) { + this.value = new Object[] { this.value }; + } } char[] internalName() { #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v retrieving revision 1.295 diff -u -r1.295 ASTConverter15Test.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 13 Apr 2010 06:24:29 -0000 1.295 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 21 Jul 2010 16:33:38 -0000 @@ -47,7 +47,7 @@ } static { -// TESTS_NUMBERS = new int[] { 342, 343 }; +// TESTS_NUMBERS = new int[] { 344 }; // TESTS_RANGE = new int[] { 325, -1 }; // TESTS_NAMES = new String[] {"test0204"}; } @@ -10990,4 +10990,73 @@ annotations = binding.getAnnotations(); assertEquals("Wrong size", 1, annotations.length); } + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=223225 + public void test344() throws JavaModelException { + String contents = + "public class X {\r\n" + + " private @interface Strings {\r\n" + + " String[] value() default \"default element\";\r\n" + + " }\r\n" + + " @Strings\r\n" + + " public void marker() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + " @Strings(\"single element\")\r\n" + + " public void single() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + " @Strings(value = \"single element\")\r\n" + + " public void singleValue() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + " @Strings({\"single element\"})\r\n" + + " public void singleArray() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + " @Strings(value = {\"single element\"})\r\n" + + " public void singleArrayValue() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + " @Strings({\"one\", \"two\", \"three\"})\r\n" + + " public void multi() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + " @Strings(value = {\"one\", \"two\", \"three\"})\r\n" + + " public void multiValue() {\r\n" + + " // nothing\r\n" + + " }\r\n" + + "}"; + this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); + CompilationUnit unit= (CompilationUnit) buildAST( + contents, + this.workingCopy, + true, + true, + true); + unit.accept(new ASTVisitor() { + public boolean visit(MarkerAnnotation node) { + return checkAnnotationBinding(node); + } + private boolean checkAnnotationBinding(Annotation annotation) { + final IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding(); + final IMemberValuePairBinding[] allMemberValuePairs = annotationBinding.getAllMemberValuePairs(); + assertEquals("Wrong size", 1, allMemberValuePairs.length); + IMemberValuePairBinding memberValuePairBinding = allMemberValuePairs[0]; + final Object value = memberValuePairBinding.getValue(); + assertTrue("Not an array", value.getClass().isArray()); + return false; + } + public boolean visit(SingleMemberAnnotation node) { + return checkAnnotationBinding(node); + } + public boolean visit(NormalAnnotation node) { + return checkAnnotationBinding(node); + } + }); + AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) ((AbstractTypeDeclaration) unit.types().get(0)).bodyDeclarations().get(0); + AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) annotationTypeDeclaration.bodyDeclarations().get(0); + final IMethodBinding binding = annotationTypeMemberDeclaration.resolveBinding(); + final Object defaultValue = binding.getDefaultValue(); + assertTrue("Not an array", !defaultValue.getClass().isArray()); + } } \ No newline at end of file