Skip to content

Use JSpecify static analysis annotations #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: SNAPSHOT
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
56 changes: 56 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package boofcv.app;

import boofcv.io.webcamcapture.OpenWebcamDialog;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import boofcv.generate.Unit;
import boofcv.gui.BoofSwingUtil;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
Expand Down Expand Up @@ -59,7 +59,7 @@ public class CreateAztecCodeDocument extends BaseMarkerDocument {
@Option(name = "--Structure", usage =
"The marker's structure. COMPACT or FULL")
protected String _structure = "FULL";
public @Nullable AztecCode.Structure structure = null;
public AztecCode.@Nullable Structure structure = null;

@Option(name = "--SaveCorners", usage = "Save location of marker corners in the document to corners.txt")
boolean saveCorners = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.printing.PDFPageable;
import org.apache.pdfbox.util.Matrix;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.awt.*;
import java.awt.print.PrinterException;
Expand Down Expand Up @@ -73,7 +73,7 @@ public class CreateCalibrationTargetGenerator {
public float UNIT_TO_POINTS;
public static final float CM_TO_POINTS = 72.0f/2.54f;

public CreateCalibrationTargetGenerator( String documentName, PaperSize paper, int rows, int cols, Unit units ) {
public CreateCalibrationTargetGenerator( @Nullable String documentName, PaperSize paper, int rows, int cols, Unit units ) {
this.paper = paper;
this.rows = rows;
this.cols = cols;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import boofcv.io.image.ConvertBufferedImage;
import boofcv.io.image.UtilImageIO;
import boofcv.struct.image.GrayU8;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import java.awt.image.BufferedImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import boofcv.generate.Unit;
import boofcv.gui.BoofSwingUtil;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class CreateMicroQrDocument extends BaseMarkerDocument {

@Option(name = "-e", aliases = {"--Error"}, usage = "Error correction level. Options: L,M,Q. Robustness: 7%, 15%, 25%, respectively ")
protected String _error = "";
public @Nullable MicroQrCode.ErrorLevel error;
public MicroQrCode.@Nullable ErrorLevel error;

@Option(name = "-v", aliases = {"--Version"}, usage =
"Micro QR-Code version. Determines size and amount of data. If unspecified it will be automatically selected based on the data. Values 1 to 4.")
Expand All @@ -67,7 +67,7 @@ public class CreateMicroQrDocument extends BaseMarkerDocument {
@Option(name = "-n", aliases = {"--Encoding"}, usage =
"Type of data that can be encoded. Default is auto select. Options: NUMERIC, ALPHANUMERIC, BYTE, KANJI")
protected String _encoding = "AUTO";
public @Nullable QrCode.Mode encoding;
public QrCode.@Nullable Mode encoding;

@Option(name = "--SaveCorners", usage = "Save location of marker corners in the document to corners.txt")
boolean saveCorners = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import boofcv.generate.Unit;
import boofcv.gui.BoofSwingUtil;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class CreateQrCodeDocument extends BaseMarkerDocument {

@Option(name = "-e", aliases = {"--Error"}, usage = "Error correction level. Options: L,M,Q,H. Robustness: 7%, 15%, 25%, 30%, respectively ")
protected String _error = "M";
public @Nullable QrCode.ErrorLevel error;
public QrCode.@Nullable ErrorLevel error;

@Option(name = "-v", aliases = {"--Version"}, usage =
"QR-Code version. Determines size and amount of data. If unspecified it will be automatically selected based on the data. Values 1 to 40.")
Expand All @@ -67,7 +67,7 @@ public class CreateQrCodeDocument extends BaseMarkerDocument {
@Option(name = "-n", aliases = {"--Encoding"}, usage =
"Type of data that can be encoded. Default is auto select. Options: NUMERIC, ALPHANUMERIC, BYTE, KANJI")
protected String _encoding = "AUTO";
public @Nullable QrCode.Mode encoding;
public QrCode.@Nullable Mode encoding;

private static void printHelpExit( CmdLineParser parser ) {
parser.getProperties().withUsageWidth(120);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import georegression.struct.se.Se3_F64;
import georegression.struct.so.Quaternion_F64;
import org.ddogleg.struct.DogArray_F64;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.awt.*;
import java.awt.image.BufferedImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import boofcv.struct.image.GrayF32;
import boofcv.struct.image.ImageType;
import georegression.struct.point.Point2D_F64;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.awt.image.BufferedImage;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import boofcv.pdf.PdfFiducialEngine;
import boofcv.struct.image.GrayU8;
import org.ddogleg.struct.DogArray_I64;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import java.io.IOException;

Expand All @@ -42,7 +42,7 @@ public class CreateSquareFiducialDocumentPDF extends CreateFiducialDocumentPDF {

@Nullable DogArray_I64 binaryPatterns;
int gridWidth;
@Nullable java.util.List<GrayU8> imagePatterns;
java.util.@Nullable List<GrayU8> imagePatterns;

String markerType = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import boofcv.generate.Unit;
import boofcv.gui.BoofSwingUtil;
import boofcv.gui.StandardAlgConfigPanel;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
Expand Down Expand Up @@ -58,9 +58,9 @@ public class CreateMicroQrControlPanel extends StandardAlgConfigPanel implements

int version = -1;
String message = "Enter Text Here";
@Nullable MicroQrCode.ErrorLevel error = null;
MicroQrCode.@Nullable ErrorLevel error = null;
@Nullable MicroQrCodeMaskPattern mask = null;
@Nullable QrCode.Mode mode = null;
QrCode.@Nullable Mode mode = null;
PaperSize paperSize;
boolean fillGrid = false;
public boolean drawGrid = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import boofcv.generate.Unit;
import boofcv.gui.BoofSwingUtil;
import boofcv.gui.StandardAlgConfigPanel;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import javax.swing.event.DocumentEvent;
Expand Down Expand Up @@ -57,9 +57,9 @@ public class CreateQrCodeControlPanel extends StandardAlgConfigPanel implements

int version = -1;
String message = "Enter Text Here";
@Nullable QrCode.ErrorLevel error = null;
QrCode.@Nullable ErrorLevel error = null;
@Nullable QrCodeMaskPattern mask = null;
@Nullable QrCode.Mode mode = null;
QrCode.@Nullable Mode mode = null;
PaperSize paperSize;
boolean fillGrid = false;
public boolean drawGrid = false;
Expand Down
31 changes: 18 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins {
id "com.peterabeles.gversion" version "1.10.3" apply false
id "net.ltgt.errorprone" version "3.0.1" apply false
id "com.diffplug.spotless" version "6.9.1" apply false
id "com.diffplug.spotless" version "7.0.2" apply false
}

ext.libpath = file('./').absolutePath
Expand All @@ -30,10 +30,9 @@ project.ext.nullaway_version = '0.10.11'
project.ext.auto64to32_version = '3.2.2'
project.ext.snakeyaml_version = '2.3'
project.ext.jmh_version = '1.36'
project.ext.jetnull_version = '23.0.0'
project.ext.jsr250_version = '1.0'
project.ext.jsr305_version = '3.0.2'
project.ext.trove4j_version = '3.0.3'
project.ext.jspecify_version = '1.0.0'

// Which native platforms are supported can be specified in the command line. Otherwise
// the default is to support all of them
Expand Down Expand Up @@ -77,10 +76,8 @@ subprojects {
// To make ErrorProne and Kotlin plugins happy
configurations.configureEach {
resolutionStrategy {
force "org.jetbrains:annotations:$project.jetnull_version"
force "com.google.guava:guava:$project.guava_version"
force "com.google.errorprone:error_prone_annotations:$project.errorprone_version"
force "com.google.code.findbugs:jsr305:$project.jsr305_version"
force 'org.checkerframework:checker-qual:2.10.0'
}
}
Expand Down Expand Up @@ -110,7 +107,9 @@ subprojects {
sourceSets {
// no auto generated code is allowed in this sourceSet. This is to get around cyclical dependencies
// See docs/AutoGeneratedCode.md
noauto { java { srcDir 'src/noauto/java' } }
noauto {
java { srcDir 'src/noauto/java' }
}

// Ensures the code in noauto is also published
main { output.dir(noauto.output) }
Expand All @@ -137,11 +136,18 @@ subprojects {
api("net.sf.trove4j:trove4j:${project.trove4j_version}")

compileOnly "org.projectlombok:lombok:${project.lombok_version}"
compileOnly "org.jetbrains:annotations:$project.jetnull_version" // @Nullable
compileOnly "org.jspecify:jspecify:$project.jspecify_version"

// Static analysis annotations

noautoCompileOnly("org.jspecify:jspecify:$project.jspecify_version")
// noautoApi("org.jspecify:jspecify:$project.jspecify_version")

implementation("org.jspecify:jspecify:$project.jspecify_version")

compileOnly "javax.annotation:jsr250-api:$project.jsr250_version" // @Generated

noautoCompileOnly "org.projectlombok:lombok:${project.lombok_version}"
noautoCompileOnly "org.jetbrains:annotations:$project.jetnull_version" // @Nullable
compileOnly "javax.annotation:jsr250-api:$project.jsr250_version" // @Generated

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
Expand Down Expand Up @@ -272,28 +278,27 @@ subprojects {
}

spotless {
ratchetFrom 'origin/SNAPSHOT'
// ratchetFrom 'origin/SNAPSHOT'

format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs()
leadingSpacesToTabs()
endWithNewline()
}
java {
// There is currently no good way to exclude files that contain "@Generated" or are not versions.
// This should catch most of them with a few false positives.
target('**/java/boofcv/**/*.java')
targetExclude('**/*_MT*.java', '**/*_F32.java', '**/generated/*')
targetExclude('**/*_MT*.java', '**/*_F32.java', '**/generated/*', '**/java/boofcv/All.java')

toggleOffOn('formatter:off', 'formatter:on')
removeUnusedImports()
endWithNewline()

licenseHeaderFile "${project.rootDir}/misc/copyright.txt"
licenseHeaderFile("${project.rootDir}/misc/copyright.txt")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import org.apache.commons.io.FilenameUtils;
import org.ddogleg.struct.DogArray;
import org.ddogleg.struct.DogArray_I32;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.ddogleg.struct.DogArray;
import org.ddogleg.struct.DogArray_B;
import org.ejml.data.DMatrixRMaj;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import georegression.struct.point.Point2D_F32;
import georegression.struct.point.Point2D_F64;
import georegression.struct.shapes.Polygon2D_F64;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import boofcv.gui.BoofSwingUtil;
import boofcv.gui.StandardAlgConfigPanel;
import boofcv.gui.ViewedImageInfoPanel;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import boofcv.struct.image.ImageType;
import boofcv.struct.image.Planar;
import georegression.struct.point.Point2D_F32;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import boofcv.struct.image.ImageGray;
import boofcv.struct.wavelet.WaveletDescription;
import boofcv.struct.wavelet.WlCoef;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

import javax.swing.*;
import java.awt.*;
Expand Down
Loading