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.Modifier and Type | Class and Description |
---|---|
static class |
JDeclaredType.JsInteropType
The type of JsType this can be: NONE, NO_PROTOTYPE, JS_PROTOTYPE, NATIVE_PROTOTYPE (e.g.
|
HasName.Util
Modifier and Type | Field and Description |
---|---|
protected List<JField> |
fields
This type's fields.
|
protected JDeclaredType.JsInteropType |
jsInteropType |
protected String |
jsPrototype |
protected List<JMethod> |
methods
This type's methods.
|
BY_NAME_COMPARATOR
Constructor and Description |
---|
JDeclaredType(SourceInfo info,
String name,
JDeclaredType.JsInteropType interopType) |
JDeclaredType(SourceInfo info,
String name,
JDeclaredType.JsInteropType interopType,
String jsPrototype) |
Modifier and Type | Method and Description |
---|---|
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. |
JMethod |
findMethod(String methodSignature,
boolean recurse)
Returns the method with the given signature, if there is one.
Optionally can search up the super type chain. |
JDeclaredType |
findSubtype(Iterable<JDeclaredType> types)
Determines whether a subclass of this type is in the collection
types . |
JMethod |
getClinitMethod()
Returns the class initializer method.
|
JDeclaredType |
getClinitTarget()
Returns the class that must be initialized to use this class.
|
String[] |
getCompoundName()
Returns the compound name.
|
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() |
JDeclaredType.JsInteropType |
getJsInteropType() |
String |
getJsNamespace() |
String |
getJsniSignatureName() |
String |
getJsPrototype() |
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 |
getQualifiedExportName() |
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.
|
boolean |
isInstantiable()
Returns whether this type can be instantiated.
|
boolean |
isJsType() |
void |
removeField(int i)
Removes the field at the specified index.
|
void |
removeMethod(int i)
Removes the method at the specified index.
|
void |
resolve(List<JInterfaceType> resolvedInterfaces,
String jsNamespace)
Resolves external references during AST stitching.
|
void |
setEnclosingType(JDeclaredType enclosingType)
Sets the type which encloses this types.
|
void |
setExternal(boolean isExternal) |
void |
setJsNamespace(String jsNamespace) |
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
getName, getPackageName, getShortName, isEnumOrSubclass
getSourceInfo, setSourceInfo, toSource, toString
isAbstract
isFinal
traverse
protected final String jsPrototype
protected final JDeclaredType.JsInteropType jsInteropType
public JDeclaredType(SourceInfo info, String name, JDeclaredType.JsInteropType interopType, String jsPrototype)
public JDeclaredType(SourceInfo info, String name, JDeclaredType.JsInteropType interopType)
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 JMethod findMethod(String methodSignature, boolean recurse)
public JDeclaredType findSubtype(Iterable<JDeclaredType> types)
types
.types
- a collections of types.types
contains a subtype of this type; null otherwise.public final JMethod getClinitMethod()
public final JDeclaredType getClinitTarget()
null
if this class has no static initializer.public String[] getCompoundName()
JType
The compound name of a class is an array that contains the simple names of all enclosing types followed by the simple name of this type (in outer to inner order).
A simple name is the name as it appears in the class declaration (e.g. Name in "class Name { .. }"), i.e. it is a name that does not include enclosing type names nor package.
getCompoundName
in class JType
public JDeclaredType getEnclosingType()
null
.public List<JField> getFields()
public List<JInterfaceType> getImplements()
public final JMethod getInitMethod()
public String getJavahSignatureName()
getJavahSignatureName
in class JReferenceType
public String getJsniSignatureName()
getJsniSignatureName
in class JReferenceType
public final List<JMethod> getMethods()
public boolean isJsType()
public JDeclaredType.JsInteropType getJsInteropType()
public String getJsPrototype()
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 boolean isInstantiable()
public void removeField(int i)
public void removeMethod(int i)
public void resolve(List<JInterfaceType> resolvedInterfaces, String jsNamespace)
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
.public String getQualifiedExportName()
public String getJsNamespace()
public void setJsNamespace(String jsNamespace)
Copyright © 2018. All rights reserved.