Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352531 - [1.7] Hot code replace fails when modifying resource declaration in try with resources
Summary: [1.7] Hot code replace fails when modifying resource declaration in try with ...
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-20 02:19 EDT by Ayushman Jain CLA
Modified: 2011-07-20 10:15 EDT (History)
1 user (show)

See Also:


Attachments

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