Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 167791 Details for
Bug 311849
[quick fix] @SuppressWarnings does not work as expected inside a for loop
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_311849_2.txt (text/plain), 6.08 KB, created by
Olivier Thomann
on 2010-05-10 15:31:58 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2010-05-10 15:31:58 EDT
Size:
6.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.102 >diff -u -r1.102 ASTNode.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 6 May 2010 18:37:17 -0000 1.102 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java 10 May 2010 19:29:53 -0000 >@@ -587,29 +587,50 @@ > case Binding.FIELD : > FieldBinding field = (FieldBinding) recipient; > field.tagBits = ((FieldBinding) annotationRecipient).tagBits; >+ if (annotations != null) { >+ // need to fill the instances array >+ for (int j = 0; j < length; j++) { >+ Annotation annot = sourceAnnotations[j]; >+ annotations[j] = annot.getCompilerAnnotation(); >+ } >+ } > break; > case Binding.LOCAL : > LocalVariableBinding local = (LocalVariableBinding) recipient; > long otherLocalTagBits = ((LocalVariableBinding) annotationRecipient).tagBits; > local.tagBits = otherLocalTagBits; >- /* >- * Annotations are shared between two locals, but we still need to record >- * the suppress annotation range for the second local >- */ >- if ((otherLocalTagBits & TagBits.AnnotationSuppressWarnings) != 0) { >+ if ((otherLocalTagBits & TagBits.AnnotationSuppressWarnings) == 0) { >+ // None of the annotations is a SuppressWarnings annotation >+ // need to fill the instances array >+ if (annotations != null) { >+ for (int j = 0; j < length; j++) { >+ Annotation annot = sourceAnnotations[j]; >+ annotations[j] = annot.getCompilerAnnotation(); >+ } >+ } >+ } else if (annotations != null) { >+ // One of the annotations at least is a SuppressWarnings annotation > LocalDeclaration localDeclaration = local.declaration; >- annotation.recordSuppressWarnings(scope, localDeclaration.declarationSourceStart, localDeclaration.declarationSourceEnd, scope.compilerOptions().suppressWarnings); >+ int declarationSourceEnd = localDeclaration.declarationSourceEnd; >+ int declarationSourceStart = localDeclaration.declarationSourceStart; >+ for (int j = 0; j < length; j++) { >+ Annotation annot = sourceAnnotations[j]; >+ /* >+ * Annotations are shared between two locals, but we still need to record >+ * the suppress annotation range for the second local >+ */ >+ AnnotationBinding annotationBinding = annot.getCompilerAnnotation(); >+ annotations[j] = annotationBinding; >+ if (annotationBinding != null) { >+ final ReferenceBinding annotationType = annotationBinding.getAnnotationType(); >+ if (annotationType != null && annotationType.id == TypeIds.T_JavaLangSuppressWarnings) { >+ annot.recordSuppressWarnings(scope, declarationSourceStart, declarationSourceEnd, scope.compilerOptions().suppressWarnings); >+ } >+ } >+ } > } > break; > } >- if (annotations != null) { >- // need to fill the instances array >- annotations[0] = annotation.getCompilerAnnotation(); >- for (int j = 1; j < length; j++) { >- Annotation annot = sourceAnnotations[j]; >- annotations[j] = annot.getCompilerAnnotation(); >- } >- } > return; > } else { > annotation.recipient = recipient; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java,v >retrieving revision 1.215 >diff -u -r1.215 AnnotationTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 6 May 2010 18:37:16 -0000 1.215 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java 10 May 2010 19:29:59 -0000 >@@ -45,7 +45,7 @@ > // All specified tests which do not belong to the class are skipped... > static { > // TESTS_NAMES = new String[] { "test127" }; >-// TESTS_NUMBERS = new int[] { 287, 288 }; >+// TESTS_NUMBERS = new int[] { 289 }; > // TESTS_RANGE = new int[] { 249, -1 }; > } > >@@ -9518,7 +9518,7 @@ > raiseDeprecationReduceInvalidJavadocSeverity, > null); > } >-//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849 > public void test287() { > Map options = getCompilerOptions(); > options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); >@@ -9548,7 +9548,7 @@ > options, > null); > } >-//https://bugs.eclipse.org/bugs/show_bug.cgi?id=304031 >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849 > public void test288() { > Map options = getCompilerOptions(); > options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); >@@ -9572,4 +9572,38 @@ > options, > null); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=311849 >+public void test289() { >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportUncheckedTypeOperation, CompilerOptions.ERROR); >+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ options.put(CompilerOptions.OPTION_SuppressOptionalErrors, CompilerOptions.ENABLED); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "import java.util.ArrayList;\n" + >+ "\n" + >+ "public class X {\n" + >+ " void foo(ArrayList arg) {\n" + >+ " for (\n" + >+ " @Deprecated\n" + >+ " @Other\n" + >+ " @SuppressWarnings(\"unchecked\")\n" + >+ " boolean a= arg.add(1), b= arg.add(1);\n" + >+ " Boolean.FALSE;\n" + >+ " ) {\n" + >+ " System.out.println(a && b);\n" + >+ " }\n" + >+ " }\n" + >+ "}", >+ "Other.java", >+ "@interface Other {}" >+ }, >+ "", >+ null, >+ true, >+ null, >+ options, >+ null); >+} > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 311849
:
167310
| 167791