Package org.springframework.asm

Examples of org.springframework.asm.ClassWriter.visit()


    private static byte[] generateByteCodeForInterface(final String interfaceName, Class<?>... interfacesToImplement) {

      String interfaceResourcePath = ClassUtils.convertClassNameToResourcePath(interfaceName);

      ClassWriter cw = new ClassWriter(0);
      cw.visit(V1_6, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, interfaceResourcePath, null, "java/lang/Object",
          toResourcePaths(interfacesToImplement));
      cw.visitSource(interfaceResourcePath + ".java", null);
      cw.visitEnd();

      return cw.toByteArray();
View Full Code Here


  @SuppressWarnings("unchecked")
  private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl expressionToCompile) {
    // Create class outline 'spel/ExNNN extends org.springframework.expression.spel.CompiledExpression'
    String clazzName = "spel/Ex" + getNextSuffix();
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES);
    cw.visit(V1_5, ACC_PUBLIC, clazzName, null, "org/springframework/expression/spel/CompiledExpression", null);

    // Create default constructor
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
View Full Code Here

  }

  byte[] generateClassBytecode(String className, Class<? extends DataSerializable> clazz, int classId) {
    ClassWriter cw = new ClassWriter(0);

    cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, className, null, INSTANTIATOR_NAME, new String[] { SERIALIZABLE_NAME });
    FieldVisitor fv = cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, CLASS_FIELD_NAME, CLASS_DESCRIPTOR, null,
        null);
    fv.visitEnd();
    fv = cw.visitField(ACC_PRIVATE + ACC_FINAL + ACC_STATIC, ID_FIELD_NAME, Type.INT_TYPE.getDescriptor(), null,
        Integer.valueOf(classId));
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.