public class MultiType extends Type
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.Constructor and Description |
---|
MultiType(java.util.Map interfaces) |
MultiType(java.util.Map interfaces,
Type potentialClass) |
Modifier and Type | Method and Description |
---|---|
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() |
get, getDimensions, isSpecial
public MultiType(java.util.Map interfaces)
public MultiType(java.util.Map interfaces, Type potentialClass)
public CtClass getCtClass()
getCtClass
in class Type
public Type getComponent()
getComponent
in class Type
public int getSize()
public boolean isArray()
public boolean isAssignableFrom(Type type)
Type
isAssignableFrom
in class Type
type
- the type to test assignability topublic boolean isAssignableTo(Type type)
public boolean isReference()
isReference
in class Type
public Type merge(Type type)
Type
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.Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.