View | Details | Raw Unified | Return to bug 304122 | Differences between
and this patch

Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/IBinding.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 95-104 Link Here
95
	 * </li>
95
	 * </li>
96
	 * <li>Type bindings - these are annotations on a class, interface, enum,
96
	 * <li>Type bindings - these are annotations on a class, interface, enum,
97
	 * or annotation type declaration. The result is the same regardless of
97
	 * or annotation type declaration. The result is the same regardless of
98
	 * whether the type is generic.</li>
98
	 * whether the type is parameterized.</li>
99
	 * <li>Method bindings - these are annotations on a method or constructor
99
	 * <li>Method bindings - these are annotations on a method or constructor
100
	 * declaration. The result is the same regardless of whether the method is
100
	 * declaration. The result is the same regardless of whether the method is
101
	 * generic.</li>
101
	 * parameterized.</li>
102
	 * <li>Variable bindings - these are annotations on a field, enum constant,
102
	 * <li>Variable bindings - these are annotations on a field, enum constant,
103
	 * or formal parameter declaration.</li>
103
	 * or formal parameter declaration.</li>
104
	 * <li>Annotation bindings - an empty array is always returned</li>
104
	 * <li>Annotation bindings - an empty array is always returned</li>
(-)dom/org/eclipse/jdt/core/dom/MethodBinding.java (-8 / +2 lines)
Lines 99-112 Link Here
99
		if (this.annotations != null) {
99
		if (this.annotations != null) {
100
			return this.annotations;
100
			return this.annotations;
101
		}
101
		}
102
		int length = 0;
102
		org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = this.binding.getAnnotations();
103
		org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = null;
103
		int length = internalAnnotations == null ? 0 : internalAnnotations.length;
104
		if (this.binding.original() == this.binding) {
105
			internalAnnotations = this.binding.getAnnotations();
106
			if (internalAnnotations != null) {
107
				length = internalAnnotations.length;
108
			}
109
		}
110
		if (length != 0) {
104
		if (length != 0) {
111
			IAnnotationBinding[] tempAnnotations = new IAnnotationBinding[length];
105
			IAnnotationBinding[] tempAnnotations = new IAnnotationBinding[length];
112
			int convertedAnnotationCount = 0;
106
			int convertedAnnotationCount = 0;
(-)dom/org/eclipse/jdt/core/dom/TypeBinding.java (-7 / +7 lines)
Lines 81-93 Link Here
81
		if (this.annotations != null) {
81
		if (this.annotations != null) {
82
			return this.annotations;
82
			return this.annotations;
83
		}
83
		}
84
		if (!(this.binding instanceof ParameterizedTypeBinding)
84
		org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding refType = null;
85
				&& (this.binding.isAnnotationType()
85
		if (this.binding instanceof ParameterizedTypeBinding) {
86
						|| this.binding.isClass()
86
			refType = ((ParameterizedTypeBinding) this.binding).genericType();
87
						|| this.binding.isEnum()
87
		} else if (this.binding.isAnnotationType() || this.binding.isClass() || this.binding.isEnum() || this.binding.isInterface()) {
88
						|| this.binding.isInterface())) {
88
			refType = (org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.binding;
89
			org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding refType =
89
		}
90
				(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.binding;
90
		if (refType != null) {
91
			org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = refType.getAnnotations();
91
			org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = refType.getAnnotations();
92
			int length = internalAnnotations == null ? 0 : internalAnnotations.length;
92
			int length = internalAnnotations == null ? 0 : internalAnnotations.length;
93
			if (length != 0) {
93
			if (length != 0) {
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-2 / +2 lines)
Lines 10957-10963 Link Here
10957
		FieldDeclaration fieldDeclaration = (FieldDeclaration) getASTNode(unit, 0, 0);
10957
		FieldDeclaration fieldDeclaration = (FieldDeclaration) getASTNode(unit, 0, 0);
10958
		binding = fieldDeclaration.getType().resolveBinding();
10958
		binding = fieldDeclaration.getType().resolveBinding();
10959
		annotations = binding.getAnnotations();
10959
		annotations = binding.getAnnotations();
10960
		assertEquals("Wrong size", 0, annotations.length);
10960
		assertEquals("Wrong size", 1, annotations.length);
10961
	}
10961
	}
10962
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304122
10962
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304122
10963
	public void test343() throws JavaModelException {
10963
	public void test343() throws JavaModelException {
Lines 10987-10993 Link Here
10987
		MethodInvocation expression = (MethodInvocation) statement.getExpression();
10987
		MethodInvocation expression = (MethodInvocation) statement.getExpression();
10988
		binding = expression.resolveMethodBinding();
10988
		binding = expression.resolveMethodBinding();
10989
		annotations = binding.getAnnotations();
10989
		annotations = binding.getAnnotations();
10990
		assertEquals("Wrong size", 0, annotations.length);
10990
		assertEquals("Wrong size", 1, annotations.length);
10991
		binding = binding.getMethodDeclaration();
10991
		binding = binding.getMethodDeclaration();
10992
		annotations = binding.getAnnotations();
10992
		annotations = binding.getAnnotations();
10993
		assertEquals("Wrong size", 1, annotations.length);
10993
		assertEquals("Wrong size", 1, annotations.length);

Return to bug 304122