javassist.bytecode.analysis
Class MultiType
java.lang.Object
javassist.bytecode.analysis.Type
javassist.bytecode.analysis.MultiType
public class MultiType
- extends Type
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
Fields inherited from class javassist.bytecode.analysis.Type |
BOGUS, BOOLEAN, BYTE, CHAR, CLONEABLE, DOUBLE, FLOAT, INTEGER, LONG, OBJECT, RETURN_ADDRESS, SERIALIZABLE, SHORT, THROWABLE, TOP, UNINIT, VOID |
Constructor Summary |
MultiType(java.util.Map interfaces)
|
MultiType(java.util.Map interfaces,
Type potentialClass)
|
Method Summary |
boolean |
equals(java.lang.Object o)
|
Type |
getComponent()
Always returns null since this type is never used for an array. |
CtClass |
getCtClass()
Gets the class that corresponds with this type. |
int |
getSize()
Always returns 1, since this type is a reference. |
boolean |
isArray()
Always reutnrs false since this type is never used for an array |
boolean |
isAssignableFrom(Type type)
Determines whether this type is assignable, to the passed type. |
boolean |
isAssignableTo(Type type)
|
boolean |
isReference()
Always returns true, since this type is always a reference. |
Type |
merge(Type type)
Finds the common base type, or interface which both this and the specified
type can be assigned. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
MultiType
public MultiType(java.util.Map interfaces)
MultiType
public MultiType(java.util.Map interfaces,
Type potentialClass)
getCtClass
public CtClass getCtClass()
- Gets the class that corresponds with this type. If this information
is not yet known, java.lang.Object will be returned.
- Overrides:
getCtClass
in class Type
- Returns:
- the class for this type, or null if special
getComponent
public Type getComponent()
- Always returns null since this type is never used for an array.
- Overrides:
getComponent
in class Type
- Returns:
- the array component if an array, otherwise null
getSize
public int getSize()
- Always returns 1, since this type is a reference.
- Overrides:
getSize
in class Type
- Returns:
- the number of words needed to hold this type
isArray
public boolean isArray()
- Always reutnrs false since this type is never used for an array
- Overrides:
isArray
in class Type
- Returns:
- true if an array, false if not
isAssignableFrom
public boolean isAssignableFrom(Type type)
- Description copied from class:
Type
- 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.
- Overrides:
isAssignableFrom
in class Type
- Parameters:
type
- the type to test assignability to
- Returns:
- true if this is assignable to type, otherwise false
isAssignableTo
public boolean isAssignableTo(Type type)
isReference
public boolean isReference()
- Always returns true, since this type is always a reference.
- Overrides:
isReference
in class Type
- Returns:
- true
merge
public Type merge(Type type)
- Description copied from class:
Type
- 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.
- Overrides:
merge
in class Type
- Parameters:
type
- the type to merge with
- Returns:
- the merged type
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in class Type
toString
public java.lang.String toString()
- Overrides:
toString
in class Type
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2010 Shigeru Chiba. All Rights Reserved.