latest changes in java.lang.Class

Andrew Luo andrewluotechnologies at
Sun Dec 30 12:16:32 UTC 2018

Stream.of should not be used with null.

I think you'd be right if it were Stream.ofNullable, and there does appear to be a bug in that code (never appended to sb) - thanks for pointing that out...



-----Original Message-----
From: core-libs-dev <core-libs-dev-bounces at> On Behalf Of ?????? ???????
Sent: Saturday, December 29, 2018 11:23 PM
To: core-libs-dev <core-libs-dev at>
Subject: latest changes in java.lang.Class


looking into Class::methodToString I've found some changes done into it recently in JDK 11 repository.

Currently the method looks like this:

private String methodToString(String name, Class<?>[] argTypes) {
    StringBuilder sb = new StringBuilder();
    sb.append(getName() + "." + name + "(");
    if (argTypes != null) {
        Stream.of(argTypes).map(c -> {return (c == null) ? "null" : c.getName();}).
    return sb.toString();

Here result of Stream.collect() is ignored, i. e. even when condition argTypes != null is true nothing is appended to sb.
It seems in this case we either don’t need this `if` branch or need to append to sb.

Am I missing something?

Kind regards,
Sergey Tsypanov

More information about the core-libs-dev mailing list