RFR: 8267948: [lword] Core reflection and method handles support for L/Q model

Roger Riggs rriggs at openjdk.java.net
Sat Jun 5 18:43:18 UTC 2021


On Thu, 3 Jun 2021 03:45:41 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> This PR implements the primary (`ref`) mirror and secondary (`val`) mirror for primitive classes [1].   The following APIs returning `Class` return the primary mirror: 
> 
> `Object::getClass`
> `Class::getClass`
> `Class::forName`
> `java.lang.reflect.Member::getDeclaringClass` (i.e. `Field`, `Method` and `Constructor`)
> 
> `Class::getName` and `Class::getSimpleName` return the same name for the `ref` and `val` mirror of a primitive class.  Therefore, Class.forName(type.getName()) will work if the type is either `ref` or `val` mirror.
> 
> `Class::getTypeName` returns `Foo.ref` if this `Class` is a primitive reference type.  (we will revisit this for reference-favoring primitive class.)
> 
> New proposed APIs: 
> `Class::isPrimitiveClass` returns true for the `ref` and `val` mirror of a primitive class. 
> 
> `Class::isPrimaryType` returns true if this `Class` object represents the primary mirror
> `Class::asPrimaryType` returns the primary type of this class or interface.
> - An alternative I considered is `Class::isReferenceType` and `Class::asReferenceType` but they will have to specify the special case for primitive types which are not (yet) primitive classes.   I want to go with this initial patch to make progress for the prototype.  We will follow up the API discussion next.
> 
> `Class::isValueType` returns true if this `Class` object represents the primary mirror
> `Class::asValueType` returns the primary type of this class or interface.
> 
> Several tests fail when running with -Xcomp which may depend on the second phase JIT support work (JDK-8267932) which depends on this work to make progress.
> 
> [1] https://github.com/openjdk/valhalla-docs/blob/main/site/design-notes/state-of-valhalla/03-vm-model.md

Generally looks ok.
I think there will be confusion between Class.isPrimitive() and Class.isPrimitiveClass()
but that's the way it is.

-------------

Marked as reviewed by rriggs (Committer).

PR: https://git.openjdk.java.net/valhalla/pull/436


More information about the valhalla-dev mailing list