From 215cb537b645e7d620ddeaf26f04fccc5037ab6e Mon Sep 17 00:00:00 2001 From: Nandakumar Vadivelu Date: Mon, 12 Feb 2024 00:03:42 +0530 Subject: [PATCH] [Java] Reduce guava TypeToken dependency. --- NOTICE | 1 + .../fury/builder/BaseObjectCodecBuilder.java | 2 +- .../org/apache/fury/builder/CodecBuilder.java | 2 +- .../org/apache/fury/builder/CodecUtils.java | 2 +- .../fury/builder/CompatibleCodecBuilder.java | 2 +- .../fury/builder/MetaSharedCodecBuilder.java | 2 +- .../fury/builder/ObjectCodecBuilder.java | 2 +- .../apache/fury/codegen/CodegenContext.java | 2 +- .../org/apache/fury/codegen/Expression.java | 2 +- .../apache/fury/codegen/ExpressionUtils.java | 2 +- .../fury/codegen/ExpressionVisitor.java | 2 +- .../org/apache/fury/reflect/TypeToken.java | 335 ++++++++++++++++++ .../apache/fury/resolver/ClassResolver.java | 2 +- .../apache/fury/resolver/FieldResolver.java | 2 +- .../fury/serializer/ObjectSerializer.java | 2 +- .../fury/serializer/StructSerializer.java | 2 +- .../collection/AbstractMapSerializer.java | 2 +- .../java/org/apache/fury/type/ClassDef.java | 2 +- .../java/org/apache/fury/type/Descriptor.java | 2 +- .../org/apache/fury/type/GenericType.java | 2 +- .../java/org/apache/fury/type/ScalaTypes.java | 2 +- .../java/org/apache/fury/type/TypeUtils.java | 2 +- .../org/apache/fury/util/ReflectionUtils.java | 2 +- .../java/org/apache/fury/FuryInitPerf.java | 2 +- .../fury/codegen/CodegenContextTest.java | 2 +- .../fury/codegen/ExpressionVisitorTest.java | 2 +- .../collection/CollectionSerializersTest.java | 2 +- .../collection/MapSerializersTest.java | 2 +- .../fury/type/DescriptorGrouperTest.java | 2 +- .../org/apache/fury/type/DescriptorTest.java | 6 +- .../org/apache/fury/type/TypeUtilsTest.java | 2 +- .../fury/format/encoder/ArrayDataForEach.java | 2 +- .../format/encoder/ArrayEncoderBuilder.java | 2 +- .../encoder/BaseBinaryEncoderBuilder.java | 2 +- .../apache/fury/format/encoder/Encoders.java | 2 +- .../format/encoder/MapEncoderBuilder.java | 2 +- .../format/encoder/RowEncoderBuilder.java | 2 +- .../fury/format/row/binary/BinaryUtils.java | 2 +- .../fury/format/type/TypeInference.java | 2 +- .../fury/format/encoder/ArrayEncoderTest.java | 2 +- .../fury/format/encoder/MapEncoderTest.java | 2 +- licenserc.toml | 1 + 42 files changed, 378 insertions(+), 41 deletions(-) create mode 100644 java/fury-core/src/main/java/org/apache/fury/reflect/TypeToken.java diff --git a/NOTICE b/NOTICE index 22a89703d0..f325074c74 100644 --- a/NOTICE +++ b/NOTICE @@ -21,6 +21,7 @@ The text of each license is the standard Apache 2.0 license. * guava (https://github.com/google/guava) Files: java/fury-core/src/main/java/org/apache/fury/util/Preconditions.java + java/fury-core/src/main/java/org/apache/fury/reflect/TypeToken.java * spark (https://github.com/apache/spark) Files: diff --git a/java/fury-core/src/main/java/org/apache/fury/builder/BaseObjectCodecBuilder.java b/java/fury-core/src/main/java/org/apache/fury/builder/BaseObjectCodecBuilder.java index 0b0b759404..83b9deba6b 100644 --- a/java/fury-core/src/main/java/org/apache/fury/builder/BaseObjectCodecBuilder.java +++ b/java/fury-core/src/main/java/org/apache/fury/builder/BaseObjectCodecBuilder.java @@ -50,7 +50,6 @@ import static org.apache.fury.util.Preconditions.checkArgument; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -81,6 +80,7 @@ import org.apache.fury.codegen.ExpressionVisitor.ExprHolder; import org.apache.fury.collection.Tuple2; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassInfo; import org.apache.fury.resolver.ClassInfoHolder; import org.apache.fury.resolver.ClassResolver; diff --git a/java/fury-core/src/main/java/org/apache/fury/builder/CodecBuilder.java b/java/fury-core/src/main/java/org/apache/fury/builder/CodecBuilder.java index 3ce014bcab..97d745989b 100644 --- a/java/fury-core/src/main/java/org/apache/fury/builder/CodecBuilder.java +++ b/java/fury-core/src/main/java/org/apache/fury/builder/CodecBuilder.java @@ -34,7 +34,6 @@ import static org.apache.fury.type.TypeUtils.PRIMITIVE_VOID_TYPE; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.lang.invoke.MethodHandle; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -55,6 +54,7 @@ import org.apache.fury.codegen.Expression.StaticInvoke; import org.apache.fury.collection.Tuple2; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassInfo; import org.apache.fury.resolver.ClassInfoHolder; import org.apache.fury.type.Descriptor; diff --git a/java/fury-core/src/main/java/org/apache/fury/builder/CodecUtils.java b/java/fury-core/src/main/java/org/apache/fury/builder/CodecUtils.java index e5cd5a548d..4a983d6b51 100644 --- a/java/fury-core/src/main/java/org/apache/fury/builder/CodecUtils.java +++ b/java/fury-core/src/main/java/org/apache/fury/builder/CodecUtils.java @@ -19,11 +19,11 @@ package org.apache.fury.builder; -import com.google.common.reflect.TypeToken; import java.util.Collections; import org.apache.fury.Fury; import org.apache.fury.codegen.CodeGenerator; import org.apache.fury.codegen.CompileUnit; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.FieldResolver; import org.apache.fury.serializer.Serializer; import org.apache.fury.type.ClassDef; diff --git a/java/fury-core/src/main/java/org/apache/fury/builder/CompatibleCodecBuilder.java b/java/fury-core/src/main/java/org/apache/fury/builder/CompatibleCodecBuilder.java index 50117db0a3..4639a70879 100644 --- a/java/fury-core/src/main/java/org/apache/fury/builder/CompatibleCodecBuilder.java +++ b/java/fury-core/src/main/java/org/apache/fury/builder/CompatibleCodecBuilder.java @@ -33,7 +33,6 @@ import static org.apache.fury.type.TypeUtils.PRIMITIVE_VOID_TYPE; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -65,6 +64,7 @@ import org.apache.fury.codegen.ExpressionOptimizer; import org.apache.fury.codegen.ExpressionUtils; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassInfo; import org.apache.fury.resolver.ClassResolver; import org.apache.fury.resolver.FieldResolver; diff --git a/java/fury-core/src/main/java/org/apache/fury/builder/MetaSharedCodecBuilder.java b/java/fury-core/src/main/java/org/apache/fury/builder/MetaSharedCodecBuilder.java index 1c72aeaeca..c0fd1ef779 100644 --- a/java/fury-core/src/main/java/org/apache/fury/builder/MetaSharedCodecBuilder.java +++ b/java/fury-core/src/main/java/org/apache/fury/builder/MetaSharedCodecBuilder.java @@ -21,7 +21,6 @@ import static org.apache.fury.builder.Generated.GeneratedMetaSharedSerializer.SERIALIZER_FIELD_NAME; -import com.google.common.reflect.TypeToken; import java.util.Collection; import java.util.SortedMap; import org.apache.fury.Fury; @@ -32,6 +31,7 @@ import org.apache.fury.config.CompatibleMode; import org.apache.fury.config.FuryBuilder; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.CodegenSerializer; import org.apache.fury.serializer.MetaSharedSerializer; import org.apache.fury.serializer.ObjectSerializer; diff --git a/java/fury-core/src/main/java/org/apache/fury/builder/ObjectCodecBuilder.java b/java/fury-core/src/main/java/org/apache/fury/builder/ObjectCodecBuilder.java index 37365f9d86..43bf13d655 100644 --- a/java/fury-core/src/main/java/org/apache/fury/builder/ObjectCodecBuilder.java +++ b/java/fury-core/src/main/java/org/apache/fury/builder/ObjectCodecBuilder.java @@ -34,7 +34,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.common.reflect.TypeToken; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -56,6 +55,7 @@ import org.apache.fury.codegen.Expression.ReplaceStub; import org.apache.fury.codegen.Expression.StaticInvoke; import org.apache.fury.codegen.ExpressionVisitor; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.ObjectSerializer; import org.apache.fury.serializer.PrimitiveSerializers.LongSerializer; import org.apache.fury.type.Descriptor; diff --git a/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java b/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java index f41cdd7d31..0b48ca8608 100644 --- a/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java +++ b/java/fury-core/src/main/java/org/apache/fury/codegen/CodegenContext.java @@ -26,7 +26,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -42,6 +41,7 @@ import org.apache.fury.codegen.Expression.Reference; import org.apache.fury.collection.Collections; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.Preconditions; import org.apache.fury.util.ReflectionUtils; import org.apache.fury.util.StringUtils; diff --git a/java/fury-core/src/main/java/org/apache/fury/codegen/Expression.java b/java/fury-core/src/main/java/org/apache/fury/codegen/Expression.java index e63f72fdbc..c0b7832c53 100644 --- a/java/fury-core/src/main/java/org/apache/fury/codegen/Expression.java +++ b/java/fury-core/src/main/java/org/apache/fury/codegen/Expression.java @@ -47,7 +47,6 @@ import static org.apache.fury.type.TypeUtils.maxType; import static org.apache.fury.util.Preconditions.checkArgument; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Array; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -56,6 +55,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.Platform; import org.apache.fury.util.Preconditions; diff --git a/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionUtils.java b/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionUtils.java index b977eb83d7..b24076a6c8 100644 --- a/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionUtils.java +++ b/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionUtils.java @@ -28,7 +28,6 @@ import static org.apache.fury.codegen.Expression.StaticInvoke; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -36,6 +35,7 @@ import java.util.List; import org.apache.fury.codegen.Expression.Cast; import org.apache.fury.codegen.Expression.Null; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.Preconditions; import org.apache.fury.util.StringUtils; import org.apache.fury.util.function.Functions; diff --git a/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionVisitor.java b/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionVisitor.java index 81cff6f410..ea8f6179ab 100644 --- a/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionVisitor.java +++ b/java/fury-core/src/main/java/org/apache/fury/codegen/ExpressionVisitor.java @@ -19,7 +19,6 @@ package org.apache.fury.codegen; -import com.google.common.reflect.TypeToken; import java.io.Serializable; import java.lang.invoke.SerializedLambda; import java.lang.reflect.Field; @@ -34,6 +33,7 @@ import java.util.function.Function; import org.apache.fury.codegen.Expression.ListExpression; import org.apache.fury.codegen.Expression.Reference; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.Platform; import org.apache.fury.util.Preconditions; diff --git a/java/fury-core/src/main/java/org/apache/fury/reflect/TypeToken.java b/java/fury-core/src/main/java/org/apache/fury/reflect/TypeToken.java new file mode 100644 index 0000000000..538591a7b5 --- /dev/null +++ b/java/fury-core/src/main/java/org/apache/fury/reflect/TypeToken.java @@ -0,0 +1,335 @@ +/* + * Copyright (C) 2006 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.apache.fury.reflect; + +import com.google.common.reflect.TypeParameter; +import java.lang.reflect.Array; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.lang.reflect.WildcardType; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import org.apache.fury.type.TypeUtils; + +public class TypeToken { + + private final Type type; + + /** + * Constructs a new type token of {@code T}. + * + *

Clients create an empty anonymous subclass. This embeds the type parameter in the anonymous + * class's type hierarchy, so we can reconstitute it at runtime despite erasure. + * + *

For example: + * + *

{@code
+   * TypeToken> t = new TypeToken>() {};
+   * }
+ */ + protected TypeToken() { + this.type = capture(); + } + + private TypeToken(Class declaringClass) { + this.type = declaringClass; + } + + private TypeToken(Type type) { + this.type = type; + } + + /** Returns an instance of type token that wraps {@code type}. */ + public static TypeToken of(Class clazz) { + return new TypeToken(clazz); + } + + /** Returns an instance of type token that wraps {@code type}. */ + public static TypeToken of(Type type) { + return new TypeToken(type); + } + + /** Returns the captured type. */ + private Type capture() { + final Type superclass = getClass().getGenericSuperclass(); + if (!(superclass instanceof ParameterizedType)) { + throw new IllegalArgumentException(superclass + " isn't parameterized"); + } + return ((ParameterizedType) superclass).getActualTypeArguments()[0]; + } + + /** Returns the represented type. */ + public Type getType() { + return type; + } + + /** + * Returns the raw type of {@code T}. Formally speaking, if {@code T} is returned by {@link + * java.lang.reflect.Method#getGenericReturnType}, the raw type is what's returned by {@link + * java.lang.reflect.Method#getReturnType} of the same method object. Specifically: + * + *
    + *
  • If {@code T} is a {@code Class} itself, {@code T} itself is returned. + *
  • If {@code T} is a {@link ParameterizedType}, the raw type of the parameterized type is + * returned. + *
  • If {@code T} is a {@link GenericArrayType}, the returned type is the corresponding array + * class. For example: {@code List[] => List[]}. + *
  • If {@code T} is a type variable or a wildcard type, the raw type of the first upper bound + * is returned. For example: {@code => Foo}. + *
+ */ + public Class getRawType() { + // For wildcard or type variable, the first bound determines the runtime type. + Class rawType = getRawTypes(type).iterator().next(); + @SuppressWarnings("unchecked") // raw type is |T| + Class result = (Class) rawType; + return result; + } + + private static Set> getRawTypes(Type... types) { + Set> set = new HashSet<>(); + for (Type type : types) { + if (type instanceof TypeVariable) { + return getRawTypes(((TypeVariable) type).getBounds()); + } else if (type instanceof WildcardType) { + return getRawTypes(((WildcardType) type).getUpperBounds()); + } else if (type instanceof ParameterizedType) { + set.add((Class) ((ParameterizedType) type).getRawType()); + } else if (type instanceof Class) { + set.add((Class) type); + } else if (type instanceof GenericArrayType) { + set.add( + getArrayClass(of(((GenericArrayType) type).getGenericComponentType()).getRawType())); + } else { + throw new AssertionError("Unknown type: " + type); + } + } + return Collections.unmodifiableSet(set); + } + + /** Returns true if this type is one of the primitive types (including {@code void}). */ + public boolean isPrimitive() { + return type instanceof Class && ((Class) type).isPrimitive(); + } + + /** + * Returns true if this type is known to be an array type, such as {@code int[]}, {@code T[]}, + * {@code []>} etc. + */ + public boolean isArray() { + return getComponentType(type) != null; + } + + /** + * Returns the array component type if this type represents an array ({@code int[]}, {@code T[]}, + * {@code []>} etc.), or else {@code null} is returned. + */ + public TypeToken getComponentType() { + return of(getComponentType(type)); + } + + /** + * Returns the array component type if this type represents an array ({@code int[]}, {@code T[]}, + * {@code []>} etc.), or else {@code null} is returned. + */ + private static Type getComponentType(Type type) { + if (type == null) { + return null; + } + if (type instanceof TypeVariable) { + return subtypeOfComponentType(((TypeVariable) type).getBounds()); + } else if (type instanceof WildcardType) { + return subtypeOfComponentType(((WildcardType) type).getUpperBounds()); + } else if (type instanceof Class) { + return ((Class) type).getComponentType(); + } else if (type instanceof GenericArrayType) { + return ((GenericArrayType) type).getGenericComponentType(); + } + return null; + } + + /** + * Returns {@code ? extends X} if any of {@code bounds} is a subtype of {@code X[]}; or null + * otherwise. + */ + private static Type subtypeOfComponentType(Type[] bounds) { + for (Type bound : bounds) { + final Type componentType = getComponentType(bound); + if (componentType != null) { + // Only the first bound can be a class or array. + // Bounds after the first can only be interfaces. + if (componentType instanceof Class) { + final Class componentClass = (Class) componentType; + if (componentClass.isPrimitive()) { + return componentClass; + } + } + return componentType; + } + } + return null; + } + + /** + * Do not use this method. This is used only for code refactoring during Guava dependency removal. + */ + public com.google.common.reflect.TypeToken getGuavaTypeToken() { + return com.google.common.reflect.TypeToken.of(type); + } + + /** + * Resolves the given {@code type} against the type context represented by this type. For example: + * + *
{@code
+   * new TypeToken>() {}.resolveType(
+   *     List.class.getMethod("get", int.class).getGenericReturnType())
+   * => String.class
+   * }
+ */ + public TypeToken resolveType(Type iteratorReturnType) { + // TODO: Remove guava dependency. + return TypeToken.of(getGuavaTypeToken().resolveType(iteratorReturnType).getType()); + } + + /** + * Returns the generic form of {@code superclass}. For example, if this is {@code + * ArrayList}, {@code Iterable} is returned given the input {@code + * Iterable.class}. + */ + public TypeToken getSupertype(Class superclass) { + // TODO: Remove guava dependency. + return TypeToken.of( + ((com.google.common.reflect.TypeToken) getGuavaTypeToken()) + .getSupertype(superclass) + .getType()); + } + + /** + * Returns subtype of {@code this} with {@code subclass} as the raw class. For example, if this is + * {@code Iterable} and {@code subclass} is {@code List}, {@code List} is + * returned. + */ + public final TypeToken getSubtype(Class subclass) { + // TODO: Remove guava dependency. + return of(getGuavaTypeToken().getSubtype(subclass).getType()); + } + + /** Returns true if this type is a subtype of the given {@code type}. */ + public boolean isSubtypeOf(TypeToken type) { + return isSubtypeOf(type.getType()); + } + + /** Returns true if this type is a subtype of the given {@code type}. */ + public final boolean isSubtypeOf(Type supertype) { + // TODO: Remove guava dependency. + return getGuavaTypeToken().isSubtypeOf(supertype); + } + + /** Returns true if this type is a supertype of the given {@code type}. */ + public final boolean isSupertypeOf(Type type) { + // TODO: Remove guava dependency. + return of(type).getGuavaTypeToken().isSubtypeOf(getType()); + } + + /** Returns true if this type is a supertype of the given {@code type}. */ + public final boolean isSupertypeOf(TypeToken type) { + // TODO: Remove guava dependency. + return type.getGuavaTypeToken().isSubtypeOf(getType()); + } + + /** + * Returns the corresponding wrapper type if this is a primitive type; otherwise returns {@code + * this} itself. + */ + public final TypeToken wrap() { + if (isPrimitive()) { + @SuppressWarnings("unchecked") + final Class clazz = (Class) type; + // cast is safe: long.class and Long.class are both of type Class + @SuppressWarnings("unchecked") + final Class wrapped = (Class) TypeUtils.wrap(clazz); + return of(wrapped); + } + return this; + } + + /** + * Returns the corresponding primitive type if this is a wrapper type; otherwise returns {@code + * this} itself. + */ + public final TypeToken unwrap() { + if (isWrapper()) { + @SuppressWarnings("unchecked") // this is a wrapper class + final Class clazz = (Class) type; + // cast is safe: long.class and Long.class are both of type Class + @SuppressWarnings("unchecked") + final Class unwrapped = (Class) TypeUtils.unwrap(clazz); + return of(unwrapped); + } + return this; + } + + public TypeToken where(TypeParameter typeParam, Class typeArg) { + return where(typeParam, of(typeArg)); + } + + public final TypeToken where(TypeParameter typeParam, TypeToken typeArg) { + // TODO: Remove guava dependency. + return of( + getGuavaTypeToken() + .where( + typeParam, + (com.google.common.reflect.TypeToken) + com.google.common.reflect.TypeToken.of(typeArg.getType())) + .getType()); + } + + private boolean isWrapper() { + if (type instanceof Class) { + return TypeUtils.isBoxed((Class) type); + } + return false; + } + + /** + * Returns true if {@code o} is another {@code TypeToken} that represents the same {@link Type}. + */ + @Override + public boolean equals(Object o) { + if (o instanceof TypeToken) { + final TypeToken that = (TypeToken) o; + return type.equals(that.type); + } + return false; + } + + @Override + public int hashCode() { + return type.hashCode(); + } + + @Override + public String toString() { + return (type instanceof Class) ? ((Class) type).getName() : type.toString(); + } + + /** Returns the {@code Class} object of arrays with {@code componentType}. */ + private static Class getArrayClass(Class componentType) { + return Array.newInstance(componentType, 0).getClass(); + } +} diff --git a/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java b/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java index 1d376dfd0f..070fc3c822 100644 --- a/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java +++ b/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java @@ -29,7 +29,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; import java.io.Externalizable; import java.io.IOException; import java.io.Serializable; @@ -95,6 +94,7 @@ import org.apache.fury.config.Language; import org.apache.fury.exception.InsecureException; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.ArraySerializers; import org.apache.fury.serializer.BufferSerializers; import org.apache.fury.serializer.CodegenSerializer.LazyInitBeanSerializer; diff --git a/java/fury-core/src/main/java/org/apache/fury/resolver/FieldResolver.java b/java/fury-core/src/main/java/org/apache/fury/resolver/FieldResolver.java index cf9128c69e..c6e8fcc968 100644 --- a/java/fury-core/src/main/java/org/apache/fury/resolver/FieldResolver.java +++ b/java/fury-core/src/main/java/org/apache/fury/resolver/FieldResolver.java @@ -27,7 +27,6 @@ import static org.apache.fury.resolver.FieldResolver.FieldInfoEncodingType.SEPARATE_TYPES_HASH; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -47,6 +46,7 @@ import org.apache.fury.collection.Tuple2; import org.apache.fury.exception.ClassNotCompatibleException; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.PrimitiveSerializers; import org.apache.fury.serializer.collection.CollectionSerializer; import org.apache.fury.serializer.collection.MapSerializer; diff --git a/java/fury-core/src/main/java/org/apache/fury/serializer/ObjectSerializer.java b/java/fury-core/src/main/java/org/apache/fury/serializer/ObjectSerializer.java index d652878a63..b0374605f9 100644 --- a/java/fury-core/src/main/java/org/apache/fury/serializer/ObjectSerializer.java +++ b/java/fury-core/src/main/java/org/apache/fury/serializer/ObjectSerializer.java @@ -21,7 +21,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.lang.invoke.MethodHandle; import java.util.ArrayList; import java.util.Arrays; @@ -34,6 +33,7 @@ import org.apache.fury.collection.Tuple3; import org.apache.fury.exception.FuryException; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassInfo; import org.apache.fury.resolver.ClassInfoHolder; import org.apache.fury.resolver.ClassResolver; diff --git a/java/fury-core/src/main/java/org/apache/fury/serializer/StructSerializer.java b/java/fury-core/src/main/java/org/apache/fury/serializer/StructSerializer.java index 7da098f21a..40f9237f4c 100644 --- a/java/fury-core/src/main/java/org/apache/fury/serializer/StructSerializer.java +++ b/java/fury-core/src/main/java/org/apache/fury/serializer/StructSerializer.java @@ -19,7 +19,6 @@ package org.apache.fury.serializer; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -32,6 +31,7 @@ import org.apache.fury.config.Language; import org.apache.fury.exception.ClassNotCompatibleException; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.Descriptor; import org.apache.fury.type.GenericType; import org.apache.fury.type.Generics; diff --git a/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java b/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java index 7da5217d49..71046a5b37 100644 --- a/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java +++ b/java/fury-core/src/main/java/org/apache/fury/serializer/collection/AbstractMapSerializer.java @@ -21,13 +21,13 @@ import static org.apache.fury.type.TypeUtils.MAP_TYPE; -import com.google.common.reflect.TypeToken; import java.lang.invoke.MethodHandle; import java.util.Map; import org.apache.fury.Fury; import org.apache.fury.collection.IdentityMap; import org.apache.fury.collection.Tuple2; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassInfoHolder; import org.apache.fury.resolver.ClassResolver; import org.apache.fury.resolver.RefResolver; diff --git a/java/fury-core/src/main/java/org/apache/fury/type/ClassDef.java b/java/fury-core/src/main/java/org/apache/fury/type/ClassDef.java index fa22d0af25..fbb7c4228b 100644 --- a/java/fury-core/src/main/java/org/apache/fury/type/ClassDef.java +++ b/java/fury-core/src/main/java/org/apache/fury/type/ClassDef.java @@ -24,7 +24,6 @@ import static org.apache.fury.type.TypeUtils.collectionOf; import static org.apache.fury.type.TypeUtils.mapOf; -import com.google.common.reflect.TypeToken; import java.io.ObjectStreamClass; import java.io.Serializable; import java.lang.reflect.Field; @@ -44,6 +43,7 @@ import org.apache.fury.config.FuryBuilder; import org.apache.fury.memory.MemoryBuffer; import org.apache.fury.memory.MemoryUtils; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassResolver; import org.apache.fury.serializer.CompatibleSerializer; import org.apache.fury.util.LoggerFactory; diff --git a/java/fury-core/src/main/java/org/apache/fury/type/Descriptor.java b/java/fury-core/src/main/java/org/apache/fury/type/Descriptor.java index 35c339e43d..dca8728d2c 100644 --- a/java/fury-core/src/main/java/org/apache/fury/type/Descriptor.java +++ b/java/fury-core/src/main/java/org/apache/fury/type/Descriptor.java @@ -23,7 +23,6 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -46,6 +45,7 @@ import org.apache.fury.annotation.Ignore; import org.apache.fury.annotation.Internal; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.Platform; import org.apache.fury.util.Preconditions; import org.apache.fury.util.StringUtils; diff --git a/java/fury-core/src/main/java/org/apache/fury/type/GenericType.java b/java/fury-core/src/main/java/org/apache/fury/type/GenericType.java index 84f2802a07..eb2d98ec1b 100644 --- a/java/fury-core/src/main/java/org/apache/fury/type/GenericType.java +++ b/java/fury-core/src/main/java/org/apache/fury/type/GenericType.java @@ -21,7 +21,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.lang.reflect.GenericArrayType; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; @@ -30,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.ClassResolver; import org.apache.fury.serializer.Serializer; import org.apache.fury.util.ReflectionUtils; diff --git a/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java b/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java index fbd9bec086..6ef25511be 100644 --- a/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java +++ b/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java @@ -19,10 +19,10 @@ package org.apache.fury.type; -import com.google.common.reflect.TypeToken; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.ReflectionUtils; /** Scala types utils using reflection without dependency on scala library. */ diff --git a/java/fury-core/src/main/java/org/apache/fury/type/TypeUtils.java b/java/fury-core/src/main/java/org/apache/fury/type/TypeUtils.java index 25f2009bee..254af5d3e2 100644 --- a/java/fury-core/src/main/java/org/apache/fury/type/TypeUtils.java +++ b/java/fury-core/src/main/java/org/apache/fury/type/TypeUtils.java @@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.reflect.TypeParameter; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Array; import java.lang.reflect.GenericArrayType; import java.lang.reflect.Modifier; @@ -50,6 +49,7 @@ import java.util.stream.Collectors; import org.apache.fury.collection.IdentityMap; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.Preconditions; import org.apache.fury.util.ReflectionUtils; diff --git a/java/fury-core/src/main/java/org/apache/fury/util/ReflectionUtils.java b/java/fury-core/src/main/java/org/apache/fury/util/ReflectionUtils.java index d423f43202..326010f373 100644 --- a/java/fury-core/src/main/java/org/apache/fury/util/ReflectionUtils.java +++ b/java/fury-core/src/main/java/org/apache/fury/util/ReflectionUtils.java @@ -22,7 +22,6 @@ import static org.apache.fury.type.TypeUtils.OBJECT_TYPE; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -48,6 +47,7 @@ import org.apache.fury.annotation.CodegenInvoke; import org.apache.fury.annotation.Internal; import org.apache.fury.collection.Tuple3; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.function.Functions; import org.apache.fury.util.unsafe._JDKAccess; diff --git a/java/fury-core/src/test/java/org/apache/fury/FuryInitPerf.java b/java/fury-core/src/test/java/org/apache/fury/FuryInitPerf.java index 2e3ecfb97b..297065db6f 100644 --- a/java/fury-core/src/test/java/org/apache/fury/FuryInitPerf.java +++ b/java/fury-core/src/test/java/org/apache/fury/FuryInitPerf.java @@ -19,12 +19,12 @@ package org.apache.fury; -import com.google.common.reflect.TypeToken; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.apache.fury.config.CompatibleMode; import org.apache.fury.config.Language; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.resolver.MetaContext; import org.apache.fury.test.bean.BeanA; import org.apache.fury.test.bean.BeanB; diff --git a/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java b/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java index 38cbfcbcb7..a22cf23046 100644 --- a/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/codegen/CodegenContextTest.java @@ -19,10 +19,10 @@ package org.apache.fury.codegen; -import com.google.common.reflect.TypeToken; import java.util.List; import org.apache.fury.codegen.Expression.Invoke; import org.apache.fury.codegen.Expression.Literal; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.Serializer; import org.apache.fury.type.TypeUtils; import org.testng.Assert; diff --git a/java/fury-core/src/test/java/org/apache/fury/codegen/ExpressionVisitorTest.java b/java/fury-core/src/test/java/org/apache/fury/codegen/ExpressionVisitorTest.java index e265c93ccf..960f85a2a7 100644 --- a/java/fury-core/src/test/java/org/apache/fury/codegen/ExpressionVisitorTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/codegen/ExpressionVisitorTest.java @@ -21,7 +21,6 @@ import static org.testng.Assert.assertEquals; -import com.google.common.reflect.TypeToken; import java.lang.invoke.SerializedLambda; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -29,6 +28,7 @@ import java.util.Arrays; import java.util.List; import org.apache.fury.codegen.Expression.Literal; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.util.Preconditions; import org.apache.fury.util.ReflectionUtils; import org.testng.annotations.Test; diff --git a/java/fury-core/src/test/java/org/apache/fury/serializer/collection/CollectionSerializersTest.java b/java/fury-core/src/test/java/org/apache/fury/serializer/collection/CollectionSerializersTest.java index e36b789f59..2806289e44 100644 --- a/java/fury-core/src/test/java/org/apache/fury/serializer/collection/CollectionSerializersTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/serializer/collection/CollectionSerializersTest.java @@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; -import com.google.common.reflect.TypeToken; import java.io.Serializable; import java.util.AbstractCollection; import java.util.ArrayDeque; @@ -62,6 +61,7 @@ import org.apache.fury.config.Language; import org.apache.fury.memory.MemoryBuffer; import org.apache.fury.memory.MemoryUtils; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.collection.CollectionSerializers.JDKCompatibleCollectionSerializer; import org.apache.fury.type.GenericType; import org.testng.Assert; diff --git a/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java b/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java index 9b8c9a43e8..39b11385fa 100644 --- a/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/serializer/collection/MapSerializersTest.java @@ -26,7 +26,6 @@ import static org.testng.Assert.assertEquals; import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; import java.io.Serializable; import java.util.AbstractMap; import java.util.ArrayList; @@ -49,6 +48,7 @@ import org.apache.fury.FuryTestBase; import org.apache.fury.collection.MapEntry; import org.apache.fury.config.Language; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.serializer.collection.CollectionSerializersTest.TestEnum; import org.apache.fury.test.bean.MapFields; import org.apache.fury.type.GenericType; diff --git a/java/fury-core/src/test/java/org/apache/fury/type/DescriptorGrouperTest.java b/java/fury-core/src/test/java/org/apache/fury/type/DescriptorGrouperTest.java index 69861f0f40..bc4198942b 100644 --- a/java/fury-core/src/test/java/org/apache/fury/type/DescriptorGrouperTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/type/DescriptorGrouperTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.*; import com.google.common.primitives.Primitives; -import com.google.common.reflect.TypeToken; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; @@ -32,6 +31,7 @@ import java.util.Map; import java.util.Random; import java.util.stream.Collectors; +import org.apache.fury.reflect.TypeToken; import org.testng.annotations.Test; @SuppressWarnings("UnstableApiUsage") diff --git a/java/fury-core/src/test/java/org/apache/fury/type/DescriptorTest.java b/java/fury-core/src/test/java/org/apache/fury/type/DescriptorTest.java index 13c22f7383..73376d56b0 100644 --- a/java/fury-core/src/test/java/org/apache/fury/type/DescriptorTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/type/DescriptorTest.java @@ -19,7 +19,6 @@ package org.apache.fury.type; -import com.google.common.reflect.TypeToken; import java.beans.IntrospectionException; import java.beans.Introspector; import java.lang.reflect.Field; @@ -28,6 +27,7 @@ import java.util.SortedMap; import java.util.stream.Collectors; import org.apache.fury.codegen.CodeGenerator; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.test.bean.BeanA; import org.testng.Assert; import org.testng.annotations.Test; @@ -72,8 +72,8 @@ public void getDescriptorsTest() throws IntrospectionException { .filter(d -> d.getReadMethod() != null && d.getWriteMethod() != null) .map( p -> { - TypeToken returnType = typeToken.method(p.getReadMethod()).getReturnType(); - return Arrays.asList( + TypeToken returnType = TypeToken.of(p.getReadMethod().getReturnType()); + return Arrays.asList( p.getName(), returnType, p.getReadMethod().getName(), diff --git a/java/fury-core/src/test/java/org/apache/fury/type/TypeUtilsTest.java b/java/fury-core/src/test/java/org/apache/fury/type/TypeUtilsTest.java index 342dc01c97..c02ee7bfee 100644 --- a/java/fury-core/src/test/java/org/apache/fury/type/TypeUtilsTest.java +++ b/java/fury-core/src/test/java/org/apache/fury/type/TypeUtilsTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals; import com.google.common.collect.ImmutableList; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Type; import java.util.AbstractList; import java.util.ArrayList; @@ -36,6 +35,7 @@ import java.util.Map; import java.util.stream.Collectors; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.test.bean.BeanA; import org.apache.fury.test.bean.BeanB; import org.testng.Assert; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayDataForEach.java b/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayDataForEach.java index 68c534cb9a..599e44972c 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayDataForEach.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayDataForEach.java @@ -21,7 +21,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import org.apache.fury.annotation.Internal; import org.apache.fury.codegen.ClosureVisitable; import org.apache.fury.codegen.Code; @@ -30,6 +29,7 @@ import org.apache.fury.codegen.Expression; import org.apache.fury.format.row.binary.BinaryArray; import org.apache.fury.format.row.binary.BinaryUtils; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.Preconditions; import org.apache.fury.util.StringUtils; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayEncoderBuilder.java b/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayEncoderBuilder.java index 376de3f85c..abb1a348bd 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayEncoderBuilder.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/encoder/ArrayEncoderBuilder.java @@ -22,7 +22,6 @@ import static org.apache.fury.type.TypeUtils.CLASS_TYPE; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import org.apache.arrow.vector.types.pojo.Field; import org.apache.fury.Fury; import org.apache.fury.codegen.CodeGenerator; @@ -32,6 +31,7 @@ import org.apache.fury.format.row.binary.BinaryArray; import org.apache.fury.format.row.binary.writer.BinaryArrayWriter; import org.apache.fury.format.type.TypeInference; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.LoggerFactory; import org.apache.fury.util.StringUtils; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/encoder/BaseBinaryEncoderBuilder.java b/java/fury-format/src/main/java/org/apache/fury/format/encoder/BaseBinaryEncoderBuilder.java index 3d52a7aa3a..8c1d953b2d 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/encoder/BaseBinaryEncoderBuilder.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/encoder/BaseBinaryEncoderBuilder.java @@ -21,7 +21,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; @@ -63,6 +62,7 @@ import org.apache.fury.format.row.binary.writer.BinaryWriter; import org.apache.fury.format.type.DataTypes; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.DateTimeUtils; import org.apache.fury.util.Preconditions; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/encoder/Encoders.java b/java/fury-format/src/main/java/org/apache/fury/format/encoder/Encoders.java index 3750773784..7caae8b984 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/encoder/Encoders.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/encoder/Encoders.java @@ -21,7 +21,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.util.Collection; import java.util.HashSet; import java.util.Map; @@ -43,6 +42,7 @@ import org.apache.fury.format.type.TypeInference; import org.apache.fury.memory.MemoryBuffer; import org.apache.fury.memory.MemoryUtils; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.LoggerFactory; import org.slf4j.Logger; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/encoder/MapEncoderBuilder.java b/java/fury-format/src/main/java/org/apache/fury/format/encoder/MapEncoderBuilder.java index 1126181e01..3d69f23217 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/encoder/MapEncoderBuilder.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/encoder/MapEncoderBuilder.java @@ -22,7 +22,6 @@ import static org.apache.fury.type.TypeUtils.CLASS_TYPE; import static org.apache.fury.type.TypeUtils.getRawType; -import com.google.common.reflect.TypeToken; import java.util.Map; import org.apache.arrow.vector.types.pojo.Field; import org.apache.fury.Fury; @@ -34,6 +33,7 @@ import org.apache.fury.format.row.binary.BinaryMap; import org.apache.fury.format.row.binary.writer.BinaryArrayWriter; import org.apache.fury.format.type.TypeInference; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.LoggerFactory; import org.apache.fury.util.StringUtils; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/encoder/RowEncoderBuilder.java b/java/fury-format/src/main/java/org/apache/fury/format/encoder/RowEncoderBuilder.java index d35f3fe843..2797b4c8f8 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/encoder/RowEncoderBuilder.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/encoder/RowEncoderBuilder.java @@ -23,7 +23,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; import com.google.common.base.CaseFormat; -import com.google.common.reflect.TypeToken; import java.lang.reflect.Modifier; import java.util.SortedMap; import org.apache.arrow.vector.types.pojo.Field; @@ -46,6 +45,7 @@ import org.apache.fury.format.row.binary.writer.BinaryRowWriter; import org.apache.fury.format.type.DataTypes; import org.apache.fury.format.type.TypeInference; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.Descriptor; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.GraalvmSupport; diff --git a/java/fury-format/src/main/java/org/apache/fury/format/row/binary/BinaryUtils.java b/java/fury-format/src/main/java/org/apache/fury/format/row/binary/BinaryUtils.java index 8d09dc7ba6..c07a86c93b 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/row/binary/BinaryUtils.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/row/binary/BinaryUtils.java @@ -19,8 +19,8 @@ package org.apache.fury.format.row.binary; -import com.google.common.reflect.TypeToken; import org.apache.fury.memory.MemoryBuffer; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.TypeUtils; /** Util class for building generated binary encoder. */ diff --git a/java/fury-format/src/main/java/org/apache/fury/format/type/TypeInference.java b/java/fury-format/src/main/java/org/apache/fury/format/type/TypeInference.java index 8024fae798..74a4e467fb 100644 --- a/java/fury-format/src/main/java/org/apache/fury/format/type/TypeInference.java +++ b/java/fury-format/src/main/java/org/apache/fury/format/type/TypeInference.java @@ -23,7 +23,6 @@ import static org.apache.fury.type.TypeUtils.getRawType; import com.google.common.base.CaseFormat; -import com.google.common.reflect.TypeToken; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; @@ -39,6 +38,7 @@ import org.apache.arrow.vector.types.pojo.FieldType; import org.apache.arrow.vector.types.pojo.Schema; import org.apache.fury.collection.Tuple2; +import org.apache.fury.reflect.TypeToken; import org.apache.fury.type.Descriptor; import org.apache.fury.type.TypeUtils; import org.apache.fury.util.DecimalUtils; diff --git a/java/fury-format/src/test/java/org/apache/fury/format/encoder/ArrayEncoderTest.java b/java/fury-format/src/test/java/org/apache/fury/format/encoder/ArrayEncoderTest.java index 4d375e8480..ad006d4217 100644 --- a/java/fury-format/src/test/java/org/apache/fury/format/encoder/ArrayEncoderTest.java +++ b/java/fury-format/src/test/java/org/apache/fury/format/encoder/ArrayEncoderTest.java @@ -19,13 +19,13 @@ package org.apache.fury.format.encoder; -import com.google.common.reflect.TypeToken; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.fury.format.row.binary.BinaryArray; +import org.apache.fury.reflect.TypeToken; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/java/fury-format/src/test/java/org/apache/fury/format/encoder/MapEncoderTest.java b/java/fury-format/src/test/java/org/apache/fury/format/encoder/MapEncoderTest.java index b9bf07f590..7b823c4b5a 100644 --- a/java/fury-format/src/test/java/org/apache/fury/format/encoder/MapEncoderTest.java +++ b/java/fury-format/src/test/java/org/apache/fury/format/encoder/MapEncoderTest.java @@ -19,13 +19,13 @@ package org.apache.fury.format.encoder; -import com.google.common.reflect.TypeToken; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.fury.format.row.binary.BinaryMap; +import org.apache.fury.reflect.TypeToken; import org.testng.Assert; import org.testng.annotations.Test; diff --git a/licenserc.toml b/licenserc.toml index 77d85c65a1..e42ecf2a24 100644 --- a/licenserc.toml +++ b/licenserc.toml @@ -43,6 +43,7 @@ excludes = [ "java/fury-core/src/main/java/org/apache/fury/collection/ObjectIntMap.java", "java/fury-core/src/main/java/org/apache/fury/io/ClassLoaderObjectInputStream.java", "java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java", + "java/fury-core/src/main/java/org/apache/fury/reflect/TypeToken.java", "java/fury-core/src/main/java/org/apache/fury/type/Generics.java", "java/fury-core/src/main/java/org/apache/fury/util/MurmurHash3.java", "java/fury-core/src/main/java/org/apache/fury/util/Platform.java",