RFR: 8270903: sun.net.httpserver.HttpConnection: Improve toString
Daniel Fuchs
dfuchs at openjdk.java.net
Wed Aug 4 15:14:29 UTC 2021
On Wed, 4 Aug 2021 12:43:43 GMT, Chris Hegarty <chegar at openjdk.org> wrote:
>> src/jdk.httpserver/share/classes/sun/net/httpserver/HttpConnection.java line 69:
>>
>>> 67:
>>> 68: public String toString() {
>>> 69: final var sb = new StringBuilder(HttpConnection.class.getSimpleName());
>>
>> Why not simplify into `new StringBuilder(getClass().getSimpleName());` ?
>
> Have a marginal preference for HttpConnection.class.getSimpleName(), since it is a constant, but don't object to getClass().
Right - but then why not use a string literal? If you're going to call a method to get the class name then I assume you want to get the actual concrete class name... I don't have much objection either way - especially since I suspect there are no subclasses anyway...
-------------
PR: https://git.openjdk.java.net/jdk/pull/4928
More information about the net-dev
mailing list