RFR: 8275075: Remove unnecessary conversion to String in jdk.hotspot.agent

Andrey Turbanov duke at openjdk.java.net
Tue Oct 12 20:57:53 UTC 2021


On Tue, 12 Oct 2021 05:37:53 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

>> Cleanup unnecessary toString() calls when conversion will happen implicitly anyway
>
> src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java line 1012:
> 
>> 1010:          tmpBuf.append(Long.toHexString(startPc + visitor.getInstructionSize()));
>> 1011:          tmpBuf.append(",0x");
>> 1012:          tmpBuf.append(Long.toHexString(startPc));
> 
> Overall these changes look good, although I do wonder what motivated to `toString()` calls in the first place, especially this example where lines 1010 and 1012 are similar, but only 1010 used `toString()`.

Often reason for such mistakes is pretty trivial: copy-paste error, refactoring stopped in the middle or incorrect merge.
Unfortunately this code is from pre-OpenJDK and it's impossible to find original motifaction.

-------------

PR: https://git.openjdk.java.net/jdk/pull/5800


More information about the serviceability-dev mailing list