Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352469 - [1.7] Hot code replace fails when a new resource is added to try-with-resources
Summary: [1.7] Hot code replace fails when a new resource is added to try-with-resources
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-19 11:03 EDT by Deepak Azad CLA
Modified: 2011-07-21 08:53 EDT (History)
2 users (show)

See Also:


Attachments
error (20.17 KB, image/png)
2011-07-19 11:03 EDT, Deepak Azad CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2011-07-19 11:03:22 EDT
Created attachment 199909 [details]
error

An example without twr
- create a breakpoint on the indicated line
- Debug as > Java application
- when the breakpoint is hit, uncomment the indicated line
- debugger jumps to beginning of foo() => GOOD !
-------------------------------------------------------------------------------
class Try {
	public static void main(String[] args) throws Throwable {
		foo();
	}

	private static void foo() {
		System.out.println("1");
		Test t = new Test();
		//Test t1 = new Test();  // uncomment this line after breakpoint is hit
		try {
			String line = "";  // breakpoint on this line
			System.out.println(line);
		} finally {
		}
	}

	private static class Test {
		public Test() {
			System.out.println("constructor");
		}
	}
}
------------------------------------------------------------------------------

An example with twr
- create a breakpoint on the indicated line
- Debug as > Java application
- when the breakpoint is hit, uncomment the indicated line
- obsolete methods error (see screenshot) => BAD !
------------------------------------------------------------------------------
class TryWithResources1 {
	public static void main(String[] args) throws Throwable {
		foo();
	}

	private static void foo() throws IOException {
		System.out.println("1");
		try (Test t = new Test();/*Test t1 = new Test();*/) {  // uncomment declaration of t1
			String line="";  // breakpoint on this line
			System.out.println(line);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	private static class Test implements AutoCloseable {
		@Override
		public void close() throws IOException {
			System.out.println("closing");
			throw new IOException();
		}
		
		public Test() {
			System.out.println("constructor");
		}
	}
}
------------------------------------------------------------------------------
Comment 1 Michael Rennie CLA 2011-07-19 16:31:58 EDT
This works fine for me using Oracle 1.7 b147 and the latest IBM 1.7.

Did you perhaps make an edit to a method declaration during your test?
Comment 2 Michael Rennie CLA 2011-07-19 16:32:53 EDT
(In reply to comment #1)
> This works fine for me using Oracle 1.7 b147 and the latest IBM 1.7.
> 

Also works fine using Oracle 1.7 update 1
Comment 3 Dani Megert CLA 2011-07-20 05:02:45 EDT
Same here on Windows 7.
Comment 4 Dani Megert CLA 2011-07-20 05:03:23 EDT
(In reply to comment #3)
> Same here on Windows 7.
Just to clarify: I can also not reproduce it.
Comment 5 Michael Rennie CLA 2011-07-20 10:08:55 EDT
closing worksforme
Comment 6 Deepak Azad CLA 2011-07-21 08:53:31 EDT
I also cannot reproduce it today. Sorry for the trouble.