8325949: Create an internal utility method for creating VarHandle instances

Reviewed-by: rriggs
This commit is contained in:
Per Minborg 2024-09-23 10:57:43 +00:00
parent 67448b0eb2
commit 384deda65f
31 changed files with 232 additions and 317 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, 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
@ -24,6 +24,8 @@
*/
package java.util.stream;
import jdk.internal.invoke.MhUtil;
import java.util.Objects;
import java.util.Spliterator;
import java.util.concurrent.CountedCompleter;
@ -370,15 +372,8 @@ final class ForEachOps {
private Node<T> node;
private ForEachOrderedTask<S, T> next;
private static final VarHandle NEXT;
static {
try {
MethodHandles.Lookup l = MethodHandles.lookup();
NEXT = l.findVarHandle(ForEachOrderedTask.class, "next", ForEachOrderedTask.class);
} catch (Exception e) {
throw new InternalError(e);
}
}
private static final VarHandle NEXT = MhUtil.findVarHandle(
MethodHandles.lookup(), "next", ForEachOrderedTask.class);
protected ForEachOrderedTask(PipelineHelper<T> helper,
Spliterator<S> spliterator,