On Wed, 18 Jan 2023 16:34:57 GMT, Per Minborg <[email protected]> wrote:
> This PR proposes using a performance optimization using a new supported API
> for operations similar to those found in `java.io.Bits`
src/java.base/share/classes/java/io/ObjectStreamClass.java line 2486:
> 2484: );
> 2485: } catch (NoSuchMethodException | IllegalAccessException e) {
> 2486: throw new InternalError("Can't lookup
> BigEndian.getXXX", e);
BigEndian -> ByteArrayAccess
src/java.base/share/classes/jdk/internal/util/access/ByteArrayAccess.java line
26:
> 24: */
> 25:
> 26: package jdk.internal.util.access;
This is pretty deep; I'd drop the final "access". The package name
`jdk.internal.util` is fine.
src/java.base/share/classes/jdk/internal/util/access/ByteArrayAccess.java line
60:
> 58: /*
> 59: * Methods for unpacking primitive values from byte arrays starting at
> 60: * a given offsets.
Typo: "a given offsets".
src/java.base/share/classes/jdk/internal/util/access/ByteArrayAccess.java line
64:
> 62:
> 63: /**
> 64: * Gets a {@code boolean} from the provided {@code array} at the
> given {@code offset}.
This could use the concise javadoc tag that provides both the first line and
@return value. For example,
`{@return Returns a {@code boolean} from the provided {@code array} at the
given {@code offset}}`
src/java.base/share/classes/jdk/internal/util/access/ByteArrayAccess.java line
69:
> 67: * @param offset where extraction in the array should begin
> 68: * @return a {@code boolean} from the array
> 69: * @throws NullPointerException if the provided {@code array} is
> {@code null}
With the class level statement about throwing NullPointer, the @throws is not
necessary in each method.
src/java.base/share/classes/jdk/internal/util/access/ByteArrayAccess.java line
614:
> 612: /*
> 613: * Methods for packing primitive values into byte arrays starting at
> offset zero.
> 614: */
Is the only advantage to the zero offset versions in the API.
Is there any performance difference?
-------------
PR: https://git.openjdk.org/jdk/pull/12076