Examples of ClassWriter


Examples of org.powermock.objectweb.asm.ClassWriter

    public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
        if (loader == null || shouldIgnore(className)) {
            return null;
        }
        final ClassReader reader = new ClassReader(classfileBuffer);
        final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        reader.accept(new PowerMockClassVisitor(writer),
                ClassReader.SKIP_FRAMES);
        return writer.toByteArray();
    }
View Full Code Here

Examples of org.rsbot.loader.asm.ClassWriter

  }

  private ClassVisitor delegate(final String clazz) {
    final ClassAdapter delegate = adapters.get(clazz);
    if (delegate == null) {
      final ClassWriter writer = new ClassWriter(0);
      writers.put(clazz, writer);
      return writer;
    } else {
      return delegate;
    }
View Full Code Here

Examples of org.springframework.asm.ClassWriter

    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

Examples of scala.tools.asm.ClassWriter

        className.startsWith("instrumented/"));
  }

        public byte[] transform(final ClassLoader classLoader, final String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
          if (shouldTransform(className)) {
            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS) {
              @Override protected String getCommonSuperClass(final String type1, final String type2) {
                // Since we are not recomputing stack frame map, this should never be called we override this method because
                // default implementation uses reflection for implementation and might try to load the class that we are
                // currently processing. That leads to weird results like swallowed exceptions and classes being not
                // transformed.
                throw new RuntimeException("Unexpected call to getCommonSuperClass(" + type1 + ", " + type2 +
                    ") while transforming " + className);
              }
            };
                ProfilerVisitor visitor = new ProfilerVisitor(writer);
                ClassReader reader = new ClassReader(classfileBuffer);
                reader.accept(visitor, 0);
                return writer.toByteArray();
          } else {
            return classfileBuffer;
          }
        }
View Full Code Here

Examples of webit.script.asm.lib.ClassWriter

    static Class createResolverClass(Class beanClass) throws Exception {
        //XXX: rewrite
        if (ClassUtil.isPublic(beanClass)) {
            final String className = "webit.script.asm.Resolver".concat(ASMUtil.getSn());

            final ClassWriter classWriter = new ClassWriter(Constants.V1_5, Constants.ACC_PUBLIC + Constants.ACC_FINAL, ASMUtil.getInternalName(className), "java/lang/Object", ASM_RESOLVER);
            ASMUtil.visitConstructor(classWriter);

            final FieldInfo[] all = FieldInfoResolver.resolve(beanClass);
            Arrays.sort(all);
            final int size = all.length;
            int[] hashs;
            int[] indexer;
            if (size > 0) {
                hashs = new int[size];
                indexer = new int[size];
                int hashsCount = 0;
                int hash;
                hashs[hashsCount++] = hash = all[0].hashCode;
                int i = 1;
                while (i < size) {
                    FieldInfo fieldInfo = all[i];
                    if (hash != fieldInfo.hashCode) {
                        indexer[hashsCount - 1] = i;
                        hashs[hashsCount++] = hash = fieldInfo.hashCode;
                    }
                    i++;
                }
                indexer[hashsCount - 1] = size;
                hashs = Arrays.copyOf(hashs, hashsCount);
                indexer = Arrays.copyOf(indexer, hashsCount);
            } else {
                hashs = null;
                indexer = null;
            }

            visitXetMethod(true, classWriter, beanClass, all, hashs, indexer);
            visitXetMethod(false, classWriter, beanClass, all, hashs, indexer);

            //getMatchClass
            final MethodWriter m = classWriter.visitMethod(Constants.ACC_PUBLIC, "getMatchClass", "()Ljava/lang/Class;", null);
            m.visitInsn(Constants.ACONST_NULL);
            m.visitInsn(Constants.ARETURN);
            m.visitMaxs();

            return ASMUtil.loadClass(className, classWriter);
View Full Code Here

Examples of writers.ClassWriter

            }
          }
         
        } else {
          // document a class and its public properties
          new ClassWriter().write( classDoc );
          Tag[] classTags = classDoc.tags(Shared.i().getWebrefTagName());
          if (classTags.length != 0) {
            // add to the index under the @webref category:sub_category
            indexWriter.addItem(classDoc, classTags[0]);
          }
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.