Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354108 - [1.7][compiler] Wrong compilation of new try-resource-clause
Summary: [1.7][compiler] Wrong compilation of new try-resource-clause
Status: VERIFIED DUPLICATE of bug 353535
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 critical (vote)
Target Milestone: 3.7.1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-08 03:54 EDT by Frank Ulbricht CLA
Modified: 2011-08-25 06:56 EDT (History)
2 users (show)

See Also:


Attachments
The class to reproduce the problem (271 bytes, text/plain)
2011-08-08 03:56 EDT, Frank Ulbricht CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.