latest changes in java.lang.Class

Сергей Цыпанов sergei.tsypanov at yandex.ru
Sun Dec 30 07:23:15 UTC 2018


Hi,

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();}).
            collect(Collectors.joining(","));
    }
    sb.append(")");
    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