|
Java™ Platform Standard Ed. 7 DRAFT ea-b76 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.dyn.MethodType
public final class MethodType extends Object
Run-time token used to match call sites with method handles.
The structure is a return type accompanied by any number of parameter types.
The types (primitive, void, and reference) are represented by Class objects.
All instances of MethodType are immutable.
Two instances are completely interchangeable if they compare equal.
Equality depends exactly on the return and parameter types.
This type can be created only by factory methods, which manage interning.
| Modifier and Type | Method and Description |
|---|---|
MethodType |
changeParameterType(int num,
Class<?> nptype)
Convenience method for #make(java.lang.Class, java.lang.Class[], boolean). |
MethodType |
changeReturnType(Class<?> nrtype)
Convenience method for #make(java.lang.Class, java.lang.Class[], boolean). |
MethodType |
dropParameterType(int num)
Convenience method for #make(java.lang.Class, java.lang.Class[], boolean). |
boolean |
equals(Object x)
Compares the specified object with this type for equality. |
MethodType |
erase()
Convenience method for make(java.lang.Class, java.lang.Class[]). |
static MethodType |
fromBytecodeString(String bytecodeSignature,
ClassLoader loader)
Convenience method for make(java.lang.Class, java.lang.Class[]). |
MethodType |
generic()
Convenience method for makeGeneric(int). |
int |
hashCode()
Returns the hash code value for this method type. |
boolean |
hasPrimitives()
Convenience method. |
boolean |
hasWrappers()
Convenience method. |
MethodType |
insertParameterType(int num,
Class<?> nptype)
Convenience method for #make(java.lang.Class, java.lang.Class[], boolean). |
static MethodType |
make(Class<?> rtype)
Convenience method for make(java.lang.Class, java.lang.Class[]). |
static MethodType |
make(Class<?> rtype,
Class<?> ptype0)
Convenience method for make(java.lang.Class, java.lang.Class[]). |
static MethodType |
make(Class<?> rtype,
Class<?>[] ptypes)
Find or create an instance of the given method type. |
static MethodType |
make(Class<?> rtype,
Class<?> ptype0,
Class<?>... ptypes)
Convenience method for make(java.lang.Class, java.lang.Class[]). |
static MethodType |
make(Class<?> rtype,
List<? extends Class<?>> ptypes)
Convenience method for make(java.lang.Class, java.lang.Class[]). |
static MethodType |
make(Class<?> rtype,
MethodType ptypes)
Convenience method for make(java.lang.Class, java.lang.Class[]). |
static MethodType |
makeGeneric(int objectArgCount)
All parameters and the return type will be Object. |
static MethodType |
makeGeneric(int objectArgCount,
boolean varargs)
Convenience method for #make(java.lang.Class, java.lang.Class[], boolean). |
Class<?>[] |
parameterArray()
Convenience method to present the arguments as an array. |
int |
parameterCount()
|
List<Class<?>> |
parameterList()
Convenience method to present the arguments as a list. |
int |
parameterSlotCount()
The number of JVM stack slots required to invoke a method of this type. |
int |
parameterSlotDepth(int num)
Number of JVM stack slots which carry all parameters after the given position, which must be in the range of 0 to parameterCount inclusive. |
Class<?> |
parameterType(int num)
|
int |
returnSlotCount()
The number of JVM stack slots required to receive a return value from a method of this type. |
Class<?> |
returnType()
|
String |
toBytecodeString()
Create a bytecode signature representation of the type. |
String |
toString()
The string representation of a method type is a parenthesis enclosed, comma separated list of type names, followed immediately by the return type. |
MethodType |
unwrap()
Convenience method for make(java.lang.Class, java.lang.Class[]). |
MethodType |
wrap()
Convenience method for make(java.lang.Class, java.lang.Class[]). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static MethodType make(Class<?> rtype,
Class<?>[] ptypes)
rtype - the return typeptypes - the parameter typesNullPointerException - if rtype or any ptype is nullIllegalArgumentException - if any of the ptypes is void
public static MethodType make(Class<?> rtype,
List<? extends Class<?>> ptypes)
make(java.lang.Class, java.lang.Class[]).
public static MethodType make(Class<?> rtype,
Class<?> ptype0,
Class<?>... ptypes)
make(java.lang.Class, java.lang.Class[]).
The leading parameter type is prepended to the remaining array.
public static MethodType make(Class<?> rtype)
make(java.lang.Class, java.lang.Class[]).
The resulting method has no parameter types.
public static MethodType make(Class<?> rtype,
Class<?> ptype0)
make(java.lang.Class, java.lang.Class[]).
The resulting method has the single given parameter type.
public static MethodType make(Class<?> rtype,
MethodType ptypes)
make(java.lang.Class, java.lang.Class[]).
The resulting method has the same parameter types as ptypes,
and the specified return type.
public static MethodType makeGeneric(int objectArgCount,
boolean varargs)
#make(java.lang.Class, java.lang.Class[], boolean).
All parameters and the return type will be Object, except the final varargs parameter if any.
objectArgCount - number of parameters (excluding the varargs parameter if any)varargs - whether there will be a varargs parameter, of type Object[]makeGeneric(int)public static MethodType makeGeneric(int objectArgCount)
objectArgCount - number of parametersmakeGeneric(int, boolean)
public MethodType changeParameterType(int num,
Class<?> nptype)
#make(java.lang.Class, java.lang.Class[], boolean).
num - the index (zero-based) of the parameter type to changenptype - a new parameter type to replace the old one with
public MethodType insertParameterType(int num,
Class<?> nptype)
#make(java.lang.Class, java.lang.Class[], boolean).
num - the position (zero-based) of the inserted parameter typenptype - a new parameter type to insert into the parameter listpublic MethodType dropParameterType(int num)
#make(java.lang.Class, java.lang.Class[], boolean).
num - the index (zero-based) of the parameter type to removepublic MethodType changeReturnType(Class<?> nrtype)
#make(java.lang.Class, java.lang.Class[], boolean).
nrtype - a return parameter type to replace the old one withpublic boolean hasPrimitives()
public boolean hasWrappers()
Integer.
public MethodType erase()
make(java.lang.Class, java.lang.Class[]).
Erase all reference types to Object.
public MethodType generic()
makeGeneric(int).
Convert all types, both reference and primitive, to Object.
public MethodType wrap()
make(java.lang.Class, java.lang.Class[]).
Convert all primitive types to their corresponding wrapper types.
A void return type is changed to the type java.lang.Void.
public MethodType unwrap()
make(java.lang.Class, java.lang.Class[]).
Convert all wrapper types to their corresponding primitive types.
A return type of java.lang.Void is changed to void.
public Class<?> parameterType(int num)
num - the index (zero-based) of the desired parameter typepublic int parameterCount()
public Class<?> returnType()
public List<Class<?>> parameterList()
public Class<?>[] parameterArray()
public boolean equals(Object x)
equals in class Objectx - object to comparetrue if this object is the same as the obj
argument; false otherwise.Object.equals(Object)public int hashCode()
hashCode in class ObjectObject.hashCode(),
equals(Object),
List.hashCode()public String toString()
If a type name is array, it the base type followed by [], rather than the Class.getName of the array type.
toString in class Objectpublic int parameterSlotCount()
parameterCount() plus the
number of long and double parameters (if any).
This method is included for the benfit of applications that must generate bytecodes that process method handles and invokedynamic.
public int parameterSlotDepth(int num)
parameterCount inclusive. Successive parameters are
more shallowly stacked, and parameters are indexed in the bytecodes
according to their trailing edge. Thus, to obtain the depth
in the outgoing call stack of parameter N, obtain
the parameterSlotDepth of its trailing edge
at position N+1.
Parameters of type long and double occupy
two stack slots (for historical reasons) and all others occupy one.
Therefore, the number returned is the number of arguments
including and after the given parameter,
plus the number of long or double arguments
at or after after the argument for the given parameter.
This method is included for the benfit of applications that must generate bytecodes that process method handles and invokedynamic.
num - an index (zero-based, inclusive) within the parameter typespublic int returnSlotCount()
return type is void, it will be zero,
else if the return type is long or double, it will be two, else one.
This method is included for the benfit of applications that must generate bytecodes that process method handles and invokedynamic.
public static MethodType fromBytecodeString(String bytecodeSignature,
ClassLoader loader)
throws IllegalArgumentException,
TypeNotPresentException
make(java.lang.Class, java.lang.Class[]).
Find or create an instance (interned) of the given method type.
Any class or interface name embedded in the signature string
will be resolved by calling ClassLoader.loadClass(java.lang.String)
on the given loader (or if it is null, on the system class loader).
Note that it is possible to build method types which cannot be constructed by this method, because their component types are not all reachable from a common class loader.
This method is included for the benfit of applications that must generate bytecodes that process method handles and invokedynamic.
bytecodeSignature - a bytecode-level signature string "(T...)T"loader - the class loader in which to look up the typesIllegalArgumentException - if the string is not well-formedTypeNotPresentException - if a named type cannot be foundpublic String toBytecodeString()
This method is included for the benfit of applications that must
generate bytecodes that process method handles and invokedynamic.
fromBytecodeString(java.lang.String, java.lang.ClassLoader),
because the latter requires a suitable class loader argument.
|
Java™ Platform Standard Ed. 7 DRAFT ea-b76 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.