diff options
| author | Stephan Herrmann | 2012-07-31 18:57:58 +0000 |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2012-08-10 07:03:54 +0000 |
| commit | 1380663d32eef4fe51daddb994c3d2197de60d56 (patch) | |
| tree | 4cdd4668d8b40a4e1f2c286cc8337caeb9111eef | |
| parent | 63c8a2ec89eae9c5f71458dc20e19fe16c16341b (diff) | |
| download | eclipse.jdt.core-1380663d32eef4fe51daddb994c3d2197de60d56.tar.gz eclipse.jdt.core-1380663d32eef4fe51daddb994c3d2197de60d56.tar.xz eclipse.jdt.core-1380663d32eef4fe51daddb994c3d2197de60d56.zip | |
Fixed bug 383690 - [compiler] location of error re uninitialized final
field should be aligned
5 files changed, 46 insertions, 16 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java index 56b2ce30f5..7c02b9dfd8 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java @@ -11,6 +11,7 @@ * bug 236385 - [compiler] Warn for potential programming problem if an object is created but not used * bug 349326 - [1.7] new warning for missing try-with-resources * bug 360328 - [compiler][null] detect null problems in nested code (local class inside a loop) + * bug 383690 - [compiler] location of error re uninitialized final field should be aligned *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -2320,9 +2321,9 @@ public void testBug338234c() { "}\n" }, "----------\n" + - "1. ERROR in X.java (at line 1)\n" + - " public class X {\n" + - " ^\n" + + "1. ERROR in X.java (at line 2)\n" + + " public final int field1;\n" + + " ^^^^^^\n" + "The blank final field field1 may not have been initialized\n" + "----------\n" + "2. WARNING in X.java (at line 7)\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java index 5c8749a6e7..0809428192 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java @@ -12,6 +12,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Stephan Herrmann - Contribution for bug 383690 - [compiler] location of error re uninitialized final field should be aligned *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -6674,9 +6675,9 @@ public class GenericTypeTest extends AbstractComparableTest { "G is a raw type. References to generic type G<E> should be parameterized\n" + "----------\n" + "----------\n" + - "1. ERROR in test\\cheetah\\G.java (at line 2)\n" + - " public class G<E> {\n" + - " ^\n" + + "1. ERROR in test\\cheetah\\G.java (at line 3)\n" + + " protected final Object o;\n" + + " ^\n" + "The blank final field o may not have been initialized\n" + "----------\n"); } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java index 85d63b15bd..89a3d14d4d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java @@ -7,7 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - contribution for bug 324178 - [null] ConditionalExpression.nullStatus(..) doesn't take into account the analysis of condition itself + * Stephan Herrmann - contributions for + * bug 324178 - [null] ConditionalExpression.nullStatus(..) doesn't take into account the analysis of condition itself + * bug 383690 - [compiler] location of error re uninitialized final field should be aligned *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -464,6 +466,28 @@ public void testBug324178d() { "The local variable b2 may not have been initialized\n" + "----------\n"); } +// Bug 383690 - [compiler] location of error re uninitialized final field should be aligned +public void testBug383690() { + this.runNegativeTest( + new String[] { + "X.java", + "public class X {\n" + + " final Object o; // report here!\n" + + " final static Object oStatic; // report here!\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " final Object o; // report here!\n" + + " ^\n" + + "The blank final field o may not have been initialized\n" + + "----------\n" + + "2. ERROR in X.java (at line 3)\n" + + " final static Object oStatic; // report here!\n" + + " ^^^^^^^\n" + + "The blank final field oStatic may not have been initialized\n" + + "----------\n"); +} public static Class testClass() { return InitializationTests.class; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java index c2e389ff10..7d1b587f55 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java @@ -22,6 +22,7 @@ * bug 349326 - [1.7] new warning for missing try-with-resources * bug 360328 - [compiler][null] detect null problems in nested code (local class inside a loop) * bug 367879 - Incorrect "Potential null pointer access" warning on statement after try-with-resources within try-finally + * bug 383690 - [compiler] location of error re uninitialized final field should be aligned *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -11003,9 +11004,9 @@ public void test2014_flow_info() { " }\n" + "}\n"}, "----------\n" + - "1. ERROR in X.java (at line 12)\n" + - " class Inner extends X {\n" + - " ^^^^^\n" + + "1. ERROR in X.java (at line 20)\n" + + " final int m164;\n" + + " ^^^^\n" + "The blank final field m164 may not have been initialized\n" + "----------\n"); } @@ -11068,11 +11069,11 @@ public void test2015_flow_info() { " System.out.println((new Inner()).bar());\n" + " }\n" + "}\n"}, - "----------\n" + - "1. ERROR in X.java (at line 26)\n" + - " class Inner extends X {\n" + - " ^^^^^\n" + - "The blank final field m164 may not have been initialized\n" + + "----------\n" + + "1. ERROR in X.java (at line 34)\n" + + " final int m164;\n" + + " ^^^^\n" + + "The blank final field m164 may not have been initialized\n" + "----------\n"); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java index 1b955e0846..89ac33a572 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java @@ -13,6 +13,7 @@ * bug 186342 - [compiler][null] Using annotations for null checking * bug 361407 - Resource leak warning when resource is assigned to a field outside of constructor * bug 368546 - [compiler][resource] Avoid remaining false positives found when compiling the Eclipse SDK + * bug 383690 - [compiler] location of error re uninitialized final field should be aligned *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -170,7 +171,9 @@ public void analyseCode(ClassScope classScope, InitializationFlowContext initial && (!flowInfo.isDefinitelyAssigned(fields[i]))) { this.scope.problemReporter().uninitializedBlankFinalField( field, - ((this.bits & ASTNode.IsDefaultConstructor) != 0) ? (ASTNode) this.scope.referenceType() : this); + ((this.bits & ASTNode.IsDefaultConstructor) != 0) + ? (ASTNode) this.scope.referenceType().declarationOf(field.original()) + : this); } } } |
