I'm having some issues understanding the errors about initialization. I've read over the section in the manual a couple of times and I thought I had it figured out, but the compiler doesn't agree with me.
I have the following class:
public class DefaultBean implements Bean, Serializable {
/**
* Base constructor. Source is
{@code this}.
*/
public DefaultBean() {
this.propertyListener = new PropertyChangeSupport(this);
}
private final PropertyChangeSupport propertyListener;
}
I understand that "this" is under initialization when it's passed to the constructor for PropertyChangeSupport. I believe that the appropriate annotation is @UnderInitialization(Object.class).
@SafeEffect
public PropertyChangeSupport(@UnderInitialization(Object.class) @PolyUI Object sourceBean) {
...
}
However I'm still getting errors. In addition to the specified class, I'm not clear on when to use ".class" and when not to in these annotations.
/home/jpschewe/projects/infra/working-dir/src/main/java/net/mtu/eggplant/util/DefaultBean.java:42: warning: [assignment.type.incompatible] incompatible types in assignment.
this.propertyListener = new PropertyChangeSupport(this);
^
found : @UnderInitialization(java.beans.PropertyChangeSupport.class) @NonNull PropertyChangeSupport
required: @Initialized @NonNull PropertyChangeSupport
/home/jpschewe/projects/infra/working-dir/src/main/java/net/mtu/eggplant/util/DefaultBean.java:42: warning: [argument.type.incompatible] incompatible argument for parameter sourceBean of <init>.
this.propertyListener = new PropertyChangeSupport(this);
^
found : @UnderInitialization @NonNull DefaultBean
required: @Initialized @NonNull Object
Thanks,
Jon