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

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTest.java (+27 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.core.tests.dom;
11
package org.eclipse.jdt.core.tests.dom;
12
12
13
import java.io.IOException;
13
import java.io.IOException;
14
import java.util.List;
14
import java.util.Map;
15
import java.util.Map;
15
16
16
import junit.framework.Test;
17
import junit.framework.Test;
Lines 973-976 Link Here
973
			"Invalid float literal number\n",
974
			"Invalid float literal number\n",
974
			result);
975
			result);
975
}
976
}
977
978
/**
979
 * @bug 223838: [dom] AnnotationBinding.isRecovered() always return false
980
 * @test That the annotation binding is well flagged as recovered when the annotation is an unknown type
981
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=223838"
982
 */
983
public void testBug223838() throws JavaModelException {
984
	String contents =
985
		"package b223838;\n" +
986
		"@Deprecated\n" + 
987
		"@Invalid\n" + 
988
		"public class Test {\n" + 
989
		"}\n";
990
	ICompilationUnit workingCopy = getWorkingCopy(
991
   			"/Converter15/src/b223838/Test.java",
992
   			contents,
993
   			true/*resolve*/
994
   		);
995
   	ASTNode node = buildAST(contents, workingCopy, false);
996
	CompilationUnit unit = (CompilationUnit) node;
997
	List types = unit.types();
998
	TypeDeclaration type = (TypeDeclaration) types.get(0);
999
	ITypeBinding typeBinding = type.resolveBinding();
1000
	IAnnotationBinding[] annotations = typeBinding.getAnnotations();
1001
	assertTrue("Expected recovered annotation binding!", annotations[1].isRecovered());
1002
}
976
}
1003
}
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-5 / +5 lines)
Lines 6918-6924 Link Here
6918
		IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
6918
		IAnnotationBinding annotationBinding = annotation.resolveAnnotationBinding();
6919
		assertNotNull("No binding", annotationBinding);
6919
		assertNotNull("No binding", annotationBinding);
6920
		assertEquals("LX;.fXoo)I@LTest;", annotationBinding.getKey());
6920
		assertEquals("LX;.fXoo)I@LTest;", annotationBinding.getKey());
6921
		assertFalse("Annotation should not be flagged as recovered", annotationBinding.isRecovered());
6921
		assertTrue("Annotation should not flagged as recovered", annotationBinding.isRecovered());
6922
		assertTrue("Annotation type should be flagged as recovered", annotationBinding.getAnnotationType().isRecovered());		
6922
		assertTrue("Annotation type should be flagged as recovered", annotationBinding.getAnnotationType().isRecovered());		
6923
	}
6923
	}
6924
	/*
6924
	/*
Lines 7096-7102 Link Here
7096
		assertEquals("Wrong size", 1, annotations.length);
7096
		assertEquals("Wrong size", 1, annotations.length);
7097
		assertNotNull("No binding", annotations[0]);
7097
		assertNotNull("No binding", annotations[0]);
7098
		assertEquals("LX;.foo()V@LZork;", annotations[0].getKey());
7098
		assertEquals("LX;.foo()V@LZork;", annotations[0].getKey());
7099
		assertFalse("Annotation should not be flagged as recovered", annotations[0].isRecovered());
7099
		assertTrue("Annotation should be flagged as recovered", annotations[0].isRecovered());
7100
		assertTrue("Annotation type should be flagged as recovered", annotations[0].getAnnotationType().isRecovered());		
7100
		assertTrue("Annotation type should be flagged as recovered", annotations[0].getAnnotationType().isRecovered());		
7101
	}
7101
	}
7102
	/*
7102
	/*
Lines 7123-7129 Link Here
7123
		assertEquals("Wrong size", 1, annotations.length);
7123
		assertEquals("Wrong size", 1, annotations.length);
7124
		assertNotNull("No binding", annotations[0]);
7124
		assertNotNull("No binding", annotations[0]);
7125
		assertEquals("LX;@LZork;", annotations[0].getKey());
7125
		assertEquals("LX;@LZork;", annotations[0].getKey());
7126
		assertFalse("Annotation should not be flagged as recovered", annotations[0].isRecovered());
7126
		assertTrue("Annotation should be flagged as recovered", annotations[0].isRecovered());
7127
		assertTrue("Annotation type should be flagged as recovered", annotations[0].getAnnotationType().isRecovered());
7127
		assertTrue("Annotation type should be flagged as recovered", annotations[0].getAnnotationType().isRecovered());
7128
	}
7128
	}
7129
	/*
7129
	/*
Lines 7154-7160 Link Here
7154
		assertEquals("Wrong size", 1, bindings.length);
7154
		assertEquals("Wrong size", 1, bindings.length);
7155
		assertNotNull("No binding", bindings[0]);
7155
		assertNotNull("No binding", bindings[0]);
7156
		assertEquals("@LZork;", bindings[0].getKey());
7156
		assertEquals("@LZork;", bindings[0].getKey());
7157
		assertFalse("Annotation should not be flagged as recovered", bindings[0].isRecovered());
7157
		assertTrue("Annotation should be flagged as recovered", bindings[0].isRecovered());
7158
		assertTrue("Annotation type should be flagged as recovered", bindings[0].getAnnotationType().isRecovered());				
7158
		assertTrue("Annotation type should be flagged as recovered", bindings[0].getAnnotationType().isRecovered());				
7159
	}
7159
	}
7160
	/*
7160
	/*
Lines 9373-9379 Link Here
9373
		IAnnotationBinding[] annotations = typeBinding.getAnnotations();
9373
		IAnnotationBinding[] annotations = typeBinding.getAnnotations();
9374
		assertEquals("wrong size", 2, annotations.length);
9374
		assertEquals("wrong size", 2, annotations.length);
9375
		assertEquals("LX;@LInvalid;", annotations[0].getKey());
9375
		assertEquals("LX;@LInvalid;", annotations[0].getKey());
9376
		assertFalse("Annotation should not be flagged as recovered", annotations[0].isRecovered());
9376
		assertTrue("Annotation should be flagged as recovered", annotations[0].isRecovered());
9377
		assertTrue("Annotation type should be flagged as recovered", annotations[0].getAnnotationType().isRecovered());		
9377
		assertTrue("Annotation type should be flagged as recovered", annotations[0].getAnnotationType().isRecovered());		
9378
		assertEquals("LX;@Ljava/lang/Deprecated;", annotations[1].getKey());
9378
		assertEquals("LX;@Ljava/lang/Deprecated;", annotations[1].getKey());
9379
	}
9379
	}
(-)dom/org/eclipse/jdt/core/dom/AnnotationBinding.java (-2 / +3 lines)
Lines 18-23 Link Here
18
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
18
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair;
19
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
19
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
20
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
20
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
21
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
21
import org.eclipse.jdt.internal.compiler.util.*;
22
import org.eclipse.jdt.internal.compiler.util.*;
22
23
23
/**
24
/**
Lines 199-206 Link Here
199
	 * @see org.eclipse.jdt.core.dom.IBinding#isRecovered()
200
	 * @see org.eclipse.jdt.core.dom.IBinding#isRecovered()
200
	 */
201
	 */
201
	public boolean isRecovered() {
202
	public boolean isRecovered() {
202
		return false;
203
        ReferenceBinding annotationType = binding.getAnnotationType();
203
	}
204
        return annotationType == null || (annotationType.tagBits & TagBits.HasMissingType) != 0;	}
204
205
205
	public boolean isSynthetic() {
206
	public boolean isSynthetic() {
206
		return false;
207
		return false;

Return to bug 223838