Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 566927 - [15] record component - One breakpoint stops at all accessors and the constructor
Summary: [15] record component - One breakpoint stops at all accessors and the constru...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.17   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.19 M3   Edit
Assignee: Sarika Sinha CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-14 03:14 EDT by Manoj N Palat CLA
Modified: 2021-02-15 11:51 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manoj N Palat CLA 2020-09-14 03:14:58 EDT
Given

@SuppressWarnings("preview")
record R(int i, String s) {}

public class X {
	
	public static void main(String[] args) {
		R r = new R(0, "Hello");
		System.out.println(r.i());
		System.out.println(r.s());
	}

}

select the component "s" in "record R(int i, String s) " and put breakpoint.

In the breakpoint pane, the following is shown:

R [line: 3] - i	

It stops at the  three places:

1)constructor, 
2)r.i()
3)r.s()

Is this the expected behaviour?
Comment 1 Sarika Sinha CLA 2020-09-14 03:36:35 EDT
If we don’t select i or s and and then put a breakpoint it is creates a class breakpoint as expected but on selection of i/s it is creating a line breakpoint.

Will investigate the reason and impact.
Comment 2 Sarika Sinha CLA 2020-11-23 08:50:29 EST
Analysis:
The behaviour is expected with the current way of determining the type of member for the Java Element. 
org.eclipse.jdt.internal.core.JavaElement.getSourceElementAt(int)
If there is a selection then based on the position, member type is analyzed and as "S" selection is a field in the ISourceRef R, it lands up as a line breakpoint.
When there is no text selection it is the sourcetype record identified as the type and hence the class breakpoint.

Method Breakpoint works differently as it not sourceRef type and hence we always get a method entry/exit breakpoint.

If we want a behaviour like Method, there needs to be support from model to identify of source type is "Class" or "Record".

This issue is not critical for 4.18 as per the analysis.
Comment 3 Eclipse Genie CLA 2021-01-25 07:33:18 EST
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/175309
Comment 4 Sarika Sinha CLA 2021-01-25 07:34:25 EST
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created:
> https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/175309

Have handled with extra checks in Debug to make sure that if selected member has the parent as Record, identify the member as the record.
Comment 6 Sarika Sinha CLA 2021-01-27 02:57:45 EST
Adding the test case in beta stream for Java 16 as this is a standard feature.

Bug 570677
Comment 7 Sarika Sinha CLA 2021-02-15 11:51:35 EST
I20210214-1800