summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorStephan Herrmann2012-07-31 14:57:58 (EDT)
committer Jayaprakash Arthanareeswaran2012-08-10 03:03:54 (EDT)
commit1380663d32eef4fe51daddb994c3d2197de60d56 (patch)
tree4cdd4668d8b40a4e1f2c286cc8337caeb9111eef
parent63c8a2ec89eae9c5f71458dc20e19fe16c16341b (diff)
downloadeclipse.jdt.core-1380663d32eef4fe51daddb994c3d2197de60d56.zip
eclipse.jdt.core-1380663d32eef4fe51daddb994c3d2197de60d56.tar.gz
eclipse.jdt.core-1380663d32eef4fe51daddb994c3d2197de60d56.tar.bz2
Fixed bug 383690 - [compiler] location of error re uninitialized final
field should be aligned
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java7
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InitializationTests.java26
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java17
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java5
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 56b2ce3..7c02b9d 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 5c8749a..0809428 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 85d63b1..89a3d14 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 c2e389f..7d1b587 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 1b955e0..89ac33a 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);
}
}
}