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, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 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 parameterized.</li>
98
	 * whether the type is generic.</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
	 * parameterized.</li>
101
	 * generic.</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 (-2 / +8 lines)
Lines 99-106 Link Here
99
		if (this.annotations != null) {
99
		if (this.annotations != null) {
100
			return this.annotations;
100
			return this.annotations;
101
		}
101
		}
102
		org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = this.binding.getAnnotations();
102
		int length = 0;
103
		int length = internalAnnotations == null ? 0 : internalAnnotations.length;
103
		org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = null;
104
		if (this.binding.original() == this.binding) {
105
			internalAnnotations = this.binding.getAnnotations();
106
			if (internalAnnotations != null) {
107
				length = internalAnnotations.length;
108
			}
109
		}
104
		if (length != 0) {
110
		if (length != 0) {
105
			IAnnotationBinding[] tempAnnotations = new IAnnotationBinding[length];
111
			IAnnotationBinding[] tempAnnotations = new IAnnotationBinding[length];
106
			int convertedAnnotationCount = 0;
112
			int convertedAnnotationCount = 0;
(-)dom/org/eclipse/jdt/core/dom/TypeBinding.java (-1 / +5 lines)
Lines 81-87 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.isAnnotationType() || this.binding.isClass() || this.binding.isEnum() || this.binding.isInterface()) {
84
		if (!(this.binding instanceof ParameterizedTypeBinding)
85
				&& (this.binding.isAnnotationType()
86
						|| this.binding.isClass()
87
						|| this.binding.isEnum()
88
						|| this.binding.isInterface())) {
85
			org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding refType =
89
			org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding refType =
86
				(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.binding;
90
				(org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding) this.binding;
87
			org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = refType.getAnnotations();
91
			org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] internalAnnotations = refType.getAnnotations();
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +57 lines)
Lines 47-53 Link Here
47
	}
47
	}
48
48
49
	static {
49
	static {
50
//		TESTS_NUMBERS = new int[] { 341 };
50
//		TESTS_NUMBERS = new int[] { 342, 343 };
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 10936-10939 Link Here
10936
		IMethodBinding methodBinding2 = ((MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(1)).getExpression()).resolveMethodBinding();
10936
		IMethodBinding methodBinding2 = ((MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(1)).getExpression()).resolveMethodBinding();
10937
		assertTrue("Bindings differ", methodBinding1 == methodBinding2);
10937
		assertTrue("Bindings differ", methodBinding1 == methodBinding2);
10938
	}
10938
	}
10939
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304122
10940
	public void test342() throws JavaModelException {
10941
		String contents =
10942
			"@Deprecated\n" +
10943
			"public class X<T> {\n" +
10944
			"	X<String> field;\n" +
10945
			"}";
10946
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
10947
		CompilationUnit unit= (CompilationUnit) buildAST(
10948
			contents,
10949
			this.workingCopy,
10950
			true,
10951
			true,
10952
			true);
10953
		TypeDeclaration typeDeclaration = (TypeDeclaration) getASTNode(unit, 0);
10954
		ITypeBinding binding = typeDeclaration.resolveBinding();
10955
		IAnnotationBinding[] annotations = binding.getAnnotations();
10956
		assertEquals("Wrong size", 1, annotations.length);
10957
		FieldDeclaration fieldDeclaration = (FieldDeclaration) getASTNode(unit, 0, 0);
10958
		binding = fieldDeclaration.getType().resolveBinding();
10959
		annotations = binding.getAnnotations();
10960
		assertEquals("Wrong size", 0, annotations.length);
10961
	}
10962
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=304122
10963
	public void test343() throws JavaModelException {
10964
		String contents =
10965
			"public class X {\n" +
10966
			"	@Deprecated\n" +
10967
			"	<T> Object foo(T t) {\n" +
10968
			"		return t;\n" +
10969
			"	}\n" +
10970
			"	public static Object bar() {\n" +
10971
			"		return new X().<String>foo(\"Hello\");\n" +
10972
			"	}\n" +
10973
			"}";
10974
		this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
10975
		CompilationUnit unit= (CompilationUnit) buildAST(
10976
			contents,
10977
			this.workingCopy,
10978
			true,
10979
			true,
10980
			true);
10981
		MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0);
10982
		IMethodBinding binding = methodDeclaration.resolveBinding();
10983
		IAnnotationBinding[] annotations = binding.getAnnotations();
10984
		assertEquals("Wrong size", 1, annotations.length);
10985
		methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 1);
10986
		ReturnStatement statement = (ReturnStatement) methodDeclaration.getBody().statements().get(0);
10987
		MethodInvocation expression = (MethodInvocation) statement.getExpression();
10988
		binding = expression.resolveMethodBinding();
10989
		annotations = binding.getAnnotations();
10990
		assertEquals("Wrong size", 0, annotations.length);
10991
		binding = binding.getMethodDeclaration();
10992
		annotations = binding.getAnnotations();
10993
		assertEquals("Wrong size", 1, annotations.length);
10994
	}
10939
}
10995
}

Return to bug 304122