8342707: Prepare Gatherers for graduation from Preview
Reviewed-by: alanb, liach
This commit is contained in:
parent
889f906235
commit
ef0dc2518e
@ -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> { }
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -76,7 +76,6 @@ public @interface PreviewFeature {
|
||||
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,
|
||||
|
@ -35,7 +35,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Testing public API of Gatherer
|
||||
* @enablePreview
|
||||
* @run junit GathererAPITest
|
||||
*/
|
||||
|
||||
|
@ -32,7 +32,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
* @test
|
||||
* @bug 8328316
|
||||
* @summary Testing Gatherer behavior under short circuiting
|
||||
* @enablePreview
|
||||
* @run junit GathererShortCircuitTest
|
||||
*/
|
||||
|
||||
|
@ -37,7 +37,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Testing the Gatherer contract
|
||||
* @enablePreview
|
||||
* @library /lib/testlibrary/bootlib
|
||||
* @build java.base/java.util.stream.DefaultMethodStreams
|
||||
* @run junit GathererTest
|
||||
|
@ -34,7 +34,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Tests the API and contract of Gatherers.fold
|
||||
* @enablePreview
|
||||
* @run junit GatherersFoldTest
|
||||
*/
|
||||
|
||||
|
@ -38,7 +38,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Tests the API and contract of Gatherers.mapConcurrent
|
||||
* @enablePreview
|
||||
* @run junit GatherersMapConcurrentTest
|
||||
*/
|
||||
|
||||
|
@ -35,7 +35,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Tests the API and contract of Gatherers.scan
|
||||
* @enablePreview
|
||||
* @run junit GatherersScanTest
|
||||
*/
|
||||
|
||||
|
@ -36,7 +36,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Tests the API and contract of Gatherers.windowFixed
|
||||
* @enablePreview
|
||||
* @run junit GatherersWindowFixedTest
|
||||
*/
|
||||
|
||||
|
@ -36,7 +36,6 @@ import static org.junit.jupiter.api.Assumptions.*;
|
||||
/**
|
||||
* @test
|
||||
* @summary Tests the API and contract of Gatherers.windowSliding
|
||||
* @enablePreview
|
||||
* @run junit GatherersWindowSlidingTest
|
||||
*/
|
||||
|
||||
|
@ -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
|
||||
@ -49,7 +49,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -49,7 +49,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -48,7 +48,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -48,7 +48,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -48,7 +48,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -48,7 +48,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -49,7 +49,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -51,7 +51,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -49,7 +49,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -51,7 +51,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
@ -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
|
||||
@ -49,7 +49,7 @@ import static org.openjdk.bench.java.util.stream.ops.ref.BenchmarkGathererImpls.
|
||||
@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 {
|
||||
|
Loading…
Reference in New Issue
Block a user