Package com.caucho.bytecode

Examples of com.caucho.bytecode.CodeWriterAttribute


        JavaMethod ctor =
          jClass.createMethod("<init>",
                              "(Lcom/caucho/config/inject/InjectManager$ReferenceFactory;)V");
        ctor.setAccessFlags(Modifier.PUBLIC);

        CodeWriterAttribute code = ctor.createCodeWriter();
        code.setMaxLocals(3);
        code.setMaxStack(4);

        code.pushObjectVar(0);
        code.pushObjectVar(1);
        code.putField(thisClassName, factoryField.getName(),
                      factoryField.getDescriptor());
       
        code.pushObjectVar(0);
        code.invokespecial(superClassName, "<init>", "()V", 1, 0);
        code.addReturn();
        code.close();

        createGetDelegateMethod(jClass);
        createSerialize(jClass);

        for (Method method : getMethods(_types)) {
View Full Code Here


                                             descriptor);
    jMethod.setAccessFlags(Modifier.PUBLIC);

    Class<?> []parameterTypes = method.getParameterTypes();

    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(1 + 2 * parameterTypes.length);
    code.setMaxStack(3 + 2 * parameterTypes.length);

    code.pushObjectVar(0);
    code.getField(jClass.getThisClass(), "_factory",
                  "Lcom/caucho/config/inject/InjectManager$ReferenceFactory;");
   
    code.invoke("com/caucho/config/inject/InjectManager$ReferenceFactory",
                "create",
                "()Ljava/lang/Object;",
                3, 1);

    code.cast(method.getDeclaringClass().getName().replace('.', '/'));

    int stack = 1;
    int index = 1;
    for (Class<?> type : parameterTypes) {
      if (boolean.class.equals(type)
          || byte.class.equals(type)
          || short.class.equals(type)
          || int.class.equals(type)) {
        code.pushIntVar(index);
        index += 1;
        stack += 1;
      }
      else if (long.class.equals(type)) {
        code.pushLongVar(index);
        index += 2;
        stack += 2;
      }
      else if (float.class.equals(type)) {
        code.pushFloatVar(index);
        index += 1;
        stack += 1;
      }
      else if (double.class.equals(type)) {
        code.pushDoubleVar(index);
        index += 2;
        stack += 2;
      }
      else {
        code.pushObjectVar(index);
        index += 1;
        stack += 1;
      }
    }

    if (isInterface) {
      code.invokeInterface(method.getDeclaringClass().getName().replace('.', '/'),
                           method.getName(),
                           createDescriptor(method),
                           stack, 1);
    }
    else {
      code.invoke(method.getDeclaringClass().getName().replace('.', '/'),
                  method.getName(),
                  createDescriptor(method),
                  stack, 1);
    }

    Class<?> retType = method.getReturnType();

    if (boolean.class.equals(retType)
        || byte.class.equals(retType)
        || short.class.equals(retType)
        || int.class.equals(retType)) {
      code.addIntReturn();
    }
    else if (long.class.equals(retType)) {
      code.addLongReturn();
    }
    else if (float.class.equals(retType)) {
      code.addFloatReturn();
    }
    else if (double.class.equals(retType)) {
      code.addDoubleReturn();
    }
    else if (void.class.equals(retType)) {
      code.addReturn();
    }
    else {
      code.addObjectReturn();
    }

    code.close();
  }
View Full Code Here

                                             descriptor);
    jMethod.setAccessFlags(Modifier.PUBLIC);

    Class<?> []parameterTypes = method.getParameterTypes();

    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(1 + 2 * parameterTypes.length);
    code.setMaxStack(3 + 2 * parameterTypes.length);

    code.newInstance("java/lang/UnsupportedOperationException");
    code.dup();
    code.invokespecial("java/lang/UnsupportedOperationException",
                       "<init>",
                       "()V",
                       3, 1);
    code.addThrow();

    code.close();
  }
