private void createArrayDefinition(final MethodVisitor mv, final int size, final Class<?> type) { if (size < 0) { throw new IllegalStateException("Array size cannot be less than zero"); } pushIntOntoStack(mv, size); mv.visitTypeInsn(ANEWARRAY, type.getCanonicalName().replace('.', '/')); }
/** * pushes an array of the specified size to the method visitor. The generated bytecode will leave * the new array at the top of the stack. * * @param mv MethodVisitor to use * @param size Size of the array to create * @param type Type of array to create * @throws ProxyGenerationException */ protected void createArrayDefinition(MethodVisitor mv, int size, Class<?> type) throws ProxyGenerationException { // create a new array of java.lang.class (2) if (size < 0) { throw new ProxyGenerationException("Array size cannot be less than zero"); } pushIntOntoStack(mv, size); mv.visitTypeInsn(Opcodes.ANEWARRAY, type.getCanonicalName().replace('.', '/')); }
mv.visitTypeInsn(Opcodes.CHECKCAST, Type.getInternalName(classToProxy));
mv.visitTypeInsn(Opcodes.CHECKCAST, getCastType(returnType));
private void createSerialisation(final ClassWriter cw, final String pluginId, final String key) { final MethodVisitor mv = cw .visitMethod(Modifier.PUBLIC, "writeReplace", "()Ljava/lang/Object;", null, new String[] { Type.getType(ObjectStreamException.class).getInternalName() }); mv.visitCode(); mv.visitTypeInsn(NEW, "org/talend/sdk/component/runtime/serialization/SerializableService"); mv.visitInsn(DUP); mv.visitLdcInsn(pluginId); mv.visitLdcInsn(key); mv .visitMethodInsn(INVOKESPECIAL, "org/talend/sdk/component/runtime/serialization/SerializableService", "<init>", "(Ljava/lang/String;Ljava/lang/String;)V", false); mv.visitInsn(ARETURN); mv.visitMaxs(-1, -1); mv.visitEnd(); }
mv.visitTypeInsn(CHECKCAST, getCastType(returnType)); .visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/InvocationTargetException", "getCause", "()Ljava/lang/Throwable;", false); mv.visitTypeInsn(CHECKCAST, getCastType(exceptionType)); mv.visitInsn(ATHROW); mv.visitLabel(l6); mv.visitTypeInsn(NEW, "java/lang/reflect/UndeclaredThrowableException"); mv.visitInsn(DUP); mv.visitVarInsn(ALOAD, length);
mv.visitTypeInsn(Opcodes.CHECKCAST, getCastType(returnType)); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/reflect/InvocationTargetException", "getCause", "()Ljava/lang/Throwable;", false); mv.visitTypeInsn(Opcodes.CHECKCAST, getCastType(exceptionType)); mv.visitInsn(Opcodes.ATHROW); mv.visitLabel(l6); mv.visitTypeInsn(Opcodes.NEW, "java/lang/reflect/UndeclaredThrowableException"); mv.visitInsn(Opcodes.DUP); mv.visitVarInsn(Opcodes.ALOAD, length);