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 178912 Details for
Bug 325229
[compiler] eclipse compiler differs from javac when assert is present (FUP of bug 319510)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch under test
patch325229.txt (text/plain), 9.48 KB, created by
Ayushman Jain
on 2010-09-15 07:02:13 EDT
(
hide
)
Description:
patch under test
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-09-15 07:02:13 EDT
Size:
9.48 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.80 >diff -u -r1.80 EqualExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 25 Feb 2010 15:27:01 -0000 1.80 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/EqualExpression.java 15 Sep 2010 10:58:49 -0000 >@@ -56,6 +56,9 @@ > flowContext.recordUsingNullReference(scope, local, reference, > FlowContext.CAN_ONLY_NULL | FlowContext.IN_COMPARISON_NON_NULL, flowInfo); > initsWhenTrue.markAsComparedEqualToNonNull(local); // from thereon it is set >+ if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { >+ initsWhenTrue.markedAsNullOrNonNullInAssertExpression(local); >+ } > } else { > flowContext.recordUsingNullReference(scope, local, reference, > FlowContext.CAN_ONLY_NULL | FlowContext.IN_COMPARISON_NULL, flowInfo); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java,v >retrieving revision 1.130 >diff -u -r1.130 Expression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 9 Sep 2010 17:36:21 -0000 1.130 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/Expression.java 15 Sep 2010 10:58:49 -0000 >@@ -511,8 +511,14 @@ > } > flowInfo.markAsComparedEqualToNonNull(local); > // from thereon it is set >+ if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { >+ flowInfo.markedAsNullOrNonNullInAssertExpression(local); >+ } > if (flowContext.initsOnFinally != null) { > flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); >+ if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { >+ flowContext.initsOnFinally.markedAsNullOrNonNullInAssertExpression(local); >+ } > } > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java,v >retrieving revision 1.61 >diff -u -r1.61 InstanceOfExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java 13 Apr 2010 06:24:32 -0000 1.61 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/InstanceOfExpression.java 15 Sep 2010 10:58:49 -0000 >@@ -37,6 +37,9 @@ > unconditionalInits(); > FlowInfo initsWhenTrue = flowInfo.copy(); > initsWhenTrue.markAsComparedEqualToNonNull(local); >+ if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { >+ initsWhenTrue.markedAsNullOrNonNullInAssertExpression(local); >+ } > flowContext.recordUsingNullReference(currentScope, local, > this.expression, FlowContext.CAN_ONLY_NULL | FlowContext.IN_INSTANCEOF, flowInfo); > // no impact upon enclosing try context >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.143 >diff -u -r1.143 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 22 Jul 2010 14:15:47 -0000 1.143 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 15 Sep 2010 10:58:49 -0000 >@@ -230,8 +230,14 @@ > } > flowInfo.markAsComparedEqualToNonNull(local); > // from thereon it is set >+ if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { >+ flowInfo.markedAsNullOrNonNullInAssertExpression(local); >+ } > if (flowContext.initsOnFinally != null) { > flowContext.initsOnFinally.markAsComparedEqualToNonNull(local); >+ if ((flowContext.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) != 0) { >+ flowContext.initsOnFinally.markedAsNullOrNonNullInAssertExpression(local); >+ } > } > } > } >#P org.eclipse.jdt.core.tests.compiler >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.102 >diff -u -r1.102 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 9 Sep 2010 17:36:17 -0000 1.102 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 15 Sep 2010 10:59:06 -0000 >@@ -35,7 +35,7 @@ > // Only the highest compliance level is run; add the VM argument > // -Dcompliance=1.4 (for example) to lower it if needed > static { >-// TESTS_NAMES = new String[] { "testBug292478g" }; >+// TESTS_NAMES = new String[] { "testBug325229" }; > // TESTS_NUMBERS = new int[] { 561 }; > // TESTS_RANGE = new int[] { 1, 2049 }; > } >@@ -13350,4 +13350,147 @@ > "}\n" > }); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229 >+// instancof expression >+public void testBug325229a() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING); >+ this.runConformTest( >+ new String[] { >+ "Test.java", >+ "public class Test {\n" + >+ " void foo(Object a) {\n" + >+ " assert a instanceof Object;\n " + >+ " if (a!=null) {\n" + >+ " System.out.println(\"a is not null\");\n" + >+ " } else{\n" + >+ " System.out.println(\"a is null\");\n" + >+ " }\n" + >+ " }\n" + >+ " public static void main(String[] args){\n" + >+ " Test test = new Test();\n" + >+ " test.foo(null);\n" + >+ " }\n" + >+ "}\n"}, >+ "a is null", >+ null, >+ true, >+ new String[] {"-da"}, >+ compilerOptions, >+ null); >+ } >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229 >+// MessageSend in assert >+public void testBug325229b() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING); >+ this.runConformTest( >+ new String[] { >+ "Test.java", >+ "public class Test {\n" + >+ " boolean bar() {\n" + >+ " return false;\n" + >+ " }" + >+ " void foo(Test a) {\n" + >+ " assert a.bar();\n " + >+ " if (a!=null) {\n" + >+ " System.out.println(\"a is not null\");\n" + >+ " } else{\n" + >+ " System.out.println(\"a is null\");\n" + >+ " }\n" + >+ " }\n" + >+ " public static void main(String[] args){\n" + >+ " Test test = new Test();\n" + >+ " test.foo(null);\n" + >+ " }\n" + >+ "}\n"}, >+ "a is null", >+ null, >+ true, >+ new String[] {"-da"}, >+ compilerOptions, >+ null); >+ } >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229 >+// QualifiedNameReference in assert >+public void testBug325229c() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING); >+ this.runConformTest( >+ new String[] { >+ "Test.java", >+ "public class Test {\n" + >+ " boolean bar() {\n" + >+ " return false;\n" + >+ " }" + >+ " Test tfield;\n" + >+ " void foo(Test a) {\n" + >+ " assert a.tfield.bar();\n " + >+ " if (a!=null) {\n" + >+ " System.out.println(\"a is not null\");\n" + >+ " } else{\n" + >+ " System.out.println(\"a is null\");\n" + >+ " }\n" + >+ " }\n" + >+ " public static void main(String[] args){\n" + >+ " Test test = new Test();\n" + >+ " test.foo(null);\n" + >+ " }\n" + >+ "}\n"}, >+ "a is null", >+ null, >+ true, >+ new String[] {"-da"}, >+ compilerOptions, >+ null); >+ } >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=325229 >+// EqualExpression in assert, comparison against non null >+public void testBug325229d() { >+ if (this.complianceLevel >= ClassFileConstants.JDK1_5) { >+ Map compilerOptions = getCompilerOptions(); >+ compilerOptions.put(CompilerOptions.OPTION_ReportRedundantNullCheck, CompilerOptions.WARNING); >+ this.runConformTest( >+ new String[] { >+ "Test.java", >+ "public class Test {\n" + >+ " void foo(Object a) {\n" + >+ " Object b = null;" + >+ " assert a == b;\n " + >+ " if (a!=null) {\n" + >+ " System.out.println(\"a is not null\");\n" + >+ " } else{\n" + >+ " System.out.println(\"a is null\");\n" + >+ " }\n" + >+ " assert a != b;\n " + >+ " if (a!=null) {\n" + >+ " System.out.println(\"a is not null\");\n" + >+ " } else{\n" + >+ " System.out.println(\"a is null\");\n" + >+ " }\n" + >+ " }\n" + >+ " public static void main(String[] args){\n" + >+ " Test test = new Test();\n" + >+ " test.foo(null);\n" + >+ " }\n" + >+ "}\n"}, >+ "a is null\n" + >+ "a is null", >+ null, >+ true, >+ new String[] {"-da"}, >+ compilerOptions, >+ null); >+ } >+} > } >\ No newline at end of file
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 325229
: 178912