Community
Participate
Working Groups
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?
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.
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.
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/175309
(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.
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/175309 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=31ae9c6aa02aee277cc55baf86205ebd0b9f3671
Adding the test case in beta stream for Java 16 as this is a standard feature. Bug 570677
I20210214-1800