From 209d87a856b1a7bd60910b517d8ff5beb322ec0b Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Mon, 5 Feb 2024 21:31:17 +0000 Subject: [PATCH] 8324960: Unsafe.allocateMemory documentation incorrect regarding zero return value Reviewed-by: rriggs --- .../share/classes/jdk/internal/misc/Unsafe.java | 9 +++++---- src/jdk.unsupported/share/classes/sun/misc/Unsafe.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index 47e8bf80c50..0b7d83a6c0b 100644 --- a/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -597,9 +597,10 @@ public final class Unsafe { /** * Allocates a new block of native memory, of the given size in bytes. The * contents of the memory are uninitialized; they will generally be - * garbage. The resulting native pointer will never be zero, and will be - * aligned for all value types. Dispose of this memory by calling {@link - * #freeMemory}, or resize it with {@link #reallocateMemory}. + * garbage. The resulting native pointer will be zero if and only if the + * requested size is zero. The resulting native pointer will be aligned for + * all value types. Dispose of this memory by calling {@link #freeMemory} + * or resize it with {@link #reallocateMemory}. * * Note: It is the responsibility of the caller to make * sure arguments are checked before the methods are called. While diff --git a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java index 419a59bf67c..3f91fd70db4 100644 --- a/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java +++ b/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -436,9 +436,10 @@ public final class Unsafe { /** * Allocates a new block of native memory, of the given size in bytes. The * contents of the memory are uninitialized; they will generally be - * garbage. The resulting native pointer will never be zero, and will be - * aligned for all value types. Dispose of this memory by calling {@link - * #freeMemory}, or resize it with {@link #reallocateMemory}. + * garbage. The resulting native pointer will be zero if and only if the + * requested size is zero. The resulting native pointer will be aligned for + * all value types. Dispose of this memory by calling {@link #freeMemory} + * or resize it with {@link #reallocateMemory}. * * Note: It is the responsibility of the caller to make * sure arguments are checked before the methods are called. While