Package org.mvel2.asm

Examples of org.mvel2.asm.Handle


                "java/lang/Object",
                null);

        mv = cw.visitMethod(ACC_PUBLIC, "foo", "()V", null, null);
        mv.visitCode();
        Handle h = new Handle(H_INVOKESTATIC,
                "C",
                "bsm",
                "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/CallSite;");
        mv.visitInvokeDynamicInsn("bar", "()V", h, Type.getType("()V"), h);
        mv.visitInsn(RETURN);
View Full Code Here


        } else if (cst instanceof String) {
            appendString(buf, (String) cst);
        } else if (cst instanceof Type) {
            buf.append("Type.getType(\"").append(cst).append("\")");
        } else if (cst instanceof Handle) {
            Handle h = (Handle) cst;
            buf.append("new Handle(").append(h.getTag()).
                append(", \"").append(h.getOwner()).
                append("\", \"").append(h.getName()).
                append("\", \"").append(h.getDesc()).append("\")");
        } else {
            buf.append(cst);
        }
    }
View Full Code Here

        assertEquals(INVOKESPECIAL, mn.getOpcode());
        assertEquals(AbstractInsnNode.METHOD_INSN, mn.getType());
    }

    public void testInvokeDynamicInsnNode() {
        Handle bsm = new Handle(Opcodes.H_INVOKESTATIC, "owner", "name", "()V");
        InvokeDynamicInsnNode mn = new InvokeDynamicInsnNode(
                "name",
                "()V",
                bsm,
                new Object[0]);
View Full Code Here

                int tag = Integer.parseInt(val.substring(tagIndex + 1, val.length() - 1));
                String owner = val.substring(0, dotIndex);
                String name = val.substring(dotIndex + 1, descIndex);
                String desc = val.substring(descIndex, tagIndex - 1);
                return new Handle(tag, owner, name, desc);

            } catch(RuntimeException e) {
                throw new SAXException("Malformed handle "+val, e);
            }
        }
View Full Code Here

        }

        @Override
        public final void end(final String element) {
            ArrayList<?> bsmArgs = (ArrayList<?>)pop();
            Handle bsm = (Handle)pop();
            String desc = (String)pop();
            String name = (String)pop();
            getCodeVisitor().visitInvokeDynamicInsn(name, desc, bsm, bsmArgs.toArray());
        }
View Full Code Here

    private void addConstant(final Object cst) {
        if (cst instanceof Type) {
            addType((Type) cst);
        } else if (cst instanceof Handle) {
            Handle h = (Handle) cst;
            addInternalName(h.getOwner());
            addMethodDesc(h.getDesc());
        }
    }
View Full Code Here

                return newMethodType(t.getDescriptor());
            } else {
                throw new IllegalArgumentException("value " + cst);
            }
        } else if (cst instanceof Handle) {
            Handle h = (Handle) cst;
            return newHandle(h.getTag(), h.getOwner(), h.getName(), h.getDesc());
        } else {
            throw new IllegalArgumentException("value " + cst);
        }
    }
View Full Code Here

                    case 'y':
                        d = c1.strVal1.compareTo(c2.strVal1);
                        if (d == 0) {
                            d = c1.strVal2.compareTo(c2.strVal2);
                            if (d == 0) {
                                Handle bsm1 = (Handle)c1.objVal3;
                                Handle bsm2 = (Handle)c2.objVal3;
                                d = compareHandle(bsm1, bsm2);
                                if (d == 0) {
                                    d = compareObjects(c1.objVals, c2.objVals);
                                }
                            }
View Full Code Here

            buf.append("Type.getType(\"");
            buf.append(((Type) cst).getDescriptor());
            buf.append("\")");
        } else if (cst instanceof Handle) {
            buf.append("new Handle(");
            Handle h = (Handle) cst;
            buf.append("Handle.").append(HANDLE_TAG[h.getTag()]).append(", \"");
            buf.append(h.getOwner()).append("\", \"");
            buf.append(h.getName()).append("\", \"");
            buf.append(h.getDesc()).append("\")");
        } else if (cst instanceof Byte) {
            buf.append("new Byte((byte)").append(cst).append(')');
        } else if (cst instanceof Boolean) {
            buf.append(((Boolean) cst).booleanValue() ? "Boolean.TRUE" : "Boolean.FALSE");
        } else if (cst instanceof Short) {
View Full Code Here

    public Object mapValue(Object value) {
        if (value instanceof Type) {
            return mapType((Type) value);
        }
        if (value instanceof Handle) {
            Handle h = (Handle) value;
            return new Handle(h.getTag(),
                    mapType(h.getOwner()),
                    mapMethodName(h.getOwner(), h.getName(), h.getDesc()),
                    mapMethodDesc(h.getDesc()));
        }
        return value;
    }
View Full Code Here

TOP

Related Classes of org.mvel2.asm.Handle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.