RFR 8144931: Assert class signatures are correct and refer to valid classes
shilpi.rastogi at oracle.com
shilpi.rastogi at oracle.com
Fri Feb 19 05:32:49 UTC 2016
Hi All,
Please see the updated webrev
http://cr.openjdk.java.net/~srastogi/8144931/webrev.03/
Regards,
Shilpi
On 2/18/2016 8:33 PM, Paul Sandoz wrote:
>> On 18 Feb 2016, at 15:55, Vladimir Ivanov <vladimir.x.ivanov at oracle.com> wrote:
>>
>>> P.S.: You could improve the assertion with the Type class, so it would also fail on otherwise broken descriptor strings (missing "L" or missing ";"):
>> I like how it shapes out with Type. Thanks, Uwe!
>>
> Me too!
>
> Paul.
>
>> Best regards,
>> Vladimir Ivanov
>>
>>> static boolean checkClassName(String cn) {
>>> Type tp = Type.getType(cn);
>>> // additional sanity so only valid "L;" descriptors work
>>> if (tp.getSort() != Type.OBJECT) {
>>> return false;
>>> }
>>> try {
>>> Class<?> c = Class.forName(tp.getClassName(), false, null);
>>> return true;
>>> } catch (ClassNotFoundException e) {
>>> return false;
>>> }
>>> }
>>>
>>> -----
>>> Uwe Schindler
>>> uschindler at apache.org
>>> ASF Member, Apache Lucene PMC / Committer
>>> Bremen, Germany
>>> http://lucene.apache.org/
More information about the core-libs-dev
mailing list