java.lang.constant.ClassDesc and TypeDescriptor for hidden class??

Brian Goetz brian.goetz at oracle.com
Thu Apr 2 21:33:21 UTC 2020


>> Given the choice between (a) and (b), well, both are going to result in
>> user surprises (though, the spec for TD::descriptorString doesn't
>> prohibit returning null.)  Taken together, I think (b) is less awful
>> than (a), so I revise my answer to (b).
> (a) and (b) are incompatible changes.
> returning null is equivalent of throwing a NPE because at least the existing callers will not expect null, so i think (a) is better because you can have a proper error message.

This is a pretty tenuous line of argument.

I think what you mean is: "a and b are bad."  And that's true. Also, c 
is bad. So the game here is to find the least bad choice...

> And the javadoc can explain that testing myClass.isHidden() upfront is the right way to avoid the exception.

That's true for all of a, b, and c.  THe problem is, as you say, no one 
will think to do this, until they've been bitten once.  Hence, all the 
options are bad.



More information about the valhalla-dev mailing list