View Full Code Here

    JavaMethod jMethod = jClass.createMethod("__caucho_getDelegate",
                                             descriptor);
    jMethod.setAccessFlags(Modifier.PUBLIC);

    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(1);
    code.setMaxStack(3);

    code.pushObjectVar(0);
    code.getField(jClass.getThisClass(), "_factory",
                  "Lcom/caucho/config/inject/InjectManager$ReferenceFactory;");

    code.invoke("com/caucho/config/inject/InjectManager$ReferenceFactory",
                "create",
                "()Ljava/lang/Object;",
                3, 1);

    code.addObjectReturn();

    code.close();
  }
View Full Code Here

    JavaMethod jMethod = jClass.createMethod("writeReplace",
                                             descriptor);
   
    jMethod.setAccessFlags(Modifier.PRIVATE);

    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(1);
    code.setMaxStack(3);

    code.newInstance("com/caucho/config/bytecode/ScopeProxyHandle");
    code.dup();
   
    code.pushObjectVar(0);
    code.getField(jClass.getThisClass(), "_factory",
                  "Lcom/caucho/config/inject/InjectManager$ReferenceFactory;");
   
    code.invokespecial("com/caucho/config/bytecode/ScopeProxyHandle",
                       "<init>",
                       "(Lcom/caucho/config/inject/InjectManager$ReferenceFactory;)V",
                       3, 1);

    code.addObjectReturn();

    code.close();
  }
View Full Code Here

     
    JavaMethod ctor = jClass.createMethod("<init>", descriptor);
     
    ctor.setAccessFlags(Modifier.PUBLIC);
     
    CodeWriterAttribute code = ctor.createCodeWriter();
    code.setMaxLocals(5 + 2 * types.length);
    code.setMaxStack(5 + 2 * types.length);

    code.pushObjectVar(0);

    marshal(code, types);

    code.invokespecial(superClassName, "<init>", descriptor, 1, 0);
    code.addReturn();
    code.close();
  }
View Full Code Here

    JavaMethod jMethod
      = jClass.createMethod("writeReplace", "()Ljava/lang/Object;");
   
    jMethod.setAccessFlags(Modifier.PRIVATE);
     
    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(5);
    code.setMaxStack(5);

    code.pushObjectVar(0);
    code.getField(jClass.getThisClass(), "__caucho_handle",
                   "Ljava/lang/Object;");

    code.addObjectReturn();
   
    code.close();
  }
View Full Code Here

    JavaMethod jMethod
      = jClass.createMethod("setSerializationHandle", "(Ljava/lang/Object;)V");
   
    jMethod.setAccessFlags(Modifier.PUBLIC);
     
    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(5);
    code.setMaxStack(5);

    code.pushObjectVar(0);
    code.pushObjectVar(1);
    code.putField(jClass.getThisClass(), "__caucho_handle",
                  "Ljava/lang/Object;");

    code.addReturn();
   
    code.close();
  }
View Full Code Here

      JavaMethod ctor =
        jClass.createMethod("<init>", "()V");
      ctor.setAccessFlags(Modifier.PUBLIC);

      CodeWriterAttribute code = ctor.createCodeWriter();
      code.setMaxLocals(3);
      code.setMaxStack(4);

      code.pushObjectVar(0);
      code.invokespecial(superClassName, "<init>", "()V", 1, 0);
      code.addReturn();
      code.close();

      for (Method method : _cl.getMethods()) {
        if (Modifier.isStatic(method.getModifiers()))
          continue;
        if (Modifier.isFinal(method.getModifiers()))
View Full Code Here

                                             descriptor);
    jMethod.setAccessFlags(Modifier.PUBLIC);

    Class<?> []parameterTypes = method.getParameterTypes();

    CodeWriterAttribute code = jMethod.createCodeWriter();
    code.setMaxLocals(1 + 2 * parameterTypes.length);
    code.setMaxStack(3 + 2 * parameterTypes.length);
   
    String exnClass = UnsupportedOperationException.class.getName();
    exnClass = exnClass.replace('.', '/');
   
    code.newInstance(exnClass);
    code.dup();
   
    code.invokespecial(exnClass, "<init>", "()V", 1, 1);

    code.addThrow();

    code.close();
  }
View Full Code Here

TOP

Related Classes of com.caucho.bytecode.CodeWriterAttribute

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.