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 190644 Details for
Bug 339139
[compiler] HEAD contents of org.eclipse.wst.jsdt.core doesn't compile anymore
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
fix + tests
patch339139.txt (text/plain), 14.64 KB, created by
Ayushman Jain
on 2011-03-08 06:53:53 EST
(
hide
)
Description:
fix + tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-03-08 06:53:53 EST
Size:
14.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java,v >retrieving revision 1.79 >diff -u -r1.79 LocalDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 8 Feb 2011 05:59:17 -0000 1.79 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 8 Mar 2011 11:51:32 -0000 >@@ -38,7 +38,7 @@ > > public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { > // record variable initialization if any >- if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { >+ if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { > this.bits |= ASTNode.IsLocalDeclarationReachable; // only set if actually reached > } > if (this.binding != null && this.type.resolvedType instanceof TypeVariableBinding) { >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.118 >diff -u -r1.118 TryStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 5 Mar 2011 17:18:43 -0000 1.118 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 8 Mar 2011 11:51:32 -0000 >@@ -159,7 +159,7 @@ > catchInfo); > this.catchExitInitStateIndexes[i] = currentScope.methodScope().recordInitializationStates(catchInfo); > this.catchExits[i] = >- (catchInfo.tagBits & FlowInfo.UNREACHABLE) != 0; >+ (catchInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0; > tryInfo = tryInfo.mergedWith(catchInfo.unconditionalInits()); > } > } >@@ -268,7 +268,7 @@ > catchInfo); > this.catchExitInitStateIndexes[i] = currentScope.methodScope().recordInitializationStates(catchInfo); > this.catchExits[i] = >- (catchInfo.tagBits & FlowInfo.UNREACHABLE) != 0; >+ (catchInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0; > tryInfo = tryInfo.mergedWith(catchInfo.unconditionalInits()); > } > } >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.45 >diff -u -r1.45 ExceptionHandlingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java 7 Mar 2009 00:59:06 -0000 1.45 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/ExceptionHandlingFlowContext.java 8 Mar 2011 11:51:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -227,8 +227,8 @@ > } > > public void recordReturnFrom(UnconditionalFlowInfo flowInfo) { >- if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { >- if ((this.initsOnReturn.tagBits & FlowInfo.UNREACHABLE) == 0) { >+ if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { >+ if ((this.initsOnReturn.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { > this.initsOnReturn = this.initsOnReturn.mergedWith(flowInfo); > } > else { >Index: compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java,v >retrieving revision 1.21 >diff -u -r1.21 InsideSubRoutineFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java 7 Mar 2009 01:08:10 -0000 1.21 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/InsideSubRoutineFlowContext.java 8 Mar 2011 11:51:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -43,7 +43,7 @@ > } > > public void recordReturnFrom(UnconditionalFlowInfo flowInfo) { >- if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { >+ if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { > if (this.initsOnReturn == FlowInfo.DEAD_END) { > this.initsOnReturn = (UnconditionalFlowInfo) flowInfo.copy(); > } else { >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.55 >diff -u -r1.55 LoopingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 5 Mar 2011 17:18:43 -0000 1.55 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 8 Mar 2011 11:51:32 -0000 >@@ -385,8 +385,8 @@ > } > > public void recordContinueFrom(FlowContext innerFlowContext, FlowInfo flowInfo) { >- if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { >- if ((this.initsOnContinue.tagBits & FlowInfo.UNREACHABLE) == 0) { >+ if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { >+ if ((this.initsOnContinue.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { > this.initsOnContinue = this.initsOnContinue. > mergedWith(flowInfo.unconditionalInitsWithoutSideEffect()); > } >Index: compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java,v >retrieving revision 1.32 >diff -u -r1.32 SwitchFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java 7 Mar 2009 01:08:10 -0000 1.32 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/SwitchFlowContext.java 8 Mar 2011 11:51:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -42,7 +42,7 @@ > } > > public void recordBreakFrom(FlowInfo flowInfo) { >- if ((this.initsOnBreak.tagBits & FlowInfo.UNREACHABLE) == 0) { >+ if ((this.initsOnBreak.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { > this.initsOnBreak = this.initsOnBreak.mergedWith(flowInfo.unconditionalInits()); > } > else { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java,v >retrieving revision 1.78 >diff -u -r1.78 MethodScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java 1 Nov 2010 14:15:47 -0000 1.78 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodScope.java 8 Mar 2011 11:51:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -409,7 +409,7 @@ > } > > public final int recordInitializationStates(FlowInfo flowInfo) { >- if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return -1; >+ if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) != 0) return -1; > UnconditionalFlowInfo unconditionalFlowInfo = flowInfo.unconditionalInitsWithoutSideEffect(); > long[] extraInits = unconditionalFlowInfo.extra == null ? > null : unconditionalFlowInfo.extra[0]; >#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.157 >diff -u -r1.157 ConformTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/ConformTest.java 5 Mar 2011 17:18:29 -0000 1.157 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/ConformTest.java 8 Mar 2011 11:51:34 -0000 >@@ -6688,15 +6688,13 @@ > " [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: 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: 49, full, stack: {java.lang.Exception}, locals: {X, int, java.lang.String, java.lang.StringBuffer, java.lang.String[], java.lang.Object[]}]\n" + >- " [pc: 59, chop 2 local(s)]\n" + >- " [pc: 62, append: {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" + >@@ -7569,6 +7567,46 @@ > } > } > >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=303448 >+//To check that code gen is not optimized for an if statement >+//where a local variable's definite nullness or otherwise is known because of >+//an earlier assert expression (inside finally context) >+public void testBug339139() throws Exception { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public abstract class X {\n" + >+ " private static Object[] bar() {\n" + >+ " return null;\n" + >+ " }\n" + >+ " protected final Object foo() {\n" + >+ " Object[] tab = null;\n" + >+ " if(tab != null) {\n" + >+ " Object[] v = bar(); \n" + >+ " int length = tab.length;\n" + >+ " loop : for (int i = 0, max = v.length; i < max; i++) {\n" + >+ " Object o = v[i];\n" + >+ " if (o == null) continue loop;\n" + >+ " if(0 == length) {\n" + >+ " loop2 : for (int j = 0; j < length; j++) {\n" + >+ " Object o2 = null;\n" + >+ " for (int k = 0; k < length; k++) {\n" + >+ " if (o2 == tab[k]) {\n" + >+ " continue loop2;\n" + >+ " }\n" + >+ " }\n" + >+ " continue loop;\n" + >+ " }\n" + >+ " return o;\n" + >+ " }\n" + >+ " }\n" + >+ " }\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n", >+ }); // custom requestor >+} >+ > public static Class testClass() { > return ConformTest.class; > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v >retrieving revision 1.31 >diff -u -r1.31 ProgrammingProblemsTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 16 Feb 2011 08:09:15 -0000 1.31 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 8 Mar 2011 11:51:36 -0000 >@@ -36,7 +36,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[] { "test0055" }; >+ TESTS_NAMES = new String[] { "test0059" }; > // TESTS_NUMBERS = new int[] { 56 }; > // TESTS_RANGE = new int[] { 1, -1 }; > } >@@ -2309,4 +2309,42 @@ > true/*shouldFlushOutputDirectory*/, > customOptions); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=339139 >+// Issue local variable not used warning inside deadcode >+public void test0059() throws Exception { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ customOptions.put(CompilerOptions.OPTION_ReportDeadCode, CompilerOptions.WARNING); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " Object a = null;\n" + >+ " if (a != null){\n" + >+ " int j = 3;\n" + >+ " j++;\n" + // value is not used >+ " }\n" + >+ " System.out.println(\"OK\");\n" + >+ " }\n" + >+ "}" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 4)\n" + >+ " if (a != null){\n" + >+ " int j = 3;\n" + >+ " j++;\n" + >+ " }\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 5)\n" + >+ " int j = 3;\n" + >+ " ^\n" + >+ "The value of the local variable j is not used\n" + >+ "----------\n", >+ null/*classLibraries*/, >+ true/*shouldFlushOutputDirectory*/, >+ customOptions); >+} > } >\ 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 339139
:
190598
|
190636
|
190644
|
190668
|
190669