Top Description Fields Constructors Methods
javassist.bytecode.analysis

public Class MultiType

extends Type
Class Inheritance
Imports
java.util.HashMap, .Map, javassist.CtClass

MultiType represents an unresolved type. Whenever two Type instances are merged, if they share more than one super type (either an interface or a superclass), then a MultiType is used to represent the possible super types. The goal of a MultiType is to reduce the set of possible types down to a single resolved type. This is done by eliminating non-assignable types from the typeset when the MultiType is passed as an argument to Type#isAssignableFrom(Type), as well as removing non-intersecting types during a merge.

Note

Currently the MultiType instance is reused as much as possible so that updates are visible from all frames. In addition, all MultiType merge paths are also updated. This is somewhat hackish, but it appears to handle most scenarios.

Author
Jason T. Greene

Field Summary

Modifier and TypeField and Description
private boolean
private Map<String, CtClass>
private MultiType
private Type
private Type
Inherited from javassist.bytecode.analysis.Type:
BOGUSBOOLEANBYTECHARCLONEABLEDOUBLEFLOATINTEGERLONGOBJECTRETURN_ADDRESSSERIALIZABLESHORTTHROWABLETOPUNINITVOID

Constructor Summary

AccessConstructor and Description
public
MultiType(Map<String, CtClass> interfaces)

public
MultiType(Map<String, CtClass> interfaces, Type potentialClass)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides javassist.bytecode.analysis.Type.equals.

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

private Map<String, CtClass>
public Type
getComponent()

Overrides javassist.bytecode.analysis.Type.getComponent.

Always returns null since this type is never used for an array.

public CtClass
getCtClass()

Overrides javassist.bytecode.analysis.Type.getCtClass.

Gets the class that corresponds with this type.

public int
getSize()

Overrides javassist.bytecode.analysis.Type.getSize.

Always returns 1, since this type is a reference.

public int
hashCode()

Overrides javassist.bytecode.analysis.Type.hashCode.

Returns a hash code value for this object.

private boolean
public boolean
isArray()

Overrides javassist.bytecode.analysis.Type.isArray.

Always reutnrs false since this type is never used for an array

public boolean
isAssignableFrom(Type
the type to test assignability to
type
)

Overrides javassist.bytecode.analysis.Type.isAssignableFrom.

Determines whether this type is assignable, to the passed type.

public boolean
public boolean

Returns:

true
isReference
()

Overrides javassist.bytecode.analysis.Type.isReference.

Always returns true, since this type is always a reference.

public Type
merge(Type
the type to merge with
type
)

Overrides javassist.bytecode.analysis.Type.merge.

Finds the common base type, or interface which both this and the specified type can be assigned.

private Map<String, CtClass>
private Map<String, CtClass>
pack-priv boolean
popChanged()

Overrides javassist.bytecode.analysis.Type.popChanged.

Returns true if the internal state has changed.

private void
private void
public String
toString()

Overrides javassist.bytecode.analysis.Type.toString.

Returns a string representation of the object.

Inherited from javassist.bytecode.analysis.Type:
arrayNameeqfindCommonInterfacesgetgetAllInterfacesgetDeclaredInterfacesgetDimensionsgetRootComponentisSpecial

Field Detail

changedback to summary
private boolean changed
interfacesback to summary
private Map<String, CtClass> interfaces
mergeSourceback to summary
private MultiType mergeSource
potentialClassback to summary
private Type potentialClass
resolvedback to summary
private Type resolved

Constructor Detail

MultiTypeback to summary
public MultiType(Map<String, CtClass> interfaces)
MultiTypeback to summary
public MultiType(Map<String, CtClass> interfaces, Type potentialClass)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides javassist.bytecode.analysis.Type.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
o: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
getAllMultiInterfacesback to summary
private Map<String, CtClass> getAllMultiInterfaces(MultiType type)
getComponentback to summary
public Type getComponent()

Overrides javassist.bytecode.analysis.Type.getComponent.

Always returns null since this type is never used for an array.

Returns:Type

Doc from javassist.bytecode.analysis.Type.getComponent.

the array component if an array, otherwise null

Annotations
@Override
getCtClassback to summary
public CtClass getCtClass()

Overrides javassist.bytecode.analysis.Type.getCtClass.

Gets the class that corresponds with this type. If this information is not yet known, java.lang.Object will be returned.

Returns:CtClass

Doc from javassist.bytecode.analysis.Type.getCtClass.

the class for this type, or null if special

Annotations
@Override
getSizeback to summary
public int getSize()

Overrides javassist.bytecode.analysis.Type.getSize.

Always returns 1, since this type is a reference.

Returns:int

Doc from javassist.bytecode.analysis.Type.getSize.

the number of words needed to hold this type

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides javassist.bytecode.analysis.Type.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
inMergeSourceback to summary
private boolean inMergeSource(MultiType source)
isArrayback to summary
public boolean isArray()

Overrides javassist.bytecode.analysis.Type.isArray.

Always reutnrs false since this type is never used for an array

Returns:boolean

Doc from javassist.bytecode.analysis.Type.isArray.

true if an array, false if not

Annotations
@Override
isAssignableFromback to summary
public boolean isAssignableFrom(Type type)

Overrides javassist.bytecode.analysis.Type.isAssignableFrom.

Doc from javassist.bytecode.analysis.Type.isAssignableFrom.

Determines whether this type is assignable, to the passed type. A type is assignable to another if it is either the same type, or a sub-type.

Parameters
type:Type

the type to test assignability to

Returns:boolean

true if this is assignable to type, otherwise false

Annotations
@Override
isAssignableToback to summary
public boolean isAssignableTo(Type type)
isReferenceback to summary
public boolean isReference()

Overrides javassist.bytecode.analysis.Type.isReference.

Always returns true, since this type is always a reference.

Returns:boolean

true

Annotations
@Override
mergeback to summary
public Type merge(Type type)

Overrides javassist.bytecode.analysis.Type.merge.

Doc from javassist.bytecode.analysis.Type.merge.

Finds the common base type, or interface which both this and the specified type can be assigned. If there is more than one possible answer, then a MultiType, or a MultiArrayType is returned. Multi-types have special rules, and successive merges and assignment tests on them will alter their internal state, as well as other multi-types they have been merged with. This method is used by the data-flow analyzer to merge the type state from multiple branches.

Parameters
type:Type

the type to merge with

Returns:Type

the merged type

Annotations
@Override
mergeMultiAndSingleback to summary
private Map<String, CtClass> mergeMultiAndSingle(MultiType multi, Type single)
mergeMultiInterfacesback to summary
private Map<String, CtClass> mergeMultiInterfaces(MultiType type1, MultiType type2)
popChangedback to summary
pack-priv boolean popChanged()

Overrides javassist.bytecode.analysis.Type.popChanged.

Returns true if the internal state has changed.

Annotations
@Override
propogateResolvedback to summary
private void propogateResolved()
propogateStateback to summary
private void propogateState()
toStringback to summary
public String toString()

Overrides javassist.bytecode.analysis.Type.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override