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 190016 Details for
Bug 338402
[1.7][compiler][enh] Open issues in try with resources implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch - part 1
patch.txt (text/plain), 13.14 KB, created by
Srikanth Sankaran
on 2011-03-01 00:57:56 EST
(
hide
)
Description:
Patch - part 1
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-03-01 00:57:56 EST
Size:
13.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.225.2.9 >diff -u -r1.225.2.9 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 28 Feb 2011 18:45:41 -0000 1.225.2.9 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 1 Mar 2011 05:42:58 -0000 >@@ -1371,6 +1371,8 @@ > int AssignmentToResource = Internal + 872; > /** @since 3.7 */ > int InvalidDisjunctiveTypeReferenceSequence = Internal + TypeRelated + 873; >+ /** @since 3.7 */ >+ int AutoManagedResourceNotBelow17 = Syntax + Internal + 874; > /** > * External problems -- These are problems defined by other plugins > */ >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TryStatementWithResources.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Attic/TryStatementWithResources.java,v >retrieving revision 1.1.2.7 >diff -u -r1.1.2.7 TryStatementWithResources.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TryStatementWithResources.java 9 Feb 2011 17:05:23 -0000 1.1.2.7 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TryStatementWithResources.java 1 Mar 2011 05:42:58 -0000 >@@ -29,7 +29,8 @@ > > public class TryStatementWithResources extends TryStatement { > >- public LocalDeclaration[] resources; >+ private static LocalDeclaration [] NO_RESOURCES = new LocalDeclaration[0]; >+ public LocalDeclaration[] resources = NO_RESOURCES; > > public StringBuffer printStatement(int indent, StringBuffer output) { > printIndent(indent, output).append("try ("); //$NON-NLS-1$ >@@ -132,7 +133,13 @@ > int shiftScopesLength = this.catchArguments == null ? 1 : this.catchArguments.length + 1; > shiftScopesLength += this.resources.length; > finallyScope.shiftScopes = new BlockScope[shiftScopesLength]; >- finallyScope.shiftScopes[0] = tryScope; >+ for (int i = 0, max = this.resources.length; i < max; i++) { >+ LocalVariableBinding localVariableBinding = this.resources[i].binding; >+ if (localVariableBinding != null && localVariableBinding.isValidBinding()) { >+ finallyScope.shiftScopes[i] = localVariableBinding.declaringScope; >+ } >+ } >+ finallyScope.shiftScopes[this.resources.length] = tryScope; > } > } > >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java,v >retrieving revision 1.123.2.1 >diff -u -r1.123.2.1 BlockScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 16 Feb 2011 08:15:24 -0000 1.123.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 1 Mar 2011 05:42:59 -0000 >@@ -841,8 +841,10 @@ > int max = -1; > if (this.shiftScopes != null){ > for (int i = 0, length = this.shiftScopes.length; i < length; i++){ >- int subMaxOffset = this.shiftScopes[i].maxOffset; >- if (subMaxOffset > max) max = subMaxOffset; >+ if (this.shiftScopes[i] != null) { >+ int subMaxOffset = this.shiftScopes[i].maxOffset; >+ if (subMaxOffset > max) max = subMaxOffset; >+ } > } > } > return max; >Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v >retrieving revision 1.422.2.10 >diff -u -r1.422.2.10 Parser.java >--- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 28 Feb 2011 18:45:41 -0000 1.422.2.10 >+++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 1 Mar 2011 05:43:07 -0000 >@@ -7453,7 +7453,11 @@ > resources, > 0, > length); >- tryStmt.resources = resources; >+ if (this.options.sourceLevel < ClassFileConstants.JDK1_7) { >+ problemReporter().autoManagedResourcesNotBelow17(resources); >+ } else { >+ tryStmt.resources = resources; >+ } > //positions > tryStmt.sourceEnd = this.endStatementPosition; > tryStmt.sourceStart = this.intStack[this.intPtr--]; >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.430.2.12 >diff -u -r1.430.2.12 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 28 Feb 2011 18:45:41 -0000 1.430.2.12 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 1 Mar 2011 05:43:19 -0000 >@@ -7688,4 +7688,13 @@ > typeRef.sourceStart, > typeRef.sourceEnd); > } >+ >+public void autoManagedResourcesNotBelow17(LocalDeclaration[] resources) { >+ this.handle( >+ IProblem.AutoManagedResourceNotBelow17, >+ NoArgument, >+ NoArgument, >+ resources[0].declarationSourceStart, >+ resources[resources.length - 1].declarationSourceEnd); >+} > } >\ No newline at end of file >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.262.2.9 >diff -u -r1.262.2.9 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 28 Feb 2011 18:45:41 -0000 1.262.2.9 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 1 Mar 2011 05:43:21 -0000 >@@ -635,6 +635,7 @@ > 871 = The resource type {0} has to be a subclass of java.lang.AutoCloseable > 872 = The resource {0} of a try-with-resources statement cannot be assigned > 873 = The exception {0} is already caught by the exception {1} >+874 = Resource specification not allowed here for source level below 1.7 > > ### ELABORATIONS > ## Access restrictions >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java,v >retrieving revision 1.46.2.1 >diff -u -r1.46.2.1 ComplianceDiagnoseTest.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java 23 Feb 2011 12:45:30 -0000 1.46.2.1 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/ComplianceDiagnoseTest.java 1 Mar 2011 05:43:28 -0000 >@@ -2460,4 +2460,42 @@ > expected15ProblemLog > ); > } >+public void test0054() { >+ String[] testFiles = new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " try (int i = 0) {};\n" + >+ " }\n" + >+ "}\n" >+ }; >+ >+ String expected13ProblemLog = >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " try (int i = 0) {};\n" + >+ " ^^^^^^^^^\n" + >+ "Resource specification not allowed here for source level below 1.7\n" + >+ "----------\n"; >+ String expected14ProblemLog = >+ expected13ProblemLog; >+ >+ String expected15ProblemLog = >+ expected14ProblemLog; >+ >+ String expected17ProblemLog = >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " try (int i = 0) {};\n" + >+ " ^^^\n" + >+ "The resource type int has to be a subclass of java.lang.AutoCloseable \n" + >+ "----------\n"; >+ runComplianceParserTest( >+ testFiles, >+ expected13ProblemLog, >+ expected14ProblemLog, >+ expected15ProblemLog, >+ expected17ProblemLog >+ ); >+} > } >Index: src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/Attic/ParserTest1_7.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 ParserTest1_7.java >--- src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java 31 Jan 2011 15:58:26 -0000 1.1.2.2 >+++ src/org/eclipse/jdt/core/tests/compiler/parser/ParserTest1_7.java 1 Mar 2011 05:43:29 -0000 >@@ -235,9 +235,9 @@ > > protected Map getCompilerOptions() { > Map options = super.getCompilerOptions(); >- options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); >- options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); >- options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); >+ options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_7); >+ options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7); >+ options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7); > return options; > } > public void test0001() { >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.40.2.5 >diff -u -r1.40.2.5 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 23 Feb 2011 12:45:31 -0000 1.40.2.5 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 1 Mar 2011 05:43:33 -0000 >@@ -362,6 +362,7 @@ > expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(CategorizedProblem.CAT_POTENTIAL_PROGRAMMING_PROBLEM)); > expectedProblemAttributes.put("AssignmentToMultiCatchParameter", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); > expectedProblemAttributes.put("AssignmentToResource", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >+ expectedProblemAttributes.put("AutoManagedResourceNotBelow17", new ProblemAttributes(CategorizedProblem.CAT_SYNTAX)); > expectedProblemAttributes.put("BodyForAbstractMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("BodyForNativeMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("BoundCannotBeArray", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); >@@ -1018,6 +1019,7 @@ > expectedProblemAttributes.put("AssignmentHasNoEffect", new ProblemAttributes(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT)); > expectedProblemAttributes.put("AssignmentToMultiCatchParameter", SKIP); > expectedProblemAttributes.put("AssignmentToResource", SKIP); >+ expectedProblemAttributes.put("AutoManagedResourceNotBelow17", SKIP); > expectedProblemAttributes.put("BodyForAbstractMethod", SKIP); > expectedProblemAttributes.put("BodyForNativeMethod", SKIP); > expectedProblemAttributes.put("BoundCannotBeArray", SKIP); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Attic/TryWithResourcesStatementTest.java,v >retrieving revision 1.1.2.6 >diff -u -r1.1.2.6 TryWithResourcesStatementTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java 24 Feb 2011 09:24:07 -0000 1.1.2.6 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java 1 Mar 2011 05:43:33 -0000 >@@ -376,6 +376,48 @@ > "y cannot be resolved to a variable\n" + > "----------\n"); > } >+public void _test014() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String [] args) { \n" + >+ " try (Y y = new Y();) {\n" + >+ " System.out.println(\"Try block\");\n" + >+ " } finally {\n" + >+ " System.out.println(\"Finally block\");\n" + >+ " }\n" + >+ " }\n" + >+ "} \n" + >+ "\n" + >+ "class Y implements AutoCloseable {\n" + >+ " public Y() throws WeirdException {\n" + >+ " throw new WeirdException();\n" + >+ " }\n" + >+ " public void close() {\n" + >+ " System.out.println(\"Closing resource\");\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "class WeirdException extends Throwable {}\n", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 5)\n" + >+ " public void foo(int p) {\n" + >+ " ^\n" + >+ "The parameter p is hiding another local variable defined in an enclosing type scope\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 8)\n" + >+ " } catch (Exception y) {\n" + >+ " ^\n" + >+ "The parameter y is hiding another local variable defined in an enclosing type scope\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 13)\n" + >+ " System.out.println(y);\n" + >+ " ^\n" + >+ "y cannot be resolved to a variable\n" + >+ "----------\n"); >+} > public static Class testClass() { > return TryWithResourcesStatementTest.class; > }
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 338402
: 190016 |
190034
|
190131
|
190659
|
190744
|
190751