On Tue, 18 Oct 2022 19:10:00 GMT, Brent Christian <bchri...@openjdk.org> wrote:
>> test/jdk/java/util/Formatter/BasicByteObject.java line 232: >> >>> 230: >>> 231: private static Byte negate(Byte v) { >>> 232: return (byte) -v.byteValue(); >> >> We want to be returning a `Byte`, so casting to `(byte)` doesn't seem right >> to me. >> >> `Byte.valueOf()` takes a `byte` and returns a `Byte`, so using that as the >> replacement for `new Byte`, we get: >> `return Byte.valueOf(-v.byteValue());` >> Is there a way to get the template to do that? > > So, the above suggestion gives explicit auto-boxing, though some might find > it wordier than necessary. > > Since `v.byteValue()` already returns a `byte`, the `(byte)` cast doesn't > seem necessary. I see that L242 does: >> `return -v.intValue();` > > which is a pretty clean look. So `return -v.byteValue();` would be an option, > too. Negating v.byteValue() promotes it into an int. So then casting to byte would be necessary. ------------- PR: https://git.openjdk.org/jdk/pull/10684