Skip to content

Commit

Permalink
8324960: Unsafe.allocateMemory documentation incorrect regarding zero…
Browse files Browse the repository at this point in the history
… return value

Reviewed-by: rriggs
  • Loading branch information
Brian Burkhalter committed Feb 5, 2024
1 parent 7777eb5 commit 209d87a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/java.base/share/classes/jdk/internal/misc/Unsafe.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -597,9 +597,10 @@ private long alignToHeapWordSize(long bytes) {
/**
* 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}.
*
* <em>Note:</em> It is the responsibility of the caller to make
* sure arguments are checked before the methods are called. While
Expand Down
9 changes: 5 additions & 4 deletions src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -436,9 +436,10 @@ public void putAddress(long address, long x) {
/**
* 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}.
*
* <em>Note:</em> It is the responsibility of the caller to make
* sure arguments are checked before the methods are called. While
Expand Down

1 comment on commit 209d87a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.