Hi Claes,
On 11/11/2015 03:32 PM, Claes Redestad wrote:
Paul,
On 2015-11-10 11:55, Paul Sandoz wrote:
DirectMethodHandle
—
682 private static @Stable NamedFunction[] FUNCTIONS = new
NamedFunction[NF_LIMIT];
Invokers
—
442 private static @Stable NamedFunction[] FUNCTIONS = new
NamedFunction[NF_LIMIT];
MethodHandleImpl
—
1627 private static @Stable NamedFunction[] FUNCTIONS = new
NamedFunction[NF_LIMIT];
To be complete you could add “final”, thus it makes it clear that
@Stable refers specifically to the array element.
Paul.
Thanks for having a look and catching this:
http://cr.openjdk.java.net/~redestad/8142334/webrev.03
- added final keyword to FUNCTIONS and HANDLES
- added @Stable to ARRAYS, FILL_ARRAYS, and FILL_ARRAY_TO_RIGHT
/Claes
Would constructing NamedFunction(s) using MemberName(s) directly,
bypassing reflection, make any sense (for example in DMH):
private static NamedFunction makeConstantFunction(int idx) {
try {
switch (idx) {
case NF_internalMemberName:
return makeConstantFunction(Object.class,
"internalMemberName", Object.class);
case NF_internalMemberNameEnsureInit:
return makeConstantFunction(Object.class,
"internalMemberNameEnsureInit", Object.class);
case NF_ensureInitialized:
return makeConstantFunction(void.class,
"ensureInitialized", Object.class);
case NF_fieldOffset:
return makeConstantFunction(long.class,
"fieldOffset", Object.class);
case NF_checkBase:
return makeConstantFunction(Object.class,
"checkBase", Object.class);
case NF_staticBase:
return makeConstantFunction(Object.class,
"staticBase", Object.class);
case NF_staticOffset:
return makeConstantFunction(long.class,
"staticOffset", Object.class);
case NF_checkCast:
return makeConstantFunction(Object.class,
"checkCast", Object.class, Object.class);
case NF_allocateInstance:
return makeConstantFunction(Object.class,
"allocateInstance", Object.class);
case NF_constructorMethod:
return makeConstantFunction(Object.class,
"constructorMethod", Object.class);
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
throw newInternalError("Unknown function index: " + idx);
}
private static NamedFunction makeConstantFunction(
Class<?> rtype, String name, Class<?> ... ptypes) throws
NoSuchMethodException {
return new NamedFunction(
new MemberName(
DirectMethodHandle.class, name,
MethodType.methodType(rtype, ptypes), REF_invokeStatic));
}
...if reflection is not used, there might be some space savings. Or not?
Regards, Peter