Bug 549641 - Method in child class not found
Summary: Method in child class not found
Status: CLOSED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.11   Edit
Hardware: PC Windows 10
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2019-07-29 14:26 EDT by Thai Le CLA
Modified: 2023-07-12 17:46 EDT (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 Thai Le CLA 2019-07-29 14:26:37 EDT
We have the following hierachy:

package com.castortech.iris.zk.components.vm;
public abstract class AbstractComponentViewModel extends Item implements ComponentViewModel {
  protected static <B extends AbstractComponentViewModel.Builder<B, T>, T extends AbstractComponentViewModel> Builder<B, T> builder(T m) {
    return new AbstractComponentViewModel.Builder<>(m);
  }

  protected static class Builder<B extends AbstractComponentViewModel.Builder<B, T>, T extends AbstractComponentViewModel> extends Item.Builder<B, T> { //NOSONAR ok to hide super
  ....
  }
}
==============================================
package com.castortech.iris.zk.components.structure;
public abstract class AbstractListboxViewModel<M> extends AbstractComponentViewModel implements ISelectionChangedProvider {
  protected static class Builder<B extends AbstractListboxViewModel.Builder<B, T>, T extends AbstractListboxViewModel<?>> extends AbstractComponentViewModel.Builder<B, T> { //NOSONAR ok to hide super
    protected Builder(T m) {
      super(m);
    }
    public B multiple(boolean multiple) {
      instance.setMultiple(multiple);
      return getThis();
    }
  }
}
========================================
package com.castortech.iris.zk.components.structure;
public abstract class ListboxViewModel extends AbstractListboxViewModel<ListModel> {
  protected static class Builder<B extends ListboxViewModel.Builder<B, T>, T extends ListboxViewModel> extends AbstractListboxViewModel.Builder<B, T> { //NOSONAR ok to hide super
    protected Builder(T m) {
      super(m);
    }
  }
}
====================================
package com.castortech.iris.zk.ba.component.vm;
public abstract class BaListBoxViewModel<T> extends ListboxViewModel{
  public static <B extends BaListBoxViewModel.Builder<B, T>, T extends BaListBoxViewModel<?>> Builder<B, T> builder(T m) {
    return new BaListBoxViewModel.Builder<>(m);
  }

  public static class Builder<B extends BaListBoxViewModel.Builder<B, T>, T extends BaListBoxViewModel<?>> extends ListboxViewModel.Builder<B, T> { //NOSONAR ok to hide super
    protected Builder(T m) {
      super(m);
      super.initModel();
    }

    @SuppressWarnings("unchecked")
    @Override
    public B getThis() {
      return (B)this;
    }
  }
}

When I tried to use the multiple(boolean) of the AbstractListboxViewModel as followed, i got compilation error that there is no such method. It look like eclipse try to use the base class AbstractComponentViewModel.builder instead of BaListBoxViewModel.builder

package com.castortech.iris.zk.ba.component.vm;
public class BaSelectCategoryPopupViewModel{
  protected void initListBox() {
    BaListBoxViewModel.builder(new BaListBoxViewModel() {...})
      .multiple(true) <---CANT THIS METHOD
      .checkmark(true)
      .rows(5)
      .showHeader(false)
      .withSearchTextVM(true).build());
  }
}
My colleague uses eclipse oxygen and does not have this error. Is this a regression from 4.11 ?
Comment 1 Stephan Herrmann CLA 2019-07-31 08:51:17 EDT
Thanks for sharing the code.

Unfortunately, still some essential bits are missing, so even with guessing some missing types I cannot be sure to see the same as you do.

One thing I can see already: new BaListBoxViewModel() uses a raw type!

This likely spoils all subsequent attempts at type inference.

Interestingly, adding "<>" to the above instantiation moves the error one down, from multiple() to checkmark().

It seems you really need to tell what kind of BaListBoxViewModel you need.

Please try saying "new BaListBoxViewModel<>()" and report back what you see.
Comment 2 Thai Le CLA 2019-07-31 10:41:21 EDT
Thank you Stephan,

You are right that i'm instantiating a raw type: new BaListBoxViewModel() but it just show a warning that's why i didnt pay attention. However, my take is that in this case, the BaListBoxViewModel.builder() got confused of its argument because the parent of BaListBoxViewModel which is AbstractComponentViewModel is not generic.

using "new BaListBoxViewModel<>()" give me error on the same line: '<>' cannot be used with anonymous classes

However using "new BaListBoxViewModel<Object>()" get rid of all errors in both eclipse oxygen and 4.11.
Comment 3 Eclipse Genie CLA 2021-07-21 06:01: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 4 Eclipse Genie CLA 2023-07-12 13:47:30 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 Stephan Herrmann CLA 2023-07-12 17:46:13 EDT
(In reply to Thai Le from comment #2)
> using "new BaListBoxViewModel<>()" give me error on the same line: '<>'
> cannot be used with anonymous classes

Since Java 9 even that is possible.

I assume all is well by now.