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 156644 Details for
Bug 293917
Invalid 'potential null access' warning reports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
same patch with two additional tests
patchNull.txt (text/plain), 82.85 KB, created by
Ayushman Jain
on 2010-01-20 09:02:10 EST
(
hide
)
Description:
same patch with two additional tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-01-20 09:02:10 EST
Size:
82.85 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java,v >retrieving revision 1.76 >diff -u -r1.76 EqualExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 24 Sep 2009 20:46:00 -0000 1.76 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 20 Jan 2010 13:13:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -59,6 +59,12 @@ > } > break; > } >+ // set the optimize constant to optimize code gen >+ if ((initsWhenTrue.tagBits & FlowInfo.UNREACHABLE) != 0) { >+ this.optimizedBooleanConstant = BooleanConstant.fromValue(false); >+ } else if ((initsWhenFalse.tagBits & FlowInfo.UNREACHABLE) != 0) { >+ this.optimizedBooleanConstant = BooleanConstant.fromValue(true); >+ } > // we do not impact enclosing try context because this kind of protection > // does not preclude the variable from being null in an enclosing scope > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java,v >retrieving revision 1.65 >diff -u -r1.65 IfStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java 15 Jul 2009 17:42:43 -0000 1.65 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java 20 Jan 2010 13:13:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -138,13 +138,19 @@ > || this.elseStatement.isEmptyBlock()); > if (hasThenPart) { > BranchLabel falseLabel = null; >- // generate boolean condition >- this.condition.generateOptimizedBoolean( >- currentScope, >- codeStream, >- null, >- hasElsePart ? (falseLabel = new BranchLabel(codeStream)) : endifLabel, >- true/*cst == Constant.NotAConstant*/); >+ // generate boolean condition only if needed >+ if (cst != Constant.NotAConstant && cst.booleanValue() == true) { >+ // No need to generate if condition statement when we know that only the then action >+ // will be executed >+ this.condition.generateCode(currentScope, codeStream, false); >+ } else { >+ this.condition.generateOptimizedBoolean( >+ currentScope, >+ codeStream, >+ null, >+ hasElsePart ? (falseLabel = new BranchLabel(codeStream)) : endifLabel, >+ true/*cst == Constant.NotAConstant*/); >+ } > // May loose some local variable initializations : affecting the local variable attributes > if (this.thenInitStateIndex != -1) { > codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.thenInitStateIndex); >@@ -173,13 +179,19 @@ > this.elseStatement.generateCode(currentScope, codeStream); > } > } else if (hasElsePart) { >- // generate boolean condition >- this.condition.generateOptimizedBoolean( >- currentScope, >- codeStream, >- endifLabel, >- null, >- true/*cst == Constant.NotAConstant*/); >+ // generate boolean condition only if needed >+ if (cst != Constant.NotAConstant && cst.booleanValue() == false) { >+ // No need to generate if condition statement when we know that only the else action >+ // will be executed >+ this.condition.generateCode(currentScope, codeStream, false); >+ } else { >+ this.condition.generateOptimizedBoolean( >+ currentScope, >+ codeStream, >+ endifLabel, >+ null, >+ true/*cst == Constant.NotAConstant*/); >+ } > // generate else statement > // May loose some local variable initializations : affecting the local variable attributes > if (this.elseInitStateIndex != -1) { >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java,v >retrieving revision 1.30 >diff -u -r1.30 FinallyFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java 19 Nov 2009 15:57:21 -0000 1.30 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java 20 Jan 2010 13:13:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -192,8 +192,10 @@ > if (flowInfo.cannotBeNull(local)) { > if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > } else if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > } > return; > } >@@ -201,9 +203,11 @@ > switch(checkType & CONTEXT_MASK) { > case FlowContext.IN_COMPARISON_NULL: > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_COMPARISON_NON_NULL: > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_ASSIGNMENT: > scope.problemReporter().localVariableRedundantNullAssignment(local, reference); >@@ -234,8 +238,10 @@ > if (flowInfo.isDefinitelyNonNull(local)) { > if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > } else { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > } > return; > } >@@ -248,9 +254,11 @@ > switch(checkType & CONTEXT_MASK) { > case FlowContext.IN_COMPARISON_NULL: > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_COMPARISON_NON_NULL: > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_ASSIGNMENT: > scope.problemReporter().localVariableRedundantNullAssignment(local, reference); >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.61 >diff -u -r1.61 FlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 7 Mar 2009 00:59:06 -0000 1.61 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 20 Jan 2010 13:13:09 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -543,8 +543,10 @@ > if (flowInfo.isDefinitelyNonNull(local)) { > if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > } else { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > } > return; > } >@@ -560,9 +562,11 @@ > switch(checkType & CONTEXT_MASK) { > case FlowContext.IN_COMPARISON_NULL: > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_COMPARISON_NON_NULL: > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_ASSIGNMENT: > scope.problemReporter().localVariableRedundantNullAssignment(local, reference); >Index: compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java,v >retrieving revision 1.45 >diff -u -r1.45 LoopingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 19 Nov 2009 14:29:15 -0000 1.45 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 20 Jan 2010 13:13:10 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -396,14 +396,18 @@ > if (flowInfo.isDefinitelyNonNull(local)) { > if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NON_NULL)) { > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > } else { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > } > } else if (flowInfo.isDefinitelyNull(local)) { > if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > } else { > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > } > } else if (this.upstreamNullFlowInfo.isDefinitelyNonNull(local) && !flowInfo.isPotentiallyNull(local)) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=291418 > flowInfo.markAsDefinitelyNonNull(local); >@@ -428,9 +432,11 @@ > switch(checkType & CONTEXT_MASK) { > case FlowContext.IN_COMPARISON_NULL: > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_COMPARISON_NON_NULL: > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); > return; > case FlowContext.IN_ASSIGNMENT: > scope.problemReporter().localVariableRedundantNullAssignment(local, reference); >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/ConformTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/ConformTest.java,v >retrieving revision 1.152 >diff -u -r1.152 ConformTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/ConformTest.java 27 Jun 2008 16:02:01 -0000 1.152 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/ConformTest.java 20 Jan 2010 13:13:16 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -6531,42 +6531,35 @@ > " 40 aload 5 [data]\n" + > " 42 invokevirtual java.lang.StringBuffer.append(java.lang.Object) : java.lang.StringBuffer [27]\n" + > " 45 pop\n" + >- " 46 goto 62\n" + >+ " 46 goto 54\n" + > " 49 astore 6 [e]\n" + > " 51 aload 6 [e]\n" + >- " 53 ifnull 59\n" + >- " 56 aload 6 [e]\n" + >- " 58 athrow\n" + >- " 59 aconst_null\n" + >- " 60 astore_3 [buffer]\n" + >- " 61 return\n" + >- " 62 iload_1 [delete]\n" + >- " 63 ifeq 93\n" + >- " 66 aload_3 [buffer]\n" + >- " 67 iconst_0\n" + >- " 68 aload_3 [buffer]\n" + >- " 69 invokevirtual java.lang.StringBuffer.length() : int [31]\n" + >- " 72 invokevirtual java.lang.StringBuffer.delete(int, int) : java.lang.StringBuffer [35]\n" + >- " 75 pop\n" + >- " 76 goto 93\n" + >- " 79 astore 4\n" + >- " 81 aconst_null\n" + >- " 82 astore_3 [buffer]\n" + >- " 83 goto 95\n" + >- " 86 astore 7\n" + >- " 88 aconst_null\n" + >- " 89 astore_3 [buffer]\n" + >- " 90 aload 7\n" + >- " 92 athrow\n" + >- " 93 aconst_null\n" + >- " 94 astore_3 [buffer]\n" + >- " 95 return\n" + >+ " 53 athrow\n" + >+ " 54 iload_1 [delete]\n" + >+ " 55 ifeq 85\n" + >+ " 58 aload_3 [buffer]\n" + >+ " 59 iconst_0\n" + >+ " 60 aload_3 [buffer]\n" + >+ " 61 invokevirtual java.lang.StringBuffer.length() : int [31]\n" + >+ " 64 invokevirtual java.lang.StringBuffer.delete(int, int) : java.lang.StringBuffer [35]\n" + >+ " 67 pop\n" + >+ " 68 goto 85\n" + >+ " 71 astore 4\n" + >+ " 73 aconst_null\n" + >+ " 74 astore_3 [buffer]\n" + >+ " 75 goto 87\n" + >+ " 78 astore 7\n" + >+ " 80 aconst_null\n" + >+ " 81 astore_3 [buffer]\n" + >+ " 82 aload 7\n" + >+ " 84 athrow\n" + >+ " 85 aconst_null\n" + >+ " 86 astore_3 [buffer]\n" + >+ " 87 return\n" + > " Exception Table:\n" + > " [pc: 34, pc: 46] -> 49 when : java.lang.Exception\n" + >- " [pc: 13, pc: 59] -> 79 when : java.lang.Exception\n" + >- " [pc: 62, pc: 76] -> 79 when : java.lang.Exception\n" + >- " [pc: 13, pc: 59] -> 86 when : any\n" + >- " [pc: 62, pc: 81] -> 86 when : any\n" + >+ " [pc: 13, pc: 68] -> 71 when : java.lang.Exception\n" + >+ " [pc: 13, pc: 73] -> 78 when : any\n" + > " Line numbers:\n" + > " [pc: 0, line: 4]\n" + > " [pc: 5, line: 5]\n" + >@@ -6574,29 +6567,24 @@ > " [pc: 24, line: 10]\n" + > " [pc: 34, line: 12]\n" + > " [pc: 49, line: 13]\n" + >- " [pc: 51, line: 14]\n" + >- " [pc: 56, line: 15]\n" + >- " [pc: 59, line: 24]\n" + >- " [pc: 61, line: 16]\n" + >- " [pc: 62, line: 19]\n" + >- " [pc: 66, line: 20]\n" + >- " [pc: 79, line: 22]\n" + >- " [pc: 81, line: 24]\n" + >- " [pc: 86, line: 23]\n" + >- " [pc: 88, line: 24]\n" + >- " [pc: 90, line: 25]\n" + >- " [pc: 93, line: 24]\n" + >- " [pc: 95, line: 26]\n" + >+ " [pc: 51, line: 15]\n" + >+ " [pc: 54, line: 19]\n" + >+ " [pc: 58, line: 20]\n" + >+ " [pc: 71, line: 22]\n" + >+ " [pc: 73, line: 24]\n" + >+ " [pc: 78, line: 23]\n" + >+ " [pc: 80, line: 24]\n" + >+ " [pc: 82, line: 25]\n" + >+ " [pc: 85, line: 24]\n" + >+ " [pc: 87, line: 26]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 96] local: this index: 0 type: X\n" + >- " [pc: 0, pc: 96] local: delete index: 1 type: boolean\n" + >- " [pc: 5, pc: 96] local: s index: 2 type: java.lang.String\n" + >- " [pc: 13, pc: 96] local: buffer index: 3 type: java.lang.StringBuffer\n" + >- " [pc: 24, pc: 59] local: datas index: 4 type: java.lang.String[]\n" + >- " [pc: 62, pc: 79] local: datas index: 4 type: java.lang.String[]\n" + >- " [pc: 34, pc: 59] local: data index: 5 type: java.lang.Object[]\n" + >- " [pc: 62, pc: 79] local: data index: 5 type: java.lang.Object[]\n" + >- " [pc: 51, pc: 59] local: e index: 6 type: java.lang.Exception\n" >+ " [pc: 0, pc: 88] local: this index: 0 type: X\n" + >+ " [pc: 0, pc: 88] local: delete index: 1 type: boolean\n" + >+ " [pc: 5, pc: 88] local: s index: 2 type: java.lang.String\n" + >+ " [pc: 13, pc: 88] local: buffer index: 3 type: java.lang.StringBuffer\n" + >+ " [pc: 24, pc: 71] local: datas index: 4 type: java.lang.String[]\n" + >+ " [pc: 34, pc: 71] local: data index: 5 type: java.lang.Object[]\n" + >+ " [pc: 51, pc: 54] local: e index: 6 type: java.lang.Exception\n" > : " // Method descriptor #15 (Z)V\n" + > " // Stack: 4, Locals: 8\n" + > " private void foo(boolean delete);\n" + >@@ -6627,42 +6615,35 @@ > " 40 aload 5 [data]\n" + > " 42 invokevirtual java.lang.StringBuffer.append(java.lang.Object) : java.lang.StringBuffer [27]\n" + > " 45 pop\n" + >- " 46 goto 62\n" + >+ " 46 goto 54\n" + > " 49 astore 6 [e]\n" + > " 51 aload 6 [e]\n" + >- " 53 ifnull 59\n" + >- " 56 aload 6 [e]\n" + >- " 58 athrow\n" + >- " 59 aconst_null\n" + >- " 60 astore_3 [buffer]\n" + >- " 61 return\n" + >- " 62 iload_1 [delete]\n" + >- " 63 ifeq 93\n" + >- " 66 aload_3 [buffer]\n" + >- " 67 iconst_0\n" + >- " 68 aload_3 [buffer]\n" + >- " 69 invokevirtual java.lang.StringBuffer.length() : int [31]\n" + >- " 72 invokevirtual java.lang.StringBuffer.delete(int, int) : java.lang.StringBuffer [35]\n" + >- " 75 pop\n" + >- " 76 goto 93\n" + >- " 79 astore 4\n" + >- " 81 aconst_null\n" + >- " 82 astore_3 [buffer]\n" + >- " 83 goto 95\n" + >- " 86 astore 7\n" + >- " 88 aconst_null\n" + >- " 89 astore_3 [buffer]\n" + >- " 90 aload 7\n" + >- " 92 athrow\n" + >- " 93 aconst_null\n" + >- " 94 astore_3 [buffer]\n" + >- " 95 return\n" + >+ " 53 athrow\n" + >+ " 54 iload_1 [delete]\n" + >+ " 55 ifeq 85\n" + >+ " 58 aload_3 [buffer]\n" + >+ " 59 iconst_0\n" + >+ " 60 aload_3 [buffer]\n" + >+ " 61 invokevirtual java.lang.StringBuffer.length() : int [31]\n" + >+ " 64 invokevirtual java.lang.StringBuffer.delete(int, int) : java.lang.StringBuffer [35]\n" + >+ " 67 pop\n" + >+ " 68 goto 85\n" + >+ " 71 astore 4\n" + >+ " 73 aconst_null\n" + >+ " 74 astore_3 [buffer]\n" + >+ " 75 goto 87\n" + >+ " 78 astore 7\n" + >+ " 80 aconst_null\n" + >+ " 81 astore_3 [buffer]\n" + >+ " 82 aload 7\n" + >+ " 84 athrow\n" + >+ " 85 aconst_null\n" + >+ " 86 astore_3 [buffer]\n" + >+ " 87 return\n" + > " Exception Table:\n" + > " [pc: 34, pc: 46] -> 49 when : java.lang.Exception\n" + >- " [pc: 13, pc: 59] -> 79 when : java.lang.Exception\n" + >- " [pc: 62, pc: 76] -> 79 when : java.lang.Exception\n" + >- " [pc: 13, pc: 59] -> 86 when : any\n" + >- " [pc: 62, pc: 81] -> 86 when : any\n" + >+ " [pc: 13, pc: 68] -> 71 when : java.lang.Exception\n" + >+ " [pc: 13, pc: 73] -> 78 when : any\n" + > " Line numbers:\n" + > " [pc: 0, line: 4]\n" + > " [pc: 5, line: 5]\n" + >@@ -6670,36 +6651,32 @@ > " [pc: 24, line: 10]\n" + > " [pc: 34, line: 12]\n" + > " [pc: 49, line: 13]\n" + >- " [pc: 51, line: 14]\n" + >- " [pc: 56, line: 15]\n" + >- " [pc: 59, line: 24]\n" + >- " [pc: 61, line: 16]\n" + >- " [pc: 62, line: 19]\n" + >- " [pc: 66, line: 20]\n" + >- " [pc: 79, line: 22]\n" + >- " [pc: 81, line: 24]\n" + >- " [pc: 86, line: 23]\n" + >- " [pc: 88, line: 24]\n" + >- " [pc: 90, line: 25]\n" + >- " [pc: 93, line: 24]\n" + >- " [pc: 95, line: 26]\n" + >+ " [pc: 51, line: 15]\n" + >+ " [pc: 54, line: 19]\n" + >+ " [pc: 58, line: 20]\n" + >+ " [pc: 71, line: 22]\n" + >+ " [pc: 73, line: 24]\n" + >+ " [pc: 78, line: 23]\n" + >+ " [pc: 80, line: 24]\n" + >+ " [pc: 82, line: 25]\n" + >+ " [pc: 85, line: 24]\n" + >+ " [pc: 87, line: 26]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 96] local: this index: 0 type: X\n" + >- " [pc: 0, pc: 96] local: delete index: 1 type: boolean\n" + >- " [pc: 5, pc: 96] local: s index: 2 type: java.lang.String\n" + >- " [pc: 13, pc: 96] local: buffer index: 3 type: java.lang.StringBuffer\n" + >- " [pc: 24, pc: 79] local: datas index: 4 type: java.lang.String[]\n" + >- " [pc: 34, pc: 79] local: data index: 5 type: java.lang.Object[]\n" + >- " [pc: 51, pc: 62] local: e index: 6 type: java.lang.Exception\n" + >- " Stack map table: number of frames 8\n" + >+ " [pc: 0, pc: 88] local: this index: 0 type: X\n" + >+ " [pc: 0, pc: 88] local: delete index: 1 type: boolean\n" + >+ " [pc: 5, pc: 88] local: s index: 2 type: java.lang.String\n" + >+ " [pc: 13, pc: 88] local: buffer index: 3 type: java.lang.StringBuffer\n" + >+ " [pc: 24, pc: 71] local: datas index: 4 type: java.lang.String[]\n" + >+ " [pc: 34, pc: 71] local: data index: 5 type: java.lang.Object[]\n" + >+ " [pc: 51, pc: 54] local: e index: 6 type: java.lang.Exception\n" + >+ " Stack map table: number of frames 7\n" + > " [pc: 49, full, stack: {java.lang.Exception}, locals: {X, int, java.lang.String, java.lang.StringBuffer, java.lang.String[], java.lang.Object[]}]\n" + >- " [pc: 59, append: {java.lang.Exception}]\n" + >- " [pc: 62, chop 1 local(s)]\n" + >- " [pc: 76, same]\n" + >- " [pc: 79, full, stack: {java.lang.Exception}, locals: {X, int, java.lang.String, java.lang.StringBuffer}]\n" + >- " [pc: 86, same_locals_1_stack_item, stack: {java.lang.Throwable}]\n" + >- " [pc: 93, same]\n" + >- " [pc: 95, same]\n"; >+ " [pc: 54, same]\n" + >+ " [pc: 68, same]\n" + >+ " [pc: 71, full, stack: {java.lang.Exception}, locals: {X, int, java.lang.String, java.lang.StringBuffer}]\n" + >+ " [pc: 78, same_locals_1_stack_item, stack: {java.lang.Throwable}]\n" + >+ " [pc: 85, same]\n" + >+ " [pc: 87, same]\n"; > > File f = new File(OUTPUT_DIR + File.separator + "X.class"); > byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >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.126 >diff -u -r1.126 InitializationTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 17 Aug 2009 17:45:39 -0000 1.126 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 20 Jan 2010 13:13:17 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -4890,7 +4890,7 @@ > > // 45357 > public void test169() { >- this.runConformTest( >+ this.runNegativeTest( > new String[] { > "X.java", > "public class X {\n" + >@@ -4921,7 +4921,15 @@ > " }\n" + > "}", > }, >- "SUCCESS"); >+ "----------\n" + >+ "1. WARNING in X.java (at line 18)\n" + >+ " if (obj != null) {\n" + >+ " result = null;\n" + >+ " foo(); \n" + >+ " } else {\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n"); > } > > // 45433 >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java,v >retrieving revision 1.330 >diff -u -r1.330 NegativeTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 4 Jan 2010 19:28:12 -0000 1.330 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/NegativeTest.java 20 Jan 2010 13:13:22 -0000 >@@ -9622,6 +9622,11 @@ > " fireTableCellUpdated();\n" + > " ^^^^^^^^^^^^^^^^^^^^\n" + > "Cannot refer to an instance method while explicitly invoking a constructor\n" + >+ "----------\n" + >+ "4. WARNING in p\\d\\One.java (at line 40)\n" + >+ " if (m == null) return;\n" + >+ " ^^^^^^^\n" + >+ "Dead code\n" + > "----------\n"); > } > public void test236() { >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java,v >retrieving revision 1.64 >diff -u -r1.64 AssignmentTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 4 Jan 2010 19:28:16 -0000 1.64 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 20 Jan 2010 13:13:24 -0000 >@@ -23,6 +23,7 @@ > } > protected Map getCompilerOptions() { > Map options = super.getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.IGNORE); > options.put(CompilerOptions.OPTION_ReportNullReference, CompilerOptions.ERROR); > options.put(CompilerOptions.OPTION_ReportPotentialNullReference, CompilerOptions.ERROR); > options.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.ERROR); >@@ -975,15 +976,8 @@ > null /* no class libraries */, > options /* custom options */, > // compiler results >- "----------\n" + /* expected compiler log */ >- "1. WARNING in X.java (at line 3)\n" + >- " if (false) {\n" + >- " b = false;\n" + >- " }\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Dead code\n" + > "----------\n" + >- "2. ERROR in X.java (at line 4)\n" + >+ "1. ERROR in X.java (at line 4)\n" + > " b = false;\n" + > " ^\n" + > "The parameter b should not be assigned\n" + >@@ -1016,12 +1010,7 @@ > options /* custom options */, > // compiler results > "----------\n" + /* expected compiler log */ >- "1. WARNING in X.java (at line 6)\n" + >- " b = false;\n" + >- " ^^^^^^^^^\n" + >- "Dead code\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 6)\n" + >+ "1. ERROR in X.java (at line 6)\n" + > " b = false;\n" + > " ^\n" + > "The parameter b should not be assigned\n" + >@@ -1046,15 +1035,8 @@ > " }\n" + > "}\n", > }, >- "----------\n" + >- "1. WARNING in X.java (at line 3)\n" + >- " if (false) {\n" + >- " b = false;\n" + >- " }\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Dead code\n" + > "----------\n" + >- "2. ERROR in X.java (at line 4)\n" + >+ "1. ERROR in X.java (at line 4)\n" + > " b = false;\n" + > " ^\n" + > "The final local variable b cannot be assigned. It must be blank and not using a compound assignment\n" + >@@ -1371,19 +1353,10 @@ > "class MyException extends Exception {\n" + > " private static final long serialVersionUID = 1L;\n" + > "}" >- }, >+ }, > // compiler results >- "----------\n" + /* expected compiler log */ >- "1. WARNING in X.java (at line 5)\n" + >- " if (false) {\n" + >- " i = 0;\n" + >- " System.out.println(i);\n" + >- " throw new MyException();\n" + >- " }\n" + >- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >- "Dead code\n" + >- "----------\n" + >- "2. ERROR in X.java (at line 11)\n" + >+ "----------\n" + /* expected compiler log */ >+ "1. ERROR in X.java (at line 11)\n" + > " i = 1;\n" + > " ^\n" + > "The final local variable i may already have been assigned\n" + >Index: src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java,v >retrieving revision 1.17 >diff -u -r1.17 BooleanTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java 27 Jun 2008 16:04:44 -0000 1.17 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/BooleanTest.java 20 Jan 2010 13:13:25 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -2266,20 +2266,17 @@ > " X(boolean b1);\n" + > " 0 aload_0 [this]\n" + > " 1 invokespecial java.lang.Object() [8]\n" + >- " 4 iload_1 [b1]\n" + >- " 5 ifeq 8\n" + >- " 8 getstatic java.lang.System.out : java.io.PrintStream [11]\n" + >- " 11 iload_1 [b1]\n" + >- " 12 invokevirtual java.io.PrintStream.println(boolean) : void [17]\n" + >- " 15 return\n" + >+ " 4 getstatic java.lang.System.out : java.io.PrintStream [11]\n" + >+ " 7 iload_1 [b1]\n" + >+ " 8 invokevirtual java.io.PrintStream.println(boolean) : void [17]\n" + >+ " 11 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 2]\n" + >- " [pc: 4, line: 4]\n" + >- " [pc: 8, line: 5]\n" + >- " [pc: 15, line: 7]\n" + >+ " [pc: 4, line: 5]\n" + >+ " [pc: 11, line: 7]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 16] local: this index: 0 type: X\n" + >- " [pc: 0, pc: 16] local: b1 index: 1 type: boolean\n"; >+ " [pc: 0, pc: 12] local: this index: 0 type: X\n" + >+ " [pc: 0, pc: 12] local: b1 index: 1 type: boolean\n"; > > File f = new File(OUTPUT_DIR + File.separator + "X.class"); > byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >@@ -2362,21 +2359,19 @@ > " 0 aload_0 [this]\n" + > " 1 invokespecial java.lang.Object() [8]\n" + > " 4 iload_1 [b1]\n" + >- " 5 ifeq 12\n" + >- " 8 iload_1 [b1]\n" + >- " 9 ifeq 12\n" + >- " 12 getstatic java.lang.System.out : java.io.PrintStream [11]\n" + >- " 15 iload_1 [b1]\n" + >- " 16 invokevirtual java.io.PrintStream.println(boolean) : void [17]\n" + >- " 19 return\n" + >+ " 5 ifeq 8\n" + >+ " 8 getstatic java.lang.System.out : java.io.PrintStream [11]\n" + >+ " 11 iload_1 [b1]\n" + >+ " 12 invokevirtual java.io.PrintStream.println(boolean) : void [17]\n" + >+ " 15 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 2]\n" + > " [pc: 4, line: 4]\n" + >- " [pc: 12, line: 5]\n" + >- " [pc: 19, line: 7]\n" + >+ " [pc: 8, line: 5]\n" + >+ " [pc: 15, line: 7]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 20] local: this index: 0 type: X\n" + >- " [pc: 0, pc: 20] local: b1 index: 1 type: boolean\n"; >+ " [pc: 0, pc: 16] local: this index: 0 type: X\n" + >+ " [pc: 0, pc: 16] local: b1 index: 1 type: boolean\n"; > > File f = new File(OUTPUT_DIR + File.separator + "X.class"); > byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java,v >retrieving revision 1.15 >diff -u -r1.15 ClassFileReaderTest_1_4.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java 27 Jun 2008 16:04:45 -0000 1.15 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ClassFileReaderTest_1_4.java 20 Jan 2010 13:13:27 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2008 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -385,21 +385,17 @@ > " public static void main(java.lang.String[] args);\n" + > " 0 bipush 6\n" + > " 2 istore_1 [i]\n" + >- " 3 iload_1 [i]\n" + >- " 4 bipush 6\n" + >- " 6 if_icmpeq 9\n" + >- " 9 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >- " 12 iload_1 [i]\n" + >- " 13 invokevirtual java.io.PrintStream.println(int) : void [22]\n" + >- " 16 return\n" + >+ " 3 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >+ " 6 iload_1 [i]\n" + >+ " 7 invokevirtual java.io.PrintStream.println(int) : void [22]\n" + >+ " 10 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 3]\n" + >- " [pc: 3, line: 4]\n" + >- " [pc: 9, line: 6]\n" + >- " [pc: 16, line: 8]\n" + >+ " [pc: 3, line: 6]\n" + >+ " [pc: 10, line: 8]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 17] local: args index: 0 type: java.lang.String[]\n" + >- " [pc: 3, pc: 17] local: i index: 1 type: int\n"; >+ " [pc: 0, pc: 11] local: args index: 0 type: java.lang.String[]\n" + >+ " [pc: 3, pc: 11] local: i index: 1 type: int\n"; > checkClassFile("A", source, expectedOutput); > } > >@@ -1950,20 +1946,16 @@ > " static void foo();\n" + > " 0 iconst_5\n" + > " 1 istore_0 [i]\n" + >- " 2 iload_0 [i]\n" + >- " 3 bipush 6\n" + >- " 5 if_icmpne 8\n" + >- " 8 getstatic java.lang.System.out : java.io.PrintStream [21]\n" + >- " 11 iload_0 [i]\n" + >- " 12 invokevirtual java.io.PrintStream.println(int) : void [27]\n" + >- " 15 return\n" + >+ " 2 getstatic java.lang.System.out : java.io.PrintStream [21]\n" + >+ " 5 iload_0 [i]\n" + >+ " 6 invokevirtual java.io.PrintStream.println(int) : void [27]\n" + >+ " 9 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 6]\n" + >- " [pc: 2, line: 7]\n" + >- " [pc: 8, line: 9]\n" + >- " [pc: 15, line: 11]\n" + >+ " [pc: 2, line: 9]\n" + >+ " [pc: 9, line: 11]\n" + > " Local variable table:\n" + >- " [pc: 2, pc: 16] local: i index: 0 type: int\n"; >+ " [pc: 2, pc: 10] local: i index: 0 type: int\n"; > checkClassFile("X", source, expectedOutput); > } > >@@ -2015,20 +2007,16 @@ > " static void bar();\n" + > " 0 bipush 6\n" + > " 2 istore_0 [i]\n" + >- " 3 iload_0 [i]\n" + >- " 4 bipush 6\n" + >- " 6 if_icmpeq 9\n" + >- " 9 getstatic java.lang.System.out : java.io.PrintStream [21]\n" + >- " 12 iload_0 [i]\n" + >- " 13 invokevirtual java.io.PrintStream.println(int) : void [27]\n" + >- " 16 return\n" + >+ " 3 getstatic java.lang.System.out : java.io.PrintStream [21]\n" + >+ " 6 iload_0 [i]\n" + >+ " 7 invokevirtual java.io.PrintStream.println(int) : void [27]\n" + >+ " 10 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 6]\n" + >- " [pc: 3, line: 7]\n" + >- " [pc: 9, line: 8]\n" + >- " [pc: 16, line: 10]\n" + >+ " [pc: 3, line: 8]\n" + >+ " [pc: 10, line: 10]\n" + > " Local variable table:\n" + >- " [pc: 3, pc: 17] local: i index: 0 type: int\n"; >+ " [pc: 3, pc: 11] local: i index: 0 type: int\n"; > checkClassFile("X", source, expectedOutput); > } > >@@ -2094,20 +2082,20 @@ > " 1 istore_0 [i]\n" + > " 2 iload_0 [i]\n" + > " 3 bipush 6\n" + >- " 5 if_icmpne 14\n" + >+ " 5 if_icmpne 12\n" + > " 8 invokestatic X.boom() : boolean [26]\n" + >- " 11 ifeq 14\n" + >- " 14 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >- " 17 iload_0 [i]\n" + >- " 18 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >- " 21 return\n" + >+ " 11 pop\n" + >+ " 12 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >+ " 15 iload_0 [i]\n" + >+ " 16 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >+ " 19 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 9]\n" + > " [pc: 2, line: 10]\n" + >- " [pc: 14, line: 12]\n" + >- " [pc: 21, line: 14]\n" + >+ " [pc: 12, line: 12]\n" + >+ " [pc: 19, line: 14]\n" + > " Local variable table:\n" + >- " [pc: 2, pc: 22] local: i index: 0 type: int\n"; >+ " [pc: 2, pc: 20] local: i index: 0 type: int\n"; > checkClassFile("X", source, expectedOutput); > } > >@@ -2173,20 +2161,20 @@ > " 2 istore_0 [i]\n" + > " 3 iload_0 [i]\n" + > " 4 bipush 6\n" + >- " 6 if_icmpeq 15\n" + >+ " 6 if_icmpeq 13\n" + > " 9 invokestatic X.boom() : boolean [26]\n" + >- " 12 ifne 15\n" + >- " 15 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >- " 18 iload_0 [i]\n" + >- " 19 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >- " 22 return\n" + >+ " 12 pop\n" + >+ " 13 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >+ " 16 iload_0 [i]\n" + >+ " 17 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >+ " 20 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 9]\n" + > " [pc: 3, line: 10]\n" + >- " [pc: 15, line: 11]\n" + >- " [pc: 22, line: 13]\n" + >+ " [pc: 13, line: 11]\n" + >+ " [pc: 20, line: 13]\n" + > " Local variable table:\n" + >- " [pc: 3, pc: 23] local: i index: 0 type: int\n"; >+ " [pc: 3, pc: 21] local: i index: 0 type: int\n"; > checkClassFile("X", source, expectedOutput); > } > >@@ -2508,20 +2496,20 @@ > " 1 istore_0 [i]\n" + > " 2 iload_0 [i]\n" + > " 3 bipush 6\n" + >- " 5 if_icmpne 14\n" + >+ " 5 if_icmpne 12\n" + > " 8 invokestatic X.boom() : boolean [26]\n" + >- " 11 ifeq 14\n" + >- " 14 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >- " 17 iload_0 [i]\n" + >- " 18 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >- " 21 return\n" + >+ " 11 pop\n" + >+ " 12 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >+ " 15 iload_0 [i]\n" + >+ " 16 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >+ " 19 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 9]\n" + > " [pc: 2, line: 10]\n" + >- " [pc: 14, line: 12]\n" + >- " [pc: 21, line: 14]\n" + >+ " [pc: 12, line: 12]\n" + >+ " [pc: 19, line: 14]\n" + > " Local variable table:\n" + >- " [pc: 2, pc: 22] local: i index: 0 type: int\n"; >+ " [pc: 2, pc: 20] local: i index: 0 type: int\n"; > checkClassFile("X", source, expectedOutput); > } > >@@ -2587,20 +2575,20 @@ > " 2 istore_0 [i]\n" + > " 3 iload_0 [i]\n" + > " 4 bipush 6\n" + >- " 6 if_icmpeq 15\n" + >+ " 6 if_icmpeq 13\n" + > " 9 invokestatic X.boom() : boolean [26]\n" + >- " 12 ifne 15\n" + >- " 15 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >- " 18 iload_0 [i]\n" + >- " 19 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >- " 22 return\n" + >+ " 12 pop\n" + >+ " 13 getstatic java.lang.System.out : java.io.PrintStream [28]\n" + >+ " 16 iload_0 [i]\n" + >+ " 17 invokevirtual java.io.PrintStream.println(int) : void [34]\n" + >+ " 20 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 9]\n" + > " [pc: 3, line: 10]\n" + >- " [pc: 15, line: 11]\n" + >- " [pc: 22, line: 13]\n" + >+ " [pc: 13, line: 11]\n" + >+ " [pc: 20, line: 13]\n" + > " Local variable table:\n" + >- " [pc: 3, pc: 23] local: i index: 0 type: int\n"; >+ " [pc: 3, pc: 21] local: i index: 0 type: int\n"; > checkClassFile("X", source, expectedOutput); > } > >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java,v >retrieving revision 1.30 >diff -u -r1.30 ConstantTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java 27 Jun 2008 16:04:44 -0000 1.30 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java 20 Jan 2010 13:13:28 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2008 IBM Corporation and others. >+ * Copyright (c) 2003, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -382,17 +382,15 @@ > " 66 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" + > " 69 aconst_null\n" + > " 70 astore_2 [s]\n" + >- " 71 aload_2 [s]\n" + >- " 72 ifnonnull 83\n" + >- " 75 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >- " 78 ldc <String \"4\"> [55]\n" + >- " 80 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" + >- " 83 ldc <String \"aaa\"> [57]\n" + >- " 85 astore_3 [s2]\n" + >- " 86 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >- " 89 ldc <String \"5\"> [59]\n" + >- " 91 invokevirtual java.io.PrintStream.println(java.lang.String) : void [61]\n" + >- " 94 return\n" + >+ " 71 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >+ " 74 ldc <String \"4\"> [55]\n" + >+ " 76 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" + >+ " 79 ldc <String \"aaa\"> [57]\n" + >+ " 81 astore_3 [s2]\n" + >+ " 82 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >+ " 85 ldc <String \"5\"> [59]\n" + >+ " 87 invokevirtual java.io.PrintStream.println(java.lang.String) : void [61]\n" + >+ " 90 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 3]\n" + > " [pc: 8, line: 4]\n" + >@@ -401,14 +399,14 @@ > " [pc: 61, line: 7]\n" + > " [pc: 69, line: 8]\n" + > " [pc: 71, line: 9]\n" + >- " [pc: 83, line: 10]\n" + >- " [pc: 86, line: 11]\n" + >- " [pc: 94, line: 12]\n" + >- " Local variable table:\n" + >- " [pc: 0, pc: 95] local: args index: 0 type: java.lang.String[]\n" + >- " [pc: 61, pc: 95] local: b index: 1 type: boolean\n" + >- " [pc: 71, pc: 95] local: s index: 2 type: java.lang.String\n" + >- " [pc: 86, pc: 95] local: s2 index: 3 type: java.lang.String\n"; >+ " [pc: 79, line: 10]\n" + >+ " [pc: 82, line: 11]\n" + >+ " [pc: 90, line: 12]\n" + >+ " Local variable table:\n" + >+ " [pc: 0, pc: 91] local: args index: 0 type: java.lang.String[]\n" + >+ " [pc: 61, pc: 91] local: b index: 1 type: boolean\n" + >+ " [pc: 71, pc: 91] local: s index: 2 type: java.lang.String\n" + >+ " [pc: 82, pc: 91] local: s2 index: 3 type: java.lang.String\n"; > > String expectedOutput15 = > " // Method descriptor #15 ([Ljava/lang/String;)V\n" + >@@ -447,17 +445,15 @@ > " 66 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" + > " 69 aconst_null\n" + > " 70 astore_2 [s]\n" + >- " 71 aload_2 [s]\n" + >- " 72 ifnonnull 83\n" + >- " 75 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >- " 78 ldc <String \"4\"> [55]\n" + >- " 80 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" + >- " 83 ldc <String \"aaa\"> [57]\n" + >- " 85 astore_3 [s2]\n" + >- " 86 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >- " 89 ldc <String \"5\"> [59]\n" + >- " 91 invokevirtual java.io.PrintStream.println(java.lang.String) : void [61]\n" + >- " 94 return\n" + >+ " 71 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >+ " 74 ldc <String \"4\"> [55]\n" + >+ " 76 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" + >+ " 79 ldc <String \"aaa\"> [57]\n" + >+ " 81 astore_3 [s2]\n" + >+ " 82 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + >+ " 85 ldc <String \"5\"> [59]\n" + >+ " 87 invokevirtual java.io.PrintStream.println(java.lang.String) : void [61]\n" + >+ " 90 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 3]\n" + > " [pc: 8, line: 4]\n" + >@@ -466,14 +462,14 @@ > " [pc: 61, line: 7]\n" + > " [pc: 69, line: 8]\n" + > " [pc: 71, line: 9]\n" + >- " [pc: 83, line: 10]\n" + >- " [pc: 86, line: 11]\n" + >- " [pc: 94, line: 12]\n" + >- " Local variable table:\n" + >- " [pc: 0, pc: 95] local: args index: 0 type: java.lang.String[]\n" + >- " [pc: 61, pc: 95] local: b index: 1 type: boolean\n" + >- " [pc: 71, pc: 95] local: s index: 2 type: java.lang.String\n" + >- " [pc: 86, pc: 95] local: s2 index: 3 type: java.lang.String\n"; >+ " [pc: 79, line: 10]\n" + >+ " [pc: 82, line: 11]\n" + >+ " [pc: 90, line: 12]\n" + >+ " Local variable table:\n" + >+ " [pc: 0, pc: 91] local: args index: 0 type: java.lang.String[]\n" + >+ " [pc: 61, pc: 91] local: b index: 1 type: boolean\n" + >+ " [pc: 71, pc: 91] local: s index: 2 type: java.lang.String\n" + >+ " [pc: 82, pc: 91] local: s2 index: 3 type: java.lang.String\n"; > > if (this.complianceLevel >= ClassFileConstants.JDK1_5) { > int index = actualOutput.indexOf(expectedOutput15); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v >retrieving revision 1.83 >diff -u -r1.83 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 19 Nov 2009 15:57:22 -0000 1.83 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 20 Jan 2010 13:13:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -12,9 +12,10 @@ > > import java.util.Map; > >+import junit.framework.Test; >+ > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >-import junit.framework.Test; > > /* See also NullReferenceImplTests for low level, implementation dependent > * tests. */ >@@ -178,6 +179,11 @@ > " if (o != null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o can only be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o != null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -849,6 +855,11 @@ > " if (i == null) {};\n" + > " ^\n" + > "Null comparison always yields false: The variable i cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (i == null) {};\n" + >+ " ^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -911,6 +922,11 @@ > " if (i == null) {}\n" + > " ^\n" + > "Null comparison always yields false: The variable i cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (i == null) {}\n" + >+ " ^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -996,6 +1012,11 @@ > " if (o == null) {};\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o == null) {};\n" + >+ " ^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1062,6 +1083,11 @@ > " if (o == null) {/* empty */}\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o == null) {/* empty */}\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1116,6 +1142,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1153,6 +1184,11 @@ > " if (c == null) {};\n" + > " ^\n" + > "Null comparison always yields false: The variable c cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (c == null) {};\n" + >+ " ^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1216,6 +1252,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1243,6 +1284,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 6)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1415,6 +1461,11 @@ > " if (x == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable x cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (x == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1776,6 +1827,13 @@ > " if (o == null) {\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o == null) {\n" + >+ " // do nothing\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1918,10 +1976,15 @@ > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 7)\n" + >- " o.toString();\n" + >- " ^\n" + >- "Potential null pointer access: The variable o may be null at this location\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 6)\n" + >+ " if (o != null) { /* */ }\n" + >+ " ^\n" + >+ "Redundant null check: The variable o cannot be null at this location\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -1945,6 +2008,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -2083,6 +2151,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -2121,6 +2194,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -2402,7 +2480,7 @@ > " o.toString();\n" + > " }\n" + > " else {\n" + >- " o.toString();\n" + // must complain anyway (could be quite distant from the if test) >+ " o.toString();\n" + > " }\n" + > " o.toString();\n" + // quiet > " }\n" + >@@ -2413,19 +2491,21 @@ > " ^\n" + > "Redundant null check: The variable o cannot be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 8)\n" + >- " o.toString();\n" + >- " ^\n" + >- "Null pointer access: The variable o can only be null at this location\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " else {\n" + >+ " o.toString();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } > > // null analysis - if/else >-// TODO (maxime) https://bugs.eclipse.org/bugs/show_bug.cgi?id=129581 >-// this is a limit of the fix for bug 128014 - calls for a nuance >-// between potential null and tainted null >-public void _test0335_if_else() { >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=129581 >+// Test that no false null reference warning is issued for a variable >+// that has been wrongly tainted by a redundant null check upstream. >+public void test0335_if_else() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -2473,10 +2553,12 @@ > " ^\n" + > "Redundant null check: The variable o cannot be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 8)\n" + >- " o.toString();\n" + >- " ^\n" + >- "Null pointer access: The variable o can only be null at this location\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " else {\n" + >+ " o.toString();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -3147,6 +3229,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -3172,6 +3259,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -3241,6 +3333,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 6)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -4492,6 +4589,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -4517,6 +4619,13 @@ > " if (o == null) {\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " if (o == null) {\n" + >+ " o = new Object();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -5810,6 +5919,12 @@ > " if (ex == null) {\n" + > " ^^\n" + > "Null comparison always yields false: The variable ex cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 20)\n" + >+ " if (ex == null) {\n" + >+ " }\n" + >+ " ^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -7587,6 +7702,11 @@ > " if(o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 12)\n" + >+ " if(o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -7962,7 +8082,12 @@ > " ^^\n" + > "Null comparison always yields false: The variable o1 cannot be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 5)\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o1 == null) { };\n" + >+ " ^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 5)\n" + > " if (o2 == null) { };\n" + > " ^^\n" + > "Redundant null check: The variable o2 can only be null at this location\n" + >@@ -8011,6 +8136,11 @@ > " if (o == null) { };\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o == null) { };\n" + >+ " ^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8040,6 +8170,11 @@ > " if (o == null) { };\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 5)\n" + >+ " if (o == null) { };\n" + >+ " ^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8208,20 +8343,17 @@ > " ^\n" + > "Null comparison always yields false: The variable x cannot be null at this location\n" + > "----------\n" + >- "3. ERROR in X.java (at line 6)\n" + >- " x.foo(null); // 3\n" + >- " ^\n" + >- "Null pointer access: The variable x can only be null at this location\n" + >+ "3. WARNING in X.java (at line 5)\n" + >+ " if (x == null) { // 2\n" + >+ " x.foo(null); // 3\n" + >+ " } else if (x instanceof X) { // 4\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n" + > "4. ERROR in X.java (at line 9)\n" + > " } else if (x != null) { // 6\n" + > " ^\n" + > "Redundant null check: The variable x cannot be null at this location\n" + >- "----------\n" + >- "5. ERROR in X.java (at line 12)\n" + >- " x.foo(null); // 8\n" + >- " ^\n" + >- "Potential null pointer access: The variable x may be null at this location\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8375,6 +8507,17 @@ > " if (other != null) {\n" + > " ^^^^^\n" + > "Redundant null check: The variable other cannot be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 11)\n" + >+ " if (other == null) {\n" + >+ " ^^^^^\n" + >+ "Null comparison always yields false: The variable other cannot be null at this location\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 11)\n" + >+ " if (other == null) {\n" + >+ " }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8428,10 +8571,12 @@ > " ^\n" + > "Null comparison always yields false: The variable x cannot be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 5)\n" + >- " x.foo(this);\n" + >- " ^\n" + >- "Null pointer access: The variable x can only be null at this location\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (x == null) {\n" + >+ " x.foo(this);\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8680,6 +8825,11 @@ > " if (o == null) return;\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 13)\n" + >+ " if (o == null) return;\n" + >+ " ^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8739,6 +8889,11 @@ > " if (o == null) return;\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 10)\n" + >+ " if (o == null) return;\n" + >+ " ^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8890,6 +9045,13 @@ > " if (a == null) {\n" + > " ^\n" + > "Null comparison always yields false: The variable a cannot be null at this location\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 13)\n" + >+ " if (a == null) {\n" + >+ " System.out.println();\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -8947,6 +9109,11 @@ > " if(a!=null)\n" + > " ^\n" + > "Null comparison always yields false: The variable a can only be null at this location\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 9)\n" + >+ " { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -9043,7 +9210,14 @@ > "}\n" > } /* testFiles */, > "----------\n" + >- "1. WARNING in X.java (at line 8)\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " if (o != null) {\n" + >+ " o = null;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 8)\n" + > " o.toString();\n" + > " ^\n" + > "Null pointer access: The variable o can only be null at this location\n" + >@@ -9105,18 +9279,25 @@ > " }\n" + > "}\n"}, > "----------\n" + >- "1. ERROR in X.java (at line 4)\r\n" + >- " if (o != null) {\r\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " if (o != null) {\n" + > " ^\n" + >- "Null comparison always yields false: The variable o can only be null at this location\n" + >+ "Null comparison always yields false: The variable o can only be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 8)\r\n" + >- " o.toString();\r\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o != null) {\n" + >+ " o = null;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " o.toString();\n" + > " ^\n" + > "Null pointer access: The variable o can only be null at this location\n" + > "----------\n" + >- "3. ERROR in X.java (at line 9)\r\n" + >- " p.toString();\r\n" + >+ "4. ERROR in X.java (at line 9)\n" + >+ " p.toString();\n" + > " ^\n" + > "Potential null pointer access: The variable p may be null at this location\n" + > "----------\n", >@@ -9152,8 +9333,15 @@ > customOptions /* custom options */, > // compiler results > "----------\n" + /* expected compiler log */ >- "1. ERROR in X.java (at line 8)\r\n" + >- " o.toString();\r\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " if (o != null) {\n" + >+ " o = null;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " o.toString();\n" + > " ^\n" + > "Null pointer access: The variable o can only be null at this location\n" + > "----------\n", >@@ -9190,13 +9378,20 @@ > customOptions /* custom options */, > // compiler results > "----------\n" + /* expected compiler log */ >- "1. ERROR in X.java (at line 4)\r\n" + >- " if (o != null) {\r\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " if (o != null) {\n" + > " ^\n" + > "Null comparison always yields false: The variable o can only be null at this location\n" + > "----------\n" + >- "2. WARNING in X.java (at line 8)\r\n" + >- " o.toString();\r\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o != null) {\n" + >+ " o = null;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 8)\n" + >+ " o.toString();\n" + > " ^\n" + > "Null pointer access: The variable o can only be null at this location\n" + > "----------\n", >@@ -9233,13 +9428,20 @@ > customOptions /* custom options */, > // compiler results > "----------\n" + /* expected compiler log */ >- "1. ERROR in X.java (at line 4)\r\n" + >- " if (o != null) {\r\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " if (o != null) {\n" + > " ^\n" + > "Null comparison always yields false: The variable o can only be null at this location\n" + > "----------\n" + >- "2. ERROR in X.java (at line 9)\r\n" + >- " p.toString();\r\n" + >+ "2. WARNING in X.java (at line 4)\n" + >+ " if (o != null) {\n" + >+ " o = null;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 9)\n" + >+ " p.toString();\n" + > " ^\n" + > "Potential null pointer access: The variable p may be null at this location\n" + > "----------\n", >@@ -9278,8 +9480,15 @@ > customOptions /* custom options */, > // compiler results > "----------\n" + /* expected compiler log */ >- "1. ERROR in X.java (at line 9)\r\n" + >- " o.toString();\r\n" + >+ "1. WARNING in X.java (at line 5)\n" + >+ " if (o != null) {\n" + >+ " o = null;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 9)\n" + >+ " o.toString();\n" + > " ^\n" + > "Null pointer access: The variable o can only be null at this location\n" + > "----------\n", >@@ -9489,6 +9698,16 @@ > " if (o65 == null) { /* */ }\n" + > " ^^^\n" + > "Null comparison always yields false: The variable o65 cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 18)\n" + >+ " if (o65 == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 19)\n" + >+ " if (o65 != null) { /* */ }\n" + >+ " ^^^\n" + >+ "Redundant null check: The variable o65 cannot be null at this location\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -9746,6 +9965,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 20)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -9783,6 +10007,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 21)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -9823,6 +10052,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 24)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -9863,6 +10097,11 @@ > " if (o == null) { /* */ }\n" + > " ^\n" + > "Null comparison always yields false: The variable o cannot be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 24)\n" + >+ " if (o == null) { /* */ }\n" + >+ " ^^^^^^^^^\n" + >+ "Dead code\n" + > "----------\n", > JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); > } >@@ -10328,4 +10567,134 @@ > "----------\n"); > } > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=293917 >+// Test that a redundant null check doesn't affect the null status of >+// a variable downstream. >+public void testBug293917a() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void foo(){\n" + >+ " String x = null, y = null;\n" + >+ " if (x == null) x = \"foo\";\n" + >+ " if (x != null) y = \"bar\";\n" + >+ " x.length();\n" + // shouldn't warn here >+ " y.length();\n" + // shouldn't warn here >+ " }\n" + >+ "}\n"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " if (x == null) x = \"foo\";\n" + >+ " ^\n" + >+ "Redundant null check: The variable x can only be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 5)\n" + >+ " if (x != null) y = \"bar\";\n" + >+ " ^\n" + >+ "Redundant null check: The variable x cannot be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=293917 >+// Test that a redundant null check doesn't affect the null status of >+// a variable downstream in a loop. >+public void testBug293917b() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void foo(){\n" + >+ " String x = null, y = null;" + >+ " while(true) {\n" + >+ " if (x == null) x = \"foo\";\n" + >+ " if (x != null) y = \"bar\";\n" + >+ " x.length();\n" + // shouldn't warn here >+ " y.length();\n" + // shouldn't warn here >+ " }\n" + >+ " }\n" + >+ "}\n"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " if (x != null) y = \"bar\";\n" + >+ " ^\n" + >+ "Redundant null check: The variable x cannot be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=293917 >+// Test that a redundant null check doesn't affect the null status of >+// a variable downstream in a finally block. >+public void testBug293917c() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public void foo(){\n" + >+ " String x = null, y = null;" + >+ " try {}\n" + >+ " finally {\n" + >+ " if (x == null) x = \"foo\";\n" + >+ " if (x != null) y = \"bar\";\n" + >+ " x.length();\n" + // shouldn't warn here >+ " y.length();\n" + // shouldn't warn here >+ " }\n" + >+ " }\n" + >+ "}\n"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 5)\n" + >+ " if (x == null) x = \"foo\";\n" + >+ " ^\n" + >+ "Redundant null check: The variable x can only be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " if (x != null) y = \"bar\";\n" + >+ " ^\n" + >+ "Redundant null check: The variable x cannot be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=190623 >+// Test that a redundant null check doesn't affect the null status of >+// a variable downstream. >+public void testBug190623() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " Number n = getNumber();\n" + >+ " if (n instanceof Double) {\n" + >+ " Double d= (Double) n;\n" + >+ " if (d != null && d.isNaN()) {\n" + >+ " System.out.println(\"outside loop\");\n" + >+ " }\n" + >+ " for (int i= 0; i < 10; i++) {\n" + >+ " if (d != null && d.isNaN()) {\n" + >+ " System.out.println(\"inside loop\");\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ " private static Number getNumber() {\n" + >+ " return new Double(Math.sqrt(-1));\n" + >+ " }\n" + >+ "}\n"}, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " if (d != null && d.isNaN()) {\n" + >+ " ^\n" + >+ "Redundant null check: The variable d cannot be null at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 10)\n" + >+ " if (d != null && d.isNaN()) {\n" + >+ " ^\n" + >+ "Redundant null check: The variable d cannot be null at this location\n" + >+ "----------\n", >+ JavacTestOptions.Excuse.EclipseWarningConfiguredAsError); >+} > } >\ No newline at end of file >Index: src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java,v >retrieving revision 1.45 >diff -u -r1.45 StackMapAttributeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java 4 Jan 2010 19:32:55 -0000 1.45 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java 20 Jan 2010 13:13:38 -0000 >@@ -6142,8 +6142,11 @@ > " int b = 1;\n" + > " };\n" + > "\n" + >+ " private Object bar2() {\n" + >+ " return null;\n" + >+ " }\n" + > " private Object bar() {\n" + >- " Object o = null;\n" + >+ " Object o = bar2();\n" + > " if (o != null) {\n" + > " o.toString();\n" + > " }\n" + >@@ -6154,27 +6157,29 @@ > }, > ""); > String expectedOutput = >+ " // Method descriptor #23 ()Ljava/lang/Object;\n" + > " // Stack: 1, Locals: 2\n" + > " private java.lang.Object bar();\n" + >- " 0 aconst_null\n" + >- " 1 astore_1 [o]\n" + >- " 2 aload_1 [o]\n" + >- " 3 ifnull 11\n" + >- " 6 aload_1 [o]\n" + >- " 7 invokevirtual java.lang.Object.toString() : java.lang.String [24]\n" + >- " 10 pop\n" + >- " 11 aconst_null\n" + >- " 12 areturn\n" + >+ " 0 aload_0 [this]\n" + >+ " 1 invokespecial X.bar2() : java.lang.Object [25]\n" + >+ " 4 astore_1 [o]\n" + >+ " 5 aload_1 [o]\n" + >+ " 6 ifnull 14\n" + >+ " 9 aload_1 [o]\n" + >+ " 10 invokevirtual java.lang.Object.toString() : java.lang.String [27]\n" + >+ " 13 pop\n" + >+ " 14 aconst_null\n" + >+ " 15 areturn\n" + > " Line numbers:\n" + >- " [pc: 0, line: 8]\n" + >- " [pc: 2, line: 9]\n" + >- " [pc: 6, line: 10]\n" + >- " [pc: 11, line: 12]\n" + >+ " [pc: 0, line: 11]\n" + >+ " [pc: 5, line: 12]\n" + >+ " [pc: 9, line: 13]\n" + >+ " [pc: 14, line: 15]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 13] local: this index: 0 type: X\n" + >- " [pc: 2, pc: 13] local: o index: 1 type: java.lang.Object\n" + >+ " [pc: 0, pc: 16] local: this index: 0 type: X\n" + >+ " [pc: 5, pc: 16] local: o index: 1 type: java.lang.Object\n" + > " Stack map table: number of frames 1\n" + >- " [pc: 11, append: {java.lang.Object}]\n"; >+ " [pc: 14, append: {java.lang.Object}]\n"; > checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=251539 >@@ -6203,8 +6208,11 @@ > " int b = 1;\n" + > " int c = 2;\n" + > " };\n" + >+ " private Object bar2() {\n" + >+ " return null;\n" + >+ " }\n" + > " private Object bar() {\n" + >- " Object o = null;\n" + >+ " Object o = bar2();\n" + > " if (o != null) {\n" + > " o.toString();\n" + > " }\n" + >@@ -6215,27 +6223,29 @@ > ""); > > String expectedOutput = >+ " // Method descriptor #29 ()Ljava/lang/Object;\n" + > " // Stack: 1, Locals: 2\n" + > " private java.lang.Object bar();\n" + >- " 0 aconst_null\n" + >- " 1 astore_1 [o]\n" + >- " 2 aload_1 [o]\n" + >- " 3 ifnull 11\n" + >- " 6 aload_1 [o]\n" + >- " 7 invokevirtual java.lang.Object.toString() : java.lang.String [30]\n" + >- " 10 pop\n" + >- " 11 aconst_null\n" + >- " 12 areturn\n" + >+ " 0 aload_0 [this]\n" + >+ " 1 invokespecial X.bar2() : java.lang.Object [31]\n" + >+ " 4 astore_1 [o]\n" + >+ " 5 aload_1 [o]\n" + >+ " 6 ifnull 14\n" + >+ " 9 aload_1 [o]\n" + >+ " 10 invokevirtual java.lang.Object.toString() : java.lang.String [33]\n" + >+ " 13 pop\n" + >+ " 14 aconst_null\n" + >+ " 15 areturn\n" + > " Line numbers:\n" + >- " [pc: 0, line: 12]\n" + >- " [pc: 2, line: 13]\n" + >- " [pc: 6, line: 14]\n" + >- " [pc: 11, line: 16]\n" + >+ " [pc: 0, line: 15]\n" + >+ " [pc: 5, line: 16]\n" + >+ " [pc: 9, line: 17]\n" + >+ " [pc: 14, line: 19]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 13] local: this index: 0 type: X\n" + >- " [pc: 2, pc: 13] local: o index: 1 type: java.lang.Object\n" + >+ " [pc: 0, pc: 16] local: this index: 0 type: X\n" + >+ " [pc: 5, pc: 16] local: o index: 1 type: java.lang.Object\n" + > " Stack map table: number of frames 1\n" + >- " [pc: 11, append: {java.lang.Object}]\n"; >+ " [pc: 14, append: {java.lang.Object}]\n"; > checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=260031
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
Flags:
srikanth_sankaran
:
iplog+
srikanth_sankaran
:
review+
Actions:
View
|
Diff
Attachments on
bug 293917
:
154955
|
156262
| 156644