Dear JDK Security-devs,

Recently, during profiling, I noticed that UnixNumericUserPrincipal has
useless conversion between long and string:

```
    private String name;

    public UnixNumericUserPrincipal(long name) {
        this.name = Long.toString(name);
    }

    /**
     * Return the user identification number (UID) for this
     * {@code UnixNumericUserPrincipal} as a long.
     *
     * @return the user identification number (UID) for this
     *          {@code UnixNumericUserPrincipal} as a long.
     */
    public long longValue() {
        return Long.parseLong(name);
    }

```

My naive assumption is, that if one uses UnixNumericXxxPrincipal,
then with a high probability, `longValue` will be called, thus
converting long to a string and back is not that efficient (which
is visible in the profiler). The same is true for
UnixNumericGroupPrincipal too.

Unfortunately, the presence of `readObject`method makes modifications
to the class not trivial.

Best regards,
   Tigran.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to