Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate some recent io APIs. #113

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/io/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public Console print(@Nullable Object obj) {
* @since 23
*/
@PreviewFeature(feature = PreviewFeature.Feature.IMPLICIT_CLASSES)
public String readln(@Nullable String prompt) {
public @Nullable String readln(@Nullable String prompt) {
throw newUnsupportedOperationException();
}

Expand All @@ -242,7 +242,7 @@ public String readln(@Nullable String prompt) {
* @since 24
*/
@PreviewFeature(feature = PreviewFeature.Feature.IMPLICIT_CLASSES)
public String readln() {
public @Nullable String readln() {
throw newUnsupportedOperationException();
}

Expand Down
11 changes: 7 additions & 4 deletions src/java.base/share/classes/java/io/IO.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
package java.io;

import jdk.internal.javac.PreviewFeature;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/**
* A collection of static convenience methods that provide access to
Expand All @@ -41,6 +43,7 @@
* @since 23
*/
@PreviewFeature(feature = PreviewFeature.Feature.IMPLICIT_CLASSES)
@NullMarked
public final class IO {

private IO() {
Expand All @@ -59,7 +62,7 @@ private IO() {
* @throws IOError if {@code System.console()} returns {@code null},
* or if an I/O error occurs
*/
public static void println(Object obj) {
public static void println(@Nullable Object obj) {
con().println(obj);
}

Expand Down Expand Up @@ -90,7 +93,7 @@ public static void println() {
* @throws IOError if {@code System.console()} returns {@code null},
* or if an I/O error occurs
*/
public static void print(Object obj) {
public static void print(@Nullable Object obj) {
con().print(obj);
}

Expand All @@ -110,7 +113,7 @@ public static void print(Object obj) {
* @throws IOError if {@code System.console()} returns {@code null},
* or if an I/O error occurs
*/
public static String readln(String prompt) {
public static @Nullable String readln(@Nullable String prompt) {
return con().readln(prompt);
}

Expand All @@ -128,7 +131,7 @@ public static String readln(String prompt) {
* or if an I/O error occurs
* @since 24
*/
public static String readln() {
public static @Nullable String readln() {
return con().readln();
}

Expand Down
Loading