Skip to content

Commit

Permalink
8342707: Prepare Gatherers for graduation from Preview
Browse files Browse the repository at this point in the history
Reviewed-by: alanb, liach
  • Loading branch information
Viktor Klang committed Nov 11, 2024
1 parent 889f906 commit ef0dc25
Show file tree
Hide file tree
Showing 24 changed files with 31 additions and 50 deletions.
13 changes: 4 additions & 9 deletions src/java.base/share/classes/java/util/stream/Gatherer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package java.util.stream;

import jdk.internal.javac.PreviewFeature;
import jdk.internal.vm.annotation.ForceInline;

import java.util.*;
Expand Down Expand Up @@ -195,9 +194,8 @@
* @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
Expand Down Expand Up @@ -481,10 +479,9 @@ static <T, A, R> Gatherer<T, A, R> of(
* 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> {

/**
Expand Down Expand Up @@ -524,10 +521,9 @@ interface Downstream<T> {
* @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
Expand Down Expand Up @@ -584,10 +580,9 @@ static <A, T, R> Greedy<A, T, R> ofGreedy(Greedy<A, T, R> greedy) {
* @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> { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* 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")
Expand Down
6 changes: 2 additions & 4 deletions src/java.base/share/classes/java/util/stream/Gatherers.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -48,9 +47,8 @@
* 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

Expand Down
7 changes: 2 additions & 5 deletions src/java.base/share/classes/java/util/stream/Stream.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.*;
Expand Down Expand Up @@ -1096,9 +1094,8 @@ <U> U reduce(U identity,
* @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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public enum Feature {
STRUCTURED_CONCURRENCY,
@JEP(number=466, title="ClassFile API", status="Second Preview")
CLASSFILE_API,
@JEP(number=473, title="Stream Gatherers", status="Second Preview")
STREAM_GATHERERS,
@JEP(number=476, title="Module Import Declarations", status="Preview")
MODULE_IMPORTS,
Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GathererAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
/**
* @test
* @summary Testing public API of Gatherer
* @enablePreview
* @run junit GathererAPITest
*/

Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GathererShortCircuitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @test
* @bug 8328316
* @summary Testing Gatherer behavior under short circuiting
* @enablePreview
* @run junit GathererShortCircuitTest
*/

Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GathererTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
/**
* @test
* @summary Testing the Gatherer contract
* @enablePreview
* @library /lib/testlibrary/bootlib
* @build java.base/java.util.stream.DefaultMethodStreams
* @run junit GathererTest
Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GatherersFoldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/**
* @test
* @summary Tests the API and contract of Gatherers.fold
* @enablePreview
* @run junit GatherersFoldTest
*/

Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GatherersMapConcurrentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/**
* @test
* @summary Tests the API and contract of Gatherers.mapConcurrent
* @enablePreview
* @run junit GatherersMapConcurrentTest
*/

Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GatherersScanTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
/**
* @test
* @summary Tests the API and contract of Gatherers.scan
* @enablePreview
* @run junit GatherersScanTest
*/

Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GatherersWindowFixedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* @test
* @summary Tests the API and contract of Gatherers.windowFixed
* @enablePreview
* @run junit GatherersWindowFixedTest
*/

Expand Down
1 change: 0 additions & 1 deletion test/jdk/java/util/stream/GatherersWindowSlidingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
/**
* @test
* @summary Tests the API and contract of Gatherers.windowSliding
* @enablePreview
* @run junit GatherersWindowSlidingTest
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherFMRPar {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherFMRSeq {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,7 +48,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherFlatMapInfinitySeq {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,7 +48,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherFlatMapSeq {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,7 +48,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherMapPar {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,7 +48,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherMapSeq {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherMiscPar {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -51,7 +51,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherMiscSeq {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherReducePar {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -51,7 +51,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherReduceSeq {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgs = "--enable-preview", value = 1)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Thread)
public class GatherWhileOrdered {
Expand Down

0 comments on commit ef0dc25

Please sign in to comment.