Skip to content

Commit

Permalink
Added fail on warning lint for Javadoc, and rawtypes fixes for Bytes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-lawrey committed Apr 29, 2024
1 parent 38b8949 commit 6d7878c
Show file tree
Hide file tree
Showing 47 changed files with 146 additions and 123 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -95,7 +95,7 @@ public void copyTo(Data data) {
}

@Override
public BytesStore bytesStore() {
public BytesStore<?, ?> bytesStore() {
return bytesStore;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
*
* @param <M> Represents the meta-data associated with the class being generated.
*/
@SuppressWarnings("unchecked")
public abstract class AbstractClassGenerator<M extends AbstractClassGenerator.MetaData<M>> {

// TODO Use Wires.loadFromJava() instead of a public static final
Expand Down Expand Up @@ -140,7 +141,7 @@ public synchronized <T> Class<T> acquireClass(ClassLoader classLoader) {
}

// Compile and load the generated class.
return CACHED_COMPILER.loadFromJava(classLoader, fullName, sourceCode.toString());
return (Class<T>) 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*
* @param <E> The type parameter extending AbstractEventCfg
*/
@SuppressWarnings("unchecked")
public class AbstractEventCfg<E extends AbstractEventCfg<E>> extends AbstractMarshallableCfg implements Event<E> {

// The unique identifier for the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
* <p>
* 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.
* <p>
*
* @see LongConverter for the interface this abstract class implements.
*/
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/net/openhft/chronicle/wire/BinaryWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/openhft/chronicle/wire/DefaultValueIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/openhft/chronicle/wire/HashWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/openhft/chronicle/wire/JSONWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<WeakReference<StopCharsTester>> STRICT_ESCAPED_END_OF_TEXT_JSON = new ThreadLocal<>();
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -964,7 +964,7 @@ public JSONWire rawText(CharSequence value) {
}

@Override
public @NotNull <V> JSONWire object(@NotNull Class<V> expectedType, V v) throws InvalidMarshallableException {
public @NotNull <V> JSONWire object(@NotNull Class<? extends V> expectedType, V v) throws InvalidMarshallableException {
return (JSONWire) (useTypes ? super.object(v) : super.object(expectedType, v));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ default void writeMap(@NotNull Map<?, ?> map) throws UnrecoverableTimeoutExcepti
*/
@SuppressWarnings("rawtypes")
@NotNull
default <T> T methodWriter(@NotNull Class<T> tClass, Class... additional) {
default <T> T methodWriter(@NotNull Class<T> tClass, Class<?>... additional) {
VanillaMethodWriterBuilder<T> builder =
(VanillaMethodWriterBuilder<T>) methodWriterBuilder(false, tClass);
Stream.of(additional).forEach(builder::addInterface);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/openhft/chronicle/wire/QueryWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/openhft/chronicle/wire/RawWire.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 6d7878c

Please sign in to comment.