RFR: 8274811: Remove superfluous use of boxing in java.base

Talden github.com+6776231+talden at openjdk.java.net
Sat Oct 9 03:19:09 UTC 2021


On Sat, 11 Sep 2021 12:11:50 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

> Usages of primitive types should be preferred and makes code easier to read.
> Similar cleanups:
> 1. [JDK-8273168](https://bugs.openjdk.java.net/browse/JDK-8273168) java.desktop
> 2. [JDK-8274234](https://bugs.openjdk.java.net/browse/JDK-8274234) java.sql.rowset

src/java.base/share/classes/sun/security/tools/keytool/Main.java line 4135:

> 4133:                 if (date != null) {
> 4134:                     if (date.matches("\\d\\d\\d\\d\\/\\d\\d\\/\\d\\d")) {
> 4135:                         c.set(Integer.parseInt(date.substring(0, 4)),

Could this, and several of the other cases identified in this PR, be replaced with a call to the `Integer.parseInt(CharSequence, int, int, int)` method to also avoid the String allocation?

Though there are enough other places in the JDK where this opportunity seems valuable that maybe it warrants a tracking issue of its own.

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

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


More information about the core-libs-dev mailing list