RFR 8144931: Assert class signatures are correct and refer to valid classes
Paul Sandoz
paul.sandoz at oracle.com
Thu Feb 18 15:03:40 UTC 2016
> 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