Skip to content

Commit c519ba2

Browse files
committed
8267614: Outline VarHandleGuards exact behavior checks
Reviewed-by: psandoz, mchung
1 parent f690959 commit c519ba2

File tree

3 files changed

+95
-324
lines changed

3 files changed

+95
-324
lines changed

src/java.base/share/classes/java/lang/invoke/VarHandle.java

+14
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.function.Function;
4141

4242
import jdk.internal.util.Preconditions;
43+
import jdk.internal.vm.annotation.DontInline;
4344
import jdk.internal.vm.annotation.ForceInline;
4445
import jdk.internal.vm.annotation.IntrinsicCandidate;
4546
import jdk.internal.vm.annotation.Stable;
@@ -2028,6 +2029,19 @@ public final MethodType accessModeType(AccessMode accessMode) {
20282029
return accessModeType(accessMode.at.ordinal());
20292030
}
20302031

2032+
@ForceInline
2033+
final void checkExactAccessMode(VarHandle.AccessDescriptor ad) {
2034+
if (exact && accessModeType(ad.type) != ad.symbolicMethodTypeExact) {
2035+
throwWrongMethodTypeException(ad);
2036+
}
2037+
}
2038+
2039+
@DontInline
2040+
private final void throwWrongMethodTypeException(VarHandle.AccessDescriptor ad) {
2041+
throw new WrongMethodTypeException("expected " + accessModeType(ad.type) + " but found "
2042+
+ ad.symbolicMethodTypeExact);
2043+
}
2044+
20312045
@ForceInline
20322046
final MethodType accessModeType(int accessTypeOrdinal) {
20332047
TypesAndInvokers tis = getTypesAndInvokers();

0 commit comments

Comments
 (0)