| Summary: | [1.7][compiler] Try with resources does not work because of an IAE | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Deepak Azad <deepakazad> |
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> |
| Status: | VERIFIED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | amj87.iitr, jarthana, Olivier_Thomann |
| Version: | 3.7 | ||
| Target Milestone: | 3.7.1 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=338402 for the master bug. This feature implementation is work in progress, no support exists for code generation yet (deep where is the current failure). This problem is fixed by the patch posted at https://bugs.eclipse.org/bugs/show_bug.cgi?id=338402#c11 which has been released into the BETA_JAVA7 branch. I have added a slightly modified version of the test from comment#0 into org.eclipse.jdt.core.tests.compiler.regression.TryWithResourcesStatementTest.test029() (see bug 338402 comment 12 for printStackTrace related problems) *** This bug has been marked as a duplicate of bug 338402 *** Verified. |
-------------------------------------------------------------------------- package p; import java.io.File; import java.io.FileReader; import java.io.IOException; class TryWithResources { void foo() { File file = new File("C:\\somefile"); try(FileReader fileReader = new FileReader(file);) { char[] in = new char[50]; fileReader.read(in); } catch (IOException e) { e.printStackTrace(); } finally{ } } public static void main(String[] args) { new TryWithResources().foo(); } } ------------------------------------------------------------------------- The exception java.lang.IllegalArgumentException: info cannot be null at org.eclipse.jdt.internal.compiler.codegen.StackMapFrame.addStackItem(StackMapFrame.java:81) at org.eclipse.jdt.internal.compiler.ClassFile.traverse(ClassFile.java:4535) at org.eclipse.jdt.internal.compiler.ClassFile.generateStackMapTableAttribute(ClassFile.java:3367) at org.eclipse.jdt.internal.compiler.ClassFile.completeCodeAttribute(ClassFile.java:1191) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:257) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:182) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:543) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:612) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:361) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1187) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:681) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1183) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:809) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480) at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:126) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:169) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$3.run(SelectionListenerWithASTManager.java:154) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)