Skip to content

Commit 1307449

Browse files
authored
feat: Add JSpecify nullability annotations (package-url#175)
* Add nullability annotations This change adds nullability annotations ([JSpecify](https://jspecify.dev)) to `packageurl-java` and modifies somes behavior. Specifically: - It marks with `@Nullable` all public methods that can return `null`. - It marks with `@Nullable` all method parameters that can have a `null` value **without** throwing any exception. - It modifies the behavior of the remaining parameters: passing `null` to those parameters will result in an NPE, instead of `MalformedPackageURLException`. This is at least a behavior change (minor version bump), but it _might_ be a breaking change. * Fix qualifier semantics
1 parent 681b0aa commit 1307449

File tree

9 files changed

+230
-159
lines changed

9 files changed

+230
-159
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
<optional>true</optional>
112112
<scope>provided</scope>
113113
</dependency>
114+
<dependency>
115+
<groupId>org.jspecify</groupId>
116+
<artifactId>jspecify</artifactId>
117+
<version>1.0.0</version>
118+
</dependency>
114119
<dependency>
115120
<groupId>junit</groupId>
116121
<artifactId>junit</artifactId>

src/main/java/com/github/packageurl/MalformedPackageURLException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
*/
2222
package com.github.packageurl;
2323

24+
import org.jspecify.annotations.Nullable;
25+
2426
/**
2527
* Exception class intended to be used for PackageURL parsing exceptions.
2628
*
@@ -42,7 +44,7 @@ public MalformedPackageURLException() {
4244
*
4345
* @param msg the detail message.
4446
*/
45-
public MalformedPackageURLException(String msg) {
47+
public MalformedPackageURLException(@Nullable String msg) {
4648
super(msg);
4749
}
4850

0 commit comments

Comments
 (0)