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 124259 Details for
Bug 257716
[compiler] Erroneous blank field may not have been initialized
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch for 3.3
257716--33x.txt (text/plain), 31.75 KB, created by
Philipe Mulet
on 2009-01-30 07:46:40 EST
(
hide
)
Description:
Proposed patch for 3.3
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2009-01-30 07:46:40 EST
Size:
31.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java,v >retrieving revision 1.106.2.2 >diff -u -r1.106.2.2 InitializationTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 10 Jun 2008 09:24:47 -0000 1.106.2.2 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 30 Jan 2009 12:45:30 -0000 >@@ -5640,6 +5640,325 @@ > }, > ""); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 >+public void test196() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X() {\n" + >+ " hello = 0;\n" + >+ " new Object() {\n" + >+ " int i = hello;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ }, >+ ""); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 >+public void test197() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X(int i) {\n" + >+ " new Object() {\n" + >+ " int j = hello;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " public X(int i) {\n" + >+ " ^^^^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " int j = hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.j is never read locally\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 5)\n" + >+ " int j = hello;\n" + >+ " ^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 >+public void test198() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X(long l) {\n" + >+ " if (l > 0) {\n" + >+ " new Object() {\n" + >+ " int j = hello;\n" + >+ " };\n" + >+ " }\n" + >+ " } \n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " public X(long l) {\n" + >+ " ^^^^^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " int j = hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.j is never read locally\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 6)\n" + >+ " int j = hello;\n" + >+ " ^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 - variation >+public void test199() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X() {\n" + >+ " hello = 0;\n" + >+ " new Object() {\n" + >+ " int i = X.this.hello;\n" + >+ " };\n" + >+ " }\n" + >+ " public X(int a) {\n" + >+ " new Object() {\n" + >+ " int j = X.this.hello;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 6)\n" + >+ " int i = X.this.hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.i is never read locally\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " public X(int a) {\n" + >+ " ^^^^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 11)\n" + >+ " int j = X.this.hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.j is never read locally\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 - variation >+public void test200() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X() {\n" + >+ " hello = 0;\n" + >+ " new Object() {\n" + >+ " X x = X.this;\n" + >+ " int i = x.hello;\n" + >+ " };\n" + >+ " }\n" + >+ " public X(int a) {\n" + >+ " new Object() {\n" + >+ " X x = X.this;\n" + >+ " int j = x.hello;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 7)\n" + >+ " int i = x.hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.i is never read locally\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 10)\n" + >+ " public X(int a) {\n" + >+ " ^^^^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 13)\n" + >+ " int j = x.hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.j is never read locally\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 - variation >+public void test201() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " class M {\n" + >+ " public M() {\n" + >+ " hello = 0;\n" + >+ " new Object() {\n" + >+ " int i = hello;\n" + >+ " };\n" + >+ " }\n" + >+ " public M(int a) {\n" + >+ " new Object() {\n" + >+ " int j = hello;\n" + >+ " };\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 1)\n" + >+ " public class X {\n" + >+ " ^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 5)\n" + >+ " hello = 0;\n" + >+ " ^^^^^\n" + >+ "The final field X.hello cannot be assigned\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 7)\n" + >+ " int i = hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.i is never read locally\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 12)\n" + >+ " int j = hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.j is never read locally\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 - variation >+public void test202() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X() {\n" + >+ " hello = 0;\n" + >+ " class Local {\n" + >+ " Object o = new Object() {\n" + >+ " int i = hello;\n" + >+ " };\n" + >+ " }\n" + >+ " }\n" + >+ " public X(int a) {\n" + >+ " class Local {\n" + >+ " Object o = new Object() {\n" + >+ " int j = hello;\n" + >+ " };\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 5)\n" + >+ " class Local {\n" + >+ " ^^^^^\n" + >+ "The type Local is never used locally\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " Object o = new Object() {\n" + >+ " ^\n" + >+ "The field Local.o is never read locally\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 7)\n" + >+ " int i = hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.i is never read locally\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 11)\n" + >+ " public X(int a) {\n" + >+ " ^^^^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 12)\n" + >+ " class Local {\n" + >+ " ^^^^^\n" + >+ "The type Local is never used locally\n" + >+ "----------\n" + >+ "6. WARNING in X.java (at line 13)\n" + >+ " Object o = new Object() {\n" + >+ " ^\n" + >+ "The field Local.o is never read locally\n" + >+ "----------\n" + >+ "7. WARNING in X.java (at line 14)\n" + >+ " int j = hello;\n" + >+ " ^\n" + >+ "The field new Object(){}.j is never read locally\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=257716 - variation >+public void test203() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " final int hello;\n" + >+ " public X() {\n" + >+ " hello = 0;\n" + >+ " new X() {\n" + >+ " final int world;\n" + >+ " {\n" + >+ " world = 0;\n" + >+ " }\n" + >+ " int i = new Object() {\n" + >+ " int j = hello + world; \n" + >+ " }.j;\n" + >+ " };\n" + >+ " }\n" + >+ " public X(int i) {\n" + >+ " new X() {\n" + >+ " final int world;\n" + >+ " {\n" + >+ " world = 0;\n" + >+ " } \n" + >+ " int k = new Object() { \n" + >+ " int l = hello + world; \n" + >+ " }.l;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 10)\n" + >+ " int i = new Object() {\n" + >+ " ^\n" + >+ "The field new X(){}.i is never read locally\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 15)\n" + >+ " public X(int i) {\n" + >+ " ^^^^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 21)\n" + >+ " int k = new Object() { \n" + >+ " ^\n" + >+ "The field new X(){}.k is never read locally\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 22)\n" + >+ " int l = hello + world; \n" + >+ " ^^^^^\n" + >+ "The blank final field hello may not have been initialized\n" + >+ "----------\n"); >+} >+ > public static Class testClass() { > return InitializationTest.class; > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java,v >retrieving revision 1.137 >diff -u -r1.137 TypeDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 25 Apr 2007 16:59:23 -0000 1.137 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 30 Jan 2009 12:45:31 -0000 >@@ -593,8 +593,8 @@ > this.scope.problemReporter().unusedPrivateType(this); > } > } >- InitializationFlowContext initializerContext = new InitializationFlowContext(null, this, this.initializerScope); >- InitializationFlowContext staticInitializerContext = new InitializationFlowContext(null, this, this.staticInitializerScope); >+ InitializationFlowContext initializerContext = new InitializationFlowContext(null, this, flowInfo, flowContext, this.initializerScope); >+ InitializationFlowContext staticInitializerContext = new InitializationFlowContext(null, this, flowInfo, flowContext, this.staticInitializerScope); > FlowInfo nonStaticFieldInfo = flowInfo.unconditionalFieldLessCopy(); > FlowInfo staticFieldInfo = flowInfo.unconditionalFieldLessCopy(); > if (this.fields != null) { >@@ -609,11 +609,7 @@ > } else {*/ > staticInitializerContext.handledExceptions = Binding.ANY_EXCEPTION; // tolerate them all, and record them > /*}*/ >- staticFieldInfo = >- field.analyseCode( >- this.staticInitializerScope, >- staticInitializerContext, >- staticFieldInfo); >+ staticFieldInfo = field.analyseCode(this.staticInitializerScope, staticInitializerContext, staticFieldInfo); > // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable > // branch, since the previous initializer already got the blame. > if (staticFieldInfo == FlowInfo.DEAD_END) { >@@ -629,8 +625,7 @@ > } else {*/ > initializerContext.handledExceptions = Binding.ANY_EXCEPTION; // tolerate them all, and record them > /*}*/ >- nonStaticFieldInfo = >- field.analyseCode(this.initializerScope, initializerContext, nonStaticFieldInfo); >+ nonStaticFieldInfo = field.analyseCode(this.initializerScope, initializerContext, nonStaticFieldInfo); > // in case the initializer is not reachable, use a reinitialized flowInfo and enter a fake reachable > // branch, since the previous initializer already got the blame. > if (nonStaticFieldInfo == FlowInfo.DEAD_END) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java,v >retrieving revision 1.49 >diff -u -r1.49 Clinit.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java 27 Apr 2007 15:51:38 -0000 1.49 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Clinit.java 30 Jan 2009 12:45:30 -0000 >@@ -53,6 +53,7 @@ > staticInitializerFlowContext.parent, > this, > Binding.NO_EXCEPTIONS, >+ staticInitializerFlowContext, > scope, > FlowInfo.DEAD_END); > >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java,v >retrieving revision 1.107 >diff -u -r1.107 TryStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 5 Mar 2007 15:32:08 -0000 1.107 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 30 Jan 2009 12:45:31 -0000 >@@ -87,6 +87,7 @@ > flowContext, > this, > this.caughtExceptionTypes, >+ null, > this.scope, > flowInfo.unconditionalInits()); > handlingContext.initsOnFinally = >@@ -198,6 +199,7 @@ > insideSubContext, > this, > this.caughtExceptionTypes, >+ null, > this.scope, > flowInfo.unconditionalInits()); > handlingContext.initsOnFinally = >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java,v >retrieving revision 1.87 >diff -u -r1.87 ConstructorDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java 25 Apr 2007 16:59:23 -0000 1.87 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ConstructorDeclaration.java 30 Jan 2009 12:45:30 -0000 >@@ -76,6 +76,7 @@ > initializerFlowContext.parent, > this, > this.binding.thrownExceptions, >+ initializerFlowContext, > this.scope, > FlowInfo.DEAD_END); > initializerFlowContext.checkInitializerExceptions( >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.97.2.4 >diff -u -r1.97.2.4 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 30 Jun 2008 22:10:33 -0000 1.97.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 30 Jan 2009 12:45:31 -0000 >@@ -43,7 +43,8 @@ > FieldBinding fieldBinding; > if ((fieldBinding = (FieldBinding) binding).isBlankFinal() > && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { >- if (!flowInfo.isDefinitelyAssigned(fieldBinding)) { >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(fieldBinding)) { > currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); > } > } >@@ -154,7 +155,8 @@ > } > // check if reading a final blank field > if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { >- if (!flowInfo.isDefinitelyAssigned(fieldBinding)) { >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(fieldBinding)) { > currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v >retrieving revision 1.109.2.4 >diff -u -r1.109.2.4 FieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 30 Jun 2008 22:10:33 -0000 1.109.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 30 Jan 2009 12:45:31 -0000 >@@ -45,22 +45,20 @@ > public FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound) { > // compound assignment extra work > if (isCompound) { // check the variable part is initialized if blank final >- if (binding.isBlankFinal() >- && receiver.isThis() >- && currentScope.needBlankFinalFieldInitializationCheck(binding) >- && (!flowInfo.isDefinitelyAssigned(binding))) { >- currentScope.problemReporter().uninitializedBlankFinalField(binding, this); >- // we could improve error msg here telling "cannot use compound assignment on final blank field" >+ if (binding.isBlankFinal() && receiver.isThis() && currentScope.needBlankFinalFieldInitializationCheck(this.binding)) { >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(this.binding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(this.binding)) { >+ currentScope.problemReporter().uninitializedBlankFinalField(this.binding, this); >+ // we could improve error msg here telling "cannot use compound assignment on final blank field" >+ } > } > manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/); > } >- flowInfo = >- receiver >+ flowInfo = receiver > .analyseCode(currentScope, flowContext, flowInfo, !binding.isStatic()) > .unconditionalInits(); > if (assignment.expression != null) { >- flowInfo = >- assignment >+ flowInfo = assignment > .expression > .analyseCode(currentScope, flowContext, flowInfo) > .unconditionalInits(); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java,v >retrieving revision 1.60.2.1 >diff -u -r1.60.2.1 MethodDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 29 Feb 2008 23:54:15 -0000 1.60.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MethodDeclaration.java 30 Jan 2009 12:45:31 -0000 >@@ -72,6 +72,7 @@ > initializationContext, > this, > binding.thrownExceptions, >+ null, > scope, > FlowInfo.DEAD_END); > >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v >retrieving revision 1.116.2.3 >diff -u -r1.116.2.3 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 30 Jun 2008 22:10:33 -0000 1.116.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 30 Jan 2009 12:45:31 -0000 >@@ -88,10 +88,9 @@ > if (lastFieldBinding.isBlankFinal() > && this.otherBindings != null // the last field binding is only assigned > && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) { >- if (!flowInfo.isDefinitelyAssigned(lastFieldBinding)) { >- currentScope.problemReporter().uninitializedBlankFinalField( >- lastFieldBinding, >- this); >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) { >+ currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this); > } > } > break; >@@ -136,9 +135,11 @@ > if (isCompound) { > if (otherBindingsCount == 0 > && lastFieldBinding.isBlankFinal() >- && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding) >- && (!flowInfo.isDefinitelyAssigned(lastFieldBinding))) { >- currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this); >+ && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) { >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) { >+ currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this); >+ } > } > TypeBinding lastReceiverType; > switch (otherBindingsCount) { >@@ -239,9 +240,11 @@ > } > // check if reading a final blank field > if (fieldBinding.isBlankFinal() >- && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding) >- && !flowInfo.isDefinitelyAssigned(fieldBinding)) { >- currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); >+ && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(fieldBinding)) { >+ currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); >+ } > } > } > break; >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.5933.2.109 >diff -u -r1.5933.2.109 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 17 Dec 2008 09:51:17 -0000 1.5933.2.109 >+++ buildnotes_jdt-core.html 30 Jan 2009 12:45:30 -0000 >@@ -44,11 +44,24 @@ > </td> > </tr> > </table> >+<a name="v_797_R33x"></a> >+<hr><h1> >+Eclipse Platform Build Notes<br> >+Java Development Tooling Core</h1> >+Eclipse SDK 3.3.3 - %date% - Posted on JDT/Core update area >+<br>Project org.eclipse.jdt.core v_797_R33x >+(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_797_R33x">cvs</a>). >+<h2>What's new in this drop</h2> >+ >+<h3>Problem Reports Fixed</h3> >+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=257716">257716</a> >+[compiler] Erroneous blank field field may not have been initialized >+ > <a name="v_796_R33x"></a> > <hr><h1> > Eclipse Platform Build Notes<br> > Java Development Tooling Core</h1> >-Eclipse SDK 3.3.3 - December 17, 2008 - Posted on JDT/Core update area >+Eclipse SDK 3.3.3 - December 17, 2008 > <br>Project org.eclipse.jdt.core v_796_R33x > (<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_796_R33x">cvs</a>). > <h2>What's new in this drop</h2> >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java,v >retrieving revision 1.47.12.4 >diff -u -r1.47.12.4 CodeSnippetSingleNameReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 26 May 2008 10:50:12 -0000 1.47.12.4 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 30 Jan 2009 12:45:32 -0000 >@@ -56,7 +56,8 @@ > FieldBinding fieldBinding; > if ((fieldBinding = (FieldBinding) this.binding).isBlankFinal() > && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { >- if (!flowInfo.isDefinitelyAssigned(fieldBinding)) { >+ FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.erasure(), flowInfo); >+ if (!fieldInits.isDefinitelyAssigned(fieldBinding)) { > currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java,v >retrieving revision 1.38 >diff -u -r1.38 ExceptionHandlingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java 28 Mar 2006 20:32:37 -0000 1.38 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java 30 Jan 2009 12:45:31 -0000 >@@ -40,7 +40,8 @@ > boolean isMethodContext; > > public UnconditionalFlowInfo initsOnReturn; >- >+ public FlowContext initializationParent; // special parent relationship only for initialization purpose >+ > // for dealing with anonymous constructor thrown exceptions > public ArrayList extendedExceptions; > >@@ -48,6 +49,7 @@ > FlowContext parent, > ASTNode associatedNode, > ReferenceBinding[] handledExceptions, >+ FlowContext initializationParent, > BlockScope scope, > UnconditionalFlowInfo flowInfo) { > >@@ -70,6 +72,7 @@ > } > System.arraycopy(this.isReached, 0, this.isNeeded, 0, cacheSize); > this.initsOnReturn = FlowInfo.DEAD_END; >+ this. initializationParent = initializationParent; > } > > public void complainIfUnusedExceptionHandlers(AbstractMethodDeclaration method) { >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java,v >retrieving revision 1.57 >diff -u -r1.57 FlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 2 Apr 2007 11:05:51 -0000 1.57 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 30 Jan 2009 12:45:32 -0000 >@@ -18,6 +18,7 @@ > import org.eclipse.jdt.internal.compiler.ast.Reference; > import org.eclipse.jdt.internal.compiler.ast.SubRoutineStatement; > import org.eclipse.jdt.internal.compiler.ast.TryStatement; >+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.codegen.BranchLabel; > import org.eclipse.jdt.internal.compiler.lookup.Binding; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >@@ -44,6 +45,25 @@ > > boolean deferNullDiagnostic, preemptNullDiagnostic; > >+public static final int >+ CAN_ONLY_NULL_NON_NULL = 0x0000, >+ // check against null and non null, with definite values -- comparisons >+ CAN_ONLY_NULL = 0x0001, >+ // check against null, with definite values -- comparisons >+ CAN_ONLY_NON_NULL = 0x0002, >+ // check against non null, with definite values -- comparisons >+ MAY_NULL = 0x0003, >+ // check against null, with potential values -- NPE guard >+ CHECK_MASK = 0x00FF, >+ IN_COMPARISON_NULL = 0x0100, >+ IN_COMPARISON_NON_NULL = 0x0200, >+ // check happened in a comparison >+ IN_ASSIGNMENT = 0x0300, >+ // check happened in an assignment >+ IN_INSTANCEOF = 0x0400, >+ // check happened in an instanceof expression >+ CONTEXT_MASK = ~CHECK_MASK; >+ > public FlowContext(FlowContext parent, ASTNode associatedNode) { > this.parent = parent; > this.associatedNode = associatedNode; >@@ -287,6 +307,28 @@ > return null; > } > >+public FlowInfo getInitsForFinalBlankInitializationCheck(TypeBinding declaringType, FlowInfo flowInfo) { >+ FlowContext current = this; >+ FlowInfo inits = flowInfo; >+ do { >+ if (current instanceof InitializationFlowContext) { >+ InitializationFlowContext initializationContext = (InitializationFlowContext) current; >+ if (((TypeDeclaration)initializationContext.associatedNode).binding == declaringType) { >+ return inits; >+ } >+ inits = initializationContext.initsBeforeContext; >+ current = initializationContext.initializationParent; >+ } else if (current instanceof ExceptionHandlingFlowContext) { >+ ExceptionHandlingFlowContext exceptionContext = (ExceptionHandlingFlowContext) current; >+ current = exceptionContext.initializationParent == null ? exceptionContext.parent : exceptionContext.initializationParent; >+ } else { >+ current = current.parent; >+ } >+ } while (current != null); >+ // not found >+ return null; >+} >+ > /* > * lookup through break labels > */ >@@ -468,25 +510,6 @@ > } > } > >-public static final int >- CAN_ONLY_NULL_NON_NULL = 0x0000, >- // check against null and non null, with definite values -- comparisons >- CAN_ONLY_NULL = 0x0001, >- // check against null, with definite values -- comparisons >- CAN_ONLY_NON_NULL = 0x0002, >- // check against non null, with definite values -- comparisons >- MAY_NULL = 0x0003, >- // check against null, with potential values -- NPE guard >- CHECK_MASK = 0x00FF, >- IN_COMPARISON_NULL = 0x0100, >- IN_COMPARISON_NON_NULL = 0x0200, >- // check happened in a comparison >- IN_ASSIGNMENT = 0x0300, >- // check happened in an assignment >- IN_INSTANCEOF = 0x0400, >- // check happened in an instanceof expression >- CONTEXT_MASK = ~CHECK_MASK; >- > /** > * Record a null reference for use by deferred checks. Only looping or > * finally contexts really record that information. The context may >Index: compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java,v >retrieving revision 1.16 >diff -u -r1.16 InitializationFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java 28 Mar 2006 20:32:37 -0000 1.16 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/InitializationFlowContext.java 30 Jan 2009 12:45:32 -0000 >@@ -26,17 +26,17 @@ > public TypeBinding[] thrownExceptions = new TypeBinding[5]; > public ASTNode[] exceptionThrowers = new ASTNode[5]; > public FlowInfo[] exceptionThrowerFlowInfos = new FlowInfo[5]; >+ public FlowInfo initsBeforeContext; > >- public InitializationFlowContext( >- FlowContext parent, >- ASTNode associatedNode, >- BlockScope scope) { >+ public InitializationFlowContext(FlowContext parent, ASTNode associatedNode, FlowInfo initsBeforeContext, FlowContext initializationParent, BlockScope scope) { > super( > parent, > associatedNode, > Binding.NO_EXCEPTIONS, // no exception allowed by default >+ initializationParent, > scope, > FlowInfo.DEAD_END); >+ this.initsBeforeContext = initsBeforeContext; > } > > public void checkInitializerExceptions( >Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v >retrieving revision 1.645.2.30 >diff -u -r1.645.2.30 messages.properties >--- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 17 Dec 2008 09:32:17 -0000 1.645.2.30 >+++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 30 Jan 2009 12:45:30 -0000 >@@ -14,7 +14,7 @@ > #Format: compiler.name = word1 word2 word3 > compiler.name = Eclipse Java Compiler > #Format: compiler.version = 0.XXX[, other words (don't forget the comma if adding other words)] >-compiler.version = 0.796_R33x, 3.3.3 >+compiler.version = 0.797_R33x, 3.3.3 > compiler.copyright = Copyright IBM Corp 2000, 2008. All rights reserved. > > ### progress
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 257716
:
124145
|
124147
|
124163
| 124259