Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.MethodNode


        shimClassNode.methods.add(mn);
    }

    private void implementShimInvoke(ClassNode shimClassNode)
    {
        MethodNode mn = new MethodNode(ACC_PUBLIC, "invoke", OBJECT_INT_OBJECT_ARRAY_TO_METHOD_INVOCATION_RESULT, null,
                null);

        InstructionBuilder builder = newBuilder(mn);

        // Arg 0 is the target instance
View Full Code Here


                        FieldNode field = context.getFieldNode();
                        return field.name.equals(expected);
                    }

                    if (context.getMethodNode() != null) {
                        MethodNode method = context.getMethodNode();
                        return method.name.equals(expected);
                    }

                    if (context.getClassNode() != null) {
                        ClassNode clazz = context.getClassNode();
View Full Code Here

     * @param exceptions : method exceptions
     * @return the Method Visitor.
     * @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])
     */
    public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
        return new MethodMetadataCollector(workbench, new MethodNode(access, name, desc, signature, exceptions), reporter);
    }
View Full Code Here

                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {

                        ComponentWorkbench workbench = context.getWorkbench();
                        // @Property on method parameter
                        Element properties = Elements.getPropertiesElement(workbench);
                        MethodNode method = context.getMethodNode();
                        return new ParameterPropertyVisitor(properties, method, context.getParameterIndex());
                    }
                });

        bind(Validate.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new LifecycleVisitor(context.getWorkbench(),
                                Names.computeEffectiveMethodName(node.name),
                                LifecycleVisitor.Transition.VALIDATE);
                    }
                });

        bind(Invalidate.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new LifecycleVisitor(context.getWorkbench(),
                                Names.computeEffectiveMethodName(node.name),
                                LifecycleVisitor.Transition.INVALIDATE);
                    }
                });

        bind(Updated.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new UpdatedVisitor(context.getWorkbench(),
                                Names.computeEffectiveMethodName(node.name));
                    }
                });

        bind(Bind.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new MethodBindVisitor(context.getWorkbench(), Action.BIND, node, context.getReporter());
                    }
                });

        bind(Unbind.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new MethodBindVisitor(context.getWorkbench(), Action.UNBIND, node, context.getReporter());
                    }
                });

        bind(Modified.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new MethodBindVisitor(context.getWorkbench(), Action.MODIFIED, node, context.getReporter());
                    }
                });

        bind(PostRegistration.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new PostRegistrationVisitor(context.getWorkbench(), node.name);
                    }
                });

        bind(PostUnregistration.class)
                .to(new AnnotationVisitorFactory() {
                    public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
                        MethodNode node = context.getMethodNode();
                        return new PostRegistrationVisitor(context.getWorkbench(), node.name);
                    }
                });

        bind(Context.class).to(new GenericVisitorFactory("context", ""));
View Full Code Here

    public void visitEnd() {
      for (Iterator<?> it = classToMerge.fields.iterator(); it.hasNext();) {
        ((FieldNode) it.next()).accept(this);
      }
      for (Iterator<?> it = classToMerge.methods.iterator(); it.hasNext();) {
        MethodNode mn = (MethodNode) it.next();

        // skip the init.
        if (mn.name.equals("<init>"))
          continue;

        String[] exceptions = new String[mn.exceptions.size()];
        mn.exceptions.toArray(exceptions);
        MethodVisitor mv = cv.visitMethod(mn.access | Modifier.FINAL, mn.name, mn.desc, mn.signature, exceptions);
        mn.instructions.resetLabels();
        // mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, new
        // SimpleRemapper("org.apache.drill.exec.compile.ExampleTemplate", "Bunky")));
        mn.accept(new RemappingMethodAdapter(mn.access, mn.desc, mv, new SimpleRemapper(cname.replace('.', FileUtils.separatorChar),
            classToMerge.name.replace('.', FileUtils.separatorChar))));
      }
      super.visitEnd();
    }
View Full Code Here

    }
   
    @Override
    protected void transformNode(ClassNode cn) {
        for( Object omn : cn.methods ) {
            MethodNode mn = (MethodNode) omn;
            if ( shouldVisit( cn, mn )) {
                transformMethod( cn, mn );
            }
        }
    }
View Full Code Here

        cr.accept(new CheckClassAdapter(ca), ClassWriter.COMPUTE_MAXS);
        boolean failed = false;

        List methods = ca.methods;
        for (int i = 0; i < methods.size(); ++i) {
            MethodNode method = (MethodNode) methods.get(i);
            if (method.instructions.size() > 0) {
                Analyzer a = new Analyzer(new SimpleVerifier());
                try {
                    a.analyze(ca.name, method);
                    continue;
View Full Code Here

  @Test
  public void checkAnnotationLogic() throws Exception {
    PurrPackageSelector selector = new PurrPackageSelector();
    selector.classLoader = clb.makeUninstrumentedClassLoader();
    ClassNode cn = new ClassNode();
    MethodNode mn = new MethodNode();
    cn.name = "jcr/SampleTest";
    mn.name = "foo";
    // null annotations.
    assertFalse(selector.shouldVisit(cn, mn));
View Full Code Here

  @Test
    public void testCheckForOldStyleJUnitTests() throws Exception {
      ClassNode cn = new ClassNode();
      cn.name = "jcr/OldStyleSampleTest";

      MethodNode mn = new MethodNode();
      mn.name = "testFoo";

      PurrPackageSelector selector = new PurrPackageSelector( );
      selector.classLoader = this.getClass().getClassLoader();
      try {       
View Full Code Here

        private String createAccessMethod()
        {
            String name = String.format("%s$access%s", node.name, PlasticUtils.nextUID());

            // Kind of awkward that exceptions are specified as String[] when what we have handy is List<String>
            MethodNode mn = new MethodNode(ACC_SYNTHETIC | ACC_FINAL, name, node.desc, node.signature, null);
            // But it is safe enough for the two nodes to share
            mn.exceptions = node.exceptions;

            InstructionBuilder builder = newBuilder(mn);
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.MethodNode

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.