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

Bug 352531

Summary: [1.7] Hot code replace fails when modifying resource declaration in try with resources
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ayushman Jain CLA 2011-07-20 02:19:41 EDT
BETA_JAVA7

class Test {
   FileInputStream fisField = null;
   public static void main(String[] args) {
          try (FileInputStream fis = fisField) {
                 fis.available();
           } catch (Exception e) {
           }
   }
}

Debug as>Java application. Step through the code and when the resource has been initialized, change "FileInputStream fis = fisField" to "FileInputStream fis = new FileInputStream("")" and save.
Hot code replace fails -> Obsolete methods in the stack.
Expected: Debugger should jump to start of main.

This also happens if one edits the statements inside the try block. (Try commenting out fis.available())

I'm using IBM JRE 7
Comment 1 Michael Rennie CLA 2011-07-20 10:15:34 EDT
Closing as worksforme.

This is a VM limitation of hot code replace, you cannot pop the main entry point off the stack and re-enter it.

Any code you try to hot swap in the main method will fail - this limitation is not unique to 1.7.