From 91dbd7474041880d2babc7124fcce20fe61493c1 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 17 Oct 2022 19:38:56 +0200 Subject: Remove Checker Framework; add NullAway, Picnic Error Prone Support. Change-Id: I6558f0b4db0f9a192c18bbe45e2eaf10595bc666 --- jgvariant-core/pom.xml | 14 ---- .../main/java/eu/mulk/jgvariant/core/Decoder.java | 16 +++-- .../java/eu/mulk/jgvariant/core/Signature.java | 10 +-- .../java/eu/mulk/jgvariant/core/DecoderTest.java | 81 ++++++++++++---------- jgvariant-ostree/pom.xml | 14 ---- .../main/java/eu/mulk/jgvariant/ostree/Commit.java | 10 +-- .../java/eu/mulk/jgvariant/ostree/DirTree.java | 11 ++- .../java/eu/mulk/jgvariant/ostree/Metadata.java | 6 +- .../java/eu/mulk/jgvariant/ostree/SignedDelta.java | 5 +- .../java/eu/mulk/jgvariant/ostree/Summary.java | 5 +- .../eu/mulk/jgvariant/ostree/SummarySignature.java | 6 +- .../eu/mulk/jgvariant/ostree/ByteStringTest.java | 8 +-- .../mulk/jgvariant/ostree/OstreeDecoderTest.java | 19 +++-- jgvariant-parent/pom.xml | 37 +++++----- 14 files changed, 116 insertions(+), 126 deletions(-) diff --git a/jgvariant-core/pom.xml b/jgvariant-core/pom.xml index f8c7b42..b37b65c 100644 --- a/jgvariant-core/pom.xml +++ b/jgvariant-core/pom.xml @@ -50,20 +50,6 @@ SPDX-License-Identifier: LGPL-3.0-or-later true - - - org.checkerframework - checker - provided - true - - - org.checkerframework - checker-qual - provided - true - - org.junit.jupiter diff --git a/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java b/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java index 2cb36c6..4538900 100644 --- a/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java +++ b/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java @@ -5,15 +5,16 @@ package eu.mulk.jgvariant.core; import static java.nio.ByteOrder.LITTLE_ENDIAN; +import static java.util.Objects.requireNonNullElse; import static java.util.stream.Collectors.toMap; +import com.google.errorprone.annotations.Immutable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.RecordComponent; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; import java.text.ParseException; -import java.util.AbstractMap.SimpleImmutableEntry; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -56,8 +57,9 @@ import org.jetbrains.annotations.Nullable; * * @param the type that the {@link Decoder} can decode. */ -@SuppressWarnings("java:S1610") @API(status = Status.EXPERIMENTAL) +@Immutable +@SuppressWarnings({"ImmutableListOf", "InvalidInlineTag", "java:S1610", "UnescapedEntity"}) public abstract class Decoder { private Decoder() {} @@ -523,6 +525,7 @@ public abstract class Decoder { } } + @SuppressWarnings("Immutable") private static class TupleDecoder extends Decoder { private final Decoder[] componentDecoders; @@ -625,7 +628,7 @@ public abstract class Decoder { @SuppressWarnings("unchecked") public Map.@NotNull Entry decode(ByteBuffer byteSlice) { Object[] components = tupleDecoder.decode(byteSlice); - return new SimpleImmutableEntry<>((K) components[0], (V) components[1]); + return Map.entry((K) components[0], (V) components[1]); } } @@ -800,6 +803,7 @@ public abstract class Decoder { } } + @SuppressWarnings("Immutable") private class MappingDecoder extends Decoder { private final Function<@NotNull T, @NotNull U> function; @@ -824,6 +828,7 @@ public abstract class Decoder { } } + @SuppressWarnings("Immutable") private class ContramappingDecoder extends Decoder { private final UnaryOperator function; @@ -879,6 +884,7 @@ public abstract class Decoder { return byteSlice.slice(index, length).order(byteSlice.order()); } + @SuppressWarnings("Immutable") private static class PredicateDecoder extends Decoder { private final Predicate selector; @@ -900,8 +906,8 @@ public abstract class Decoder { throw new IllegalArgumentException( "incompatible sizes in predicate branches: then=%s, else=%s" .formatted( - Objects.requireNonNullElse(thenDecoder.fixedSize(), "(null)"), - Objects.requireNonNullElse(elseDecoder.fixedSize(), "(null)"))); + requireNonNullElse(thenDecoder.fixedSize(), "(null)"), + requireNonNullElse(elseDecoder.fixedSize(), "(null)"))); } } diff --git a/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Signature.java b/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Signature.java index cc9674d..4c8cd65 100644 --- a/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Signature.java +++ b/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Signature.java @@ -4,8 +4,10 @@ package eu.mulk.jgvariant.core; +import static java.nio.charset.StandardCharsets.US_ASCII; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; import java.text.ParseException; import java.util.ArrayList; import java.util.List; @@ -41,7 +43,7 @@ public final class Signature { this.decoder = parseSignature(signatureBytes); signatureBytes.rewind(); - this.signatureString = StandardCharsets.US_ASCII.decode(signatureBytes).toString(); + this.signatureString = US_ASCII.decode(signatureBytes).toString(); } static Signature parse(ByteBuffer signatureBytes) throws ParseException { @@ -49,7 +51,7 @@ public final class Signature { } public static Signature parse(String signatureString) throws ParseException { - var signatureBytes = ByteBuffer.wrap(signatureString.getBytes(StandardCharsets.US_ASCII)); + var signatureBytes = ByteBuffer.wrap(signatureString.getBytes(US_ASCII)); return parse(signatureBytes); } @@ -93,7 +95,7 @@ public final class Signature { case 'i', 'u' -> Decoder.ofInt(); case 'x', 't' -> Decoder.ofLong(); case 'd' -> Decoder.ofDouble(); - case 's', 'o', 'g' -> Decoder.ofString(StandardCharsets.UTF_8); + case 's', 'o', 'g' -> Decoder.ofString(UTF_8); case 'v' -> Decoder.ofVariant(); case 'm' -> Decoder.ofMaybe(parseSignature(signature)); case '(' -> Decoder.ofStructure(parseTupleTypes(signature).toArray(new Decoder[0])); diff --git a/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java b/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java index 3f826be..6399f6e 100644 --- a/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java +++ b/jgvariant-core/src/test/java/eu/mulk/jgvariant/core/DecoderTest.java @@ -23,17 +23,26 @@ import org.junit.jupiter.api.Test; * Tests based on the examples given in ~desrt/gvariant-serialisation.pdf. */ +@SuppressWarnings({ + "ImmutableListOf", + "ImmutableListOf1", + "ImmutableListOf2", + "ImmutableListOf3", + "ImmutableListOf4", + "ImmutableListOf5", + "ImmutableMapOf2" +}) class DecoderTest { @Test - void testString() { + void string() { var data = new byte[] {0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x00}; var decoder = Decoder.ofString(UTF_8); assertEquals("hello world", decoder.decode(ByteBuffer.wrap(data))); } @Test - void testMaybe() { + void maybe() { var data = new byte[] {0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x00, 0x00}; var decoder = Decoder.ofMaybe(Decoder.ofString(UTF_8)); @@ -41,14 +50,14 @@ class DecoderTest { } @Test - void testBooleanArray() { + void booleanArray() { var data = new byte[] {0x01, 0x00, 0x00, 0x01, 0x01}; var decoder = Decoder.ofArray(Decoder.ofBoolean()); assertEquals(List.of(true, false, false, true, true), decoder.decode(ByteBuffer.wrap(data))); } @Test - void testStructure() { + void structure() { var data = new byte[] { 0x66, 0x6F, 0x6F, 0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x04 @@ -61,7 +70,7 @@ class DecoderTest { } @Test - void testComplexStructureArray() { + void complexStructureArray() { var data = new byte[] { 0x68, @@ -103,7 +112,7 @@ class DecoderTest { } @Test - void testDictionary() { + void dictionary() { var data = new byte[] { 0x68, @@ -137,7 +146,7 @@ class DecoderTest { } @Test - void testStringArray() { + void stringArray() { var data = new byte[] { 0x69, 0x00, 0x63, 0x61, 0x6E, 0x00, 0x68, 0x61, 0x73, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, @@ -148,7 +157,7 @@ class DecoderTest { } @Test - void testNestedStructure() { + void nestedStructure() { var data = new byte[] { 0x69, 0x63, 0x61, 0x6E, 0x00, 0x68, 0x61, 0x73, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, @@ -170,7 +179,7 @@ class DecoderTest { } @Test - void testNestedStructureVariant() { + void nestedStructureVariant() { var data = new byte[] { 0x69, 0x63, 0x61, 0x6E, 0x00, 0x68, 0x61, 0x73, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67, @@ -189,7 +198,7 @@ class DecoderTest { } @Test - void testSimpleStructure() { + void simpleStructure() { var data = new byte[] {0x60, 0x70}; record TestRecord(byte b1, byte b2) {} @@ -204,7 +213,7 @@ class DecoderTest { } @Test - void testPaddedStructureRight() { + void paddedStructureRight() { var data = new byte[] {0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00}; record TestRecord(int b1, byte b2) {} @@ -219,7 +228,7 @@ class DecoderTest { } @Test - void testPaddedStructureLeft() { + void paddedStructureLeft() { var data = new byte[] {0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00}; record TestRecord(byte b1, int b2) {} @@ -234,7 +243,7 @@ class DecoderTest { } @Test - void testSimpleStructureArray() { + void simpleStructureArray() { var data = new byte[] { 0x60, @@ -270,7 +279,7 @@ class DecoderTest { } @Test - void testByteArray() { + void byteArray() { var data = new byte[] {0x04, 0x05, 0x06, 0x07}; var decoder = Decoder.ofArray(Decoder.ofByte()); @@ -281,7 +290,7 @@ class DecoderTest { } @Test - void testPrimitiveByteArray() { + void primitiveByteArray() { var data = new byte[] {0x04, 0x05, 0x06, 0x07}; var decoder = Decoder.ofByteArray(); @@ -290,7 +299,7 @@ class DecoderTest { } @Test - void testPrimitiveByteArrayRecord() { + void primitiveByteArrayRecord() { var data = new byte[] {0x04, 0x05, 0x06, 0x07}; record TestRecord(byte[] bytes) {} @@ -301,7 +310,7 @@ class DecoderTest { } @Test - void testIntegerArray() { + void integerArray() { var data = new byte[] {0x04, 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00}; var decoder = Decoder.ofArray(Decoder.ofInt().withByteOrder(LITTLE_ENDIAN)); @@ -310,7 +319,7 @@ class DecoderTest { } @Test - void testDictionaryEntryAsMapEntry() { + void dictionaryEntryAsMapEntry() { var data = new byte[] {0x61, 0x20, 0x6B, 0x65, 0x79, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x06}; @@ -321,7 +330,7 @@ class DecoderTest { } @Test - void testDictionaryEntryAsRecord() { + void dictionaryEntryAsRecord() { var data = new byte[] {0x61, 0x20, 0x6B, 0x65, 0x79, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x06}; @@ -334,7 +343,7 @@ class DecoderTest { } @Test - void testPaddedPrimitives() { + void paddedPrimitives() { var data = new byte[] { 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -353,7 +362,7 @@ class DecoderTest { } @Test - void testEmbeddedMaybe() { + void embeddedMaybe() { var data = new byte[] {0x01, 0x01}; record TestRecord(Optional set, Optional unset) {} @@ -367,7 +376,7 @@ class DecoderTest { } @Test - void testRecordComponentMismatch() { + void recordComponentMismatch() { record TestRecord(Optional set) {} var maybeDecoder = Decoder.ofMaybe(Decoder.ofByte()); @@ -377,7 +386,7 @@ class DecoderTest { } @Test - void testTrivialRecord() { + void trivialRecord() { var data = new byte[] {0x00}; record TestRecord() {} @@ -387,7 +396,7 @@ class DecoderTest { } @Test - void testTwoElementTrivialRecordArray() { + void twoElementTrivialRecordArray() { var data = new byte[] {0x00, 0x00}; record TestRecord() {} @@ -398,7 +407,7 @@ class DecoderTest { } @Test - void testSingletonTrivialRecordArray() { + void singletonTrivialRecordArray() { var data = new byte[] {0x00}; record TestRecord() {} @@ -408,7 +417,7 @@ class DecoderTest { } @Test - void testEmptyTrivialRecordArray() { + void emptyTrivialRecordArray() { var data = new byte[] {}; record TestRecord() {} @@ -418,7 +427,7 @@ class DecoderTest { } @Test - void testVariantArray() { + void variantArray() { var data = new byte[] {}; record TestRecord() {} @@ -428,7 +437,7 @@ class DecoderTest { } @Test - void testInvalidVariantSignature() { + void invalidVariantSignature() { var data = new byte[] {0x00, 0x00, 0x2E}; var decoder = Decoder.ofVariant(); @@ -436,7 +445,7 @@ class DecoderTest { } @Test - void testMissingVariantSignature() { + void missingVariantSignature() { var data = new byte[] {0x01}; var decoder = Decoder.ofVariant(); @@ -444,7 +453,7 @@ class DecoderTest { } @Test - void testSimpleVariantRecord() throws ParseException { + void simpleVariantRecord() throws ParseException { // signature: "(bynqiuxtdsogvmiai)" var data = new byte[] { @@ -494,7 +503,7 @@ class DecoderTest { } @Test - void testSignatureString() throws ParseException { + void signatureString() throws ParseException { var data = new byte[] { 0x28, 0x62, 0x79, 0x6E, 0x71, 0x69, 0x75, 0x78, 0x74, 0x64, 0x73, 0x6F, 0x67, 0x76, 0x6D, @@ -506,21 +515,21 @@ class DecoderTest { } @Test - void testMap() { + void map() { var data = new byte[] {0x0A, 0x0B, 0x0C}; var decoder = Decoder.ofByteArray().map(bytes -> bytes.length); assertEquals(3, decoder.decode(ByteBuffer.wrap(data))); } @Test - void testContramap() { + void contramap() { var data = new byte[] {0x0A, 0x0B, 0x0C}; var decoder = Decoder.ofByteArray().contramap(bytes -> bytes.slice(1, 1)); assertArrayEquals(new byte[] {0x0B}, decoder.decode(ByteBuffer.wrap(data))); } @Test - void testPredicateTrue() { + void predicateTrue() { var data = new byte[] {0x00, 0x01, 0x00}; var innerDecoder = Decoder.ofShort().contramap(bytes -> bytes.slice(1, 2).order(bytes.order())); var decoder = @@ -532,7 +541,7 @@ class DecoderTest { } @Test - void testPredicateFalse() { + void predicateFalse() { var data = new byte[] {0x01, 0x01, 0x00}; var innerDecoder = Decoder.ofShort().contramap(bytes -> bytes.slice(1, 2).order(bytes.order())); var decoder = @@ -544,7 +553,7 @@ class DecoderTest { } @Test - void testByteOrder() { + void byteOrder() { var data = new byte[] { 0x01, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x04, 0x05, 0x00, 0x00, 0x06, 0x00, 0x07, 0x08, diff --git a/jgvariant-ostree/pom.xml b/jgvariant-ostree/pom.xml index 5c01184..79f5f48 100644 --- a/jgvariant-ostree/pom.xml +++ b/jgvariant-ostree/pom.xml @@ -63,20 +63,6 @@ SPDX-License-Identifier: LGPL-3.0-or-later xz - - - org.checkerframework - checker - provided - true - - - org.checkerframework - checker-qual - provided - true - - org.junit.jupiter diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Commit.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Commit.java index 209827d..f14e758 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Commit.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Commit.java @@ -4,9 +4,10 @@ package eu.mulk.jgvariant.ostree; +import static java.nio.charset.StandardCharsets.UTF_8; + import eu.mulk.jgvariant.core.Decoder; import java.nio.ByteOrder; -import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -48,8 +49,7 @@ public record Commit( public record RelatedObject(String ref, Checksum commitChecksum) { private static final Decoder DECODER = - Decoder.ofStructure( - RelatedObject.class, Decoder.ofString(StandardCharsets.UTF_8), Checksum.decoder()); + Decoder.ofStructure(RelatedObject.class, Decoder.ofString(UTF_8), Checksum.decoder()); public static Decoder decoder() { return DECODER; @@ -62,8 +62,8 @@ public record Commit( Metadata.decoder(), Checksum.decoder(), Decoder.ofArray(RelatedObject.decoder()), - Decoder.ofString(StandardCharsets.UTF_8), - Decoder.ofString(StandardCharsets.UTF_8), + Decoder.ofString(UTF_8), + Decoder.ofString(UTF_8), Decoder.ofLong().withByteOrder(ByteOrder.BIG_ENDIAN), Checksum.decoder(), Checksum.decoder()); diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DirTree.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DirTree.java index dc38b1b..8ac9e67 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DirTree.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/DirTree.java @@ -4,8 +4,9 @@ package eu.mulk.jgvariant.ostree; +import static java.nio.charset.StandardCharsets.UTF_8; + import eu.mulk.jgvariant.core.Decoder; -import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -34,8 +35,7 @@ public record DirTree(List files, List directories) { public record File(String name, Checksum checksum) { private static final Decoder DECODER = - Decoder.ofStructure( - File.class, Decoder.ofString(StandardCharsets.UTF_8), Checksum.decoder()); + Decoder.ofStructure(File.class, Decoder.ofString(UTF_8), Checksum.decoder()); /** * Acquires a {@link Decoder} for the enclosing type. @@ -58,10 +58,7 @@ public record DirTree(List files, List directories) { private static final Decoder DECODER = Decoder.ofStructure( - Directory.class, - Decoder.ofString(StandardCharsets.UTF_8), - Checksum.decoder(), - Checksum.decoder()); + Directory.class, Decoder.ofString(UTF_8), Checksum.decoder(), Checksum.decoder()); /** * Acquires a {@link Decoder} for the enclosing type. diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java index 6e1f820..62f0331 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Metadata.java @@ -4,9 +4,10 @@ package eu.mulk.jgvariant.ostree; +import static java.nio.charset.StandardCharsets.UTF_8; + import eu.mulk.jgvariant.core.Decoder; import eu.mulk.jgvariant.core.Variant; -import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -19,8 +20,7 @@ import java.util.Map; public record Metadata(Map fields) { private static final Decoder DECODER = - Decoder.ofDictionary(Decoder.ofString(StandardCharsets.UTF_8), Decoder.ofVariant()) - .map(Metadata::new); + Decoder.ofDictionary(Decoder.ofString(UTF_8), Decoder.ofVariant()).map(Metadata::new); /** * Acquires a {@link Decoder} for the enclosing type. diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java index e1fcd53..827d5e4 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SignedDelta.java @@ -4,11 +4,12 @@ package eu.mulk.jgvariant.ostree; +import static java.nio.charset.StandardCharsets.US_ASCII; + import eu.mulk.jgvariant.core.Decoder; import eu.mulk.jgvariant.core.Variant; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -31,7 +32,7 @@ public record SignedDelta( SignedDelta.class, Decoder.ofLong().withByteOrder(ByteOrder.BIG_ENDIAN), ByteString.decoder().map(SignedDelta::decodeSuperblock), - Decoder.ofDictionary(Decoder.ofString(StandardCharsets.US_ASCII), Decoder.ofVariant())); + Decoder.ofDictionary(Decoder.ofString(US_ASCII), Decoder.ofVariant())); private static DeltaSuperblock decodeSuperblock(ByteString byteString) { return DeltaSuperblock.decoder().decode(ByteBuffer.wrap(byteString.bytes())); diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Summary.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Summary.java index 150ab00..2b8096d 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Summary.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/Summary.java @@ -4,9 +4,10 @@ package eu.mulk.jgvariant.ostree; +import static java.nio.charset.StandardCharsets.UTF_8; + import eu.mulk.jgvariant.core.Decoder; import java.nio.ByteOrder; -import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -58,7 +59,7 @@ public record Summary(List entries, Metadata metadata) { } private static final Decoder DECODER = - Decoder.ofStructure(Entry.class, Decoder.ofString(StandardCharsets.UTF_8), Value.decoder()); + Decoder.ofStructure(Entry.class, Decoder.ofString(UTF_8), Value.decoder()); /** * Acquires a {@link Decoder} for the enclosing type. diff --git a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java index c878955..3c88759 100644 --- a/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java +++ b/jgvariant-ostree/src/main/java/eu/mulk/jgvariant/ostree/SummarySignature.java @@ -4,9 +4,10 @@ package eu.mulk.jgvariant.ostree; +import static java.nio.charset.StandardCharsets.UTF_8; + import eu.mulk.jgvariant.core.Decoder; import eu.mulk.jgvariant.core.Variant; -import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -21,8 +22,7 @@ import java.util.Map; public record SummarySignature(Map signatures) { private static final Decoder DECODER = - Decoder.ofDictionary(Decoder.ofString(StandardCharsets.UTF_8), Decoder.ofVariant()) - .map(SummarySignature::new); + Decoder.ofDictionary(Decoder.ofString(UTF_8), Decoder.ofVariant()).map(SummarySignature::new); /** * Acquires a {@link Decoder} for the enclosing type. diff --git a/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/ByteStringTest.java b/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/ByteStringTest.java index 1d3d84d..cd21e3c 100644 --- a/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/ByteStringTest.java +++ b/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/ByteStringTest.java @@ -11,25 +11,25 @@ import org.junit.jupiter.api.Test; class ByteStringTest { @Test - void testToModifiedBase64() { + void toModifiedBase64() { assertEquals("MciDXVydLGaHpQCRyFFC0bLYU_9Bap+4G07jB1RRDVI", testByteString1.modifiedBase64()); } @Test - void testOfModifiedBase64() { + void ofModifiedBase64() { assertEquals( testByteString1, ByteString.ofModifiedBase64("MciDXVydLGaHpQCRyFFC0bLYU_9Bap+4G07jB1RRDVI")); } @Test - void testToHex() { + void toHex() { assertEquals( "31c8835d5c9d2c6687a50091c85142d1b2d853ff416a9fb81b4ee30754510d52", testByteString1.hex()); } @Test - void testOfHex() { + void ofHex() { assertEquals( testByteString1, ByteString.ofHex("31c8835d5c9d2c6687a50091c85142d1b2d853ff416a9fb81b4ee30754510d52")); diff --git a/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java b/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java index d8ad271..bca8142 100644 --- a/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java +++ b/jgvariant-ostree/src/test/java/eu/mulk/jgvariant/ostree/OstreeDecoderTest.java @@ -17,7 +17,12 @@ import java.util.Map; import org.junit.jupiter.api.Test; @TestWithResources -@SuppressWarnings("initialization.field.uninitialized") +@SuppressWarnings({ + "ImmutableListOf1", + "ImmutableMapOf1", + "initialization.field.uninitialized", + "NullAway" +}) class OstreeDecoderTest { @GivenBinaryResource("/ostree/summary") @@ -42,7 +47,7 @@ class OstreeDecoderTest { byte[] deltaPartPayloadBytes; @Test - void testSummaryDecoder() { + void summaryDecoder() { var decoder = Summary.decoder(); var summary = decoder.decode(ByteBuffer.wrap(summaryBytes)); assertAll( @@ -65,35 +70,35 @@ class OstreeDecoderTest { } @Test - void testCommitDecoder() { + void commitDecoder() { var decoder = Commit.decoder(); var commit = decoder.decode(ByteBuffer.wrap(commitBytes)); System.out.println(commit); } @Test - void testDirTreeDecoder() { + void dirTreeDecoder() { var decoder = DirTree.decoder(); var dirTree = decoder.decode(ByteBuffer.wrap(dirTreeBytes)); System.out.println(dirTree); } @Test - void testDirMetaDecoder() { + void dirMetaDecoder() { var decoder = DirMeta.decoder(); var dirMeta = decoder.decode(ByteBuffer.wrap(dirMetaBytes)); System.out.println(dirMeta); } @Test - void testSuperblockDecoder() { + void superblockDecoder() { var decoder = DeltaSuperblock.decoder(); var deltaSuperblock = decoder.decode(ByteBuffer.wrap(deltaSuperblockBytes)); System.out.println(deltaSuperblock); } @Test - void testPartPayloadDecoder() { + void partPayloadDecoder() { var superblockDecoder = DeltaSuperblock.decoder(); var superblock = superblockDecoder.decode(ByteBuffer.wrap(deltaSuperblockBytes)); diff --git a/jgvariant-parent/pom.xml b/jgvariant-parent/pom.xml index 5c3f27b..41b2c59 100644 --- a/jgvariant-parent/pom.xml +++ b/jgvariant-parent/pom.xml @@ -70,12 +70,13 @@ SPDX-License-Identifier: LGPL-3.0-or-later 1.1.2 2.15.0 + 0.4.0 1.15.0 0.3.2 23.0.0 5.9.0 + 0.10.2 1.9 - 3.25.0 @@ -104,18 +105,6 @@ SPDX-License-Identifier: LGPL-3.0-or-later ${apiguardian.version} - - - org.checkerframework - checker - ${checker-framework.version} - - - org.checkerframework - checker-qual - ${checker-framework.version} - - org.tukaani @@ -178,9 +167,10 @@ SPDX-License-Identifier: LGPL-3.0-or-later ${compiler-plugin.version} true + true -XDcompilePolicy=simple - -Xplugin:ErrorProne -Xep:InvalidParam:OFF + -Xplugin:ErrorProne -Xep:InvalidParam:OFF -Xep:CollectorMutability:OFF -Xep:LexicographicalAnnotationListing:OFF -XepOpt:NullAway:AnnotatedPackages=eu.mulk -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED @@ -200,14 +190,21 @@ SPDX-License-Identifier: LGPL-3.0-or-later ${errorprone.version} - org.checkerframework - checker - ${checker-framework.version} + tech.picnic.error-prone-support + error-prone-contrib + ${error-prone-support.version} + + + tech.picnic.error-prone-support + refaster-runner + ${error-prone-support.version} + + + com.uber.nullaway + nullaway + ${nullaway.version} - - org.checkerframework.checker.nullness.NullnessChecker - -- cgit v1.2.3