Modifier and Type | Class and Description |
---|---|
pack-priv class | ClassSpecializer.
Code generation support for instances. |
pack-priv abstract class | ClassSpecializer.
Meta-data wrapper for concrete subtypes of the top class. |
Modifier and Type | Field and Description |
---|---|
private final MethodType | |
private final ConcurrentHashMap | |
private static final Function | |
private static final String[] | |
private final ClassSpecializer | |
private final Class | |
private final Class | |
private static final String | |
private static final String | |
private final MemberName | |
private final String | |
private static final String | |
private static final String | |
private final Class | |
private boolean | |
private final S | |
private final List |
Access | Constructor and Description |
---|---|
protected | ClassSpecializer(Class<T>
type mirror for T topClass, Class<K> type mirror for K keyType, Class<S> type mirror for S metaType, MethodType principal constructor type baseConstructorType, MemberName the method used to get the speciesData sdAccessor, String the name of the species data field, inject the speciesData object sdFieldName, List<MemberName> optional list of transformMethods transformMethods)Constructor for this class specializer. |
Modifier and Type | Method and Description |
---|---|
protected MethodType | |
pack-priv static String | |
pack-priv static String | |
pack-priv static String | |
pack-priv static String | |
pack-priv static String | |
protected final ClassSpecializer | |
public final S | |
public final Class | |
protected ClassSpecializer | |
public final Class | |
pack-priv static String | |
private static RuntimeException | |
protected abstract S | |
protected static <T> Constructor | |
protected static Field | |
public final Class | |
protected final S | |
protected K | |
protected final List | transformMethods()
Return the list of transform methods originally given at creation of this specializer. |
baseConstructorType | back to summary |
---|---|
private final MethodType baseConstructorType |
cache | back to summary |
---|---|
private final ConcurrentHashMap<K, Object> cache |
CREATE_RESERVATION | back to summary |
---|---|
private static final Function<Object, Object> CREATE_RESERVATION |
E_THROWABLE | back to summary |
---|---|
private static final String[] E_THROWABLE |
factory | back to summary |
---|---|
private final ClassSpecializer<T, K, S>. |
keyType | back to summary |
---|---|
private final Class<K> keyType |
metaType | back to summary |
---|---|
private final Class<S> metaType |
MH | back to summary |
---|---|
private static final String MH |
MH_SIG | back to summary |
---|---|
private static final String MH_SIG |
sdAccessor | back to summary |
---|---|
private final MemberName sdAccessor |
sdFieldName | back to summary |
---|---|
private final String sdFieldName |
STABLE | back to summary |
---|---|
private static final String STABLE |
STABLE_SIG | back to summary |
---|---|
private static final String STABLE_SIG |
topClass | back to summary |
---|---|
private final Class<T> topClass |
topClassIsSuper | back to summary |
---|---|
private boolean topClassIsSuper
|
topSpecies | back to summary |
---|---|
private final S topSpecies |
transformMethods | back to summary |
---|---|
private final List<MemberName> transformMethods |
ClassSpecializer | back to summary |
---|---|
protected ClassSpecializer(Class<T> topClass, Class<K> keyType, Class<S> metaType, MethodType baseConstructorType, MemberName sdAccessor, String sdFieldName, List<MemberName> transformMethods) Constructor for this class specializer.
|
baseConstructorType | back to summary |
---|---|
protected MethodType baseConstructorType() Report the leading arguments (if any) required by every species factory. Every species factory adds its own field types as additional arguments, but these arguments always come first, in every factory method. |
classBCName | back to summary |
---|---|
pack-priv static String classBCName(Class<?> cls) |
classBCName | back to summary |
---|---|
pack-priv static String classBCName(String str) |
className | back to summary |
---|---|
pack-priv static String className(Class<?> cls) |
classSig | back to summary |
---|---|
pack-priv static String classSig(Class<?> cls) |
classSig | back to summary |
---|---|
pack-priv static String classSig(String bcName) |
factory | back to summary |
---|---|
protected final ClassSpecializer Return the factory object used to build and load concrete species code. |
findSpecies | back to summary |
---|---|
public final S findSpecies(K key) |
keyType | back to summary |
---|---|
public final Class Return the key type mirror, for type |
makeFactory | back to summary |
---|---|
protected ClassSpecializer Hook that virtualizes the Factory class, allowing subclasses to extend it. |
metaType | back to summary |
---|---|
public final Class Return the species metadata type mirror, for type |
methodSig | back to summary |
---|---|
pack-priv static String methodSig(MethodType mt) |
newIAE | back to summary |
---|---|
private static RuntimeException newIAE(String message, Throwable cause) |
newSpeciesData | back to summary |
---|---|
protected abstract S newSpeciesData(K key) |
reflectConstructor | back to summary |
---|---|
protected static <T> Constructor |
reflectField | back to summary |
---|---|
protected static Field reflectField(Class<?> defc, String name) |
topClass | back to summary |
---|---|
public final Class Return the top type mirror, for type |
topSpecies | back to summary |
---|---|
protected final S topSpecies() Return the trivial species for the null sequence of arguments. |
topSpeciesKey | back to summary |
---|---|
protected K topSpeciesKey() |
transformMethods | back to summary |
---|---|
protected final List Return the list of transform methods originally given at creation of this specializer. |
Modifier and Type | Field and Description |
---|---|
private static final int | |
private final String | |
private final int | |
private final String | |
private final String | |
private final List | |
private final List | |
private final List |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
protected String | chooseFieldName(Class<?> type, int index)
Field names in concrete species classes adhere to this pattern: type + index, where type is a single character (L, I, J, F, D). |
private void | |
private List | |
pack-priv MethodHandle | |
private MethodHandle | |
private List | |
pack-priv Class | Returns: the generated concrete TopClass classof the species className, ClassSpecializer<T, K, S>.what species we are generating speciesDataGenerate a concrete subclass of the top class for a given combination of bound types. |
pack-priv byte[] | generateConcreteSpeciesCodeFile(String className0, ClassSpecializer<T, K, S>.
|
protected void | linkCodeToSpeciesData(Class<? extends T> speciesCode, ClassSpecializer<T, K, S>.
|
protected void | linkSpeciesDataToCode(ClassSpecializer<T, K, S>.
|
pack-priv S | Returns: a linked version of the same speciesthe species requiring the class, not yet linked speciesData)Get a concrete subclass of the top class for a given combination of bound types. |
protected S | |
pack-priv List | |
private S | |
private Field | |
private int |
ACC_PPP | back to summary |
---|---|
private static final int ACC_PPP |
SPECIES_DATA | back to summary |
---|---|
private final String SPECIES_DATA |
SPECIES_DATA_MODS | back to summary |
---|---|
private final int SPECIES_DATA_MODS |
SPECIES_DATA_NAME | back to summary |
---|---|
private final String SPECIES_DATA_NAME |
SPECIES_DATA_SIG | back to summary |
---|---|
private final String SPECIES_DATA_SIG |
TRANSFORM_MODS | back to summary |
---|---|
private final List<Integer> TRANSFORM_MODS |
TRANSFORM_NAMES | back to summary |
---|---|
private final List<String> TRANSFORM_NAMES |
TRANSFORM_TYPES | back to summary |
---|---|
private final List<MethodType> TRANSFORM_TYPES |
Factory | back to summary |
---|---|
pack-priv Factory() Constructs a factory. |
chooseFieldName | back to summary |
---|---|
protected String chooseFieldName(Class<?> type, int index) Field names in concrete species classes adhere to this pattern: type + index, where type is a single character (L, I, J, F, D). The factory subclass can customize this. The name is purely cosmetic, since it applies to a private field. |
emitIntConstant | back to summary |
---|---|
private void emitIntConstant(int con, MethodVisitor mv) |
findFactories | back to summary |
---|---|
private List |
findFactory | back to summary |
---|---|
pack-priv MethodHandle findFactory(Class<? extends T> speciesCode, List<Class<?>> types) |
findGetter | back to summary |
---|---|
private MethodHandle findGetter(Class<?> speciesCode, List<Class<?>> types, int index) |
findGetters | back to summary |
---|---|
private List |
generateConcreteSpeciesCode | back to summary |
---|---|
pack-priv Class Generate a concrete subclass of the top class for a given combination of bound types. A concrete species subclass roughly matches the following schema: class Species_[[types]] extends [[T]] { final [[S]] speciesData() { return ... } static [[T]] make([[fields]]) { return ... } [[fields]] final [[T]] transform([[args]]) { return ... } }The [[types]] signature is precisely the key for the species.
The [[fields]] section consists of one field definition per character in
the type signature, adhering to the naming schema described in the definition of
chooseFieldName .
For example, a concrete species for two references and one integral bound value
has a shape like the following:
class TopClass { ... private static final class Species_LLI extends TopClass { final Object argL0; final Object argL1; final int argI2; private Species_LLI(CT ctarg, ..., Object argL0, Object argL1, int argI2) { super(ctarg, ...); this.argL0 = argL0; this.argL1 = argL1; this.argI2 = argI2; } final SpeciesData speciesData() { return BMH_SPECIES; } @Stable static SpeciesData BMH_SPECIES; // injected afterwards static TopClass make(CT ctarg, ..., Object argL0, Object argL1, int argI2) { return new Species_LLI(ctarg, ..., argL0, argL1, argI2); } final TopClass copyWith(CT ctarg, ...) { return new Species_LLI(ctarg, ..., argL0, argL1, argI2); } // two transforms, for the sake of illustration: final TopClass copyWithExtendL(CT ctarg, ..., Object narg) { return BMH_SPECIES.transform(L_TYPE).invokeBasic(ctarg, ..., argL0, argL1, argI2, narg); } final TopClass copyWithExtendI(CT ctarg, ..., int narg) { return BMH_SPECIES.transform(I_TYPE).invokeBasic(ctarg, ..., argL0, argL1, argI2, narg); } } }
|
generateConcreteSpeciesCodeFile | back to summary |
---|---|
pack-priv byte[] generateConcreteSpeciesCodeFile(String className0, ClassSpecializer<T, K, S>. |
linkCodeToSpeciesData | back to summary |
---|---|
protected void linkCodeToSpeciesData(Class<? extends T> speciesCode, ClassSpecializer<T, K, S>. |
linkSpeciesDataToCode | back to summary |
---|---|
protected void linkSpeciesDataToCode(ClassSpecializer<T, K, S>. |
loadSpecies | back to summary |
---|---|
pack-priv S loadSpecies(S speciesData) Get a concrete subclass of the top class for a given combination of bound types.
|
loadSpeciesDataFromCode | back to summary |
---|---|
protected S loadSpeciesDataFromCode(Class<? extends T> speciesCode) |
makeNominalGetters | back to summary |
---|---|
pack-priv List |
readSpeciesDataFromCode | back to summary |
---|---|
private S readSpeciesDataFromCode(Class<? extends T> speciesCode) |
reflectSDField | back to summary |
---|---|
private Field reflectSDField(Class<? extends T> speciesCode) |
typeLoadOp | back to summary |
---|---|
private int typeLoadOp(char t) |
Modifier and Type | Field and Description |
---|---|
private List | |
private final List | |
private List | |
private final K | |
private List | |
private Class | |
private final MethodHandle[] |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
protected String | Returns: class name, which by default isouter().topClass().getName() + "$Species_" + deriveTypeString(key) Given a key, generate the name of the class which implements the species for that key. |
protected abstract List | deriveFieldTypes(K key)
Given a key, derive the list of field types, which all instances of this species must store. |
protected Class | Returns: the super-class of the class to be generatedReport what immediate super-class to use for the concrete class of this species. |
protected abstract MethodHandle | Returns: the method handle which creates a new result from a mix of transform arguments and field valuesthe transform being implemented transform, int the index of that transform in the original list of transforms whichtm)Given the index of a method in the transforms list, supply a factory method that takes the arguments of the transform, plus the local fields, and produce a value of the required type. |
protected abstract < the common element type of the various lists X> List | Returns: a new listthe transform being implemented transform, int the index of that transform in the original list of transforms whichtm, List<X> a list of opaque objects representing the incoming transform arguments args, List<X> a list of opaque objects representing the field values of the receiver fields)During code generation, this method is called once per transform to determine what is the mix of arguments to hand to the transform-helper. |
protected String | Returns: a string suitable for use in a class nameDefault implementation collects basic type characters, plus possibly type names, if some types don't correspond to basic types. |
public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
protected MethodHandle | |
protected final int | |
protected final List | |
protected MethodHandle | |
protected LambdaForm. | getterFunction(int i)
Return a |
protected List | |
protected List | |
public int | |
protected final boolean | |
public final K | |
protected ClassSpecializer | |
protected final Class | |
public String | |
protected MethodHandle | |
private final MethodType |
factories | back to summary |
---|---|
private List<MethodHandle> factories
|
fieldTypes | back to summary |
---|---|
private final List<Class<?>> fieldTypes |
getters | back to summary |
---|---|
private List<MethodHandle> getters
|
key | back to summary |
---|---|
private final K key |
nominalGetters | back to summary |
---|---|
private List<LambdaForm. |
speciesCode | back to summary |
---|---|
private Class<? extends T> speciesCode
|
transformHelpers | back to summary |
---|---|
private final MethodHandle[] transformHelpers
|
SpeciesData | back to summary |
---|---|
protected SpeciesData(K key) |
deriveClassName | back to summary |
---|---|
protected String deriveClassName() Given a key, generate the name of the class which implements the species for that key. This algorithm must be stable.
|
deriveFieldTypes | back to summary |
---|---|
protected abstract List Given a key, derive the list of field types, which all instances of this species must store. |
deriveSuperClass | back to summary |
---|---|
protected Class Report what immediate super-class to use for the concrete class of this species.
Normally this is
|
deriveTransformHelper | back to summary |
---|---|
protected abstract MethodHandle deriveTransformHelper(MemberName transform, int whichtm) Given the index of a method in the transforms list, supply a factory method that takes the arguments of the transform, plus the local fields, and produce a value of the required type. You can override this to return null or throw if there are no transforms. This method exists so that the transforms can be "grown" lazily. This is necessary if the transform *adds* a field to an instance, which sometimes requires the creation, on the fly, of an extended species. This method is only called once for any particular parameter. The species caches the result in a private array.
|
deriveTransformHelperArguments | back to summary |
---|---|
protected abstract <X> List During code generation, this method is called once per transform to determine what is the mix of arguments to hand to the transform-helper. The bytecode which marshals these arguments is open-coded in the species-specific transform. The two lists are of opaque objects, which you shouldn't do anything with besides reordering them into the output list. (They are both mutable, to make editing easier.) The imputed types of the args correspond to the transform's parameter list, while the imputed types of the fields correspond to the species field types. After code generation, this method may be called occasionally by error-checking code.
|
deriveTypeString | back to summary |
---|---|
protected String deriveTypeString() Default implementation collects basic type characters, plus possibly type names, if some types don't correspond to basic types.
|
equals | back to summary |
---|---|
public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
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. |
factory | back to summary |
---|---|
protected MethodHandle factory() |
fieldCount | back to summary |
---|---|
protected final int fieldCount() |
fieldTypes | back to summary |
---|---|
protected final List |
getter | back to summary |
---|---|
protected MethodHandle getter(int i) Return a |
getterFunction | back to summary |
---|---|
protected LambdaForm. Return a |
getterFunctions | back to summary |
---|---|
protected List |
getters | back to summary |
---|---|
protected List |
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
|
isResolved | back to summary |
---|---|
protected final boolean isResolved() |
key | back to summary |
---|---|
public final K key() |
outer | back to summary |
---|---|
protected ClassSpecializer |
speciesCode | back to summary |
---|---|
protected final Class Throws NPE if this species is not yet resolved. |
toString | back to summary |
---|---|
public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- |
transformHelper | back to summary |
---|---|
protected MethodHandle transformHelper(int whichtm) |
transformHelperType | back to summary |
---|---|
private final MethodType transformHelperType(int whichtm) |