mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8259911: byteArrayViewVarHandle should throw ArrayIndexOutOfBoundsException
Reviewed-by: jvernee, mchung
This commit is contained in:
parent
1f47de5f6a
commit
27cc62a5c7
30 changed files with 534 additions and 521 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -4371,7 +4371,7 @@ return mh1;
|
|||
* {@code double}.
|
||||
* <p>
|
||||
* Access of bytes at a given index will result in an
|
||||
* {@code IndexOutOfBoundsException} if the index is less than {@code 0}
|
||||
* {@code ArrayIndexOutOfBoundsException} if the index is less than {@code 0}
|
||||
* or greater than the {@code byte[]} array length minus the size (in bytes)
|
||||
* of {@code T}.
|
||||
* <p>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -35,7 +35,9 @@ import jdk.internal.vm.annotation.ForceInline;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ReadOnlyBufferException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static java.lang.invoke.MethodHandleStatics.UNSAFE;
|
||||
|
||||
|
@ -107,9 +109,12 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
|
|||
return at.accessModeType(byte[].class, $type$.class, int.class);
|
||||
}
|
||||
|
||||
private static final BiFunction<String, List<Number>, ArrayIndexOutOfBoundsException>
|
||||
OOBEF = Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
|
||||
|
||||
@ForceInline
|
||||
static int index(byte[] ba, int index) {
|
||||
return Preconditions.checkIndex(index, ba.length - ALIGN, null);
|
||||
return Preconditions.checkIndex(index, ba.length - ALIGN, OOBEF);
|
||||
}
|
||||
|
||||
@ForceInline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue