diff --git a/base/src/main/java/org/bitcoinj/base/exceptions/package-info.java b/base/src/main/java/org/bitcoinj/base/exceptions/package-info.java
new file mode 100644
index 00000000000..9a8c688830a
--- /dev/null
+++ b/base/src/main/java/org/bitcoinj/base/exceptions/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright by the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Exceptions thrown by classes in bitcoinj base.
+ */
+@NullMarked
+package org.bitcoinj.base.exceptions;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/base/src/main/java/org/bitcoinj/base/internal/Stopwatch.java b/base/src/main/java/org/bitcoinj/base/internal/Stopwatch.java
index fdda3c11d0b..4d8ef87d4a4 100644
--- a/base/src/main/java/org/bitcoinj/base/internal/Stopwatch.java
+++ b/base/src/main/java/org/bitcoinj/base/internal/Stopwatch.java
@@ -16,6 +16,8 @@
* limitations under the License.
*/
+import org.jspecify.annotations.Nullable;
+
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
@@ -33,6 +35,7 @@
*/
public class Stopwatch implements TemporalAmount {
private final Instant startTime;
+ @Nullable
private Instant stopTime = null;
/**
diff --git a/base/src/main/java/org/bitcoinj/base/internal/package-info.java b/base/src/main/java/org/bitcoinj/base/internal/package-info.java
new file mode 100644
index 00000000000..e9be49e8bed
--- /dev/null
+++ b/base/src/main/java/org/bitcoinj/base/internal/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright by the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Classes for internal use only (in both {@code bitcoinj-base} and {@code bitcoinj-core}.)
+ */
+@NullMarked
+package org.bitcoinj.base.internal;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/base/src/main/java/org/bitcoinj/base/package-info.java b/base/src/main/java/org/bitcoinj/base/package-info.java
index 5bdce928c16..6053b5b1df3 100644
--- a/base/src/main/java/org/bitcoinj/base/package-info.java
+++ b/base/src/main/java/org/bitcoinj/base/package-info.java
@@ -18,4 +18,7 @@
* The {@code base} package provides foundational types for bitcoinj. This package
* has no dependencies other than {@code slf4j-api} and {@code jspecify}.
*/
+@NullMarked
package org.bitcoinj.base;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/base/src/main/java/org/bitcoinj/base/utils/MonetaryFormat.java b/base/src/main/java/org/bitcoinj/base/utils/MonetaryFormat.java
index ee7f5ffbc93..25c14fca92d 100644
--- a/base/src/main/java/org/bitcoinj/base/utils/MonetaryFormat.java
+++ b/base/src/main/java/org/bitcoinj/base/utils/MonetaryFormat.java
@@ -18,6 +18,7 @@
import org.bitcoinj.base.Coin;
import org.bitcoinj.base.Monetary;
+import org.jspecify.annotations.Nullable;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -78,10 +79,10 @@ public final class MonetaryFormat {
private final char zeroDigit;
private final char decimalMark;
private final int minDecimals;
- private final List decimalGroups;
+ private final @Nullable List decimalGroups;
private final int shift;
private final RoundingMode roundingMode;
- private final String[] codes;
+ private final String @Nullable[] codes;
private final char codeSeparator;
private final boolean codePrefixed;
@@ -342,7 +343,7 @@ public MonetaryFormat(boolean useSymbol) {
}
private MonetaryFormat(char negativeSign, char positiveSign, char zeroDigit, char decimalMark, int minDecimals,
- List decimalGroups, int shift, RoundingMode roundingMode, String[] codes,
+ @Nullable List decimalGroups, int shift, RoundingMode roundingMode, String @Nullable[] codes,
char codeSeparator, boolean codePrefixed) {
this.negativeSign = negativeSign;
this.positiveSign = positiveSign;
@@ -513,6 +514,7 @@ private long parseValue(String str, int smallestUnitExponent) {
/**
* Get currency code that will be used for current shift.
*/
+ @Nullable
public String code() {
if (codes == null)
return null;
diff --git a/base/src/main/java/org/bitcoinj/base/utils/package-info.java b/base/src/main/java/org/bitcoinj/base/utils/package-info.java
new file mode 100644
index 00000000000..0e2a1192b7f
--- /dev/null
+++ b/base/src/main/java/org/bitcoinj/base/utils/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright by the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * bitcoinj utility classes.
+ */
+@NullMarked
+package org.bitcoinj.base.utils;
+
+import org.jspecify.annotations.NullMarked;