View | Details | Raw Unified | Return to bug 223225
Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/DefaultValuePairBinding.java (+6 lines)
Lines 26-31 Link Here
26
		super(null, resolver);
26
		super(null, resolver);
27
		this.method = binding;
27
		this.method = binding;
28
		this.value = MemberValuePairBinding.buildDOMValue(binding.getDefaultValue(), resolver);
28
		this.value = MemberValuePairBinding.buildDOMValue(binding.getDefaultValue(), resolver);
29
		if (binding.returnType != null && binding.returnType.isArrayType()) {
30
			if (!this.value.getClass().isArray()) {
31
				// wrap into an array
32
				this.value = new Object[] { this.value };
33
			}
34
		}
29
	}
35
	}
30
36
31
	public IMethodBinding getMethodBinding() {
37
	public IMethodBinding getMethodBinding() {
(-)dom/org/eclipse/jdt/core/dom/MemberValuePairBinding.java (+4 lines)
Lines 139-144 Link Here
139
		this.value = buildDOMValue(this.internalPair.getValue(), this.bindingResolver);
139
		this.value = buildDOMValue(this.internalPair.getValue(), this.bindingResolver);
140
		if (this.value == null)
140
		if (this.value == null)
141
			this.value = NoValue;
141
			this.value = NoValue;
142
		IMethodBinding methodBinding = getMethodBinding();
143
		if (methodBinding.getReturnType().isArray() && !this.value.getClass().isArray()) {
144
			this.value = new Object[] { this.value }; 
145
		}
142
	}
146
	}
143
147
144
	char[] internalName() {
148
	char[] internalName() {
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +70 lines)
Lines 47-53 Link Here
47
	}
47
	}
48
48
49
	static {
49
	static {
50
//		TESTS_NUMBERS = new int[] { 342, 343 };
50
//		TESTS_NUMBERS = new int[] { 344 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
52
//		TESTS_NAMES = new String[] {"test0204"};
52
//		TESTS_NAMES = new String[] {"test0204"};
53
	}
53
	}
Lines 10990-10993 Link Here
10990
		annotations = binding.getAnnotations();
10990
		annotations = binding.getAnnotations();
10991
		assertEquals("Wrong size", 1, annotations.length);
10991
		assertEquals("Wrong size", 1, annotations.length);
10992
	}
10992
	}
10993
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=223225
10994
	public void test344() throws JavaModelException {
10995
		String contents =
10996
			"public class X {\r\n" + 
10997
			"    private @interface Strings {\r\n" + 
10998
			"        String[] value() default \"default element\";\r\n" + 
10999
			"    }\r\n" + 
11000
			"    @Strings\r\n" + 
11001
			"    public void marker() {\r\n" + 
11002
			"        // nothing\r\n" + 
11003
			"    }\r\n" + 
11004
			"    @Strings(\"single element\")\r\n" + 
11005
			"    public void single() {\r\n" + 
11006
			"        // nothing\r\n" + 
11007
			"    }\r\n" + 
11008
			"    @Strings(value = \"single element\")\r\n" + 
11009
			"    public void singleValue() {\r\n" + 
11010
			"        // nothing\r\n" + 
11011
			"    }\r\n" + 
11012
			"    @Strings({\"single element\"})\r\n" + 
11013
			"    public void singleArray() {\r\n" + 
11014
			"        // nothing\r\n" + 
11015
			"    }\r\n" + 
11016
			"    @Strings(value = {\"single element\"})\r\n" + 
11017
			"    public void singleArrayValue() {\r\n" + 
11018
			"        // nothing\r\n" + 
11019
			"    }\r\n" + 
11020
			"    @Strings({\"one\", \"two\", \"three\"})\r\n" + 
11021
			"    public void multi() {\r\n" + 
11022
			"        // nothing\r\n" + 
11023
			"    }\r\n" + 
11024
			"    @Strings(value = {\"one\", \"two\", \"three\"})\r\n" + 
11025
			"    public void multiValue() {\r\n" + 
11026
			"        // nothing\r\n" + 
11027
			"    }\r\n" + 
11028
			"}";
11029
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
11030
		CompilationUnit unit= (CompilationUnit) buildAST(
11031
			contents,
11032
			this.workingCopy,
11033
			true,
11034
			true,
11035
			true);
11036
		unit.accept(new ASTVisitor() {
11037
			public boolean visit(MarkerAnnotation node) {
11038
				return checkAnnotationBinding(node);
11039
			}
11040
			private boolean checkAnnotationBinding(Annotation annotation) {
11041
				final IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
11042
				final IMemberValuePairBinding[] allMemberValuePairs = annotationBinding.getAllMemberValuePairs();
11043
				assertEquals("Wrong size", 1, allMemberValuePairs.length);
11044
				IMemberValuePairBinding memberValuePairBinding = allMemberValuePairs[0];
11045
				final Object value = memberValuePairBinding.getValue();
11046
				assertTrue("Not an array", value.getClass().isArray());
11047
				return false;
11048
			}
11049
			public boolean visit(SingleMemberAnnotation node) {
11050
				return checkAnnotationBinding(node);
11051
			}
11052
			public boolean visit(NormalAnnotation node) {
11053
				return checkAnnotationBinding(node);
11054
			}
11055
		});
11056
		AnnotationTypeDeclaration annotationTypeDeclaration = (AnnotationTypeDeclaration) ((AbstractTypeDeclaration) unit.types().get(0)).bodyDeclarations().get(0);
11057
		AnnotationTypeMemberDeclaration annotationTypeMemberDeclaration = (AnnotationTypeMemberDeclaration) annotationTypeDeclaration.bodyDeclarations().get(0);
11058
		final IMethodBinding binding = annotationTypeMemberDeclaration.resolveBinding();
11059
		final Object defaultValue = binding.getDefaultValue();
11060
		assertTrue("Not an array", !defaultValue.getClass().isArray());
11061
	}
10993
}
11062
}

Return to bug 223225