Skip to content

Commit 87dcc24

Browse files
committed
Replace JSR-305 annotations with spotbugs annotations
Annotations for Nonnull, CheckForNull, and several others were proposed for Java as part of dormant Java specification request JSR-305. The proposal never became a part of standard Java. Jenkins plugins should switch from using JSR-305 annotations to use Spotbugs annotations that provide the same semantics. The [mailing list discussion](https://groups.google.com/g/jenkinsci-dev/c/uE1wwtVi1W0/m/gLxdEJmlBQAJ) from James Nord describes the affected annotations and why they should be replaced with annotations that are actively maintained. The ["Improve a plugin" tutorial](https://www.jenkins.io/doc/developer/tutorial-improve/replace-jsr-305-annotations/) provides instructions to perform this change. An [OpenRewrite recipe](https://docs.openrewrite.org/recipes/jenkins/javaxannotationstospotbugs) is also available and is even better than the tutorial. Confirmed that automated tests pass on Linux with Java 21.
1 parent 36df29a commit 87dcc24

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/hudson/plugins/powershell/PowerShell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import hudson.tasks.Builder;
99
import hudson.tasks.CommandInterpreter;
1010
import jenkins.model.Jenkins;
11-
import javax.annotation.CheckForNull;
11+
import edu.umd.cs.findbugs.annotations.CheckForNull;
1212
import org.apache.commons.lang.SystemUtils;
1313
import org.kohsuke.stapler.DataBoundConstructor;
1414
import org.kohsuke.stapler.DataBoundSetter;

src/main/java/hudson/plugins/powershell/PowerShellInstallation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hudson.plugins.powershell;
22

3+
import edu.umd.cs.findbugs.annotations.NonNull;
34
import edu.umd.cs.findbugs.annotations.Nullable;
45
import hudson.EnvVars;
56
import hudson.Extension;
@@ -20,7 +21,6 @@
2021
import java.io.IOException;
2122
import java.lang.reflect.Array;
2223
import java.util.List;
23-
import javax.annotation.Nonnull;
2424

2525
public class PowerShellInstallation extends ToolInstallation implements NodeSpecific<PowerShellInstallation>,
2626
EnvironmentSpecific<PowerShellInstallation> {
@@ -38,7 +38,7 @@ public PowerShellInstallation(String name, String home, List<? extends ToolPrope
3838
}
3939

4040
@Override
41-
public PowerShellInstallation forNode(@Nonnull Node node, TaskListener log) throws IOException, InterruptedException {
41+
public PowerShellInstallation forNode(@NonNull Node node, TaskListener log) throws IOException, InterruptedException {
4242
return new PowerShellInstallation(getName(), translateFor(node, log), getProperties());
4343
}
4444

@@ -85,7 +85,7 @@ public DescriptorImpl() {
8585
}
8686

8787
@Override
88-
@Nonnull
88+
@NonNull
8989
public String getDisplayName() {
9090
return "PowerShell";
9191
}

0 commit comments

Comments
 (0)