Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.rop.type

public final Class Prototype

extends Object
implements Comparable<Prototype>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.util.HashMap

Representation of a method descriptor. Instances of this class are generally interned and may be usefully compared with each other using ==.

Field Summary

Modifier and TypeField and Description
private final String
descriptor

non-null; method descriptor

private static final HashMap<String, Prototype>
internTable

non-null; intern table mapping string descriptors to instances

private StdTypeList
parameterFrameTypes

null-ok; list of parameter frame types, if calculated

private final StdTypeList
parameterTypes

non-null; list of parameter types

private final Type
returnType

non-null; return type

Constructor Summary

AccessConstructor and Description
private
Prototype(String
non-null; the descriptor string
descriptor
,
Type returnType, StdTypeList parameterTypes)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(Prototype
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public String

Returns:

non-null; the descriptor
getDescriptor
()

Gets the descriptor string.

public StdTypeList

Returns:

non-null; the list of parameter frame types
getParameterFrameTypes
()

Gets the list of frame types corresponding to the list of parameter types.

public StdTypeList

Returns:

non-null; the list of parameter types
getParameterTypes
()

Gets the list of parameter types.

public Type

Returns:

non-null; the return type
getReturnType
()

Gets the return type.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public static Prototype

Returns:

non-null; the corresponding instance
intern
(String
non-null; the descriptor
descriptor
)

Returns the unique instance corresponding to the given method descriptor.

public static Prototype

Returns:

non-null; the interned instance
intern
(String
non-null; the descriptor string
descriptor
,
Type
non-null; class the method is defined on
definer
,
boolean
whether this is a static method
isStatic
,
boolean
whether this is an init method
isInit
)

Interns an instance, adding to the descriptor as necessary based on the given definer, name, and flags.

public static Prototype

Returns:

non-null; the interned instance
internInts
(Type
non-null; the return type
returnType
,
int
> 0; the number of elements in the prototype
count
)

Interns an instance which consists of the given number of ints along with the given return type

private static Type[]

Returns:

non-null; array large enough to hold all parsed parameter types, but which is likely actually larger than needed
makeParameterArray
(String
non-null; the descriptor string
descriptor
)

Helper for intern which returns an empty array to populate with parsed parameter types, and which also ensures that there is a '(' at the start of the descriptor and a single ')' somewhere before the end.

private static Prototype

Returns:

non-null; the actual interned object
putIntern
(Prototype
non-null; instance to make interned
desc
)

Puts the given instance in the intern table if it's not already there.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Prototype

Returns:

non-null; an appropriately-constructed instance
withFirstParameter
(Type
non-null; the new first parameter
param
)

Returns a new interned instance, which is the same as this instance, except that it has an additional parameter prepended to the original's argument list.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

descriptorback to summary
private final String descriptor

non-null; method descriptor

internTableback to summary
private static final HashMap<String, Prototype> internTable

non-null; intern table mapping string descriptors to instances

parameterFrameTypesback to summary
private StdTypeList parameterFrameTypes

null-ok; list of parameter frame types, if calculated

parameterTypesback to summary
private final StdTypeList parameterTypes

non-null; list of parameter types

returnTypeback to summary
private final Type returnType

non-null; return type

Constructor Detail

Prototypeback to summary
private Prototype(String descriptor, Type returnType, StdTypeList parameterTypes)

Constructs an instance. This is a private constructor; use one of the public static methods to get instances.

Parameters
descriptor:String

non-null; the descriptor string

Method Detail

compareToback to summary
public int compareTo(Prototype other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
other:Prototype

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getDescriptorback to summary
public String getDescriptor()

Gets the descriptor string.

Returns:String

non-null; the descriptor

getParameterFrameTypesback to summary
public StdTypeList getParameterFrameTypes()

Gets the list of frame types corresponding to the list of parameter types. The difference between the two lists (if any) is that all "intlike" types (see Type#isIntlike) are replaced by Type#INT.

Returns:StdTypeList

non-null; the list of parameter frame types

getParameterTypesback to summary
public StdTypeList getParameterTypes()

Gets the list of parameter types.

Returns:StdTypeList

non-null; the list of parameter types

getReturnTypeback to summary
public Type getReturnType()

Gets the return type.

Returns:Type

non-null; the return type

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
internback to summary
public static Prototype intern(String descriptor)

Returns the unique instance corresponding to the given method descriptor. See vmspec-2 sec4.3.3 for details on the field descriptor syntax.

Parameters
descriptor:String

non-null; the descriptor

Returns:Prototype

non-null; the corresponding instance

Exceptions
IllegalArgumentException:
thrown if the descriptor has invalid syntax
internback to summary
public static Prototype intern(String descriptor, Type definer, boolean isStatic, boolean isInit)

Interns an instance, adding to the descriptor as necessary based on the given definer, name, and flags. For example, an init method has an uninitialized object of type definer as its first argument.

Parameters
descriptor:String

non-null; the descriptor string

definer:Type

non-null; class the method is defined on

isStatic:boolean

whether this is a static method

isInit:boolean

whether this is an init method

Returns:Prototype

non-null; the interned instance

internIntsback to summary
public static Prototype internInts(Type returnType, int count)

Interns an instance which consists of the given number of ints along with the given return type

Parameters
returnType:Type

non-null; the return type

count:int

> 0; the number of elements in the prototype

Returns:Prototype

non-null; the interned instance

makeParameterArrayback to summary
private static Type[] makeParameterArray(String descriptor)

Helper for intern which returns an empty array to populate with parsed parameter types, and which also ensures that there is a '(' at the start of the descriptor and a single ')' somewhere before the end.

Parameters
descriptor:String

non-null; the descriptor string

Returns:Type[]

non-null; array large enough to hold all parsed parameter types, but which is likely actually larger than needed

putInternback to summary
private static Prototype putIntern(Prototype desc)

Puts the given instance in the intern table if it's not already there. If a conflicting value is already in the table, then leave it. Return the interned value.

Parameters
desc:Prototype

non-null; instance to make interned

Returns:Prototype

non-null; the actual interned object

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
withFirstParameterback to summary
public Prototype withFirstParameter(Type param)

Returns a new interned instance, which is the same as this instance, except that it has an additional parameter prepended to the original's argument list.

Parameters
param:Type

non-null; the new first parameter

Returns:Prototype

non-null; an appropriately-constructed instance