Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions org.eclipse.jdt.debug.tests/java8/SubClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
public class SubClass extends SuperClass {
private boolean fInitialized;

public SubClass() {
fInitialized = false;
System.out.println("SubClass constructor");
}

public static void main(String[] args) {
new SubClass();
}
}
20 changes: 20 additions & 0 deletions org.eclipse.jdt.debug.tests/java8/SuperClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
public class SuperClass {
private boolean fInitialized = true;

public SuperClass() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ synchronized void assert18Project() {
cfgs.add(createLaunchConfiguration(jp, "GH275"));
cfgs.add(createLaunchConfiguration(jp, "LambdaTest"));
cfgs.add(createLaunchConfiguration(jp, "InnerClassBug"));
cfgs.add(createLaunchConfiguration(jp, "SuperClass"));
cfgs.add(createLaunchConfiguration(jp, "SubClass"));
loaded18 = true;
waitForBuild();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1559,4 +1559,39 @@ public void testHoverOnInnerClassConstructorVariables() throws Exception {
}
}

public void testResolveSameFieldsInSuperAndSub() throws Exception {
sync(() -> TestUtil.waitForJobs(getName(), 1000, 10000, ProcessConsole.class));

final String typeName = "SubClass";
final String expectedMethod = "<init>";
final int framesNumber = 2;
final int bpLine1 = 18;

IJavaBreakpoint bp1 = createLineBreakpoint(bpLine1, "", typeName + ".java", typeName);
bp1.setSuspendPolicy(IJavaBreakpoint.SUSPEND_THREAD);
IFile file = (IFile) bp1.getMarker().getResource();
assertEquals(typeName + ".java", file.getName());

IJavaThread thread = null;
try {
thread = launchToBreakpoint(typeName);
CompilationUnitEditor part = openEditorAndValidateStack(expectedMethod, framesNumber, file, thread);

JavaDebugHover hover = new JavaDebugHover();
hover.setEditor(part);
int offset = part.getViewer().getDocument().get().indexOf("fInitialized = ");
String variableName = "fInitialized";
IRegion region = new Region(offset, variableName.length());
String text = selectAndReveal(part, bpLine1, region);
assertEquals(variableName, text);
IVariable info = (IVariable) sync(() -> hover.getHoverInfo2(part.getViewer(), region));
assertNotNull(info);
assertEquals(variableName, info.getName());
assertEquals("false", info.getValue().getValueString());
} finally {
terminateAndRemove(thread);
removeAllBreakpoints();
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2015 IBM Corporation and others.
* Copyright (c) 2000, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -277,6 +277,17 @@ public IJavaFieldVariable getField(final String name, final String declaringType
field = fieldTmp;
break;
}
List<Field> fieldList = ref.allFields(); // Possible sub class fields with same name as of super class
fieldList.remove(fieldTmp);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SougandhS : This line will cause CME on next iteration if the break at line 287 will be not reached.

You can't modify the list while iterating it, you can only use fields.remove() here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will raise a fix now

for (Field fieldCurrentTmp : fieldList) {
if (name.equals(fieldCurrentTmp.name())) {
String signatureCurrent = fieldCurrentTmp.declaringType().signature();
if (declaringTypeSignature.equals(signatureCurrent)) {
field = fieldCurrentTmp;
break main;
}
}
}
// check if we are inside local type - Signature.createTypeSignature
// can't create proper type name out of source field in JavaDebugHover
// we get LDebugHoverTest$InnerClass2; instead of LDebugHoverTest$1InnerClass2;
Expand Down
Loading