On Thu, 5 Dec 2024 17:54:34 GMT, Chen Liang <[email protected]> wrote:
>> The Type and AnnotatedType hierarchies have been enigmatic to new users: >> users have no clue how to categorize arbitrary type objects, when it is safe >> to cast to more specific types, and the exact conditions for method >> contracts. >> >> A manifest is [JDK-8306039](https://bugs.openjdk.org/browse/JDK-8306039), >> where people are massively confused by the conditions for >> `ParameterizedType::getOwnerType` to return `null`. >> >> To fix these problems, I consulted the JLS, used some terms from there and >> added JLS links to make the definitions concise and accurate. >> >> Here are some actions: >> 1. Add section for hierarchy overview for both Type and AnnotatedType >> 2. Specify the underlying type for different AnnotatedType subinterfaces >> 3. Define "inner member class" for `getOwnerType`, and refer to it in >> `AnnotatedType::getAnnotatedOwnerType`. >> 4. Improve the specification for `ParameterizedType::getActualTypeArguments` >> to note the existence of owner types; also for annotated version >> 5. Minor improvements to `ParameterizedType::getRawType` >> 6. Move the equals specification for `ParameterizedType` to the actual >> `equals` method. >> >> ApiDiff: >> https://cr.openjdk.org/~liach/apidiff/types-facelift/java.base/java/lang/reflect/package-summary.html >> Javadoc: >> https://cr.openjdk.org/~liach/javadoc/types-facelift/java.base/java/lang/reflect/package-summary.html >> >> Please review the associated CSR as well. > > Chen Liang has updated the pull request incrementally with one additional > commit since the last revision: > > Problems with owner type, kevin suggestions src/java.base/share/classes/java/lang/reflect/AnnotatedType.java line 90: > 88: * method returns a {@link Class}. > 89: * <p> > 90: * For example, an annotated use {@code @TB Outer.@TA Inner} has an > annotation ... is such an instance, and ... src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java line 39: > 37: * For example, an annotated use {@code @TA ? extends @TB Number} has an > 38: * annotation {@code @TA} and represents the wildcard type argument > {@code ? > 39: * extends Number}. Its lower bound is the annotated use {@code @TB > Number} "lower" -> "upper", similar for "no upper bound" below src/java.base/share/classes/java/lang/reflect/ParameterizedType.java line 124: > 122: * class or interface declaration} and have equal {@linkplain > 123: * #getActualTypeArguments() type parameters}, including those from > the > 124: * {@linkplain #getOwnerType() enclosing classes}. ... if they are non-static nested types. (etc.) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19977#discussion_r1899044102 PR Review Comment: https://git.openjdk.org/jdk/pull/19977#discussion_r1899043987 PR Review Comment: https://git.openjdk.org/jdk/pull/19977#discussion_r1899044212
