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

Bug 352448

Summary: [inline][1.7] Inline should not be available for variables used in the resource specification of try-with-resources
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: UIAssignee: Deepak Azad <deepakazad>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: daniel_megert, deepakazad, raksha.vasisht
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: All   
OS: All   
Whiteboard:

Description Ayushman Jain CLA 2011-07-19 08:12:52 EDT
BETA_JAVA7

class Test{
public static void main(String[] args) throws IOException {
    try (FileInputStream fis = new FileInputStream("")) {
            FileInputStream fis2 = fis;
        }
}
}

right click on fis> refactor> Inline..

You get

class Test{
public static void main(String[] args) throws IOException {
    try (FileInputStream) {
            FileInputStream fis2 = new FileInputStream("");
        }
}
}

(My use case was:
try (FileInputStream fis = new FileInputStream(""); FileInputStream fis2 = fis) {
...
}
and i was only using fis2 in the the try block, so thought of inlining fis)
Comment 1 Deepak Azad CLA 2011-07-26 07:29:49 EDT
Fix is part of the patch in bug 352445 comment 4.
Comment 2 Raksha Vasisht CLA 2011-08-02 05:05:02 EDT
Verified for Juno M1 with 4.2 build I20110729-0200.