Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354108

Summary: [1.7][compiler] Wrong compilation of new try-resource-clause
Product: [Eclipse Project] JDT Reporter: Frank Ulbricht <f.ulbricht>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED DUPLICATE QA Contact:
Severity: critical    
Priority: P3 CC: jarthana, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
The class to reproduce the problem none

Description Frank Ulbricht CLA 2011-08-08 03:54:40 EDT
Build Identifier: 20110615-0604

This code will compile without errors:

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class Test {

public static void main(String[] args) throws Exception {
  int b;
  try (final InputStream in = new ByteArrayInputStream(new byte[] { 42 })) {
    b = in.read();
  }
}

At runtime this exception will occur:

Exception in thread "main" java.lang.VerifyError: Stack map does not match the one at exception handler 53 in method Test.main([Ljava/lang/String;)V at offset 4
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
	at java.lang.Class.getMethod0(Unknown Source)
	at java.lang.Class.getMethod(Unknown Source)
	at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
	at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
}

If the class is compiled with the JDK all runs fine.

Reproducible: Always

Steps to Reproduce:
1. Compile the code with Eclipse
2. Run the class as a Java application.
Comment 1 Frank Ulbricht CLA 2011-08-08 03:56:53 EDT
Created attachment 201054 [details]
The class to reproduce the problem
Comment 2 Srikanth Sankaran CLA 2011-08-08 04:45:23 EDT
This is the same problem as bug 353535. Will carry over the test case there.

*** This bug has been marked as a duplicate of bug 353535 ***
Comment 3 Jay Arthanareeswaran CLA 2011-08-25 06:56:59 EDT
Verified for 3.7 RC2 with build M20110824-0800.