Java Code Examples for sun.invoke.util.Wrapper#basicTypeChar()
The following examples show how to use
sun.invoke.util.Wrapper#basicTypeChar() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Transformers.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
public static void spreadArray(short[] array, StackFrameWriter writer, MethodType type, int numArgs, int offset) { final Class<?>[] ptypes = type.ptypes(); for (int i = 0; i < numArgs; ++i) { Class<?> argumentType = ptypes[i + offset]; short s = array[i]; switch (Wrapper.basicTypeChar(argumentType)) { case 'L': { writer.putNextReference(s, argumentType); break; } case 'I': { writer.putNextInt(s); break; } case 'J': { writer.putNextLong(s); break; } case 'S': { writer.putNextShort(s); break; } case 'F': { writer.putNextFloat(s); break; } case 'D': { writer.putNextDouble(s); break; } default : { throw new AssertionError(); } } } }
Example 2
Source File: InvokerBytecodeGenerator.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** * Emits an actual return instruction conforming to the given return type. */ private void emitReturnInsn(Class<?> type) { int opcode; switch (Wrapper.basicTypeChar(type)) { case 'I': opcode = Opcodes.IRETURN; break; case 'J': opcode = Opcodes.LRETURN; break; case 'F': opcode = Opcodes.FRETURN; break; case 'D': opcode = Opcodes.DRETURN; break; case 'L': opcode = Opcodes.ARETURN; break; case 'V': opcode = Opcodes.RETURN; break; default: throw new InternalError("unknown return type: " + type); } mv.visitInsn(opcode); }
Example 3
Source File: InvokerBytecodeGenerator.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Emit an unboxing call (plus preceding checkcast). * * @param wrapper wrapper type class to unbox. */ private void emitUnboxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = wrapper.primitiveSimpleName() + "Value"; String desc = "()" + wrapper.basicTypeChar(); emitReferenceCast(wrapper.wrapperType(), null); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc, false); }
Example 4
Source File: InvokerBytecodeGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Emit a boxing call. * * @param wrapper primitive type class to box. */ private void emitBoxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = "valueOf"; String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";"; mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false); }
Example 5
Source File: InvokerBytecodeGenerator.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Emit a boxing call. * * @param wrapper primitive type class to box. */ private void emitBoxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = "valueOf"; String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";"; mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false); }
Example 6
Source File: InvokerBytecodeGenerator.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Emit an unboxing call (plus preceding checkcast). * * @param wrapper wrapper type class to unbox. */ private void emitUnboxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = wrapper.primitiveSimpleName() + "Value"; String desc = "()" + wrapper.basicTypeChar(); emitReferenceCast(wrapper.wrapperType(), null); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc, false); }
Example 7
Source File: InvokerBytecodeGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Emit a boxing call. * * @param wrapper primitive type class to box. */ private void emitBoxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = "valueOf"; String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";"; mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false); }
Example 8
Source File: Transformers.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private static Object shortArray(StackFrameReader reader, Class<?> ptypes[], int offset, int length) { short[] arityArray = new short[length]; for (int i = 0; i < length; ++i) { Class<?> argumentType = ptypes[i + offset]; switch (Wrapper.basicTypeChar(argumentType)) { case 'S': { arityArray[i] = reader.nextShort(); break; } case 'B': { arityArray[i] = reader.nextByte(); break; } default: { arityArray[i] = (Short) reader.nextReference(argumentType); break; } } } return arityArray; }
Example 9
Source File: InvokerBytecodeGenerator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Emit a boxing call. * * @param wrapper primitive type class to box. */ private void emitBoxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = "valueOf"; String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";"; mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false); }
Example 10
Source File: Transformers.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
public static void spreadArray(boolean[] array, StackFrameWriter writer, MethodType type, int numArgs, int offset) { final Class<?>[] ptypes = type.ptypes(); for (int i = 0; i < numArgs; ++i) { Class<?> argumentType = ptypes[i + offset]; boolean z = array[i]; switch (Wrapper.basicTypeChar(argumentType)) { case 'L': { writer.putNextReference(z, argumentType); break; } case 'Z': { writer.putNextBoolean(z); break; } default : { throw new AssertionError(); } } } }
Example 11
Source File: InvokerBytecodeGenerator.java From Java8CN with Apache License 2.0 | 5 votes |
/** * Emit a boxing call. * * @param wrapper primitive type class to box. */ private void emitBoxing(Wrapper wrapper) { String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String name = "valueOf"; String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";"; mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false); }
Example 12
Source File: MethodHandleImpl.java From Java8CN with Apache License 2.0 | 4 votes |
static String name(Class<?> arrayClass, boolean isSetter) { Class<?> elemClass = arrayClass.getComponentType(); if (elemClass == null) throw newIllegalArgumentException("not an array", arrayClass); return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass); }
Example 13
Source File: LambdaForm.java From jdk-1.7-annotated with Apache License 2.0 | 4 votes |
public static char basicType(Class<?> type) { char c = Wrapper.basicTypeChar(type); if ("ZBSC".indexOf(c) >= 0) c = 'I'; assert("LIJFDV".indexOf(c) >= 0); return c; }
Example 14
Source File: TypeConvertingMethodAdapter.java From Bytecoder with Apache License 2.0 | 4 votes |
private static String boxingDescriptor(Wrapper w) { return "(" + w.basicTypeChar() + ")L" + wrapperName(w) + ";"; }
Example 15
Source File: LambdaForm.java From hottub with GNU General Public License v2.0 | 4 votes |
static BasicType basicType(Wrapper type) { char c = type.basicTypeChar(); return basicType(c); }
Example 16
Source File: MethodHandleImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
static String name(Class<?> arrayClass, boolean isSetter) { Class<?> elemClass = arrayClass.getComponentType(); if (elemClass == null) throw newIllegalArgumentException("not an array", arrayClass); return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass); }
Example 17
Source File: InvokerBytecodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Emits a return statement from a LF invoker. If required, the result type is cast to the correct return type. */ private void emitReturn() { // return statement if (lambdaForm.result == -1) { // void mv.visitInsn(Opcodes.RETURN); } else { LambdaForm.Name rn = lambdaForm.names[lambdaForm.result]; char rtype = Wrapper.basicTypeChar(invokerType.returnType()); // put return value on the stack if it is not already there if (lambdaForm.result != lambdaForm.names.length - 1) { emitLoadInsn(rn.type, lambdaForm.result); } // potentially generate cast // rtype is the return type of the invoker - generated code must conform to this // rn.type is the type of the result Name in the LF if (rtype != rn.type) { // need cast if (rtype == 'L') { // possibly cast the primitive to the correct type for boxing char boxedType = Wrapper.forWrapperType(invokerType.returnType()).basicTypeChar(); if (boxedType != rn.type) { emitPrimCast(rn.type, boxedType); } // cast primitive to reference ("boxing") emitBoxing(invokerType.returnType()); } else { // to-primitive cast if (rn.type != 'L') { // prim-to-prim cast emitPrimCast(rn.type, rtype); } else { // ref-to-prim cast ("unboxing") throw new InternalError("no ref-to-prim (unboxing) casts supported right now"); } } } // generate actual return statement emitReturnInsn(invokerType.returnType()); } }
Example 18
Source File: MethodHandleImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static String name(Class<?> arrayClass, boolean isSetter) { Class<?> elemClass = arrayClass.getComponentType(); if (elemClass == null) throw newIllegalArgumentException("not an array", arrayClass); return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass); }
Example 19
Source File: TypeConvertingMethodAdapter.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static String unboxingDescriptor(Wrapper w) { return "()" + w.basicTypeChar(); }
Example 20
Source File: MethodHandleImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
static String name(Class<?> arrayClass, boolean isSetter) { Class<?> elemClass = arrayClass.getComponentType(); if (elemClass == null) throw newIllegalArgumentException("not an array", arrayClass); return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass); }