### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java,v retrieving revision 1.31 diff -u -r1.31 DeprecatedTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java 6 Mar 2007 04:42:12 -0000 1.31 +++ src/org/eclipse/jdt/core/tests/compiler/regression/DeprecatedTest.java 14 Jun 2007 19:59:30 -0000 @@ -731,6 +731,45 @@ false, false); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191909 (1.4 variant) +public void test019() { + Map customOptions = new HashMap(); + customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "test1/E01.java", + "package test1;\n" + + "public class E01 {\n" + + " /** @deprecated */\n" + + " public static int x = 5, y= 10;\n" + + "}", + "test1/E02.java", + "package test1;\n" + + "public class E02 {\n" + + " public void foo() {\n" + + " System.out.println(E01.x);\n" + + " System.out.println(E01.y);\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in test1\\E02.java (at line 4)\n" + + " System.out.println(E01.x);\n" + + " ^\n" + + "The field E01.x is deprecated\n" + + "----------\n" + + "2. ERROR in test1\\E02.java (at line 5)\n" + + " System.out.println(E01.y);\n" + + " ^\n" + + "The field E01.y is deprecated\n" + + "----------\n", + null, + true, + customOptions, + true, + false, + false); +} public static Class testClass() { return DeprecatedTest.class; } Index: src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java,v retrieving revision 1.6 diff -u -r1.6 Deprecated15Test.java --- src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java 6 Mar 2007 04:42:12 -0000 1.6 +++ src/org/eclipse/jdt/core/tests/compiler/regression/Deprecated15Test.java 14 Jun 2007 19:59:30 -0000 @@ -187,6 +187,45 @@ customOptions, null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=191909 +public void test004() { + Map customOptions = new HashMap(); + customOptions.put(CompilerOptions.OPTION_ReportDeprecation, CompilerOptions.ERROR); + this.runNegativeTest( + new String[] { + "test1/E01.java", + "package test1;\n" + + "public class E01 {\n" + + " @Deprecated\n" + + " public static int x = 5, y= 10;\n" + + "}", + "test1/E02.java", + "package test1;\n" + + "public class E02 {\n" + + " public void foo() {\n" + + " System.out.println(E01.x);\n" + + " System.out.println(E01.y);\n" + + " }\n" + + "}" + }, + "----------\n" + + "1. ERROR in test1\\E02.java (at line 4)\n" + + " System.out.println(E01.x);\n" + + " ^\n" + + "The field E01.x is deprecated\n" + + "----------\n" + + "2. ERROR in test1\\E02.java (at line 5)\n" + + " System.out.println(E01.y);\n" + + " ^\n" + + "The field E01.y is deprecated\n" + + "----------\n", + null, + true, + customOptions, + true, + false, + false); +} public static Class testClass() { return Deprecated15Test.class; } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java,v retrieving revision 1.83 diff -u -r1.83 ASTNode.java --- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 25 Apr 2007 16:59:23 -0000 1.83 +++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 14 Jun 2007 19:59:30 -0000 @@ -563,12 +563,36 @@ TypeBinding[] annotationTypes = new TypeBinding[length]; for (int i = 0; i < length; i++) { Annotation annotation = annotations[i]; - annotation.recipient = recipient; - annotationTypes[i] = annotation.resolveType(scope); - - // null if receiver is a package binding - if (instances != null) - instances[i] = annotation.getCompilerAnnotation(); + final Binding annotationRecipient = annotation.recipient; + if (annotationRecipient != null && recipient != null) { + // only local and field can share annnotations + switch (recipient.kind()) { + case Binding.FIELD : + FieldBinding field = (FieldBinding) recipient; + field.tagBits = ((FieldBinding) annotationRecipient).tagBits; + break; + case Binding.LOCAL : + LocalVariableBinding local = (LocalVariableBinding) recipient; + local.tagBits = ((LocalVariableBinding) annotationRecipient).tagBits; + break; + } + if (instances != null) { + // need to fill the instances array + instances[0] = annotation.getCompilerAnnotation(); + for (int j = 1; j < length; j++) { + Annotation annot = annotations[j]; + instances[j] = annot.getCompilerAnnotation(); + } + } + return; + } else { + annotation.recipient = recipient; + annotationTypes[i] = annotation.resolveType(scope); + // null if receiver is a package binding + if (instances != null) { + instances[i] = annotation.getCompilerAnnotation(); + } + } } // check duplicate annotations for (int i = 0; i < length; i++) { #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.247 diff -u -r1.247 ASTConverter15Test.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 11 May 2007 14:55:27 -0000 1.247 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 14 Jun 2007 19:59:32 -0000 @@ -46,7 +46,7 @@ } static { -// TESTS_NUMBERS = new int[] { 272 }; +// TESTS_NUMBERS = new int[] { 274, 275 }; // TESTS_RANGE = new int[] { 253, -1 }; // TESTS_NAMES = new String[] {"test0204"}; } @@ -9098,4 +9098,62 @@ CompilationUnit unit = (CompilationUnit) node; assertProblemsSize(unit, 1, "The type A is not generic; it cannot be parameterized with arguments "); } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908 + public void test0274() throws JavaModelException { + this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); + String contents = + "public class X {\n" + + " @Deprecated\n" + + " public static int x= 5, y= 10;\n" + + "}"; + ASTNode node = buildAST( + contents, + this.workingCopy, + true); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize(unit, 0); + node = getASTNode(unit, 0, 0); + assertEquals("Not a field declaration", ASTNode.FIELD_DECLARATION, node.getNodeType()); + FieldDeclaration fieldDeclaration = (FieldDeclaration) node; + List fragments = fieldDeclaration.fragments(); + assertEquals("Wrong size", 2, fragments.size()); + VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); + IVariableBinding binding = fragment.resolveBinding(); + assertTrue("Not deprecated", binding.isDeprecated()); + fragment = (VariableDeclarationFragment) fragments.get(1); + binding = fragment.resolveBinding(); + assertTrue("Not deprecated", binding.isDeprecated()); + } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=191908 + public void test0275() throws JavaModelException { + this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); + String contents = + "public class X {\n" + + " public void foo() {\n" + + " @Deprecated\n" + + " int x= 5, y= 10;\n" + + " }\n" + + "}"; + ASTNode node = buildAST( + contents, + this.workingCopy, + true); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize(unit, 0); + node = getASTNode(unit, 0, 0, 0); + assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); + VariableDeclarationStatement statement = (VariableDeclarationStatement) node; + List fragments = statement.fragments(); + assertEquals("Wrong size", 2, fragments.size()); + VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0); + IVariableBinding binding = fragment.resolveBinding(); + IAnnotationBinding[] annotations = binding.getAnnotations(); + assertEquals("Wrong size", 1, annotations.length); + fragment = (VariableDeclarationFragment) fragments.get(1); + binding = fragment.resolveBinding(); + annotations = binding.getAnnotations(); + assertEquals("Wrong size", 1, annotations.length); + } }