Skip to content

Commit 24a85df

Browse files
Fix ambiguous method invocations and enforce check (#4357)
* Fix ambiguous method invocation warnings in core classes. Qualify method calls with `this` or outer class reference to resolve SpotBugs `IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD` warnings. Update quality report script to enforce this check. * Fix IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD warnings. Resolve SpotBugs warnings by explicitly qualifying method calls using `super.` or `Outer.this.` where inner classes inherit methods that shadow outer class methods. Update quality report script to enforce this check. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent bd5b84c commit 24a85df

File tree

8 files changed

+14
-13
lines changed

8 files changed

+14
-13
lines changed

.github/scripts/generate-quality-report.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ def main() -> None:
763763
"UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
764764
"SF_SWITCH_NO_DEFAULT",
765765
"DM_DEFAULT_ENCODING",
766-
"EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS"
766+
"EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS",
767+
"IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD"
767768
}
768769
violations = [
769770
f for f in spotbugs.findings

CodenameOne/src/com/codename1/components/ToastBar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ public ToastBarComponent() {
10211021
this.getAllStyles().setBgColor(0x0);
10221022
this.getAllStyles().setBackgroundType(Style.BACKGROUND_NONE);
10231023
this.getAllStyles().setBgTransparency(128);
1024-
setVisible(false);
1024+
super.setVisible(false);
10251025
label = new TextArea();
10261026
label.setUIID(defaultMessageUIID);
10271027
label.setEditable(false);

CodenameOne/src/com/codename1/properties/UiBinding.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class BindingImpl extends Binding
295295
private boolean lock;
296296

297297
public void actionPerformed(ActionEvent evt) {
298-
if (isAutoCommit()) {
298+
if (super.isAutoCommit()) {
299299
if (lock) {
300300
return;
301301
}
@@ -306,7 +306,7 @@ public void actionPerformed(ActionEvent evt) {
306306
}
307307

308308
public void propertyChanged(PropertyBase p) {
309-
if (isAutoCommit()) {
309+
if (super.isAutoCommit()) {
310310
if (lock) {
311311
return;
312312
}
@@ -318,15 +318,15 @@ public void propertyChanged(PropertyBase p) {
318318

319319
@Override
320320
public void commit() {
321-
if (isAutoCommit()) {
321+
if (super.isAutoCommit()) {
322322
throw new RuntimeException("Can't commit in autocommit mode");
323323
}
324324
((Property) prop).set(adapt.getFrom(cmp));
325325
}
326326

327327
@Override
328328
public void rollback() {
329-
if (isAutoCommit()) {
329+
if (super.isAutoCommit()) {
330330
throw new RuntimeException("Can't rollback in autocommit mode");
331331
}
332332
adapt.assignTo(prop.get(), cmp);

CodenameOne/src/com/codename1/ui/AutoCompleteTextComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void focusLostInternal() {
9595
super.focusLostInternal();
9696
if (isInitialized() && isFocusAnimation()) {
9797
getLabel().setFocus(false);
98-
if (getText().length() == 0 && getLabel().isVisible()) {
98+
if (AutoCompleteTextComponent.this.getText().length() == 0 && AutoCompleteTextComponent.this.getLabel().isVisible()) {
9999
final Label text = new Label(getLabel().getText(), getLabel().getUIID());
100100
final Label placeholder = new Label();
101101
Component.setSameSize(placeholder, getLabel());

CodenameOne/src/com/codename1/ui/ComponentSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4640,7 +4640,7 @@ public ComponentSelector setMarginMillimeters(float margin) {
46404640
public Style createProxyStyle() {
46414641
HashSet<Style> styles = new HashSet<Style>();
46424642
for (Component c : this) {
4643-
styles.add(getStyle(c));
4643+
styles.add(this.getStyle(c));
46444644
}
46454645
return Style.createProxyStyle(styles.toArray(new Style[styles.size()]));
46464646
}

CodenameOne/src/com/codename1/ui/Form.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,10 +1552,10 @@ public Container getFormLayeredPane(Class c, boolean top) {
15521552
@Override
15531553
protected void paintBackground(Graphics g) {
15541554
if (getComponentCount() > 0) {
1555-
if (isVisible()) {
1556-
setVisible(false);
1555+
if (super.isVisible()) {
1556+
super.setVisible(false);
15571557
Form.this.paint(g);
1558-
setVisible(true);
1558+
super.setVisible(true);
15591559
}
15601560
}
15611561
}

CodenameOne/src/com/codename1/ui/TextComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void focusLostInternal() {
110110
super.focusLostInternal();
111111
if (isInitialized() && isFocusAnimation()) {
112112
getLabel().setFocus(false);
113-
if (getText().length() == 0 && getLabel().isVisible() && isOnTopMode()) {
113+
if (TextComponent.this.getText().length() == 0 && TextComponent.this.getLabel().isVisible() && isOnTopMode()) {
114114
final Label text = new Label(getLabel().getText(), getLabel().getUIID());
115115
final Label placeholder = new Label();
116116
Component.setSameSize(placeholder, getLabel());

CodenameOne/src/com/codename1/ui/scene/Node.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ void render(Graphics g) {
626626
paint(g);
627627
paintBorder(g);
628628
g.setColor(0xff0000);
629-
int alpha = g.concatenateAlpha(getStyle().getFgAlpha());
629+
int alpha = g.concatenateAlpha(super.getStyle().getFgAlpha());
630630
g.drawRect(getX(), getY(), getWidth() - 1, getHeight() - 1);
631631
g.setAlpha(alpha);
632632
} catch (Throwable t) {

0 commit comments

Comments
 (0)