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

Bug 352469

Summary: [1.7] Hot code replace fails when a new resource is added to try-with-resources
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, Michael_Rennie
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
error none

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.