Open GoogleCodeExporter opened 9 years ago
Hi Mohsen,
this is the correct behavior.
The argument to @UnderInitialization is inclusive.
At the call to setChildren, the TreeNode object is not fully initialized - the
left and right fields are not set yet.
Your signature for setChildren requires that at least the TreeNode fields are
initialized - which is not the case at the call site - and the correct error is
raised.
To make the example pass, you simply need to change the signature to:
@EnsuresNonNull({"left", "right"})
void setChildren(@UnderInitialization(Object.class) TreeNode this, TreeNode l, TreeNode r) {
Does this behavior make sense now?
Is there documentation that we're missing? The Javadoc at
https://code.google.com/p/checker-framework/source/browse/checker/src/org/checke
rframework/checker/initialization/qual/UnderInitialization.java
highlights that the argument is inclusive multiple times.
Thanks,
cu, WMD.
Original comment by wdi...@gmail.com
on 1 May 2014 at 4:33
Hi Werner,
Thank you for your quick response. I noticed that the javadoc mentioned
"inclusive" and wondered if it's a bug in the manual, javadoc, or the checker.
Your response implies that the bug is in the manual. See the example code for
@UnderInitialization at
<http://types.cs.washington.edu/checker-framework/current/checkers-manual.html#i
nitialization-checker>. Per your explanation, I expect the checker to raise an
error on the code example in the manual, right?
Original comment by reprogra...@gmail.com
on 1 May 2014 at 4:52
I agree that the second "MyClass" example in the Initialization Checker manual
seems wrong.
I think it would be best to have MyClass and MySuperClass and to detail how the
two different frames are related.
cu, WMD.
Original comment by wdi...@gmail.com
on 1 May 2014 at 6:16
Fix together with Issue 327.
Original comment by wdi...@gmail.com
on 2 May 2014 at 2:41
Original issue reported on code.google.com by
reprogra...@gmail.com
on 1 May 2014 at 12:59