Bug 427086

Summary: [1.8] HCR fails for lambdas (was: Cannot continue debugging -Obsolete methods on the stack)
Product: [Eclipse Project] JDT Reporter: Noopur Gupta <noopur_gupta>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: loskutov, Michael_Rennie
Version: 4.4Keywords: readme
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
Screenshot none

Description Noopur Gupta CLA 2014-01-31 02:40:43 EST
Created attachment 239507 [details]
Screenshot

package p1;

public class C3 {
	public static void main(String[] args) {
		I3 i3a= m1();
		System.out.println(i3a.foo(2));
	}

	private static I3 m1() {
		I3 i3a= i -> {
			int x= 100;
			return i+x;
		};
		return i3a;
	}
}

interface I3 {
	int foo(int i);
}
-----------------------------------------------------------

1. Set the breakpoint at "return i+x;" in the lambda expression.
2. While debugging (at the above mentioned line), delete the line "int x= 100;" in lambda so that the code "return i+x;" now has compilation error.
3. Save (Ctrl+s) the file. We get the warning dialog "Obsolete methods on the stack" as shown in attached screenshot.
4. Press "Continue" on the dialog.
5. Go the file C3.java, press Ctrl+z to get the deleted line back and save the file. We get the dialog again, press "Continue".
But there is no way to continue the debugging.

Replace the lambda expr with an anonymous class and perform the same steps as above - can continue debugging without any issue after Ctrl+z :

	private static I3 m1() {
		I3 i3a= new I3() {
			@Override
			public int foo(int i) {
				int x= 100;
				return i+x;
			}
		};
		return i3a;
	}
Comment 1 Michael Rennie CLA 2014-03-27 10:14:36 EDT
(In reply to Noopur Gupta from comment #0)

> 5. Go the file C3.java, press Ctrl+z to get the deleted line back and save
> the file. We get the dialog again, press "Continue".
> But there is no way to continue the debugging.
> 

This is the expected behavior (for the time being) until there is proper support in the JVM for hot-swapping methods - or they change how lambdas are hot-swapped (currently hot-swapping a lambda is the same as swapping a method, which the Oracle / OpenJDK VMs do not support).
Comment 2 Michael Rennie CLA 2014-03-27 10:21:33 EDT
*** Bug 427101 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2019-04-09 01:56:45 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Eclipse Genie CLA 2021-03-30 06:16:51 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2023-04-06 14:45:11 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.