NullPointerException when using incompletely initialized objects
There are many possible sequences through which a NullPointerException can be
generated, because most constructors do not initialize their data completely.
It is usually necessary to use a different constructor, or set data through
setters (in some cases). Given constructors are sometimes marked as not
suitable for subclasses but public otherwise. For example:
org.objectweb.asm.Label var2 = new org.objectweb.asm.Label();
new org.objectweb.asm.util.ASMifier().visitLineNumber(0, var2);
or
org.objectweb.asm.ClassWriter var2 = new org.objectweb.asm.ClassWriter(0);
new
org.objectweb.asm.tree.ClassNode().accept((org.objectweb.asm.ClassVisitor)var2);
We found a number of such cases using a modified Randoop. Some longer sequences
are perhaps more meaningful, perhaps not.
A fix would entail deprecating a constructor, making it non-public, or adding
information that it does not fully initialize all data. In some cases an
IllegalStateException, or a NullPointerException with a message "don't do that"
or similar would also clarify that this is the user's fault.
Is there an interest in modifying the code to reflect correct usage? If so, I
will try to isolate some test cases that are not overly complex.