RFR: 8267948: [lword] Core reflection and method handles support for L/Q model
Mandy Chung
mchung at openjdk.java.net
Thu Jun 3 04:06:17 UTC 2021
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
-------------
Commit messages:
- 8267948: [lword] Core reflection and method handles support for L/Q model
Changes: https://git.openjdk.java.net/valhalla/pull/436/files
Webrev: https://webrevs.openjdk.java.net/?repo=valhalla&pr=436&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8267948
Stats: 768 lines in 47 files changed: 431 ins; 137 del; 200 mod
Patch: https://git.openjdk.java.net/valhalla/pull/436.diff
Fetch: git fetch https://git.openjdk.java.net/valhalla pull/436/head:pull/436
PR: https://git.openjdk.java.net/valhalla/pull/436
More information about the valhalla-dev
mailing list