Examples of ReturnType


Examples of org.springsource.loaded.Utils.ReturnType

    }
  }

  @Test
  public void testReturnTypeFactoryMethod() throws Exception {
    ReturnType rt = ReturnType.getReturnType("I");
    assertEquals(ReturnType.Kind.PRIMITIVE, rt.kind);
    assertEquals("I", rt.descriptor);
    assertTrue(rt.isPrimitive());
    assertFalse(rt.isDoubleSlot());
    assertFalse(rt.isVoid());

    rt = ReturnType.getReturnType("[Ljava/lang/String;");
    assertEquals(ReturnType.Kind.ARRAY, rt.kind);
    assertEquals("[Ljava/lang/String;", rt.descriptor);
    assertFalse(rt.isPrimitive());
    assertFalse(rt.isDoubleSlot());
    assertFalse(rt.isVoid());

    rt = ReturnType.getReturnType("Ljava/lang/String;");
    assertEquals(ReturnType.Kind.REFERENCE, rt.kind);
    assertEquals("java/lang/String", rt.descriptor);
    assertFalse(rt.isPrimitive());
    assertFalse(rt.isDoubleSlot());
    assertFalse(rt.isVoid());

    rt = ReturnType.getReturnType("[I");
    assertEquals(ReturnType.Kind.ARRAY, rt.kind);
    assertEquals("[I", rt.descriptor);
    assertFalse(rt.isPrimitive());
    assertFalse(rt.isDoubleSlot());
    assertFalse(rt.isVoid());
  }
View Full Code Here

Examples of org.springsource.loaded.Utils.ReturnType

          log.finest("Creating super dispatcher for method "+name+descriptor+" in type "+slashedname);
        }
        // Create a superdispatcher for this method
        MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC, method.getName(), method.getDescriptor(), null, method.getExceptions());
        int ps = Utils.getParameterCount(method.getDescriptor());
        ReturnType methodReturnType = Utils.getReturnTypeDescriptor(method.getDescriptor());
        int lvarIndex = 0;
        mv.visitVarInsn(ALOAD, lvarIndex++); // load this
        Utils.createLoadsBasedOnDescriptor(mv, descriptor, lvarIndex);
        String targetMethod = method.getName().substring(0,method.getName().lastIndexOf("_$"));
        mv.visitMethodInsn(Opcodes.INVOKESPECIAL,typeDescriptor.getSupertypeName(),targetMethod,method.getDescriptor());
        Utils.addCorrectReturnInstruction(mv, methodReturnType, false);
        int maxs = ps + 1;
        if (methodReturnType.isDoubleSlot()) {
          maxs++;
        }
        mv.visitMaxs(maxs, maxs);
        mv.visitEnd();
      }
     
      for (MethodMember method : methods) {
        if (!MethodMember.isCatcher(method)) {
          continue;
        }
        String name = method.getName();
        String descriptor = method.getDescriptor();
        ReturnType returnType = Utils.getReturnTypeDescriptor(descriptor);

        // 1. Create the method signature
        int flags = method.getModifiers();
        if (Modifier.isProtected(flags)) {
          flags = flags - Modifier.PROTECTED + Modifier.PUBLIC;
        }
        MethodVisitor mv = cw.visitMethod(flags, method.getName(), method.getDescriptor(), null, method.getExceptions());

        // 2. Ask the type if anything has changed from first load
        mv.visitFieldInsn(Opcodes.GETSTATIC, slashedname, fReloadableTypeFieldName, lReloadableType);
        mv.visitLdcInsn(method.getId());
        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, tReloadableType, "fetchLatestIfExists", "(I)Ljava/lang/Object;");

        // If the return value is null, there is no implementation
        mv.visitInsn(DUP);

        // 3. create the if statement
        Label l1 = new Label();
        mv.visitJumpInsn(Opcodes.IFNULL, l1);

        // 4. if changed then call the interface to run whatever version has been added
        mv.visitTypeInsn(CHECKCAST, Utils.getInterfaceName(slashedname));

        int lvarIndex = 0;
        mv.visitVarInsn(ALOAD, lvarIndex++); // load this
        Utils.createLoadsBasedOnDescriptor(mv, descriptor, lvarIndex);
        String desc = new StringBuffer("(L").append(slashedname).append(";").append(descriptor.substring(1)).toString();
        mv.visitMethodInsn(INVOKEINTERFACE, Utils.getInterfaceName(slashedname), name, desc);
        Utils.addCorrectReturnInstruction(mv, returnType, true);

        // 5. if unchanged just run the supertype version (could be another catcher...)
        mv.visitLabel(l1);
        mv.visitInsn(POP);
        int ps = Utils.getParameterCount(method.getDescriptor());
        ReturnType methodReturnType = Utils.getReturnTypeDescriptor(method.getDescriptor());

        // A catcher for an interface method is inserted into abstract classes.  These should never be reached unless
        // they now provide an implementation (on a reload) and the subtype has deleted the implementation it had.
        // This means there is never a need to call 'super' in the logic below and getting here when there isn't
        // something to run in the executor is a bug (so we throw AbstractMethodError)
        if (MethodMember.isCatcherForInterfaceMethod(method)) {
          mv.visitTypeInsn(NEW, "java/lang/IllegalStateException");
          mv.visitInsn(DUP);
          mv.visitMethodInsn(INVOKESPECIAL, "java/lang/AbstractMethodError", "<init>", "()V");
          mv.visitInsn(ATHROW);
        } else {
          mv.visitVarInsn(ALOAD, 0); // load this
          Utils.createLoadsBasedOnDescriptor(mv, method.getDescriptor(), 1);
          mv.visitMethodInsn(INVOKESPECIAL, supertypeName, method.getName(), method.getDescriptor());
          Utils.addCorrectReturnInstruction(mv, methodReturnType, false);
        }

        int maxs = ps + 1;
        if (methodReturnType.isDoubleSlot()) {
          maxs++;
        }
        mv.visitMaxs(maxs, maxs);
        mv.visitEnd();
      }
