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

Bug 355007

Summary: Using role as resource in try-with-resources creates bogus byte code
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTJAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M2   
Hardware: Other   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
test & fix none

Description Stephan Herrmann CLA 2011-08-17 15:56:55 EDT
If a role ResourceRole implements AutoCloseable using this role in a 
Java7 try-with-resources like this:

  	try (ResourceRole r = new ResourceRole(baseResource)) {
		int in = r.read100();
		System.out.println(String.valueOf(r.chars));
	}

running the code complains 
java.lang.IncompatibleClassChangeError: Found interface Team7$ResourceRole, but class was expected
Comment 1 Stephan Herrmann CLA 2011-08-17 18:04:32 EDT
Created attachment 201679 [details]
test & fix

Fixed by simply checking isRole(), and if so, consider the resource
as an interface type using invokeinterface.
Comment 2 Stephan Herrmann CLA 2011-08-17 18:11:53 EDT
Released as r1901,1902 for 2.1 M2.
Comment 3 Stephan Herrmann CLA 2012-06-05 17:37:52 EDT
Verified for 2.1 using build 201206040388.