[code-reflection] Integrated: Improve JavaType::toString
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Jun 5 10:45:10 UTC 2024
On Fri, 31 May 2024 21:00:04 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> The string representation of `JavaType` is automatically derived from the type's externalized form. This PR tweaks the implementation of `toString` so that a more meaningful representation is generated, namely one that is consistent with `java.lang.reflect.Type::getTypeName`.
>
> For instance, instead of this:
>
>
> .<Outer<java.lang.String>, Outer$Inner<java.lang.Integer>>
>
>
> This is now generated:
>
>
> Outer<java.lang.String>$Inner<java.lang.Integer>
>
>
> I've added another combinatorial test which checks that `Type::getTypeName` of the resolved reflective type matches the string representation of the original `JavaType`.
>
> The main question is around `ClassType::toClassName`. This method is effectively attempting to generate a user-friendly type string from the `JavaType` (note that this method doesn't take into account enclosing types). Should we update this to call `toString` ? Or should we perhaps remove it, and ask clients to use `toString` instead (which now works on all types) ?
This pull request has now been integrated.
Changeset: 1ad028fd
Author: Maurizio Cimadamore <mcimadamore at openjdk.org>
URL: https://git.openjdk.org/babylon/commit/1ad028fd0f74ec61e54b183902b4dea4af0c36b5
Stats: 36 lines in 7 files changed: 29 ins; 0 del; 7 mod
Improve JavaType::toString
Reviewed-by: psandoz
-------------
PR: https://git.openjdk.org/babylon/pull/110
More information about the babylon-dev
mailing list