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

forax at univ-mlv.fr forax at univ-mlv.fr
Thu Apr 2 21:55:38 UTC 2020


----- Mail original -----
> De: "Brian Goetz" <brian.goetz at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "mandy chung" <mandy.chung at oracle.com>, "John Rose" <john.r.rose at oracle.com>, "valhalla-dev"
> <valhalla-dev at openjdk.java.net>
> Envoyé: Jeudi 2 Avril 2020 23:33:21
> Objet: Re: java.lang.constant.ClassDesc and TypeDescriptor for hidden class??

>>> 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.

The first thing my students do when they get an exception is to read the javadoc,
jokingly I say to them that Java should have only one exception, RTFMException.

Rémi


More information about the valhalla-dev mailing list