public abstract class JDeclaredType extends JReferenceType
$clinit
) and the instance initializer method
(named $init
).
The class initializer method is responsible for initializing all class variables as well as
those of the superclasses (by calling the superclass class initializer method).
The instance initializer is responsible for initializing all instance variables as well as those
of the superclasses (by calling the superclass instance initializer method).
Optimizations may eliminate class initializers ($clinit
) if no static variables need
initialization, and use the private variable clinitTarget
to keep track which
initializer in the superclass chain needs to be called.HasName.Util
Modifier and Type | Field and Description |
---|---|
protected List<JNode> |
artificialRescues
The other nodes that this node should implicitly rescue.
|
protected List<JField> |
fields
This type's fields.
|
protected List<JMethod> |
methods
This type's methods.
|
Constructor and Description |
---|
JDeclaredType(SourceInfo info,
String name) |
Modifier and Type | Method and Description |
---|---|
void |
addArtificialRescue(JNode node) |
void |
addField(JField field)
Adds a field to this type.
|
void |
addImplements(JInterfaceType superInterface)
Adds an implemented interface to this type.
|
void |
addMethod(JMethod method)
Adds a method to this type.
|
boolean |
checkClinitTo(JDeclaredType targetType)
Returns
true if a static field access of
targetType from within this type should generate a clinit
call. |
JDeclaredType |
findSubtype(Iterable<JDeclaredType> types)
Determines whether a subclass of this type is in the collection
types . |
List<JNode> |
getArtificialRescues() |
JMethod |
getClinitMethod()
Returns the class initializer method.
|
JDeclaredType |
getClinitTarget()
Returns the class that must be initialized to use this class.
|
JDeclaredType |
getEnclosingType()
Returns the type which encloses this type.
|
List<JField> |
getFields()
Returns this type's fields;does not include fields defined in a super type
unless they are overridden by this type.
|
List<JInterfaceType> |
getImplements()
Returns this type's implemented interfaces.
|
JMethod |
getInitMethod()
Returns the instance initializer ($init) method.
|
String |
getJavahSignatureName() |
String |
getJsniSignatureName() |
List<JMethod> |
getMethods()
Returns this type's declared methods; does not include methods defined in a
super type unless they are overridden by this type.
|
String |
getShortName() |
abstract JClassType |
getSuperClass()
Returns this type's super class, or
null if this type is
Object or an interface. |
boolean |
hasClinit()
Returns
true when this class's clinit must be run dynamically. |
boolean |
isExternal()
True if this class is provided externally to the program by the program's
host execution environment.
|
void |
removeField(int i)
Removes the field at the specified index.
|
void |
removeMethod(int i)
Removes the method at the specified index.
|
void |
resetClinitTarget()
Resets the clinitTarget to the current class.
|
void |
resolve(List<JInterfaceType> resolvedInterfaces,
List<JNode> resolvedRescues)
Resolves external references during AST stitching.
|
void |
setEnclosingType(JDeclaredType enclosingType)
Sets the type which encloses this types.
|
void |
setExternal(boolean isExternal) |
void |
sortFields(Comparator<? super JField> sort)
Sorts this type's fields according to the specified sort.
|
void |
sortMethods(Comparator<? super JMethod> sort)
Sorts this type's methods according to the specified sort.
|
protected abstract Object |
writeReplace()
Subclasses must replace themselves with a shallow reference when
isExternal() is true . |
canBeNull, getDefaultValue, getNonNull, getUnderlyingType, replaces
getClassLiteralFactoryMethod, getName
getSourceInfo, setSourceInfo, toSource, toString
isAbstract
isFinal
traverse
protected transient List<JNode> artificialRescues
public JDeclaredType(SourceInfo info, String name)
public JDeclaredType findSubtype(Iterable<JDeclaredType> types)
types
.types
- a collections of types.types
contains a subtype of this type; null otherwise.public void addArtificialRescue(JNode node)
public void addField(JField field)
public void addImplements(JInterfaceType superInterface)
public final void addMethod(JMethod method)
public boolean checkClinitTo(JDeclaredType targetType)
true
if a static field access of
targetType
from within this type should generate a clinit
call. This will be true in cases where targetType
has a live
clinit method which we cannot statically know has already run. We can
statically know the clinit method has already run when:
this == targetType
this
is a subclass of targetType
, because my
clinit would have already run this targetType
's clinit; see
JLS 12.4public final JMethod getInitMethod()
public final JMethod getClinitMethod()
public final JDeclaredType getClinitTarget()
null
if this class has no static initializer.public JDeclaredType getEnclosingType()
null
.public List<JField> getFields()
public List<JInterfaceType> getImplements()
public String getJavahSignatureName()
getJavahSignatureName
in class JReferenceType
public String getJsniSignatureName()
getJsniSignatureName
in class JReferenceType
public final List<JMethod> getMethods()
public String getShortName()
getShortName
in class JReferenceType
public abstract JClassType getSuperClass()
null
if this type is
Object
or an interface.public boolean hasClinit()
true
when this class's clinit must be run dynamically.public boolean isExternal()
JType
isExternal
in class JType
public void removeField(int i)
public void removeMethod(int i)
public void resetClinitTarget()
public void resolve(List<JInterfaceType> resolvedInterfaces, List<JNode> resolvedRescues)
public void setEnclosingType(JDeclaredType enclosingType)
enclosingType
- May be null
.public void setExternal(boolean isExternal)
public void sortFields(Comparator<? super JField> sort)
public void sortMethods(Comparator<? super JMethod> sort)
protected abstract Object writeReplace()
isExternal()
is true
.Copyright © 2018. All rights reserved.