Skip to content

Commit 512a3bd

Browse files
committed
Tidy up Lazy.java
- Add missing Nullable annotation. - Document Loom behaviour for synchronization. - Mark class as final Signed-off-by: ascopes <73482956+ascopes@users.noreply.github.com>
1 parent 4dafda2 commit 512a3bd

File tree

1 file changed

+6
-2
lines changed
  • java-compiler-testing/src/main/java/io/github/ascopes/jct/utils

1 file changed

+6
-2
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/Lazy.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.function.Supplier;
2020
import org.apiguardian.api.API;
2121
import org.apiguardian.api.API.Status;
22+
import org.jspecify.annotations.Nullable;
2223

2324
/**
2425
* Helper type that wraps an initializer and invokes it lazily as required.
@@ -32,16 +33,19 @@
3233
* <p>This descriptor is thread-safe. No guarantees are made about the thread-safety of the
3334
* internally stored data, nor the initializer supplier.
3435
*
36+
* <p>This descriptor currently does not support virtual threads. Any synchronization will
37+
* occur on the physical thread level.
38+
*
3539
* @param <T> the type of lazy value to return when accessed.
3640
* @author Ashley Scopes
3741
* @since 0.0.1
3842
*/
3943
@API(since = "0.0.1", status = Status.INTERNAL)
40-
public class Lazy<T> {
44+
public final class Lazy<T> {
4145

4246
private final Supplier<T> initializer;
4347
private final Object lock;
44-
private volatile T data;
48+
private volatile @Nullable T data;
4549

4650
/**
4751
* Initialize the object.

0 commit comments

Comments
 (0)