The string concatenation nested in the append argument is also strange. Won’t 
javac make an new StringBuilder to handle that? And single character appends 
should be done with chars ‘.’ not strings “.”

Scott

> On Dec 30, 2018, at 7:16 AM, Andrew Luo <andrewluotechnolog...@outlook.com> 
> wrote:
> 
> Stream.of should not be used with null.
> 
> https://docs.oracle.com/javase/9/docs/api/java/util/stream/Stream.html#of-T-
> 
> 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...
> 
> Thanks,
> 
> -Andrew
> 
> -----Original Message-----
> From: core-libs-dev <core-libs-dev-boun...@openjdk.java.net> On Behalf Of 
> ?????? ???????
> Sent: Saturday, December 29, 2018 11:23 PM
> To: core-libs-dev <core-libs-dev@openjdk.java.net>
> Subject: latest changes in java.lang.Class
> 
> 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

Reply via email to