View Full Code Here

Examples of org.springsource.loaded.Utils.ReturnType

     *
     */
    private void createProtectedFieldGetterSetter(FieldMember field) {
      String descriptor = field.descriptor;
      String name = field.name;
      ReturnType rt = ReturnType.getReturnType(descriptor);
      if (field.isStatic()) {
        MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC | Modifier.STATIC, Utils.getProtectedFieldGetterName(name), "()"
            + descriptor, null, null);
        mv.visitFieldInsn(GETSTATIC, slashedname, name, descriptor);
        Utils.addCorrectReturnInstruction(mv, rt, false);
        mv.visitMaxs(rt.isDoubleSlot() ? 2 : 1, 0);
        mv.visitEnd();

        mv = cw.visitMethod(Modifier.PUBLIC | Modifier.STATIC, Utils.getProtectedFieldSetterName(name), "(" + descriptor
            + ")V", null, null);
        insertCorrectLoad(mv, rt, 0);
        mv.visitFieldInsn(PUTSTATIC, slashedname, name, descriptor);
        mv.visitInsn(RETURN);
        mv.visitMaxs(rt.isDoubleSlot() ? 2 : 1, 1);
        mv.visitEnd();
      } else {
        MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC, Utils.getProtectedFieldGetterName(name), "()" + descriptor,
            null, null);
        mv.visitVarInsn(ALOAD, 0);
        mv.visitFieldInsn(GETFIELD, slashedname, name, descriptor);
        Utils.addCorrectReturnInstruction(mv, rt, false);
        mv.visitMaxs(rt.isDoubleSlot() ? 2 : 1, 1);
        mv.visitEnd();

        mv = cw.visitMethod(Modifier.PUBLIC, Utils.getProtectedFieldSetterName(name), "(" + descriptor + ")V", null, null);
        mv.visitVarInsn(ALOAD, 0);
        insertCorrectLoad(mv, rt, 1);
        mv.visitFieldInsn(PUTFIELD, slashedname, name, descriptor);
        mv.visitInsn(RETURN);
        mv.visitMaxs(rt.isDoubleSlot() ? 3 : 2, 2);
        mv.visitEnd();
      }
    }
View Full Code Here

