本文整理汇总了Java中sun.invoke.util.Wrapper.ordinal方法的典型用法代码示例。如果您正苦于以下问题:Java Wrapper.ordinal方法的具体用法?Java Wrapper.ordinal怎么用?Java Wrapper.ordinal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.invoke.util.Wrapper
的用法示例。
在下文中一共展示了Wrapper.ordinal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: widen
import sun.invoke.util.Wrapper; //导入方法依赖的package包/类
void widen(Wrapper ws, Wrapper wt) {
if (ws != wt) {
int opcode = wideningOpcodes[ws.ordinal()][wt.ordinal()];
if (opcode != Opcodes.NOP) {
visitInsn(opcode);
}
}
}
示例2: identity
import sun.invoke.util.Wrapper; //导入方法依赖的package包/类
/**
* Produces a method handle which returns its sole argument when invoked.
* @param type the type of the sole parameter and return value of the desired method handle
* @return a unary method handle which accepts and returns the given type
* @throws NullPointerException if the argument is null
* @throws IllegalArgumentException if the given type is {@code void.class}
*/
public static
MethodHandle identity(Class<?> type) {
Wrapper btw = (type.isPrimitive() ? Wrapper.forPrimitiveType(type) : Wrapper.OBJECT);
int pos = btw.ordinal();
MethodHandle ident = IDENTITY_MHS[pos];
if (ident == null) {
ident = setCachedMethodHandle(IDENTITY_MHS, pos, makeIdentity(btw.primitiveType()));
}
if (ident.type().returnType() == type)
return ident;
// something like identity(Foo.class); do not bother to intern these
assert(btw == Wrapper.OBJECT);
return makeIdentity(type);
}
示例3: identity
import sun.invoke.util.Wrapper; //导入方法依赖的package包/类
/**
* Produces a method handle which returns its sole argument when invoked.
* @param type the type of the sole parameter and return value of the desired method handle
* @return a unary method handle which accepts and returns the given type
* @throws NullPointerException if the argument is null
* @throws IllegalArgumentException if the given type is {@code void.class}
*/
public static
MethodHandle identity(Class<?> type) {
Wrapper btw = (type.isPrimitive() ? Wrapper.forPrimitiveType(type) : Wrapper.OBJECT);
int pos = btw.ordinal();
MethodHandle ident = IDENTITY_MHS[pos];
if (ident == null) {
ident = setCachedMethodHandle(IDENTITY_MHS, pos, makeIdentity(btw.primitiveType()));
}
if (ident.type().returnType() == type)
return ident;
// something like identity(Foo.class); do not bother to intern these
assert (btw == Wrapper.OBJECT);
return makeIdentity(type);
}
示例4: initWidening
import sun.invoke.util.Wrapper; //导入方法依赖的package包/类
private static void initWidening(Wrapper to, int opcode, Wrapper... from) {
for (Wrapper f : from) {
wideningOpcodes[f.ordinal()][to.ordinal()] = opcode;
}
}