Bug 355007 - Using role as resource in try-with-resources creates bogus byte code
Summary: Using role as resource in try-with-resources creates bogus byte code
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 2.0   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 2.1 M2   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-17 15:56 EDT by Stephan Herrmann CLA
Modified: 2012-06-05 17:37 EDT (History)
0 users

See Also:


Attachments
test & fix (5.36 KB, patch)
2011-08-17 18:04 EDT, Stephan Herrmann CLA
no flags Details | Diff

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