Package org.openrewrite.java.internal
Class JvmsTypeSignatureBuilder
java.lang.Object
org.openrewrite.java.internal.JvmsTypeSignatureBuilder
- All Implemented Interfaces:
JavaTypeSignatureBuilder
A
JavaTypeSignatureBuilder that produces cache keys using JVMS ยง4
descriptors for methods and variables, ensuring direct compatibility with
type tables built from class files (where ASM provides the descriptors).
Type signatures (class, parameterized, generic, array, primitive) use the
same format as DefaultJavaTypeSignatureBuilder since these are
used as FQN-based cache keys (the FQN passed to
JavaTypeFactory.computeClass(java.lang.String, long, org.openrewrite.java.tree.JavaType.FullyQualified.Kind, java.util.function.Consumer<org.openrewrite.java.tree.JavaType.Class>)).
Method signatures: declaringFQN.methodName:(paramDescriptors)returnDescriptor
Example: java.lang.String.substring:(II)Ljava/lang/String;
Variable signatures: ownerFQN.fieldName:fieldDescriptor
Example: java.lang.String.CASE_INSENSITIVE_ORDER:Ljava/util/Comparator;
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarraySignature(Object type) classSignature(Object type) static StringfieldDescriptor(@Nullable JavaType type) genericSignature(Object type) When generic type variables are cyclic, likeU extends Cyclic<? extends U>, represent the cycle with the bound name, likeGeneric{U extends Cyclic<? extends U>}.static StringmethodDescriptor(JavaType.Method method) methodSignature(JavaType.Method method) parameterizedSignature(Object type) primitiveSignature(Object type) variableSignature(JavaType.Variable variable)
-
Constructor Details
-
JvmsTypeSignatureBuilder
public JvmsTypeSignatureBuilder()
-
-
Method Details
-
signature
- Specified by:
signaturein interfaceJavaTypeSignatureBuilder- Parameters:
type- A type object.- Returns:
- The type signature. If
tis null, the signature is{undefined}.
-
arraySignature
- Specified by:
arraySignaturein interfaceJavaTypeSignatureBuilder- Parameters:
type- An array type.- Returns:
- Formatted like
Integer[].
-
classSignature
- Specified by:
classSignaturein interfaceJavaTypeSignatureBuilder- Parameters:
type- A class type.- Returns:
- Formatted like
java.util.List.
-
genericSignature
Description copied from interface:JavaTypeSignatureBuilderWhen generic type variables are cyclic, likeU extends Cyclic<? extends U>, represent the cycle with the bound name, likeGeneric{U extends Cyclic<? extends U>}. When the bound isObject(regardless of whether that bound is implicit or explicit in the source code),the type variable is considered invariant and the bound is omitted. SoGeneric{List<?>}is favored overGeneric{List<? extends java.lang.Object>}.- Specified by:
genericSignaturein interfaceJavaTypeSignatureBuilder- Parameters:
type- A generic type.- Returns:
- Formatted like
Generic{U extends java.lang.Comparable}(covariant) orGeneric{U super java.lang.Comparable}(contravariant).
-
parameterizedSignature
- Specified by:
parameterizedSignaturein interfaceJavaTypeSignatureBuilder- Parameters:
type- A parameterized type.- Returns:
- Formatted like
java.util.List<java.util.List<Integer>>.
-
primitiveSignature
- Specified by:
primitiveSignaturein interfaceJavaTypeSignatureBuilder- Parameters:
type- A primitive type.- Returns:
- Formatted like
Integer.
-
methodSignature
-
variableSignature
-
methodDescriptor
-
fieldDescriptor
-