From f4fa35e28b9881729ac47c8518e758bba676fdec Mon Sep 17 00:00:00 2001 From: Nizar Benalla Date: Thu, 4 Jul 2024 15:44:57 +0000 Subject: [PATCH] 8330954: since-checker - Fix remaining @ since tags in java.base Reviewed-by: liach, naoto --- .../classes/java/io/FileInputStream.java | 3 +++ .../java/lang/classfile/ClassSignature.java | 6 ++++- .../classes/java/lang/constant/ClassDesc.java | 3 +++ .../java/lang/constant/MethodHandleDesc.java | 3 +++ .../java/lang/constant/MethodTypeDesc.java | 2 ++ .../java/lang/foreign/MemorySegment.java | 2 ++ .../classes/java/lang/ref/Reference.java | 4 +--- .../share/classes/java/text/ChoiceFormat.java | 6 +++++ .../util/concurrent/CompletableFuture.java | 24 +++++++++++++++++++ .../java/util/concurrent/DelayQueue.java | 2 ++ .../java/util/concurrent/ForkJoinTask.java | 9 +++++++ .../java/util/concurrent/FutureTask.java | 9 +++++++ 12 files changed, 69 insertions(+), 4 deletions(-) diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java index 20bf57a56c7..27507108237 100644 --- a/src/java.base/share/classes/java/io/FileInputStream.java +++ b/src/java.base/share/classes/java/io/FileInputStream.java @@ -371,6 +371,9 @@ public class FileInputStream extends InputStream return (capacity == nread) ? buf : Arrays.copyOf(buf, nread); } + /** + * @since 11 + */ @Override public byte[] readNBytes(int len) throws IOException { if (len < 0) diff --git a/src/java.base/share/classes/java/lang/classfile/ClassSignature.java b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java index b3050b78a85..852d5f9baf4 100644 --- a/src/java.base/share/classes/java/lang/classfile/ClassSignature.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java @@ -41,7 +41,11 @@ public sealed interface ClassSignature /** {@return the type parameters of this class} */ List typeParameters(); - /** {@return the instantiation of the superclass in this signature} */ + /** + * {@return the instantiation of the superclass in this signature} + * + * @since 23 + */ Signature.ClassTypeSig superclassSignature(); /** {@return the instantiation of the interfaces in this signature} */ diff --git a/src/java.base/share/classes/java/lang/constant/ClassDesc.java b/src/java.base/share/classes/java/lang/constant/ClassDesc.java index 370d2eee507..d2da4ec5c85 100644 --- a/src/java.base/share/classes/java/lang/constant/ClassDesc.java +++ b/src/java.base/share/classes/java/lang/constant/ClassDesc.java @@ -374,6 +374,9 @@ public sealed interface ClassDesc */ String descriptorString(); + /** + * @since 21 + */ @Override Class resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException; diff --git a/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java b/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java index 616c5b67365..6a3541bf5e9 100644 --- a/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java +++ b/src/java.base/share/classes/java/lang/constant/MethodHandleDesc.java @@ -207,6 +207,9 @@ public sealed interface MethodHandleDesc */ MethodTypeDesc invocationType(); + /** + * @since 21 + */ @Override MethodHandle resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException; diff --git a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java index 19bce254d49..fb90b1f15c5 100644 --- a/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java +++ b/src/java.base/share/classes/java/lang/constant/MethodTypeDesc.java @@ -222,6 +222,8 @@ public sealed interface MethodTypeDesc * @apiNote {@linkplain MethodTypeDesc} can represent method type descriptors * that are not representable by {@linkplain MethodType}, such as methods with * more than 255 parameter slots, so attempts to resolve these may result in errors. + * + * @since 21 */ @Override MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException; diff --git a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java index 1b378512316..aa1f1762aec 100644 --- a/src/java.base/share/classes/java/lang/foreign/MemorySegment.java +++ b/src/java.base/share/classes/java/lang/foreign/MemorySegment.java @@ -618,6 +618,8 @@ public sealed interface MemorySegment permits AbstractMemorySegmentImpl { * // Take action (e.g. throw an Exception) * } * } + * + * @since 23 */ long maxByteAlignment(); diff --git a/src/java.base/share/classes/java/lang/ref/Reference.java b/src/java.base/share/classes/java/lang/ref/Reference.java index f29a293ce02..747aa64902f 100644 --- a/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/src/java.base/share/classes/java/lang/ref/Reference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -521,8 +521,6 @@ public abstract sealed class Reference * * @return never returns normally * @throws CloneNotSupportedException always - * - * @since 11 */ @Override protected Object clone() throws CloneNotSupportedException { diff --git a/src/java.base/share/classes/java/text/ChoiceFormat.java b/src/java.base/share/classes/java/text/ChoiceFormat.java index 5d71d9d7262..ccb6cc4a04f 100644 --- a/src/java.base/share/classes/java/text/ChoiceFormat.java +++ b/src/java.base/share/classes/java/text/ChoiceFormat.java @@ -586,12 +586,18 @@ public class ChoiceFormat extends NumberFormat { return Double.valueOf(bestNumber); } + /** + * @since 23 + */ @Override public boolean isStrict() { throw new UnsupportedOperationException( "ChoiceFormat does not utilize leniency when parsing"); } + /** + * @since 23 + */ @Override public void setStrict(boolean strict) { throw new UnsupportedOperationException( diff --git a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java index 32545155b53..1a43b29d798 100644 --- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java +++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java @@ -2178,6 +2178,9 @@ public class CompletableFuture implements Future, CompletionStage { return ((r = result) == null) ? valueIfAbsent : (T) reportJoin(r, "getNow"); } + /** + * @since 19 + */ @Override public T resultNow() { Object r = result; @@ -2193,6 +2196,9 @@ public class CompletableFuture implements Future, CompletionStage { throw new IllegalStateException(); } + /** + * @since 19 + */ @Override public Throwable exceptionNow() { Object r = result; @@ -2440,26 +2446,41 @@ public class CompletableFuture implements Future, CompletionStage { return uniExceptionallyStage(null, fn); } + /** + * @since 12 + */ public CompletableFuture exceptionallyAsync( Function fn) { return uniExceptionallyStage(defaultExecutor(), fn); } + /** + * @since 12 + */ public CompletableFuture exceptionallyAsync( Function fn, Executor executor) { return uniExceptionallyStage(screenExecutor(executor), fn); } + /** + * @since 12 + */ public CompletableFuture exceptionallyCompose( Function> fn) { return uniComposeExceptionallyStage(null, fn); } + /** + * @since 12 + */ public CompletableFuture exceptionallyComposeAsync( Function> fn) { return uniComposeExceptionallyStage(defaultExecutor(), fn); } + /** + * @since 12 + */ public CompletableFuture exceptionallyComposeAsync( Function> fn, Executor executor) { @@ -2585,6 +2606,9 @@ public class CompletableFuture implements Future, CompletionStage { return ((r = result) instanceof AltResult) && r != NIL; } + /** + * @since 19 + */ @Override public State state() { Object r = result; diff --git a/src/java.base/share/classes/java/util/concurrent/DelayQueue.java b/src/java.base/share/classes/java/util/concurrent/DelayQueue.java index c53a02ddf71..abd14142da5 100644 --- a/src/java.base/share/classes/java/util/concurrent/DelayQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/DelayQueue.java @@ -327,6 +327,8 @@ public class DelayQueue extends AbstractQueue * @return the expired head of this queue * @throws NoSuchElementException if this queue has no elements with an * expired delay + * + * @since 21 */ public E remove() { return super.remove(); diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java index e58af0b0fa5..8ca52dc5cb2 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinTask.java @@ -887,6 +887,9 @@ public abstract class ForkJoinTask implements Future, Serializable { return (status & (DONE | ABNORMAL)) == DONE; } + /** + * @since 19 + */ @Override public State state() { int s = status; @@ -896,6 +899,9 @@ public abstract class ForkJoinTask implements Future, Serializable { State.CANCELLED; } + /** + * @since 19 + */ @Override public V resultNow() { int s = status; @@ -910,6 +916,9 @@ public abstract class ForkJoinTask implements Future, Serializable { return getRawResult(); } + /** + * @since 19 + */ @Override public Throwable exceptionNow() { Throwable ex; diff --git a/src/java.base/share/classes/java/util/concurrent/FutureTask.java b/src/java.base/share/classes/java/util/concurrent/FutureTask.java index 371055d2c11..627e69559c8 100644 --- a/src/java.base/share/classes/java/util/concurrent/FutureTask.java +++ b/src/java.base/share/classes/java/util/concurrent/FutureTask.java @@ -205,6 +205,9 @@ public class FutureTask implements RunnableFuture { return report(s); } + /** + * @since 19 + */ @Override public V resultNow() { switch (state()) { // Future.State @@ -221,6 +224,9 @@ public class FutureTask implements RunnableFuture { } } + /** + * @since 19 + */ @Override public Throwable exceptionNow() { switch (state()) { // Future.State @@ -236,6 +242,9 @@ public class FutureTask implements RunnableFuture { } } + /** + * @since 19 + */ @Override public State state() { int s = state;