RFR: 8254979: Class.getSimpleName() returns non-empty for lambda and method
jmehrens
github.com+28367473+jmehrens at openjdk.java.net
Wed Mar 17 22:56:48 UTC 2021
On Tue, 16 Mar 2021 22:24:55 GMT, Joe Darcy <darcy at openjdk.org> wrote:
> java.lang.Class has a number of methods to return some kind of textual token associated with the class, including a type name, canonical name, simple name, and separately the results of toString().
>
> Bug 8254979 notes that getSimpleName mentions returning the name in source code, but operationally returns a non-null result for synthetic classes, ones without benefit of source code representation. Since it is useful to return a non-null result in such cases, I've updated the spec to mention this case. The names of synthetic classes are not covered by the JLS; using a "$" in such names is customary, but not strictly required. The synthetic classes used to implement lambdas and method references as cited in the bug report include "$"'s.
>
> Looking over the other "getFooName" methods, I don't think they need to be updated to handle this case.
src/java.base/share/classes/java/lang/Class.java line 782:
> 780:
> 781: /**
> 782: *{@return {@code true} if and only if this class has the synthetic modifier
The braces around return tag are allowed? "{@return ...} vs. "@return ..." Seems inconsistent with other uses of return tags.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3038
More information about the core-libs-dev
mailing list