Examples of org.springsource.loaded.Utils.ReturnType

      super.visitEnd();
    }
  }

  private void createDummyMethodBody() {
    ReturnType returnType = Utils.getReturnTypeDescriptor(descriptor);
    int descriptorSize = Utils.getSize(descriptor);
    if (returnType.isVoid()) {
      super.visitInsn(RETURN);
      super.visitMaxs(1, descriptorSize);
    } else if (returnType.isPrimitive()) {
      super.visitLdcInsn(0);
      switch (returnType.descriptor.charAt(0)) {
      case 'B':
      case 'C':
      case 'I':
View Full Code Here

Examples of org.springsource.loaded.Utils.ReturnType

          super.visitMethodInsn(opcode, owner, name, desc, itf);
          return;
        }
        rewroteOtherKindOfOperation = true;
        boolean hasParams = desc.charAt(1) != ')';
        ReturnType returnType = Utils.getReturnTypeDescriptor(desc);
        // boolean isVoidReturn = returnType.isVoid();
        int classId = typeRegistry.getTypeIdFor(owner, true);
        if (opcode == INVOKESTATIC) {
          rewriteINVOKESTATIC(opcode, owner, name, desc, hasParams, returnType, classId, itf);
        } else if (opcode == INVOKEINTERFACE) {
View Full Code Here

Examples of org.springsource.loaded.Utils.ReturnType

        }

        // 4. Unpack parameter array to fit the descriptor for that method
        Utils.generateInstructionsToUnpackArrayAccordingToDescriptor(mv, method.descriptor, 1);

        ReturnType returnType = Utils.getReturnTypeDescriptor(method.descriptor);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, executorClassName, method.name, callDescriptor, false);
        if (returnType.isVoid()) {
          mv.visitInsn(ACONST_NULL);
        } else if (returnType.isPrimitive()) {
          Utils.insertBoxInsns(mv, returnType.descriptor);
        }
        mv.visitInsn(Opcodes.ARETURN);
        mv.visitLabel(label);
      }
View Full Code Here

Examples of org.springsource.loaded.Utils.ReturnType

      boolean isStatic = method.isStatic();

      MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, name, descriptor, signature, exceptions);
      mv.visitCode();
      // The input descriptor will include the extra initial parameter (the instance, or null for static methods)
      ReturnType returnTypeDescriptor = Utils.getReturnTypeDescriptor(descriptor);
      // For a static method the first parameter can be ignored
      int params = Utils.getParameterCount(descriptor);
      String callDescriptor = isStatic ? originalDescriptor : descriptor;
      Utils.createLoadsBasedOnDescriptor(mv, callDescriptor, isStatic ? 2 : 1);
      mv.visitMethodInsn(INVOKESTATIC, executorClassName, name, callDescriptor, false);
View Full Code Here

Examples of org.test.proxy.doclitnonwrapped.ReturnType

        assertNotNull(service);
        DocLitnonWrappedProxy proxy = service.getPort(portName, DocLitnonWrappedProxy.class);
        assertNotNull(proxy);
        BindingProvider p = (BindingProvider)proxy;
        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
        ReturnType response = proxy.invoke(invokeObj);
        assertNotNull(response);
        TestLogger.logger.debug(">>Response =" + response.getReturnStr());

        TestLogger.logger.debug("-------------------------------------");
    }
View Full Code Here

Examples of org.test.proxy.doclitnonwrapped.ReturnType

        assertNotNull(service);
        DocLitnonWrappedProxy proxy = service.getPort(portName, DocLitnonWrappedProxy.class);
        assertNotNull(proxy);
        BindingProvider p = (BindingProvider)proxy;
        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
        ReturnType response = proxy.invoke(invokeObj);
        assertNull(response);

        TestLogger.logger.debug("-------------------------------------");
    }
View Full Code Here

Examples of org.test.proxy.doclitnonwrapped.ReturnType

        assertNotNull(service);
        DocLitnonWrappedProxy proxy = service.getPort(portName, DocLitnonWrappedProxy.class);
        assertNotNull(proxy);
        BindingProvider p = (BindingProvider)proxy;
        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,axisEndpoint);
        ReturnType response = proxy.invoke(invokeObj);
        assertNotNull(response);
        TestLogger.logger.debug(">>Response =" + response.getReturnStr());

        TestLogger.logger.debug("-------------------------------------");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.