From 6d7878c5108e473f2da4b04e9e1cc97cb7f07ab0 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Fri, 12 Apr 2024 09:24:10 +0100 Subject: [PATCH] Added fail on warning lint for Javadoc, and rawtypes fixes for Bytes (#872) --- README.adoc | 2 +- .../wire/benchmarks/ObjectPoolMain.java | 18 +++++----- .../wire/benchmarks/bytes/NativeData.java | 6 ++-- .../chronicle/wire/AbstractAnyWire.java | 2 +- .../wire/AbstractClassGenerator.java | 3 +- .../chronicle/wire/AbstractEventCfg.java | 1 + .../wire/AbstractTimestampLongConverter.java | 1 - .../openhft/chronicle/wire/BinaryWire.java | 28 +++++++-------- .../chronicle/wire/DefaultValueIn.java | 10 +++--- .../net/openhft/chronicle/wire/HashWire.java | 6 ++-- .../net/openhft/chronicle/wire/JSONWire.java | 6 ++-- .../chronicle/wire/MarshallableOut.java | 2 +- .../net/openhft/chronicle/wire/QueryWire.java | 2 +- .../net/openhft/chronicle/wire/RawWire.java | 8 ++--- .../chronicle/wire/TextMethodTester.java | 2 +- .../net/openhft/chronicle/wire/TextWire.java | 8 ++--- .../net/openhft/chronicle/wire/ValueIn.java | 6 ++-- .../net/openhft/chronicle/wire/ValueOut.java | 12 +++---- .../openhft/chronicle/wire/WireDumper.java | 1 + .../openhft/chronicle/wire/WireInternal.java | 2 +- .../chronicle/wire/WireMarshaller.java | 21 +++++------ .../net/openhft/chronicle/wire/WireOut.java | 2 +- .../net/openhft/chronicle/wire/WireType.java | 15 ++++---- .../net/openhft/chronicle/wire/Wires.java | 12 +++---- .../net/openhft/chronicle/wire/YamlWire.java | 6 ++-- .../openhft/chronicle/wire/YamlWireOut.java | 35 +++++++++---------- .../chronicle/wire/BinaryInTextTest.java | 4 +-- .../chronicle/wire/BinaryWire2Test.java | 5 +-- .../chronicle/wire/BinaryWireTest.java | 5 ++- .../chronicle/wire/DocumentContextTest.java | 1 + .../MethodReaderArgumentsRecycleTest.java | 1 + .../wire/MethodReaderDelegationTest.java | 1 + .../MethodReaderInterceptorReturnsTest.java | 3 ++ .../wire/MethodReaderMethodIdsTest.java | 1 + .../MethodReaderNonStandardInstancesTest.java | 3 ++ ...perInterfaceForSeveralReturnTypesTest.java | 1 + .../chronicle/wire/MethodWriterBytesTest.java | 4 +-- .../wire/SerializableObjectTest.java | 2 +- .../openhft/chronicle/wire/TextWireTest.java | 2 +- .../chronicle/wire/TriviallyCopyableTest.java | 5 +-- .../openhft/chronicle/wire/YamlWireTest.java | 2 +- .../PerfRegressionHolder.java | 4 +-- .../wire/channel/PerfThroughputMain.java | 2 +- .../wire/marshallable/BytesUsageTest.java | 2 +- .../wire/marshallable/ScalarValues.java | 2 +- .../wire/method/MethodWriterTest.java | 1 + .../wire/utils/dto/AbstractEvent.java | 1 + 47 files changed, 146 insertions(+), 123 deletions(-) diff --git a/README.adoc b/README.adoc index d6abdcb804..e532e427cb 100644 --- a/README.adoc +++ b/README.adoc @@ -537,7 +537,7 @@ Data{message='Howyall', number=1234567890, timeUnit=SECONDS, price=1000.0} ---- === link:https://github.com/OpenHFT/Chronicle-Wire/blob/ea/demo/src/main/java/run/chronicle/wire/demo/Example7.java[Using the `ClassAliasPool`] -This example shows how to pass your classes to `ClassAliasPool.CLASS_ALIASES.addAlias(Class... classes)`, to create alias names for them so that you can refer to them without using the complete name of their packages. +This example shows how to pass your classes to `ClassAliasPool.CLASS_ALIASES.addAlias(Class... classes)`, to create alias names for them so that you can refer to them without using the complete name of their packages. [source,java] ---- diff --git a/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/ObjectPoolMain.java b/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/ObjectPoolMain.java index db17e12c2a..3680f28d03 100644 --- a/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/ObjectPoolMain.java +++ b/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/ObjectPoolMain.java @@ -38,12 +38,12 @@ @State(Scope.Thread) public class ObjectPoolMain { - private static final BytesStore CHAR1 = BytesStoreFrom("A"); - private static final BytesStore CHAR2 = BytesStoreFrom("A2"); - private static final BytesStore CHAR4 = BytesStoreFrom("A234"); - private static final BytesStore CHAR8 = BytesStoreFrom("A2345678"); - private static final BytesStore CHAR16 = BytesStoreFrom("A234567890123456"); - private static final BytesStore CHAR32 = BytesStoreFrom("A2345678901234567890123456789012"); + private static final BytesStore CHAR1 = BytesStoreFrom("A"); + private static final BytesStore CHAR2 = BytesStoreFrom("A2"); + private static final BytesStore CHAR4 = BytesStoreFrom("A234"); + private static final BytesStore CHAR8 = BytesStoreFrom("A2345678"); + private static final BytesStore CHAR16 = BytesStoreFrom("A234567890123456"); + private static final BytesStore CHAR32 = BytesStoreFrom("A2345678901234567890123456789012"); private static final byte[] BUFFER = new byte[32]; private final Bit8StringInterner si = new Bit8StringInterner(64); @@ -79,7 +79,7 @@ public static void main(String... args) throws RunnerException, InvocationTarget } // @NotNull - protected static String newStringUTF8(BytesStore bs) { + protected static String newStringUTF8(BytesStore bs) { int length = bs.length(); bs.read(0, BUFFER, 0, length); return new String(BUFFER, 0, length, StandardCharsets.UTF_8); @@ -148,11 +148,11 @@ public String newString32() { // @Benchmark public String newStringB01() { - BytesStore bs = CHAR1; + BytesStore bs = CHAR1; return newStringHiByte0(bs); } - protected String newStringHiByte0(BytesStore bs) { + protected String newStringHiByte0(BytesStore bs) { int length = bs.length(); bs.read(0, BUFFER, 0, length); return new String(BUFFER, 0, 0, length); diff --git a/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/bytes/NativeData.java b/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/bytes/NativeData.java index e413b4bbaa..eb9ffa1991 100644 --- a/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/bytes/NativeData.java +++ b/microbenchmarks/src/main/java/net/openhft/chronicle/wire/benchmarks/bytes/NativeData.java @@ -30,7 +30,7 @@ public class NativeData implements Byteable { static final int TEXT = FLAG + 1; private static final int MAX_TEXT = 16; - private BytesStore bytesStore; + private BytesStore bytesStore; private long offset; private long length; @@ -75,7 +75,7 @@ public void setSide(Side side) { } @Override - public void bytesStore(BytesStore bytesStore, long offset, long length) { + public void bytesStore(BytesStore bytesStore, long offset, long length) { this.bytesStore = bytesStore; this.offset = offset; this.length = length; @@ -95,7 +95,7 @@ public void copyTo(Data data) { } @Override - public BytesStore bytesStore() { + public BytesStore bytesStore() { return bytesStore; } diff --git a/src/main/java/net/openhft/chronicle/wire/AbstractAnyWire.java b/src/main/java/net/openhft/chronicle/wire/AbstractAnyWire.java index 518378c213..0f15f5b5ec 100644 --- a/src/main/java/net/openhft/chronicle/wire/AbstractAnyWire.java +++ b/src/main/java/net/openhft/chronicle/wire/AbstractAnyWire.java @@ -188,7 +188,7 @@ public ValueOut write(CharSequence key) { } @Override - public ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { + public ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { return wireAcquisition.acquireWire().writeEvent(expectedType, eventKey); } diff --git a/src/main/java/net/openhft/chronicle/wire/AbstractClassGenerator.java b/src/main/java/net/openhft/chronicle/wire/AbstractClassGenerator.java index 15e68a61b7..25727bddbd 100644 --- a/src/main/java/net/openhft/chronicle/wire/AbstractClassGenerator.java +++ b/src/main/java/net/openhft/chronicle/wire/AbstractClassGenerator.java @@ -40,6 +40,7 @@ * * @param Represents the meta-data associated with the class being generated. */ +@SuppressWarnings("unchecked") public abstract class AbstractClassGenerator> { // TODO Use Wires.loadFromJava() instead of a public static final @@ -140,7 +141,7 @@ public synchronized Class acquireClass(ClassLoader classLoader) { } // Compile and load the generated class. - return CACHED_COMPILER.loadFromJava(classLoader, fullName, sourceCode.toString()); + return (Class) CACHED_COMPILER.loadFromJava(classLoader, fullName, sourceCode.toString()); } catch (Throwable e) { // If there's any error during generation, compile, or load, throw an exception. throw Jvm.rethrow(new ClassNotFoundException(e.getMessage() + '\n' + sourceCode, e)); diff --git a/src/main/java/net/openhft/chronicle/wire/AbstractEventCfg.java b/src/main/java/net/openhft/chronicle/wire/AbstractEventCfg.java index fb43d449e8..03d0a74496 100644 --- a/src/main/java/net/openhft/chronicle/wire/AbstractEventCfg.java +++ b/src/main/java/net/openhft/chronicle/wire/AbstractEventCfg.java @@ -28,6 +28,7 @@ * * @param The type parameter extending AbstractEventCfg */ +@SuppressWarnings("unchecked") public class AbstractEventCfg> extends AbstractMarshallableCfg implements Event { // The unique identifier for the event diff --git a/src/main/java/net/openhft/chronicle/wire/AbstractTimestampLongConverter.java b/src/main/java/net/openhft/chronicle/wire/AbstractTimestampLongConverter.java index 6bd255332b..4379fdb309 100644 --- a/src/main/java/net/openhft/chronicle/wire/AbstractTimestampLongConverter.java +++ b/src/main/java/net/openhft/chronicle/wire/AbstractTimestampLongConverter.java @@ -43,7 +43,6 @@ *

* Parsing of ISO dates, with or without timestamps, is supported. If an ISO date is read with no * timezone, it is assumed to be in the converter's zone. - *

* * @see LongConverter for the interface this abstract class implements. */ diff --git a/src/main/java/net/openhft/chronicle/wire/BinaryWire.java b/src/main/java/net/openhft/chronicle/wire/BinaryWire.java index 9e5d3a69b8..274c62425d 100644 --- a/src/main/java/net/openhft/chronicle/wire/BinaryWire.java +++ b/src/main/java/net/openhft/chronicle/wire/BinaryWire.java @@ -203,7 +203,7 @@ public static BinaryWire binaryOnly(@NotNull Bytes bytes) { * @param bytes The BytesStore to check * @return true if the BytesStore can be treated as text, false otherwise */ - static boolean textable(BytesStore bytes) { + static boolean textable(BytesStore bytes) { if (bytes == null) return false; for (long pos = bytes.readPosition(); pos < bytes.readLimit(); pos++) { @@ -664,7 +664,7 @@ public void readWithLength(@NotNull WireOut wire, int len) throws InvalidMarshal // For simple or NONE type, just read and process the object. @Nullable Object object = this.getValueIn().object(); if (object instanceof BytesStore) { - @Nullable BytesStore bytes = (BytesStore) object; + @Nullable BytesStore bytes = (BytesStore) object; if (textable(bytes)) { wireValueOut.text(bytes); bytes.releaseLast(); @@ -1314,7 +1314,7 @@ private void copySpecial(@NotNull WireOut wire, int peekCode) throws InvalidMars try { // Attempt to find the class for the name found in the type prefix. - Class aClass = classLookup.forName(sb); + Class aClass = classLookup.forName(sb); // Special handling based on the class type. if (aClass == byte[].class) { @@ -2165,7 +2165,7 @@ public WireOut text(@Nullable String s) { @NotNull @Override - public WireOut text(@Nullable BytesStore s) { + public WireOut text(@Nullable BytesStore s) { if (s == null) { writeCode(NULL); @@ -2183,7 +2183,7 @@ public WireOut text(@Nullable BytesStore s) { @NotNull @Override - public WireOut bytes(@Nullable BytesStore fromBytes) { + public WireOut bytes(@Nullable BytesStore fromBytes) { if (fromBytes == null) return nu11(); long remaining = fromBytes.readRemaining(); @@ -2197,7 +2197,7 @@ public WireOut bytes(@Nullable BytesStore fromBytes) { @NotNull @Override - public WireOut bytesLiteral(@Nullable BytesStore fromBytes) { + public WireOut bytesLiteral(@Nullable BytesStore fromBytes) { if (fromBytes == null) return nu11(); long remaining = fromBytes.readRemaining(); @@ -2220,7 +2220,7 @@ public int compressedSize() { * @param fromBytes The source of the bytes to be written. * @param remaining The number of bytes to be written. */ - public void bytes0(@NotNull BytesStore fromBytes, long remaining) { + public void bytes0(@NotNull BytesStore fromBytes, long remaining) { // Write the length of the bytes. writeLength(Maths.toInt32(remaining + 1)); // Write the U8_ARRAY code. @@ -2273,7 +2273,7 @@ public WireOut bytes(@NotNull byte[] fromBytes) { @NotNull @Override - public WireOut bytes(String type, @Nullable BytesStore fromBytes) { + public WireOut bytes(String type, @Nullable BytesStore fromBytes) { typePrefix(type); if (fromBytes != null) bytes0(fromBytes, fromBytes.readRemaining()); @@ -3432,9 +3432,9 @@ public WireIn bytesLiteral(@NotNull BytesOut toBytes) { @NotNull @Override - public BytesStore bytesLiteral() { + public BytesStore bytesLiteral() { int length = Maths.toUInt31(readLength()); - @NotNull BytesStore toBytes = BytesStore.wrap(new byte[length]); + @NotNull BytesStore toBytes = BytesStore.wrap(new byte[length]); toBytes.write(0, bytes, bytes.readPosition(), length); bytes.readSkip(length); return toBytes; @@ -3458,7 +3458,7 @@ public WireIn bytesSet(@NotNull PointerBytesStore toBytes) { @NotNull @Override - public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsumer consumer) { + public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsumer consumer) { long length = readLength(); int code = readCode(); if (code != U8_ARRAY) @@ -3476,13 +3476,13 @@ public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsu @Override @Nullable - public BytesStore bytesStore() { + public BytesStore bytesStore() { long length = readLength() - 1; int code = readCode(); switch (code) { case I64_ARRAY: case U8_ARRAY: - @NotNull BytesStore toBytes = BytesStore.lazyNativeBytesStoreWithFixedCapacity(length); + @NotNull BytesStore toBytes = BytesStore.lazyNativeBytesStoreWithFixedCapacity(length); toBytes.write(0, bytes, bytes.readPosition(), length); bytes.readSkip(length); return toBytes; @@ -4859,7 +4859,7 @@ public Object objectWithInferredType(Object using, @NotNull SerializationStrateg long length = bytes.readRemaining(); if (length == 0) return BytesStore.empty(); - @NotNull BytesStore toBytes = BytesStore.lazyNativeBytesStoreWithFixedCapacity(length); + @NotNull BytesStore toBytes = BytesStore.lazyNativeBytesStoreWithFixedCapacity(length); toBytes.write(0, bytes, bytes.readPosition(), length); bytes.readSkip(length); return toBytes; diff --git a/src/main/java/net/openhft/chronicle/wire/DefaultValueIn.java b/src/main/java/net/openhft/chronicle/wire/DefaultValueIn.java index 3ec1d9ae79..307d86f15d 100644 --- a/src/main/java/net/openhft/chronicle/wire/DefaultValueIn.java +++ b/src/main/java/net/openhft/chronicle/wire/DefaultValueIn.java @@ -94,7 +94,7 @@ public WireIn bytes(@NotNull BytesOut toBytes) { @Nullable Object o = defaultValue; if (o == null) return wireIn(); - @NotNull BytesStore bytes = (BytesStore) o; + @NotNull BytesStore bytes = (BytesStore) o; toBytes.write(bytes); return wireIn(); } @@ -107,16 +107,16 @@ public WireIn bytesSet(@NotNull PointerBytesStore toBytes) { toBytes.set(NoBytesStore.NO_PAGE, 0); return wireIn(); } - @NotNull BytesStore bytes = (BytesStore) o; + @NotNull BytesStore bytes = (BytesStore) o; toBytes.set(bytes.addressForRead(0), bytes.realCapacity()); return wireIn(); } @NotNull @Override - public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsumer consumer) { + public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsumer consumer) { @Nullable Object o = defaultValue; - @NotNull BytesStore bytes = (BytesStore) o; + @NotNull BytesStore bytes = (BytesStore) o; consumer.accept(compareBytes.contentEquals(bytes)); return wireIn(); } @@ -129,7 +129,7 @@ public WireIn bytes(@NotNull ReadBytesMarshallable wireInConsumer) { wireInConsumer.readMarshallable(Wires.NO_BYTES); return wireIn(); } - @Nullable BytesStore bytes = (BytesStore) o; + @Nullable BytesStore bytes = (BytesStore) o; wireInConsumer.readMarshallable(bytes.bytesForRead()); return wireIn(); } diff --git a/src/main/java/net/openhft/chronicle/wire/HashWire.java b/src/main/java/net/openhft/chronicle/wire/HashWire.java index 37431581ed..04b602bead 100644 --- a/src/main/java/net/openhft/chronicle/wire/HashWire.java +++ b/src/main/java/net/openhft/chronicle/wire/HashWire.java @@ -210,7 +210,7 @@ public ValueOut write(@NotNull CharSequence name) { @NotNull @Override - public ValueOut writeEvent(Class ignored, @NotNull Object eventKey) { + public ValueOut writeEvent(Class ignored, @NotNull Object eventKey) { hash += K0 + eventKey.hashCode() * M0; return valueOut; } @@ -394,14 +394,14 @@ public WireOut int8(byte i8) { @NotNull @Override - public WireOut bytes(@Nullable BytesStore fromBytes) { + public WireOut bytes(@Nullable BytesStore fromBytes) { hash = hash * M1 + Maths.hash64(fromBytes); return HashWire.this; } @NotNull @Override - public WireOut bytes(@NotNull String type, @Nullable BytesStore fromBytes) { + public WireOut bytes(@NotNull String type, @Nullable BytesStore fromBytes) { hash = hash * M1 + Maths.hash64(type) ^ Maths.hash64(fromBytes); return HashWire.this; } diff --git a/src/main/java/net/openhft/chronicle/wire/JSONWire.java b/src/main/java/net/openhft/chronicle/wire/JSONWire.java index 90cb086e13..a3f817edaa 100644 --- a/src/main/java/net/openhft/chronicle/wire/JSONWire.java +++ b/src/main/java/net/openhft/chronicle/wire/JSONWire.java @@ -60,7 +60,7 @@ public class JSONWire extends TextWire { // Bytes for comma, commonly used as JSON separator. @SuppressWarnings("rawtypes") - static final BytesStore COMMA = BytesStore.from(","); + static final BytesStore COMMA = BytesStore.from(","); // A thread-local variable to store a reference to the stop characters tester for JSON parsing. static final ThreadLocal> STRICT_ESCAPED_END_OF_TEXT_JSON = new ThreadLocal<>(); @@ -693,7 +693,7 @@ protected void escape0(@NotNull CharSequence s, @NotNull Quotes quotes) { @SuppressWarnings("rawtypes") @Override - public ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { + public ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { return super.writeEvent(String.class, "" + eventKey); } @@ -964,7 +964,7 @@ public JSONWire rawText(CharSequence value) { } @Override - public @NotNull JSONWire object(@NotNull Class expectedType, V v) throws InvalidMarshallableException { + public @NotNull JSONWire object(@NotNull Class expectedType, V v) throws InvalidMarshallableException { return (JSONWire) (useTypes ? super.object(v) : super.object(expectedType, v)); } diff --git a/src/main/java/net/openhft/chronicle/wire/MarshallableOut.java b/src/main/java/net/openhft/chronicle/wire/MarshallableOut.java index 80165a811c..202899f225 100644 --- a/src/main/java/net/openhft/chronicle/wire/MarshallableOut.java +++ b/src/main/java/net/openhft/chronicle/wire/MarshallableOut.java @@ -257,7 +257,7 @@ default void writeMap(@NotNull Map map) throws UnrecoverableTimeoutExcepti */ @SuppressWarnings("rawtypes") @NotNull - default T methodWriter(@NotNull Class tClass, Class... additional) { + default T methodWriter(@NotNull Class tClass, Class... additional) { VanillaMethodWriterBuilder builder = (VanillaMethodWriterBuilder) methodWriterBuilder(false, tClass); Stream.of(additional).forEach(builder::addInterface); diff --git a/src/main/java/net/openhft/chronicle/wire/QueryWire.java b/src/main/java/net/openhft/chronicle/wire/QueryWire.java index 065e5da7d2..c2ae7efd9b 100644 --- a/src/main/java/net/openhft/chronicle/wire/QueryWire.java +++ b/src/main/java/net/openhft/chronicle/wire/QueryWire.java @@ -261,7 +261,7 @@ public QueryWire int8(byte i8) { @NotNull @Override - public QueryWire bytes(@Nullable BytesStore fromBytes) { + public QueryWire bytes(@Nullable BytesStore fromBytes) { throw new UnsupportedOperationException("todo"); } diff --git a/src/main/java/net/openhft/chronicle/wire/RawWire.java b/src/main/java/net/openhft/chronicle/wire/RawWire.java index 89c0e1bcda..b45b0638fc 100644 --- a/src/main/java/net/openhft/chronicle/wire/RawWire.java +++ b/src/main/java/net/openhft/chronicle/wire/RawWire.java @@ -347,7 +347,7 @@ public WireOut text(@Nullable CharSequence s) { @NotNull @Override - public WireOut text(@Nullable BytesStore s) { + public WireOut text(@Nullable BytesStore s) { if (use8bit) if (s == null) { bytes.writeStopBit(-1); @@ -375,7 +375,7 @@ public WireOut int8(byte i8) { @NotNull @Override - public WireOut bytes(@Nullable BytesStore bytesStore) { + public WireOut bytes(@Nullable BytesStore bytesStore) { if (bytesStore == null) { writeLength(-1); } else { @@ -394,7 +394,7 @@ public WireOut bytes(String type, @NotNull byte[] bytesArr) { @NotNull @Override - public WireOut bytes(String type, @Nullable BytesStore fromBytes) { + public WireOut bytes(String type, @Nullable BytesStore fromBytes) { typePrefix(type); return bytes(fromBytes); } @@ -812,7 +812,7 @@ public WireIn bytesSet(@NotNull PointerBytesStore toBytes) { @NotNull @Override - public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsumer consumer) { + public WireIn bytesMatch(@NotNull BytesStore compareBytes, @NotNull BooleanConsumer consumer) { long length = readLength(); @NotNull Bytes bytes = wireIn().bytes(); diff --git a/src/main/java/net/openhft/chronicle/wire/TextMethodTester.java b/src/main/java/net/openhft/chronicle/wire/TextMethodTester.java index 72d757fb7c..761df547f1 100644 --- a/src/main/java/net/openhft/chronicle/wire/TextMethodTester.java +++ b/src/main/java/net/openhft/chronicle/wire/TextMethodTester.java @@ -714,7 +714,7 @@ protected StringBuilder loadLastValues() throws IOException, InvalidMarshallable key.append(",").append(m.get(s)); } long end = wireOut.bytes().readPosition(); - BytesStore bytesStore = wireOut.bytes().subBytes(start, end - start); + BytesStore bytesStore = wireOut.bytes().subBytes(start, end - start); events.put(key.toString(), bytesStore.toString().trim()); bytesStore.releaseLast(); consumeDocumentSeparator(wireOut); diff --git a/src/main/java/net/openhft/chronicle/wire/TextWire.java b/src/main/java/net/openhft/chronicle/wire/TextWire.java index 26d3c1f328..64984c092f 100644 --- a/src/main/java/net/openhft/chronicle/wire/TextWire.java +++ b/src/main/java/net/openhft/chronicle/wire/TextWire.java @@ -63,7 +63,7 @@ public class TextWire extends YamlWireOut { // Constants representing specific textual constructs in YAML. - public static final BytesStore BINARY = BytesStore.from("!!binary"); + public static final BytesStore BINARY = BytesStore.from("!!binary"); public static final @NotNull Bytes TYPE_STR = Bytes.from("type "); static final String SEQ_MAP = "!seqmap"; @@ -332,7 +332,7 @@ public TextWire strict(boolean strict) { @Override @NotNull - public T methodWriter(@NotNull Class tClass, Class... additional) { + public T methodWriter(@NotNull Class tClass, Class... additional) { VanillaMethodWriterBuilder builder = new VanillaMethodWriterBuilder<>(tClass, WireType.TEXT, () -> newTextMethodWriterInvocationHandler(tClass)); @@ -352,7 +352,7 @@ public T methodWriter(@NotNull Class tClass, Class... additional) { * @return A newly instantiated {@link TextMethodWriterInvocationHandler} for the provided interface(s). */ @NotNull - TextMethodWriterInvocationHandler newTextMethodWriterInvocationHandler(Class... interfaces) { + TextMethodWriterInvocationHandler newTextMethodWriterInvocationHandler(Class... interfaces) { for (Class anInterface : interfaces) { Comment c = Jvm.findAnnotation(anInterface, Comment.class); if (c != null) @@ -1535,7 +1535,7 @@ protected int peekBack() { @NotNull @Override - public WireIn bytesMatch(@NotNull BytesStore compareBytes, BooleanConsumer consumer) { + public WireIn bytesMatch(@NotNull BytesStore compareBytes, BooleanConsumer consumer) { throw new UnsupportedOperationException("todo"); } diff --git a/src/main/java/net/openhft/chronicle/wire/ValueIn.java b/src/main/java/net/openhft/chronicle/wire/ValueIn.java index deb64b5814..bdfa1da2d7 100644 --- a/src/main/java/net/openhft/chronicle/wire/ValueIn.java +++ b/src/main/java/net/openhft/chronicle/wire/ValueIn.java @@ -179,7 +179,7 @@ default WireIn bytesLiteral(@NotNull BytesOut toBytes) { * @return The BytesStore object or null. */ @Nullable - default BytesStore bytesLiteral() { + default BytesStore bytesLiteral() { return bytesStore(); } @@ -200,7 +200,7 @@ default BytesStore bytesLiteral() { * @return The current WireIn instance. */ @NotNull - WireIn bytesMatch(@NotNull BytesStore compareBytes, BooleanConsumer consumer); + WireIn bytesMatch(@NotNull BytesStore compareBytes, BooleanConsumer consumer); /** * Reads byte data using the provided ReadBytesMarshallable. @@ -234,7 +234,7 @@ default BytesStore bytesLiteral() { * @return The BytesStore object or null. */ @Nullable - default BytesStore bytesStore() { + default BytesStore bytesStore() { byte @Nullable [] bytes = bytes(); return bytes == null ? null : BytesStore.wrap(bytes); } diff --git a/src/main/java/net/openhft/chronicle/wire/ValueOut.java b/src/main/java/net/openhft/chronicle/wire/ValueOut.java index a59f17c766..95e59ad53f 100644 --- a/src/main/java/net/openhft/chronicle/wire/ValueOut.java +++ b/src/main/java/net/openhft/chronicle/wire/ValueOut.java @@ -156,7 +156,7 @@ default WireOut character(char c) { * @return The WireOut instance for chained calls. */ @NotNull - default WireOut text(@Nullable BytesStore s) { + default WireOut text(@Nullable BytesStore s) { return text((CharSequence) s); } @@ -189,7 +189,7 @@ default WireOut int8(long x) { * @return The WireOut instance for chained calls. */ @NotNull - WireOut bytes(@Nullable BytesStore fromBytes); + WireOut bytes(@Nullable BytesStore fromBytes); /** * Write a sequence of bytes from a {@link BytesStore} object as a literal value, @@ -199,7 +199,7 @@ default WireOut int8(long x) { * @return The WireOut instance for chained calls. */ @NotNull - default WireOut bytesLiteral(@Nullable BytesStore fromBytes) { + default WireOut bytesLiteral(@Nullable BytesStore fromBytes) { return bytes(fromBytes); } @@ -211,7 +211,7 @@ default WireOut bytesLiteral(@Nullable BytesStore fromBytes) { * @return The WireOut instance for chained calls. */ @NotNull - WireOut bytes(String type, @Nullable BytesStore fromBytes); + WireOut bytes(String type, @Nullable BytesStore fromBytes); /** * Write a raw sequence of bytes. The exact behavior of this method depends on the implementation. @@ -1125,7 +1125,7 @@ default WireOut collection(Collection coll, Class assumedClass) throws * @throws InvalidMarshallableException If the object cannot be marshalled. */ @NotNull - default WireOut object(@NotNull Class expectedType, V v) throws InvalidMarshallableException { + default WireOut object(@NotNull Class expectedType, V v) throws InvalidMarshallableException { Class vClass = v == null ? void.class : v.getClass(); // Check for various types and marshall accordingly if (v instanceof WriteMarshallable && !isAnEnum(v)) @@ -1629,7 +1629,7 @@ default WireOut compress(@NotNull String compression, @Nullable Bytes uncompr // If the byte size is smaller than the threshold, just write the bytes directly if (uncompressedBytes.readRemaining() < SMALL_MESSAGE) return bytes(uncompressedBytes); - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { Bytes tmpBytes = stlBytes.get(); Compression.compress(compression, uncompressedBytes, tmpBytes); // Write the compressed bytes diff --git a/src/main/java/net/openhft/chronicle/wire/WireDumper.java b/src/main/java/net/openhft/chronicle/wire/WireDumper.java index 25c4988f73..062208030c 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireDumper.java +++ b/src/main/java/net/openhft/chronicle/wire/WireDumper.java @@ -84,6 +84,7 @@ public static WireDumper of(@NotNull Bytes bytes) { * @param align Boolean value indicating whether to align the dumped data * @return A new WireDumper instance */ + @SuppressWarnings("deprecation") @NotNull public static WireDumper of(@NotNull Bytes bytes, boolean align) { final BinaryWire wireIn = new BinaryWire(bytes); diff --git a/src/main/java/net/openhft/chronicle/wire/WireInternal.java b/src/main/java/net/openhft/chronicle/wire/WireInternal.java index b4d7e124f1..975adcd237 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireInternal.java +++ b/src/main/java/net/openhft/chronicle/wire/WireInternal.java @@ -65,7 +65,7 @@ public enum WireInternal { .setOverrideSelfDescribing(true), Wire::clear, BINARY_WIRE_SCOPED_INSTANCES_PER_THREAD); - static final ScopedThreadLocal> BYTES_SCOPED_THREAD_LOCAL = new ScopedThreadLocal<>( + static final ScopedThreadLocal> BYTES_SCOPED_THREAD_LOCAL = new ScopedThreadLocal<>( Wires::unmonitoredDirectBytes, Bytes::clear, BYTES_SCOPED_INSTANCES_PER_THREAD); diff --git a/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java b/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java index 9c6f390d0a..c2f02253bc 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java +++ b/src/main/java/net/openhft/chronicle/wire/WireMarshaller.java @@ -50,6 +50,7 @@ * * @param The type of the object to be marshalled/unmarshalled. */ +@SuppressWarnings({"rawtypes", "unchecked"}) public class WireMarshaller { private static final Class[] UNEXPECTED_FIELDS_PARAMETER_TYPES = {Object.class, ValueIn.class}; private static final FieldAccess[] NO_FIELDS = {}; @@ -384,7 +385,7 @@ private static Type[] consumeActualTypeArguments(Map prevTypeParam */ public WireMarshaller excludeFields(String... fieldNames) { Set fieldSet = new HashSet<>(Arrays.asList(fieldNames)); - return new WireMarshaller(Stream.of(fields) + return new WireMarshaller<>(Stream.of(fields) .filter(f -> !fieldSet.contains(f.field.getName())) .toArray(FieldAccess[]::new), isLeaf, defaultValue); @@ -401,7 +402,7 @@ public WireMarshaller excludeFields(String... fieldNames) { */ public void writeMarshallable(T t, @NotNull WireOut out) throws InvalidMarshallableException { ValidatableUtil.validate(t); - HexDumpBytesDescription bytes = out.bytesComment(); + HexDumpBytesDescription bytes = out.bytesComment(); bytes.adjustHexDumpIndentation(+1); try { for (@NotNull FieldAccess field : fields) @@ -1356,7 +1357,7 @@ public void getAsBytes(Object o, Bytes bytes) { * taking into account special cases where the field may be marshaled differently based on annotations. */ static class ObjectFieldAccess extends FieldAccess { - private final Class type; // Type of the object field + private final Class type; // Type of the object field private final AsMarshallable asMarshallable; // Annotation indicating if the field should be treated as marshallable /** @@ -1649,7 +1650,7 @@ protected void copy(Object from, Object to) { */ static class ArrayFieldAccess extends FieldAccess { private final Class componentType; - private final Class objectType; + private final Class objectType; ArrayFieldAccess(@NotNull Field field) { super(field); @@ -1799,7 +1800,7 @@ static class EnumSetFieldAccess extends FieldAccess { private final BiConsumer sequenceGetter; // The type of the enum component - private final Class componentType; + private final ClasscomponentType; // A supplier for creating an empty EnumSet of the component type private final Supplier enumSetSupplier; @@ -1819,7 +1820,7 @@ static class EnumSetFieldAccess extends FieldAccess { super(field, isLeaf); this.values = values; this.componentType = componentType; - this.enumSetSupplier = () -> EnumSet.noneOf(this.componentType); + this.enumSetSupplier = () -> EnumSet.noneOf((Class) this.componentType); this.sequenceGetter = (o, out) -> sequenceGetter(o, out, this.values, this.field, this.componentType); this.addAll = this::addAll; @@ -1841,7 +1842,7 @@ private static void sequenceGetter(Object o, ValueOut out, Object[] values, Field field, - Class componentType) + ClasscomponentType) throws InvalidMarshallableException { final EnumSet coll; try { @@ -1929,7 +1930,7 @@ private void addAll(EnumSet c, ValueIn in2) { if (!c.isEmpty()) c.clear(); while (in2.hasNextSequenceItem()) { - c.add(in2.asEnum(componentType)); + c.add(in2.asEnum((Class) componentType)); } } } @@ -1948,7 +1949,7 @@ static class CollectionFieldAccess extends FieldAccess { final Supplier collectionSupplier; // The component type of the Collection - private final Class componentType; + private final ClasscomponentType; private final Class type; private final BiConsumer sequenceGetter; @@ -1962,7 +1963,7 @@ static class CollectionFieldAccess extends FieldAccess { * @param componentType The type of the elements in the collection. * @param type The type of the collection itself. */ - public CollectionFieldAccess(@NotNull Field field, Boolean isLeaf, @Nullable Supplier collectionSupplier, Class componentType, Class type) { + public CollectionFieldAccess(@NotNull Field field, Boolean isLeaf, @Nullable Supplier collectionSupplier, ClasscomponentType, Classtype) { super(field, isLeaf); this.collectionSupplier = collectionSupplier == null ? newInstance() : collectionSupplier; this.componentType = componentType; diff --git a/src/main/java/net/openhft/chronicle/wire/WireOut.java b/src/main/java/net/openhft/chronicle/wire/WireOut.java index b3574f8c38..2637e5e5c2 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireOut.java +++ b/src/main/java/net/openhft/chronicle/wire/WireOut.java @@ -71,7 +71,7 @@ default ValueOut writeEventName(CharSequence key) { * @throws InvalidMarshallableException if there's an error marshalling the event. */ @SuppressWarnings({"rawtypes", "unchecked"}) - default ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { + default ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { if (eventKey instanceof WireKey) return writeEventName((WireKey) eventKey); if (eventKey instanceof CharSequence) diff --git a/src/main/java/net/openhft/chronicle/wire/WireType.java b/src/main/java/net/openhft/chronicle/wire/WireType.java index e951ad0375..f7cf9260ee 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireType.java +++ b/src/main/java/net/openhft/chronicle/wire/WireType.java @@ -61,6 +61,7 @@ public enum WireType implements Function, Wire>, LicenceCheck { TEXT { private final boolean TEXT_AS_YAML = Jvm.getBoolean("wire.testAsYaml"); + @SuppressWarnings("deprecation") @NotNull @Override public Wire apply(@NotNull Bytes bytes) { @@ -287,6 +288,7 @@ public T fromString(@NotNull CharSequence cs) throws InvalidMarshallableExce }, // for backward compatibility, this doesn't support types JSON { + @SuppressWarnings("deprecation") @NotNull @Override public Wire apply(@NotNull Bytes bytes) { @@ -313,6 +315,7 @@ public boolean isText() { } }, YAML { + @SuppressWarnings("deprecation") @NotNull @Override public Wire apply(@NotNull Bytes bytes) { @@ -517,7 +520,7 @@ public Supplier newLongArrayReference() { */ public String asString(Object marshallable) { ValidatableUtil.startValidateDisabled(); - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { final Bytes bytes = stlBytes.get(); asBytes(marshallable, bytes); return bytes.toString(); @@ -578,7 +581,7 @@ public T fromString(@NotNull CharSequence cs) throws InvalidMarshallableExce public T fromString(Class tClass, @NotNull CharSequence cs) throws InvalidMarshallableException { if (cs.length() == 0) throw new IllegalArgumentException("cannot deserialize an empty string"); - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { Bytes bytes = stlBytes.get(); bytes.appendUtf8(cs); Wire wire = apply(bytes); @@ -706,7 +709,7 @@ public void toFileAsMap(@NotNull String filename, @NotN public void toFileAsMap(@NotNull String filename, @NotNull Map map, boolean compact) throws IOException, InvalidMarshallableException { String tempFilename = IOTools.tempName(filename); - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { Bytes bytes = stlBytes.get(); Wire wire = apply(bytes); for (@NotNull Map.Entry entry : map.entrySet()) { @@ -737,7 +740,7 @@ public void toFileAsMap(@NotNull String filename, @NotN */ public void toFile(@NotNull String filename, WriteMarshallable marshallable) throws IOException, InvalidMarshallableException { String tempFilename = IOTools.tempName(filename); - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { Bytes bytes = stlBytes.get(); Wire wire = apply(bytes); wire.getValueOut().typedMarshallable(marshallable); @@ -759,7 +762,7 @@ public void toFile(@NotNull String filename, WriteMarshallable marshallable) thr @NotNull String asHexString(Object marshallable) { ValidatableUtil.startValidateDisabled(); - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { final Bytes bytes = stlBytes.get(); asBytes(marshallable, bytes); return bytes.toHexString(); @@ -795,7 +798,7 @@ String asHexString(Object marshallable) { */ @Nullable public Map asMap(@NotNull CharSequence cs) throws InvalidMarshallableException { - try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { + try (ScopedResource> stlBytes = Wires.acquireBytesScoped()) { Bytes bytes = stlBytes.get(); bytes.appendUtf8(cs); Wire wire = apply(bytes); diff --git a/src/main/java/net/openhft/chronicle/wire/Wires.java b/src/main/java/net/openhft/chronicle/wire/Wires.java index 40b46ad2f8..2aa75fc5d6 100644 --- a/src/main/java/net/openhft/chronicle/wire/Wires.java +++ b/src/main/java/net/openhft/chronicle/wire/Wires.java @@ -381,7 +381,7 @@ public static CharSequence asText(@NotNull WireIn wireIn, Bytes output) { * @param bytes the byte buffer for the wire * @return a new instance of JSONWire */ - private static Wire newJsonWire(Bytes bytes) { + private static Wire newJsonWire(Bytes bytes) { return new JSONWire(bytes).useTypes(true).trimFirstCurly(false).useTextDocuments(); } @@ -417,7 +417,7 @@ public static Bytes asJson(@NotNull WireIn wireIn, Bytes output) throws In * @param bytes the byte buffer for the wire * @return a new instance of TextWire with timestamps */ - private static Wire newTextWire(Bytes bytes) { + private static Wire newTextWire(Bytes bytes) { return new TextWire(bytes).addTimeStamps(true); } @@ -526,7 +526,7 @@ public static int toIntU30(long l, @NotNull String error) { * @param position the position at which to lock * @return true if the lock was successfully acquired, false otherwise */ - public static boolean acquireLock(@NotNull BytesStore store, long position) { + public static boolean acquireLock(@NotNull BytesStore store, long position) { return store.compareAndSwapInt(position, NOT_INITIALIZED, NOT_COMPLETE); } @@ -586,14 +586,14 @@ public static long readWire(@NotNull WireIn wireIn, long size, @NotNull ReadMars * * @return the created Bytes instance */ - static Bytes unmonitoredDirectBytes() { - Bytes bytes = Bytes.allocateElasticDirect(128); + static Bytes unmonitoredDirectBytes() { + Bytes bytes = Bytes.allocateElasticDirect(128); IOTools.unmonitor(bytes); return bytes; } @NotNull - public static ScopedResource> acquireBytesScoped() { + public static ScopedResource> acquireBytesScoped() { return WireInternal.BYTES_SCOPED_THREAD_LOCAL.get(); } diff --git a/src/main/java/net/openhft/chronicle/wire/YamlWire.java b/src/main/java/net/openhft/chronicle/wire/YamlWire.java index 0ef8cd5586..ebd864a4ce 100644 --- a/src/main/java/net/openhft/chronicle/wire/YamlWire.java +++ b/src/main/java/net/openhft/chronicle/wire/YamlWire.java @@ -376,7 +376,7 @@ public boolean hintReadInputOrder() { @Override @NotNull - public T methodWriter(@NotNull Class tClass, Class... additional) { + public T methodWriter(@NotNull Class tClass, Class... additional) { VanillaMethodWriterBuilder builder = new VanillaMethodWriterBuilder<>(tClass, WireType.YAML, () -> newTextMethodWriterInvocationHandler(tClass)); @@ -395,7 +395,7 @@ public T methodWriter(@NotNull Class tClass, Class... additional) { * @return A new instance of TextMethodWriterInvocationHandler. */ @NotNull - TextMethodWriterInvocationHandler newTextMethodWriterInvocationHandler(Class... interfaces) { + TextMethodWriterInvocationHandler newTextMethodWriterInvocationHandler(Class... interfaces) { for (Class anInterface : interfaces) { Comment c = Jvm.findAnnotation(anInterface, Comment.class); if (c != null) @@ -1304,7 +1304,7 @@ StringBuilder textTo0(@NotNull StringBuilder a) { @NotNull @Override - public WireIn bytesMatch(@NotNull BytesStore compareBytes, BooleanConsumer consumer) { + public WireIn bytesMatch(@NotNull BytesStore compareBytes, BooleanConsumer consumer) { throw new UnsupportedOperationException(yt.toString()); } diff --git a/src/main/java/net/openhft/chronicle/wire/YamlWireOut.java b/src/main/java/net/openhft/chronicle/wire/YamlWireOut.java index ab168f1c4e..45477ab7ea 100644 --- a/src/main/java/net/openhft/chronicle/wire/YamlWireOut.java +++ b/src/main/java/net/openhft/chronicle/wire/YamlWireOut.java @@ -59,17 +59,17 @@ public abstract class YamlWireOut> extends AbstractWire @Deprecated(/* to remove in x.28 */) private static final boolean APPEND_0 = Jvm.getBoolean("bytes.append.0", true); - public static final BytesStore TYPE = BytesStore.from("!type "); + public static final BytesStore TYPE = BytesStore.from("!type "); static final String NULL = "!null \"\""; static final BitSet STARTS_QUOTE_CHARS = new BitSet(); static final BitSet QUOTE_CHARS = new BitSet(); - static final BytesStore COMMA_SPACE = BytesStore.from(", "); - static final BytesStore COMMA_NEW_LINE = BytesStore.from(",\n"); - static final BytesStore NEW_LINE = BytesStore.from("\n"); - static final BytesStore EMPTY_AFTER_COMMENT = BytesStore.wrap(new byte[0]); // not the same as EMPTY, so we can check this value. - static final BytesStore EMPTY = BytesStore.from(""); - static final BytesStore SPACE = BytesStore.from(" "); - static final BytesStore END_FIELD = NEW_LINE; + static final BytesStore COMMA_SPACE = BytesStore.from(", "); + static final BytesStore COMMA_NEW_LINE = BytesStore.from(",\n"); + static final BytesStore NEW_LINE = BytesStore.from("\n"); + static final BytesStore EMPTY_AFTER_COMMENT = BytesStore.wrap(new byte[0]); // not the same as EMPTY, so we can check this value. + static final BytesStore EMPTY = BytesStore.from(""); + static final BytesStore SPACE = BytesStore.from(" "); + static final BytesStore END_FIELD = NEW_LINE; static final char[] HEXADECIMAL = "0123456789ABCDEF".toCharArray(); // Static initializer block to configure quote characters for the YAML writer @@ -96,8 +96,7 @@ public abstract class YamlWireOut> extends AbstractWire */ protected YamlWireOut(@NotNull Bytes bytes, boolean use8bit) { super(bytes, use8bit); - bytes.decimaliser(GeneralDecimaliser.GENERAL) - .fpAppend0(APPEND_0); + bytes.decimaliser(GeneralDecimaliser.GENERAL); } /** @@ -168,7 +167,7 @@ public ValueOut write(@NotNull CharSequence name) { } @Override - public ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { + public ValueOut writeEvent(Class expectedType, Object eventKey) throws InvalidMarshallableException { if (eventKey instanceof WireKey) return writeEventName((WireKey) eventKey); if (eventKey instanceof CharSequence) @@ -519,7 +518,7 @@ class YamlValueOut implements ValueOut, CommentAnnotationNotifier { // The current separator being used. @NotNull - protected BytesStore sep = BytesStore.empty(); + protected BytesStore sep = BytesStore.empty(); // Flag indicating if the value is a leaf node (i.e., doesn't have child elements). protected boolean leaf = false; @@ -666,7 +665,7 @@ public T text(@Nullable CharSequence s) { @NotNull @Override - public T bytes(@Nullable BytesStore fromBytes) { + public T bytes(@Nullable BytesStore fromBytes) { if (dropDefault) { if (fromBytes == null) return wireOut(); @@ -713,7 +712,7 @@ public T rawText(CharSequence value) { * @param fromBytes The BytesStore object to inspect. * @return True if the content is textual, otherwise false. */ - private boolean isText(@Nullable BytesStore fromBytes) { + private boolean isText(@Nullable BytesStore fromBytes) { if (fromBytes == null) return true; @@ -761,7 +760,7 @@ public T bytes(@NotNull String type, byte[] byteArray) { @NotNull @Override - public T bytes(@NotNull String type, @Nullable BytesStore bytesStore) { + public T bytes(@NotNull String type, @Nullable BytesStore bytesStore) { if (dropDefault) { writeSavedEventName(); } @@ -1447,7 +1446,7 @@ public T marshallable(@NotNull WriteMarshallable object) throws InvalidMarshalla newLine(); object.writeMarshallable(wireOut()); - @Nullable BytesStore popSep = null; + @Nullable BytesStore popSep = null; if (wasLeaf) { if (sep.endsWith(' ')) append(" "); @@ -1501,7 +1500,7 @@ public T marshallable(@NotNull Serializable object) throws InvalidMarshallableEx newLine(); writeSerializable(object); - @Nullable BytesStore popSep = null; + @Nullable BytesStore popSep = null; if (wasLeaf) { leaf = false; } else if (seps.size() > 0) { @@ -1657,7 +1656,7 @@ public YamlValueOut write(@NotNull CharSequence name) { * @throws InvalidMarshallableException If the object cannot be serialized. */ @NotNull - public YamlValueOut write(Class expectedType, @NotNull Object objectKey) throws InvalidMarshallableException { + public YamlValueOut write(Class expectedType, @NotNull Object objectKey) throws InvalidMarshallableException { if (dropDefault) { if (expectedType != String.class) throw new UnsupportedOperationException("todo"); diff --git a/src/test/java/net/openhft/chronicle/wire/BinaryInTextTest.java b/src/test/java/net/openhft/chronicle/wire/BinaryInTextTest.java index c853c29356..154096fc29 100644 --- a/src/test/java/net/openhft/chronicle/wire/BinaryInTextTest.java +++ b/src/test/java/net/openhft/chronicle/wire/BinaryInTextTest.java @@ -56,7 +56,7 @@ public void testBytesFromText() { Bytes a = wireType.fromString(Bytes.class, "A=="); assertEquals("A==", a.toString()); - BytesStore a2 = wireType.fromString(BytesStore.class, "A=="); + BytesStore a2 = wireType.fromString(BytesStore.class, "A=="); assertEquals("A==", a2.toString()); Bytes b = wireType.fromString(Bytes.class, "!!binary BA=="); @@ -89,6 +89,6 @@ public void testReserialize() { @SuppressWarnings("rawtypes") static class BIT extends SelfDescribingMarshallable { Bytes b; - BytesStore c; + BytesStore c; } } diff --git a/src/test/java/net/openhft/chronicle/wire/BinaryWire2Test.java b/src/test/java/net/openhft/chronicle/wire/BinaryWire2Test.java index 18cf57b704..0cf1036ea0 100644 --- a/src/test/java/net/openhft/chronicle/wire/BinaryWire2Test.java +++ b/src/test/java/net/openhft/chronicle/wire/BinaryWire2Test.java @@ -62,6 +62,7 @@ public static Collection wireTypes() { } // Create a new BinaryWire instance based on the current test configuration + @SuppressWarnings("deprecation") @NotNull private BinaryWire createWire() { bytes.clear(); @@ -673,7 +674,7 @@ public void testCompression(String comp) { // Create a repetitive string and convert it to BytesStore @NotNull String str = "xxxxxxxxxxxxxxxx2xxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyy2yyyyyyyyyyyyyyyyy"; - BytesStore bytes = Bytes.from(str); + BytesStore bytes = Bytes.from(str); // Write the string to the wire using the specified compression wire.write().bytes(bytes); @@ -848,7 +849,7 @@ public void testBytesLiteral() { // Read the nested wire's content and check its value wire1.readDocument(null, w -> { - @Nullable final BytesStore bytesStore = w.read(() -> "nested") + @Nullable final BytesStore bytesStore = w.read(() -> "nested") .bytesLiteral(); assertEquals(wire.bytes(), bytesStore); }); diff --git a/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java b/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java index 985ab94ccd..d8b7cddc0b 100644 --- a/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java +++ b/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java @@ -141,6 +141,7 @@ public void readWriteString() { } // Create a BinaryWire with pre-defined properties set during initialization + @SuppressWarnings("deprecation") @NotNull private BinaryWire createWire() { bytes.clear(); @@ -1762,7 +1763,9 @@ private void createWireFromFileAnd(File file, Consumer<@ScopeConfined Wire> wire final Bytes bytes = mappedFile.acquireBytesForWrite(owner, 0); Wire wire = WireType.BINARY.apply(bytes); wireConsumer.accept(wire); - ((MappedBytesStore) bytes.bytesStore()).syncUpTo(8192); + @SuppressWarnings("unchecked") + MappedBytesStore mappedBytesStore = (MappedBytesStore) (BytesStore) bytes.bytesStore(); + mappedBytesStore.syncUpTo(8192); bytes.releaseLast(owner); } } diff --git a/src/test/java/net/openhft/chronicle/wire/DocumentContextTest.java b/src/test/java/net/openhft/chronicle/wire/DocumentContextTest.java index 54a03ad760..42ee7609ca 100644 --- a/src/test/java/net/openhft/chronicle/wire/DocumentContextTest.java +++ b/src/test/java/net/openhft/chronicle/wire/DocumentContextTest.java @@ -46,6 +46,7 @@ public void multiMessageText() { } // Test multi-message serialization in BINARY format. + @SuppressWarnings("deprecation") @Test public void multiMessageBinary() { // Create a wire of BINARY type with hex dump diff --git a/src/test/java/net/openhft/chronicle/wire/MethodReaderArgumentsRecycleTest.java b/src/test/java/net/openhft/chronicle/wire/MethodReaderArgumentsRecycleTest.java index 66a037cfd4..ddcdc208ec 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodReaderArgumentsRecycleTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodReaderArgumentsRecycleTest.java @@ -39,6 +39,7 @@ public class MethodReaderArgumentsRecycleTest extends WireTestCommon { private volatile Object lastArgumentRef; // This method sets up the test environment before each test case. + @SuppressWarnings("deprecation") @Before public void setUp() { // Create a new BinaryWire backed by a dynamically expanding Bytes object. diff --git a/src/test/java/net/openhft/chronicle/wire/MethodReaderDelegationTest.java b/src/test/java/net/openhft/chronicle/wire/MethodReaderDelegationTest.java index 66576b9933..0480718f89 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodReaderDelegationTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodReaderDelegationTest.java @@ -248,6 +248,7 @@ private void testUnsuccessfulCallNoDelegate(boolean proxy, boolean third, boolea } // Test to ensure that user exceptions are not delegated during method calls + @SuppressWarnings("deprecation") @Test public void testUserExceptionsAreNotDelegated() { // Initialize a wire with BINARY type and allocate space on the heap diff --git a/src/test/java/net/openhft/chronicle/wire/MethodReaderInterceptorReturnsTest.java b/src/test/java/net/openhft/chronicle/wire/MethodReaderInterceptorReturnsTest.java index 5c0fbc61be..82334a9381 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodReaderInterceptorReturnsTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodReaderInterceptorReturnsTest.java @@ -83,6 +83,7 @@ public void testInterceptingReaderConcurrentCreation() throws ExecutionException } } + @SuppressWarnings("deprecation") private void doTestInterceptorSupportedInGeneratedCode(CountDownLatch readerCreateLatch, boolean addDummyInstance) { BinaryWire wire = new BinaryWire(Bytes.allocateElasticOnHeap(128)); wire.usePadding(true); @@ -151,6 +152,7 @@ private void doTestInterceptorSupportedInGeneratedCode(CountDownLatch readerCrea * Covers {@link GeneratingMethodReaderInterceptorReturns}, which allows intervening in method reader's logic * without resorting to reflective calls. */ + @SuppressWarnings("deprecation") @Test public void testGeneratingAggregatingInfoInterceptor() { // Create a wire with a buffer of size 128 and padding enabled @@ -192,6 +194,7 @@ public void testGeneratingAggregatingInfoInterceptor() { * Covers {@link GeneratingMethodReaderInterceptorReturns}, which allows intervening in method reader's logic * without resorting to reflective calls. */ + @SuppressWarnings("deprecation") @Test public void testGeneratingSkippingInterceptor() { // Create a wire with a buffer of size 128 and padding enabled diff --git a/src/test/java/net/openhft/chronicle/wire/MethodReaderMethodIdsTest.java b/src/test/java/net/openhft/chronicle/wire/MethodReaderMethodIdsTest.java index d664692150..975b755802 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodReaderMethodIdsTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodReaderMethodIdsTest.java @@ -33,6 +33,7 @@ public class MethodReaderMethodIdsTest extends WireTestCommon { /** * Test case to verify that method calls can be identified by Method IDs. */ + @SuppressWarnings("deprecation") @Test public void shouldDetermineMethodNamesFromMethodIds() { final BinaryWire wire = new BinaryWire(Bytes.allocateElasticOnHeap()); diff --git a/src/test/java/net/openhft/chronicle/wire/MethodReaderNonStandardInstancesTest.java b/src/test/java/net/openhft/chronicle/wire/MethodReaderNonStandardInstancesTest.java index 2fc2af5948..e264c8c50e 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodReaderNonStandardInstancesTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodReaderNonStandardInstancesTest.java @@ -40,6 +40,7 @@ public class MethodReaderNonStandardInstancesTest extends WireTestCommon { * Test case to verify that an anonymous class can be passed to MethodReader. * It sets up a writer, writes a message, then uses a MethodReader to read and process the message using an anonymous class implementation. */ + @SuppressWarnings("deprecation") @Test public void testAnonymousClassCanBePassedToMethodReader() { // Initialization of the wire with padding @@ -73,6 +74,7 @@ public void call() { * Test case to verify that a core class can be passed to MethodReader. * Similar to the above test but uses a BooleanConsumer core class. */ + @SuppressWarnings("deprecation") @Test public void testCoreClassCanBePassedToMethodReader() throws Exception { // Initialization of the wire with padding @@ -106,6 +108,7 @@ public void accept(Boolean value) { * Test case to verify that a lambda expression can be passed to MethodReader. * It demonstrates how a lambda can be used to implement the reading functionality. */ + @SuppressWarnings("deprecation") @Test public void testLambdaCanBePassedToMethodReader() { // Initialization of the wire with padding diff --git a/src/test/java/net/openhft/chronicle/wire/MethodReaderSuperInterfaceForSeveralReturnTypesTest.java b/src/test/java/net/openhft/chronicle/wire/MethodReaderSuperInterfaceForSeveralReturnTypesTest.java index d78a357de8..bf7172fe3e 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodReaderSuperInterfaceForSeveralReturnTypesTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodReaderSuperInterfaceForSeveralReturnTypesTest.java @@ -35,6 +35,7 @@ public class MethodReaderSuperInterfaceForSeveralReturnTypesTest extends WireTes * It aims to verify that method calls from interfaces `A`, `B`, and `C` (all having a relation to interface `D`) * are correctly written to and read from a BinaryWire. */ + @SuppressWarnings("deprecation") @Test public void test() { // Initialization of the wire with padding diff --git a/src/test/java/net/openhft/chronicle/wire/MethodWriterBytesTest.java b/src/test/java/net/openhft/chronicle/wire/MethodWriterBytesTest.java index a592473634..6854803da5 100644 --- a/src/test/java/net/openhft/chronicle/wire/MethodWriterBytesTest.java +++ b/src/test/java/net/openhft/chronicle/wire/MethodWriterBytesTest.java @@ -39,7 +39,7 @@ public class MethodWriterBytesTest extends net.openhft.chronicle.wire.WireTestCo * An interface defining a single method that accepts a Bytes message. */ interface Print { - void msg(Bytes message); + void msg(Bytes message); } /** @@ -65,7 +65,7 @@ public void test() throws InterruptedException { /** * A helper method to add Bytes messages to the blocking queue. */ - private void println(Bytes bytes) { + private void println(Bytes bytes) { q.add(bytes); } diff --git a/src/test/java/net/openhft/chronicle/wire/SerializableObjectTest.java b/src/test/java/net/openhft/chronicle/wire/SerializableObjectTest.java index 1f1c2b3360..dfad114615 100644 --- a/src/test/java/net/openhft/chronicle/wire/SerializableObjectTest.java +++ b/src/test/java/net/openhft/chronicle/wire/SerializableObjectTest.java @@ -253,7 +253,7 @@ private static boolean isSerializableEqualsByObject(Object o) { * @param o An optional instance of the class to check. If null, a new instance will be created. * @return true if the class is serializable and deserializable, and the original and deserialized objects are equal; false otherwise. */ - private static boolean isSerializableEquals(Class aClass, Object o) { + private static boolean isSerializableEquals(Class aClass, Object o) { try { // Create an instance if not provided Object source = o == null ? aClass.newInstance() : o; diff --git a/src/test/java/net/openhft/chronicle/wire/TextWireTest.java b/src/test/java/net/openhft/chronicle/wire/TextWireTest.java index e3c018c170..8c3eed543a 100644 --- a/src/test/java/net/openhft/chronicle/wire/TextWireTest.java +++ b/src/test/java/net/openhft/chronicle/wire/TextWireTest.java @@ -2778,7 +2778,7 @@ public void readMarshallable(@NotNull WireIn wire) throws IORuntimeException { // Class holding byte storage and a long, with custom serialization logic. static class DtoWithBytesField extends SelfDescribingMarshallable { - BytesStore bytes; + BytesStore bytes; long another; // Implement custom deserialization logic for this object. diff --git a/src/test/java/net/openhft/chronicle/wire/TriviallyCopyableTest.java b/src/test/java/net/openhft/chronicle/wire/TriviallyCopyableTest.java index f11b34e2c3..3fa2be7602 100644 --- a/src/test/java/net/openhft/chronicle/wire/TriviallyCopyableTest.java +++ b/src/test/java/net/openhft/chronicle/wire/TriviallyCopyableTest.java @@ -65,6 +65,7 @@ public void unsafe2() { // Inner class representing a binary-serializable data structure static class AA extends BytesInBinaryMarshallable { + static final int OFFSET = BytesUtil.triviallyCopyableStart(AA.class); static final int FORMAT = 1; // version format for serialization // natural order on a 64-bit JVM. @@ -99,7 +100,7 @@ public void readMarshallable(BytesIn bytes) throws IORuntimeException { case FORMAT: if (OS.is64Bit()) // Perform direct memory read if 64-bit OS - bytes.unsafeReadObject(this, 32); + bytes.unsafeReadObject(this, OFFSET, 32); else // Read individual fields if not 64-bit OS readMarshallable1(bytes); @@ -129,7 +130,7 @@ public void writeMarshallable(BytesOut bytes) { bytes.writeStopBit(FORMAT); if (OS.is64Bit()) // Directly write the memory contents if 64-bit OS - bytes.unsafeWriteObject(this, 32); + bytes.unsafeWriteObject(this, OFFSET, 32); else // Write individual fields if not 64-bit OS writeMarshallable1(bytes); diff --git a/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java b/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java index 5c8699d515..b625fbe6bc 100644 --- a/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java +++ b/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java @@ -1998,7 +1998,7 @@ enum YWTSingleton { } interface PutData { - void put(Bytes key, Data data); + void put(Bytes key, Data data); } static class FieldWithComment extends SelfDescribingMarshallable { diff --git a/src/test/java/net/openhft/chronicle/wire/bytesmarshallable/PerfRegressionHolder.java b/src/test/java/net/openhft/chronicle/wire/bytesmarshallable/PerfRegressionHolder.java index 058c0e1683..c897900984 100644 --- a/src/test/java/net/openhft/chronicle/wire/bytesmarshallable/PerfRegressionHolder.java +++ b/src/test/java/net/openhft/chronicle/wire/bytesmarshallable/PerfRegressionHolder.java @@ -182,7 +182,7 @@ public void writeMarshallable(BytesOut bytes) throws IllegalStateException, B // Writes the provided BytesStore to the provided byte sequence as an 8-bit byte sequence @SuppressWarnings("rawtypes") - protected void write8Bit(BytesOut bytes, BytesStore a) { + protected void write8Bit(BytesOut bytes, BytesStore a) { if (a == null) { bytes.writeStopBit(-1); } else { @@ -252,7 +252,7 @@ protected void read8Bit(BytesIn bytes, Bytes a) { // and then writing each byte individually. @SuppressWarnings("rawtypes") @Override - protected void write8Bit(BytesOut bytes, BytesStore a) { + protected void write8Bit(BytesOut bytes, BytesStore a) { final int length = a.length(); bytes.writeStopBit(length); for (int i = 0; i < length; i++) diff --git a/src/test/java/net/openhft/chronicle/wire/channel/PerfThroughputMain.java b/src/test/java/net/openhft/chronicle/wire/channel/PerfThroughputMain.java index ce67c245d4..ac5fcaab24 100644 --- a/src/test/java/net/openhft/chronicle/wire/channel/PerfThroughputMain.java +++ b/src/test/java/net/openhft/chronicle/wire/channel/PerfThroughputMain.java @@ -113,7 +113,7 @@ private static void doTest(String desc, ChronicleChannelSupplier channelSupplier long end = start + RUN_TIME * 1000L; // Calculate window size based on buffer and number of clients - int window = bufferSize / (4 + size); + int window = bufferSize / (4 + size); if (size < 1024) window *= 2; if (nClients > 4) diff --git a/src/test/java/net/openhft/chronicle/wire/marshallable/BytesUsageTest.java b/src/test/java/net/openhft/chronicle/wire/marshallable/BytesUsageTest.java index 29f05e1e6e..67ec53eb05 100644 --- a/src/test/java/net/openhft/chronicle/wire/marshallable/BytesUsageTest.java +++ b/src/test/java/net/openhft/chronicle/wire/marshallable/BytesUsageTest.java @@ -39,7 +39,7 @@ public class BytesUsageTest extends WireTestCommon { @Test public void testBytes() { // Initialize a BytesStore instance from a string - BytesStore value = Bytes.from("helloWorld"); + BytesStore value = Bytes.from("helloWorld"); // Simple usage of BytesWrapper and setting its clOrdId value { diff --git a/src/test/java/net/openhft/chronicle/wire/marshallable/ScalarValues.java b/src/test/java/net/openhft/chronicle/wire/marshallable/ScalarValues.java index 6281b2bfc3..52a44bde4e 100644 --- a/src/test/java/net/openhft/chronicle/wire/marshallable/ScalarValues.java +++ b/src/test/java/net/openhft/chronicle/wire/marshallable/ScalarValues.java @@ -102,7 +102,7 @@ public ScalarValues(int i) { /** * A simple dynamic enumeration used in ScalarValues. */ -enum TestDynamicEnum implements DynamicEnum { +enum TestDynamicEnum implements DynamicEnum { ONE, // Represents the first value TWO, // Represents the second value THREE // Represents the third value diff --git a/src/test/java/net/openhft/chronicle/wire/method/MethodWriterTest.java b/src/test/java/net/openhft/chronicle/wire/method/MethodWriterTest.java index 436218ae9d..b22dd8882d 100644 --- a/src/test/java/net/openhft/chronicle/wire/method/MethodWriterTest.java +++ b/src/test/java/net/openhft/chronicle/wire/method/MethodWriterTest.java @@ -118,6 +118,7 @@ public void testDefault() { Assert.assertTrue(wire.toString().startsWith("callToDefaultMethod: hello world")); } + @SuppressWarnings("deprecation") @Test public void multiOut() { Wire wire = WireType.TEXT.apply(Bytes.allocateElasticOnHeap()); diff --git a/src/test/java/net/openhft/chronicle/wire/utils/dto/AbstractEvent.java b/src/test/java/net/openhft/chronicle/wire/utils/dto/AbstractEvent.java index cd9b512ae0..0233ae8dee 100644 --- a/src/test/java/net/openhft/chronicle/wire/utils/dto/AbstractEvent.java +++ b/src/test/java/net/openhft/chronicle/wire/utils/dto/AbstractEvent.java @@ -14,6 +14,7 @@ * * @param The type of the event extending this class, used for fluent interface pattern. */ +@SuppressWarnings("unchecked") public class AbstractEvent> extends SelfDescribingMarshallable { @ShortText private long sender;