diff --git a/api/src/main/java/ai/djl/modality/Classifications.java b/api/src/main/java/ai/djl/modality/Classifications.java index 13f3325b12e..070c0372a7a 100644 --- a/api/src/main/java/ai/djl/modality/Classifications.java +++ b/api/src/main/java/ai/djl/modality/Classifications.java @@ -53,7 +53,7 @@ public class Classifications implements JsonSerializable, Ensembleable probabilities; - private int topK; + protected int topK; /** * Constructs a {@code Classifications} using a parallel list of classNames and probabilities. diff --git a/api/src/main/java/ai/djl/modality/cv/output/CategoryMask.java b/api/src/main/java/ai/djl/modality/cv/output/CategoryMask.java index c7c676fca01..c7d5414da28 100644 --- a/api/src/main/java/ai/djl/modality/cv/output/CategoryMask.java +++ b/api/src/main/java/ai/djl/modality/cv/output/CategoryMask.java @@ -43,7 +43,7 @@ public class CategoryMask implements JsonSerializable { .registerTypeAdapter(CategoryMask.class, new SegmentationSerializer()) .create(); - private List classes; + private transient List classes; private int[][] mask; /** diff --git a/api/src/main/java/ai/djl/modality/cv/output/DetectedObjects.java b/api/src/main/java/ai/djl/modality/cv/output/DetectedObjects.java index 2fd90fe39ec..9d58575af59 100644 --- a/api/src/main/java/ai/djl/modality/cv/output/DetectedObjects.java +++ b/api/src/main/java/ai/djl/modality/cv/output/DetectedObjects.java @@ -48,7 +48,7 @@ public DetectedObjects( List classNames, List probabilities, List boundingBoxes) { super(classNames, probabilities); this.boundingBoxes = boundingBoxes; - setTopK(Integer.MAX_VALUE); + this.topK = Integer.MAX_VALUE; } /** {@inheritDoc} */ diff --git a/api/src/main/java/ai/djl/modality/nlp/Decoder.java b/api/src/main/java/ai/djl/modality/nlp/Decoder.java index e8081666950..c422665b147 100644 --- a/api/src/main/java/ai/djl/modality/nlp/Decoder.java +++ b/api/src/main/java/ai/djl/modality/nlp/Decoder.java @@ -42,6 +42,7 @@ public abstract class Decoder extends AbstractBlock { * @param block the block to be used to decode * @param version the version to use for parameter and metadata serialization */ + @SuppressWarnings("this-escape") public Decoder(byte version, Block block) { super(version); this.block = addChildBlock("Block", block); diff --git a/api/src/main/java/ai/djl/modality/nlp/Encoder.java b/api/src/main/java/ai/djl/modality/nlp/Encoder.java index 4c5a4469388..221626d7559 100644 --- a/api/src/main/java/ai/djl/modality/nlp/Encoder.java +++ b/api/src/main/java/ai/djl/modality/nlp/Encoder.java @@ -40,6 +40,7 @@ public abstract class Encoder extends AbstractBlock { * @param version the version to use for parameter and metadata serialization * @param block the encoder block */ + @SuppressWarnings("this-escape") public Encoder(byte version, Block block) { super(version); this.block = addChildBlock("Block", block); diff --git a/api/src/main/java/ai/djl/modality/nlp/EncoderDecoder.java b/api/src/main/java/ai/djl/modality/nlp/EncoderDecoder.java index 58cc67867c7..24abcb77bb8 100644 --- a/api/src/main/java/ai/djl/modality/nlp/EncoderDecoder.java +++ b/api/src/main/java/ai/djl/modality/nlp/EncoderDecoder.java @@ -46,6 +46,7 @@ public class EncoderDecoder extends AbstractBlock { * @param encoder the {@link Encoder} * @param decoder the {@link Decoder} */ + @SuppressWarnings("this-escape") public EncoderDecoder(Encoder encoder, Decoder decoder) { super(VERSION); this.encoder = addChildBlock("Encoder", encoder); diff --git a/api/src/main/java/ai/djl/modality/nlp/embedding/TrainableTextEmbedding.java b/api/src/main/java/ai/djl/modality/nlp/embedding/TrainableTextEmbedding.java index af153cb0b23..a65e9cebb4f 100644 --- a/api/src/main/java/ai/djl/modality/nlp/embedding/TrainableTextEmbedding.java +++ b/api/src/main/java/ai/djl/modality/nlp/embedding/TrainableTextEmbedding.java @@ -38,6 +38,7 @@ public class TrainableTextEmbedding extends AbstractBlock implements TextEmbeddi * * @param wordEmbedding the word embedding to embed each word */ + @SuppressWarnings("this-escape") public TrainableTextEmbedding(TrainableWordEmbedding wordEmbedding) { this.trainableWordEmbedding = addChildBlock("trainableWordEmbedding", wordEmbedding); } diff --git a/api/src/main/java/ai/djl/ndarray/BaseNDManager.java b/api/src/main/java/ai/djl/ndarray/BaseNDManager.java index 29a57739aa3..c3df1ef3301 100644 --- a/api/src/main/java/ai/djl/ndarray/BaseNDManager.java +++ b/api/src/main/java/ai/djl/ndarray/BaseNDManager.java @@ -53,6 +53,7 @@ public abstract class BaseNDManager implements NDManager { protected AtomicBoolean closed = new AtomicBoolean(false); protected AtomicBoolean capped = new AtomicBoolean(false); + @SuppressWarnings("this-escape") protected BaseNDManager(NDManager parent, Device device) { this.parent = parent; this.device = device == null ? defaultDevice() : device; diff --git a/api/src/main/java/ai/djl/ndarray/NDScope.java b/api/src/main/java/ai/djl/ndarray/NDScope.java index 8b0deb23132..764c829c2e6 100644 --- a/api/src/main/java/ai/djl/ndarray/NDScope.java +++ b/api/src/main/java/ai/djl/ndarray/NDScope.java @@ -30,6 +30,7 @@ public class NDScope implements AutoCloseable { private IdentityHashMap resources; /** Constructs a new {@code NDScope} instance. */ + @SuppressWarnings("this-escape") public NDScope() { resources = new IdentityHashMap<>(); SCOPE_STACK.get().addLast(this); diff --git a/api/src/main/java/ai/djl/nn/ParallelBlock.java b/api/src/main/java/ai/djl/nn/ParallelBlock.java index 4ebe1e8119b..269e52b6b22 100644 --- a/api/src/main/java/ai/djl/nn/ParallelBlock.java +++ b/api/src/main/java/ai/djl/nn/ParallelBlock.java @@ -62,6 +62,7 @@ public ParallelBlock(Function, NDList> function) { * @param function the function to define how the parallel branches are combined * @param blocks the blocks that form each of the parallel branches */ + @SuppressWarnings("this-escape") public ParallelBlock(Function, NDList> function, List blocks) { super(VERSION); this.function = function; @@ -74,6 +75,7 @@ public ParallelBlock(Function, NDList> function, List blocks * @param blocks the array of blocks to add * @return this block */ + @SuppressWarnings("this-escape") public final ParallelBlock addAll(Block... blocks) { return addAll(Arrays.asList(blocks)); } diff --git a/api/src/main/java/ai/djl/nn/convolutional/Convolution.java b/api/src/main/java/ai/djl/nn/convolutional/Convolution.java index f862ee13274..a049c20e2b7 100644 --- a/api/src/main/java/ai/djl/nn/convolutional/Convolution.java +++ b/api/src/main/java/ai/djl/nn/convolutional/Convolution.java @@ -89,6 +89,7 @@ public abstract class Convolution extends AbstractBlock { * * @param builder the {@code Builder} that has the necessary configurations */ + @SuppressWarnings("this-escape") public Convolution(ConvolutionBuilder builder) { super(VERSION); kernelShape = builder.kernelShape; diff --git a/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java b/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java index 667de724e2a..419780a98d1 100644 --- a/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java +++ b/api/src/main/java/ai/djl/nn/convolutional/Deconvolution.java @@ -62,6 +62,7 @@ public abstract class Deconvolution extends AbstractBlock { * * @param builder the {@code Builder} that has the necessary configurations */ + @SuppressWarnings("this-escape") public Deconvolution(DeconvolutionBuilder builder) { kernelShape = builder.kernelShape; stride = builder.stride; diff --git a/api/src/main/java/ai/djl/nn/core/ConstantEmbedding.java b/api/src/main/java/ai/djl/nn/core/ConstantEmbedding.java index d2e0acf8e46..c1c27f57935 100644 --- a/api/src/main/java/ai/djl/nn/core/ConstantEmbedding.java +++ b/api/src/main/java/ai/djl/nn/core/ConstantEmbedding.java @@ -38,6 +38,7 @@ public class ConstantEmbedding extends AbstractBlock implements AbstractIndexedE * * @param embedding the value to return for all embeddings */ + @SuppressWarnings("this-escape") public ConstantEmbedding(NDArray embedding) { this.embedding = embedding; freezeParameters(true); diff --git a/api/src/main/java/ai/djl/nn/core/Embedding.java b/api/src/main/java/ai/djl/nn/core/Embedding.java index d6a937fe9a0..ab6167ced2f 100644 --- a/api/src/main/java/ai/djl/nn/core/Embedding.java +++ b/api/src/main/java/ai/djl/nn/core/Embedding.java @@ -49,6 +49,7 @@ public abstract class Embedding extends AbstractBlock implements AbstractInde protected Parameter embedding; + @SuppressWarnings("this-escape") protected Embedding(BaseBuilder baseBuilder) { super(VERSION); embeddingSize = baseBuilder.embeddingSize; @@ -91,6 +92,7 @@ protected Embedding(NDArray embedding) { * @param embedding the embedding array * @param format whether to compute row sparse gradient in the backward calculation */ + @SuppressWarnings("this-escape") protected Embedding(NDArray embedding, SparseFormat format) { super(VERSION); numEmbeddings = Math.toIntExact(embedding.getShape().get(0)); diff --git a/api/src/main/java/ai/djl/nn/core/Linear.java b/api/src/main/java/ai/djl/nn/core/Linear.java index 530344a8858..d10c0a91eb8 100644 --- a/api/src/main/java/ai/djl/nn/core/Linear.java +++ b/api/src/main/java/ai/djl/nn/core/Linear.java @@ -62,6 +62,7 @@ public class Linear extends AbstractBlock { private Parameter weight; private Parameter bias; + @SuppressWarnings("this-escape") protected Linear(Builder builder) { super(VERSION); units = builder.units; diff --git a/api/src/main/java/ai/djl/nn/core/Prelu.java b/api/src/main/java/ai/djl/nn/core/Prelu.java index 8fcb9971330..e70d06a448b 100644 --- a/api/src/main/java/ai/djl/nn/core/Prelu.java +++ b/api/src/main/java/ai/djl/nn/core/Prelu.java @@ -41,6 +41,7 @@ public class Prelu extends AbstractBlock { private Parameter alpha; /** Creates a Parametric ReLU Block. */ + @SuppressWarnings("this-escape") public Prelu() { super(VERSION); alpha = diff --git a/api/src/main/java/ai/djl/nn/norm/LayerNorm.java b/api/src/main/java/ai/djl/nn/norm/LayerNorm.java index 5d69284132e..42ab1036aa8 100644 --- a/api/src/main/java/ai/djl/nn/norm/LayerNorm.java +++ b/api/src/main/java/ai/djl/nn/norm/LayerNorm.java @@ -66,6 +66,7 @@ public class LayerNorm extends AbstractBlock { protected Parameter gamma; protected Parameter beta; + @SuppressWarnings("this-escape") protected LayerNorm(Builder builder) { epsilon = builder.epsilon; scale = builder.scale; diff --git a/api/src/main/java/ai/djl/nn/recurrent/RecurrentBlock.java b/api/src/main/java/ai/djl/nn/recurrent/RecurrentBlock.java index 3c9bb3f89d7..981e4954e7c 100644 --- a/api/src/main/java/ai/djl/nn/recurrent/RecurrentBlock.java +++ b/api/src/main/java/ai/djl/nn/recurrent/RecurrentBlock.java @@ -58,6 +58,7 @@ public abstract class RecurrentBlock extends AbstractBlock { * * @param builder the {@code Builder} that has the necessary configurations */ + @SuppressWarnings("this-escape") public RecurrentBlock(BaseBuilder builder) { super(VERSION); stateSize = builder.stateSize; diff --git a/api/src/main/java/ai/djl/nn/transformer/BertMaskedLanguageModelBlock.java b/api/src/main/java/ai/djl/nn/transformer/BertMaskedLanguageModelBlock.java index a0b49b9430d..cb02a2f4074 100644 --- a/api/src/main/java/ai/djl/nn/transformer/BertMaskedLanguageModelBlock.java +++ b/api/src/main/java/ai/djl/nn/transformer/BertMaskedLanguageModelBlock.java @@ -46,6 +46,7 @@ public class BertMaskedLanguageModelBlock extends AbstractBlock { * @param bertBlock the bert block to create the task for * @param hiddenActivation the activation to use for the hidden layer */ + @SuppressWarnings("this-escape") public BertMaskedLanguageModelBlock( BertBlock bertBlock, Function hiddenActivation) { super(VERSION); diff --git a/api/src/main/java/ai/djl/nn/transformer/BertNextSentenceBlock.java b/api/src/main/java/ai/djl/nn/transformer/BertNextSentenceBlock.java index 549d05b629e..4c3bbdb55b8 100644 --- a/api/src/main/java/ai/djl/nn/transformer/BertNextSentenceBlock.java +++ b/api/src/main/java/ai/djl/nn/transformer/BertNextSentenceBlock.java @@ -29,6 +29,7 @@ public class BertNextSentenceBlock extends AbstractBlock { private Linear binaryClassifier; /** Creates a next sentence block. */ + @SuppressWarnings("this-escape") public BertNextSentenceBlock() { binaryClassifier = addChildBlock( diff --git a/api/src/main/java/ai/djl/nn/transformer/BertPretrainingBlock.java b/api/src/main/java/ai/djl/nn/transformer/BertPretrainingBlock.java index d196ace2782..8d9cec6c01e 100644 --- a/api/src/main/java/ai/djl/nn/transformer/BertPretrainingBlock.java +++ b/api/src/main/java/ai/djl/nn/transformer/BertPretrainingBlock.java @@ -36,6 +36,7 @@ public class BertPretrainingBlock extends AbstractBlock { * * @param builder a builder with a bert configuration */ + @SuppressWarnings("this-escape") public BertPretrainingBlock(final BertBlock.Builder builder) { this.bertBlock = addChildBlock("Bert", builder.build()); this.mlBlock = diff --git a/api/src/main/java/ai/djl/nn/transformer/PointwiseFeedForwardBlock.java b/api/src/main/java/ai/djl/nn/transformer/PointwiseFeedForwardBlock.java index 3b530808bdf..451709c3f74 100644 --- a/api/src/main/java/ai/djl/nn/transformer/PointwiseFeedForwardBlock.java +++ b/api/src/main/java/ai/djl/nn/transformer/PointwiseFeedForwardBlock.java @@ -31,6 +31,7 @@ public class PointwiseFeedForwardBlock extends SequentialBlock { * @param activationFunction the activation function to use for the hidden layers (not applied * to output) */ + @SuppressWarnings("this-escape") public PointwiseFeedForwardBlock( List hiddenSizes, int outputSize, diff --git a/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java b/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java index bc251d42e86..f01cb1adc33 100644 --- a/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java +++ b/api/src/main/java/ai/djl/nn/transformer/TransformerEncoderBlock.java @@ -51,6 +51,7 @@ public class TransformerEncoderBlock extends AbstractBlock { * @param dropoutProbability dropout probability * @param activationFunction activation function */ + @SuppressWarnings("this-escape") public TransformerEncoderBlock( int embeddingSize, int headCount, diff --git a/api/src/main/java/ai/djl/repository/zoo/DefaultModelZoo.java b/api/src/main/java/ai/djl/repository/zoo/DefaultModelZoo.java index 527871067fa..676bab73d75 100644 --- a/api/src/main/java/ai/djl/repository/zoo/DefaultModelZoo.java +++ b/api/src/main/java/ai/djl/repository/zoo/DefaultModelZoo.java @@ -29,6 +29,7 @@ public class DefaultModelZoo extends ModelZoo { private static final Logger logger = LoggerFactory.getLogger(DefaultModelZoo.class); /** Constructs a new {@code LocalModelZoo} instance. */ + @SuppressWarnings("this-escape") public DefaultModelZoo() { String locations = System.getProperty("ai.djl.repository.zoo.location"); if (locations != null) { @@ -41,6 +42,7 @@ public DefaultModelZoo() { * * @param locations a comma separated urls where the models to be loaded from */ + @SuppressWarnings("this-escape") public DefaultModelZoo(String locations) { parseLocation(locations); } diff --git a/api/src/main/java/ai/djl/training/Trainer.java b/api/src/main/java/ai/djl/training/Trainer.java index 457382c5ec5..6d79dde3eec 100644 --- a/api/src/main/java/ai/djl/training/Trainer.java +++ b/api/src/main/java/ai/djl/training/Trainer.java @@ -86,6 +86,7 @@ public class Trainer implements AutoCloseable { * @param model the model the trainer will train on * @param trainingConfig the configuration used by the trainer */ + @SuppressWarnings("this-escape") public Trainer(Model model, TrainingConfig trainingConfig) { this.model = model; manager = model.getNDManager().newSubManager(); diff --git a/api/src/main/java/ai/djl/translate/PaddingStackBatchifier.java b/api/src/main/java/ai/djl/translate/PaddingStackBatchifier.java index 3f3bb1b2d6e..359fe6bd7c5 100644 --- a/api/src/main/java/ai/djl/translate/PaddingStackBatchifier.java +++ b/api/src/main/java/ai/djl/translate/PaddingStackBatchifier.java @@ -29,10 +29,10 @@ public final class PaddingStackBatchifier implements Batchifier { private static final long serialVersionUID = 1L; - private List arraysToPad; - private List dimsToPad; + private transient List arraysToPad; + private transient List dimsToPad; private transient List paddingSuppliers; - private List paddingSizes; + private transient List paddingSizes; private boolean includeValidLengths; private PaddingStackBatchifier(Builder builder) { diff --git a/basicdataset/src/main/java/ai/djl/basicdataset/tabular/ListFeatures.java b/basicdataset/src/main/java/ai/djl/basicdataset/tabular/ListFeatures.java index 42fc1744451..b04ae800a10 100644 --- a/basicdataset/src/main/java/ai/djl/basicdataset/tabular/ListFeatures.java +++ b/basicdataset/src/main/java/ai/djl/basicdataset/tabular/ListFeatures.java @@ -44,6 +44,7 @@ public ListFeatures(int initialCapacity) { * * @param source the source list */ + @SuppressWarnings("this-escape") public ListFeatures(List source) { super(source.size()); addAll(source); diff --git a/engines/ml/lightgbm/src/main/java/ai/djl/ml/lightgbm/LgbmSymbolBlock.java b/engines/ml/lightgbm/src/main/java/ai/djl/ml/lightgbm/LgbmSymbolBlock.java index 0bb92645a89..826b1a0f900 100644 --- a/engines/ml/lightgbm/src/main/java/ai/djl/ml/lightgbm/LgbmSymbolBlock.java +++ b/engines/ml/lightgbm/src/main/java/ai/djl/ml/lightgbm/LgbmSymbolBlock.java @@ -46,6 +46,7 @@ public class LgbmSymbolBlock extends AbstractSymbolBlock implements AutoCloseabl * @param iterations the number of iterations the model was trained for * @param handle the Booster handle */ + @SuppressWarnings("this-escape") public LgbmSymbolBlock(LgbmNDManager manager, int iterations, SWIGTYPE_p_p_void handle) { this.handle = new AtomicReference<>(handle); this.iterations = iterations; diff --git a/engines/ml/xgboost/src/main/java/ai/djl/ml/xgboost/XgbSymbolBlock.java b/engines/ml/xgboost/src/main/java/ai/djl/ml/xgboost/XgbSymbolBlock.java index 1e2bcddd999..43a9e129dea 100644 --- a/engines/ml/xgboost/src/main/java/ai/djl/ml/xgboost/XgbSymbolBlock.java +++ b/engines/ml/xgboost/src/main/java/ai/djl/ml/xgboost/XgbSymbolBlock.java @@ -45,6 +45,7 @@ public class XgbSymbolBlock extends AbstractSymbolBlock implements AutoCloseable * @param manager the manager to use for the block * @param handle the Booster handle */ + @SuppressWarnings("this-escape") public XgbSymbolBlock(XgbNDManager manager, long handle) { this.handle = new AtomicReference<>(handle); this.manager = manager; diff --git a/engines/mxnet/jnarator/build.gradle b/engines/mxnet/jnarator/build.gradle index b9cc0d4cd5f..b9fd8ceab14 100644 --- a/engines/mxnet/jnarator/build.gradle +++ b/engines/mxnet/jnarator/build.gradle @@ -17,6 +17,11 @@ dependencies { checkstyleMain.source = 'src/main/java' pmdMain.source = 'src/main/java' +compileJava { + options.compilerArgs.clear() + options.compilerArgs << "--release" << "11" << "-proc:none" << "-Xlint:all,-options,-static" +} + jar { manifest { attributes ( diff --git a/engines/mxnet/jnarator/src/main/java/ai/djl/mxnet/jnarator/JnaGenerator.java b/engines/mxnet/jnarator/src/main/java/ai/djl/mxnet/jnarator/JnaGenerator.java index 3105ec9cd48..ba3e18fea3b 100644 --- a/engines/mxnet/jnarator/src/main/java/ai/djl/mxnet/jnarator/JnaGenerator.java +++ b/engines/mxnet/jnarator/src/main/java/ai/djl/mxnet/jnarator/JnaGenerator.java @@ -276,6 +276,7 @@ public void writeNativeSize() throws IOException { writer.append(" public NativeSizeByReference() {\n"); writer.append(" this(new NativeSize(0));\n"); writer.append(" }\n\n"); + writer.append(" @SuppressWarnings(\"this-escape\")\n"); writer.append(" public NativeSizeByReference(NativeSize value) {\n"); writer.append(" super(NativeSize.SIZE);\n"); writer.append(" setValue(value);\n"); diff --git a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java index 62398b1868e..b1ca8e49aa4 100644 --- a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java +++ b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/CachedOp.java @@ -63,6 +63,7 @@ public class CachedOp extends NativeResource { * @param dataIndices the input data names required by the model and their corresponding * location */ + @SuppressWarnings("this-escape") public CachedOp( Pointer handle, MxNDManager manager, diff --git a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxParameterServer.java b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxParameterServer.java index 36bead164e4..952ca2f0995 100644 --- a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxParameterServer.java +++ b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxParameterServer.java @@ -40,6 +40,7 @@ public class MxParameterServer extends NativeResource implements Parame * * @param optimizer the optimizer to use for the parameter server updates */ + @SuppressWarnings("this-escape") public MxParameterServer(Optimizer optimizer) { super(createdKVStore()); callback = new OptimizerCallback(optimizer); diff --git a/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java b/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java index aa54b43f376..4e8df210d40 100644 --- a/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java +++ b/engines/onnxruntime/onnxruntime-engine/src/main/java/ai/djl/onnxruntime/engine/OrtSymbolBlock.java @@ -59,6 +59,7 @@ public class OrtSymbolBlock extends AbstractSymbolBlock implements AutoCloseable * @param session the {@link OrtSession} contains the model information * @param manager the {@link NDManager} to holds the NDArray */ + @SuppressWarnings("this-escape") public OrtSymbolBlock(OrtSession session, OrtNDManager manager) { this.session = session; this.manager = manager; diff --git a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArray.java b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArray.java index 606aaf24e00..499f51ebad5 100644 --- a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArray.java +++ b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtNDArray.java @@ -60,6 +60,7 @@ public class PtNDArray extends NativeResource implements NDArray { * @param manager the manager to attach the new array to * @param handle the pointer to the native PyTorch memory */ + @SuppressWarnings("this-escape") public PtNDArray(PtNDManager manager, long handle) { super(handle); this.manager = manager; @@ -76,6 +77,7 @@ public PtNDArray(PtNDManager manager, long handle) { * @param handle the pointer to the native PyTorch memory * @param data the direct buffer of the data */ + @SuppressWarnings("this-escape") public PtNDArray(PtNDManager manager, long handle, ByteBuffer data) { super(handle); this.manager = manager; @@ -93,6 +95,7 @@ public PtNDArray(PtNDManager manager, long handle, ByteBuffer data) { * @param strs the string array * @param shape the {@link Shape} of the {@link NDArray} */ + @SuppressWarnings("this-escape") public PtNDArray(PtNDManager manager, String[] strs, Shape shape) { super(-1L); this.manager = manager; diff --git a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtSymbolBlock.java b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtSymbolBlock.java index 8bc28a2c21b..7075cb05efa 100644 --- a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtSymbolBlock.java +++ b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtSymbolBlock.java @@ -67,6 +67,7 @@ public class PtSymbolBlock extends AbstractSymbolBlock implements AutoCloseable * @param manager the manager to use for the block * @param handle the module handle */ + @SuppressWarnings("this-escape") public PtSymbolBlock(PtNDManager manager, long handle) { this(manager); this.handle = new AtomicReference<>(handle); diff --git a/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java b/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java index 5b421ff431f..4395ddf1a6c 100644 --- a/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java +++ b/extensions/fasttext/src/test/java/ai/djl/fasttext/CookingStackExchangeTest.java @@ -41,6 +41,7 @@ import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; @@ -129,7 +130,9 @@ public void testWord2Vec() throws IOException, MalformedModelException, ModelNot public void testBlazingText() throws IOException, ModelException { TestRequirements.nightly(); - URL url = new URL("https://resources.djl.ai/test-models/blazingtext_classification.bin"); + URL url = + URI.create("https://resources.djl.ai/test-models/blazingtext_classification.bin") + .toURL(); Path path = Paths.get("build/tmp/model"); Path modelFile = path.resolve("text_classification.bin"); if (!Files.exists(modelFile)) { diff --git a/jacoco/build.gradle b/jacoco/build.gradle index 8a2b0057e45..fa570c50a3b 100644 --- a/jacoco/build.gradle +++ b/jacoco/build.gradle @@ -40,7 +40,9 @@ dependencies { jacocoAggregation project(":extensions:tokenizers") jacocoAggregation project(":extensions:tablesaw") jacocoAggregation project(":extensions:timeseries") - jacocoAggregation project(":extensions:spark") + if (JavaVersion.current() < JavaVersion.VERSION_19) { + jacocoAggregation project(":extensions:spark") + } jacocoAggregation project(":integration") jacocoAggregation project(":model-zoo") } diff --git a/model-zoo/src/main/java/ai/djl/basicmodelzoo/basic/Mlp.java b/model-zoo/src/main/java/ai/djl/basicmodelzoo/basic/Mlp.java index 05f171c1ec2..2869e42f55d 100644 --- a/model-zoo/src/main/java/ai/djl/basicmodelzoo/basic/Mlp.java +++ b/model-zoo/src/main/java/ai/djl/basicmodelzoo/basic/Mlp.java @@ -56,6 +56,7 @@ public Mlp(int input, int output, int[] hidden) { * @param hidden the sizes of all of the hidden layers * @param activation the activation function to use */ + @SuppressWarnings("this-escape") public Mlp(int input, int output, int[] hidden, Function activation) { add(Blocks.batchFlattenBlock(input)); for (int hiddenSize : hidden) { diff --git a/settings.gradle b/settings.gradle index 7835fe2ee5e..ff6967fc308 100644 --- a/settings.gradle +++ b/settings.gradle @@ -35,7 +35,9 @@ include ':extensions:sentencepiece' include ':extensions:tokenizers' include ':extensions:tablesaw' include ':extensions:timeseries' -include ':extensions:spark' +if (JavaVersion.current() < JavaVersion.VERSION_21) { + include ':extensions:spark' +} include ':integration' include ':model-zoo' include ':testing' diff --git a/tools/gradle/publish.gradle b/tools/gradle/publish.gradle index 26062d778ff..0baa3d5a2c1 100644 --- a/tools/gradle/publish.gradle +++ b/tools/gradle/publish.gradle @@ -1,4 +1,4 @@ -configure([ +def projects = [ project(':api'), project(':basicdataset'), project(':djl-zero'), @@ -28,8 +28,13 @@ configure([ project(':extensions:tablesaw'), project(':extensions:timeseries'), project(':extensions:tokenizers'), - project(':extensions:spark'), - project(':model-zoo')]) { + project(':model-zoo') +] +if (JavaVersion.current() < JavaVersion.VERSION_21) { + projects.add(project(':extensions:spark')) +} + +configure(projects) { apply plugin: "maven-publish" apply plugin: "signing"