Skip to content

Commit

Permalink
Build: fix warnings in TypeDecoder Class (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonydenyer authored and iikirilov committed Sep 24, 2019
1 parent ba94fa4 commit 8d05f3d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions abi/src/main/java/org/web3j/abi/TypeDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.function.BiFunction;

import org.web3j.abi.datatypes.AbiTypes;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.Array;
import org.web3j.abi.datatypes.Bool;
Expand Down Expand Up @@ -185,22 +186,22 @@ static Type instantiateArrayType(TypeReference ref, Object value)
? ((TypeReference.StaticArrayTypeReference) ref).getSize()
: -1;
if (arraySize <= 0) {
listcons = DynamicArray.class.getConstructor(new Class[] {Class.class, List.class});
listcons = DynamicArray.class.getConstructor(Class.class, List.class);
} else {
Class arrayClass =
Class<?> arrayClass =
Class.forName("org.web3j.abi.datatypes.generated.StaticArray" + arraySize);
listcons = arrayClass.getConstructor(new Class[] {Class.class, List.class});
listcons = arrayClass.getConstructor(Class.class, List.class);
}
// create a list of arguments coerced to the correct type of sub-TypeReference
ArrayList transformedList = new ArrayList(values.size());
ArrayList<Type> transformedList = new ArrayList<Type>(values.size());
TypeReference subTypeReference = ref.getSubTypeReference();
for (Object o : values) {
transformedList.add(instantiateType(subTypeReference, o));
}
return (Type) listcons.newInstance(ref.getClassType(), transformedList);
}

static Type instantiateAtomicType(Class referenceClass, Object value)
static Type instantiateAtomicType(Class<?> referenceClass, Object value)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException, ClassNotFoundException {
Object constructorArg = null;
Expand Down Expand Up @@ -239,7 +240,8 @@ static Type instantiateAtomicType(Class referenceClass, Object value)
+ " of type "
+ value.getClass());
}
Constructor cons = referenceClass.getConstructor(new Class[] {constructorArg.getClass()});
Class<?>[] types = new Class[] {constructorArg.getClass()};
Constructor cons = referenceClass.getConstructor(types);
return (Type) cons.newInstance(constructorArg);
}

Expand Down Expand Up @@ -336,13 +338,7 @@ static <T extends Type> T decodeDynamicArray(
int length = decodeUintAsInt(input, offset);

BiFunction<List<T>, String, T> function =
(elements, typeName) -> {
if (elements.isEmpty()) {
return (T) DynamicArray.empty(typeName);
} else {
return (T) new DynamicArray<>(elements);
}
};
(elements, typeName) -> (T) new DynamicArray(AbiTypes.getType(typeName), elements);

int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING;

Expand All @@ -366,7 +362,7 @@ static BigInteger asBigInteger(Object arg) {

static List arrayToList(Object array) {
int len = java.lang.reflect.Array.getLength(array);
ArrayList rslt = new ArrayList(len);
ArrayList<Object> rslt = new ArrayList<Object>(len);
for (int i = 0; i < len; i++) {
rslt.add(java.lang.reflect.Array.get(array, i));
}
Expand Down

0 comments on commit 8d05f3d

Please sign in to comment.