public final class IntrinsicObjects
extends java.lang.Object
@Intrisic
annotation) may have
their layout within the containing object instance optimized by JDK implementations, such that access
to their content is faster, and avoids certain de-referencing steps.
The IntrinsicObjects
class provides static methods for constructing objects
that are @Intrisic
to their containing class. Calls to
constructWithin(String fieldName, Object containingObject)
(and variants) are used to construct and
initialize intrinsic objects associated with specific instance fields that are declared as
@Intrisic
in their containing class.
Some example of declaring an intrinsic object include:
public class Line { private static final MethodHandles.Lookup lookup = MethodHandles.lookup(); // // Simple intrinsic object declaration and initialization: // @Intrinsic private final Point endPoint1 = IntrinsicObjects.constructWithin(lookup, "endPoint1", this); @Intrinsic private final Point endPoint2 = IntrinsicObjects.constructWithin(lookup, "endPoint2", this); ... } public class Octagon { private static final MethodHandles.Lookup lookup = MethodHandles.lookup(); // // Intrinsic object declaration and initialization for a StructuredArray member: // @Intrinsic(length = 8) private final StructuredArray<Point> points = IntrinsicObjects.constructWithin(lookup, "points", this); ... }
Modifier and Type | Method and Description |
---|---|
static <T> T |
constructWithin(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.String fieldName,
java.lang.Object containingObject)
Construct an intrinsic object at the given field within the containing object, using a default constructor.
|
static <T> T |
constructWithin(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.String fieldName,
java.lang.Object containingObject,
java.lang.reflect.Constructor<T> objectConstructor,
java.lang.Object... args)
Construct an intrinsic object at the given field within the containing object, using the given
constructor and arguments.
|
static <T> T |
constructWithin(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.String fieldName,
java.lang.Object containingObject,
CtorAndArgs<T> objectCtorAndArgs)
Construct an intrinsic object at the given field within the containing object, using the
constructor and arguments supplied in the given objectCtorAndArgs argument.
|
static <T> T |
constructWithin(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.String fieldName,
java.lang.Object containingObject,
PrimitiveArrayBuilder arrayBuilder)
Construct an intrinsic object at the given field within the containing object, using the
supplied
PrimitiveArrayBuilder . |
static <T> T |
constructWithin(java.lang.invoke.MethodHandles.Lookup lookup,
java.lang.String fieldName,
java.lang.Object containingObject,
StructuredArrayBuilder arrayBuilder)
Construct an intrinsic object at the given field within the containing object, using the
supplied
StructuredArrayBuilder . |
public static <T> T constructWithin(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.String fieldName, java.lang.Object containingObject)
The field specified in fieldName
must be annotated with @Intrisic
,
and must be declared private and final.
T
- The type of the intrinsic object being constructedlookup
- The lookup object to use for accessing the fieldfieldName
- The name of the field within the containing objectcontainingObject
- The object instance that will contain this intrinsic objectpublic static <T> T constructWithin(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.String fieldName, java.lang.Object containingObject, java.lang.reflect.Constructor<T> objectConstructor, java.lang.Object... args)
The field specified in fieldName
must be annotated with @Intrisic
,
and must be declared private and final.
T
- The type of the intrinsic object being constructedlookup
- The lookup object to use for accessing the fieldfieldName
- The name of the field within the containing objectcontainingObject
- The object instance that will contain this intrinsic objectobjectConstructor
- The constructor to be used in constructing the intrinsic object instanceargs
- the arguments to be used with the objectConstructorpublic static <T> T constructWithin(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.String fieldName, java.lang.Object containingObject, CtorAndArgs<T> objectCtorAndArgs)
The field specified in fieldName
must be annotated with @Intrisic
,
and must be declared private and final.
T
- The type of the intrinsic object being constructedlookup
- The lookup object to use for accessing the fieldfieldName
- The name of the field within the containing objectcontainingObject
- The object instance that will contain this intrinsic objectobjectCtorAndArgs
- The constructor and arguments to be used in constructing the
intrinsic object instancepublic static <T> T constructWithin(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.String fieldName, java.lang.Object containingObject, StructuredArrayBuilder arrayBuilder)
StructuredArrayBuilder
. This form of constructWithin() can only be used
to construct intrinsic objects that derive from StructuredArray
.
The field specified in fieldName
must be annotated with @Intrisic
,
and must be declared private and final.
T
- The type of the intrinsic object being constructedlookup
- The lookup object to use for accessing the fieldfieldName
- The name of the field within the containing objectcontainingObject
- The object instance that will contain this intrinsic objectarrayBuilder
- The StructuredArrayBuilder
instance to be used in constructing the arraypublic static <T> T constructWithin(java.lang.invoke.MethodHandles.Lookup lookup, java.lang.String fieldName, java.lang.Object containingObject, PrimitiveArrayBuilder arrayBuilder)
PrimitiveArrayBuilder
. This form of constructWithin() can only be used
to construct intrinsic objects that derive from AbstractPrimitiveArray
.
The field specified in fieldName
must be annotated with @Intrisic
,
and must be declared private and final.
T
- The type of the intrinsic object being constructedlookup
- The lookup object to use for accessing the fieldfieldName
- The name of the field within the containing objectcontainingObject
- The object instance that will contain this intrinsic objectarrayBuilder
- The PrimitiveArrayBuilder
instance to be used in constructing the array