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

Mandy Chung mandy.chung at oracle.com
Sun Apr 12 03:35:45 UTC 2020



On 4/8/20 3:35 PM, John Rose wrote:
> On Apr 8, 2020, at 3:31 PM, John Rose <john.r.rose at oracle.com 
> <mailto:john.r.rose at oracle.com>> wrote:
>>
>> In both c and c’ there will probably be a cascading failure
>> if the name foo/Bar/123Z or foo/Bar is resolved.  In c’ there
>> is an additional cascading failure when the user that was
>> parsing the signature goes back for more parameters and
>> finds a slash (instead of LZBHCIJFD[).  The thing that tipped
>> me over to c’ is that extra diagnostic: Even though it happens
>> after the user picked up the bad descriptor, it happens closer
>> to the place where the error has its root cause, which is that
>> somebody is trying to parse an (intentionally) illegal descriptor.
>
> P.S. Having the slash+suffix *outside* the L; envelope basically
> rubs any parser’s nose in the fact that there’s something illegal
> here.  Putting it inside the envelope hides the error from the
> parser—which may be a good thing sometimes!  But it means
> that the odd name foo/Bar.123Z will float somewhere else
> and may or may not be misinterpreted.  If it’s handed to
> Class.forName you can bet that the dot will change its meaning.
> On balance, I slightly prefer the fail-fast properties of c’.

Thanks John.

I have implemented to define the descriptor string for a hidden class of 
this form:
      "L" + N + ";" + "/" + <suffix>

Please see [1] for the review thread.

For your reference, the webrev is:
http://cr.openjdk.java.net/~mchung/valhalla/webrevs/hidden-classes/webrev.06-delta/

Specdiff:
http://cr.openjdk.java.net/~mchung/valhalla/webrevs/hidden-classes/specdiff-inc/overview-summary.html

The spec of `Lookup::defineHiddenClass`, `Class::descriptorString` and
`MethodType::descriptorString` are updated to return the descriptor of
this form for a hidden class.   To support hidden class,
`java.lang.invoke.TypeDescriptor` spec is revised such that a
`TypeDescriptor` object can represent an entity that may not be
described in nominal form.   The serviceability APIs that return a type
descriptor are updated.  This webrev includes a couple other JVM TI and
java.instrument spec clarification w.r.t. hidden classes.

Mandy
[1] 
https://mail.openjdk.java.net/pipermail/valhalla-dev/2020-April/007121.html


More information about the valhalla-dev mailing list