Community
Participate
Working Groups
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 ?
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.
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.
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.
(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.