8342707: Prepare Gatherers for graduation from Preview

Reviewed-by: alanb, liach
This commit is contained in:
Viktor Klang 2024-11-11 19:57:26 +00:00
parent 889f906235
commit ef0dc2518e
24 changed files with 31 additions and 50 deletions

View file

@ -24,7 +24,6 @@
*/
package java.util.stream;
import jdk.internal.javac.PreviewFeature;
import jdk.internal.vm.annotation.ForceInline;
import java.util.*;
@ -195,9 +194,8 @@ import java.util.function.Supplier;
* @param <A> the potentially mutable state type of the gatherer operation
* (often hidden as an implementation detail)
* @param <R> the type of output elements from the gatherer operation
* @since 22
* @since 24
*/
@PreviewFeature(feature = PreviewFeature.Feature.STREAM_GATHERERS)
public interface Gatherer<T, A, R> {
/**
* A function that produces an instance of the intermediate state used for
@ -481,10 +479,9 @@ public interface Gatherer<T, A, R> {
* A Downstream object is the next stage in a pipeline of operations,
* to which elements can be sent.
* @param <T> the type of elements this downstream accepts
* @since 22
* @since 24
*/
@FunctionalInterface
@PreviewFeature(feature = PreviewFeature.Feature.STREAM_GATHERERS)
interface Downstream<T> {
/**
@ -524,10 +521,9 @@ public interface Gatherer<T, A, R> {
* @param <A> the type of state used by this integrator
* @param <T> the type of elements this integrator consumes
* @param <R> the type of results this integrator can produce
* @since 22
* @since 24
*/
@FunctionalInterface
@PreviewFeature(feature = PreviewFeature.Feature.STREAM_GATHERERS)
interface Integrator<A, T, R> {
/**
* Performs an action given: the current state, the next element, and
@ -584,10 +580,9 @@ public interface Gatherer<T, A, R> {
* @param <A> the type of state used by this integrator
* @param <T> the type of elements this greedy integrator receives
* @param <R> the type of results this greedy integrator can produce
* @since 22
* @since 24
*/
@FunctionalInterface
@PreviewFeature(feature = PreviewFeature.Feature.STREAM_GATHERERS)
interface Greedy<A, T, R> extends Integrator<A, T, R> { }
}
}

View file

@ -45,7 +45,7 @@ import java.util.stream.Gatherer.Integrator;
* The performance-critical code below contains some more complicated encodings:
* therefore, make sure to run benchmarks to verify changes to prevent regressions.
*
* @since 22
* @since 24
*/
final class GathererOp<T, A, R> extends ReferencePipeline<T, R> {
@SuppressWarnings("unchecked")

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 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
@ -25,7 +25,6 @@
package java.util.stream;
import jdk.internal.access.SharedSecrets;
import jdk.internal.javac.PreviewFeature;
import jdk.internal.vm.annotation.ForceInline;
import java.util.ArrayDeque;
@ -48,9 +47,8 @@ import java.util.stream.Gatherer.Downstream;
* operations, such as windowing functions, folding functions,
* transforming elements concurrently, etc.
*
* @since 22
* @since 24
*/
@PreviewFeature(feature = PreviewFeature.Feature.STREAM_GATHERERS)
public final class Gatherers {
private Gatherers() { } // This class is not intended to be instantiated

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,8 +24,6 @@
*/
package java.util.stream;
import jdk.internal.javac.PreviewFeature;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
@ -1096,9 +1094,8 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* @param <R> The element type of the new stream
* @param gatherer a gatherer
* @return the new stream
* @since 22
* @since 24
*/
@PreviewFeature(feature = PreviewFeature.Feature.STREAM_GATHERERS)
default <R> Stream<R> gather(Gatherer<? super T, ?, R> gatherer) {
return StreamSupport.stream(spliterator(), isParallel())
.gather(gatherer)