Examples of ClassWriter


Examples of aj.org.objectweb.asm.ClassWriter

public class StackMapAdder {

  public static byte[] addStackMaps(World world, byte[] data) {
    try {
      ClassReader cr = new ClassReader(data);
      ClassWriter cw = new AspectJConnectClassWriter(world);
      cr.accept(cw, 0);
      return cw.toByteArray();
    } catch (Throwable t) {
      System.err.println("AspectJ Internal Error: unable to add stackmap attributes. " + t.getMessage());
      AsmDetector.isAsmAround = false;
      return data;
    }
View Full Code Here

Examples of br.com.caelum.vraptor.asm.ClassWriter

    final String newTypeName = method.getDeclaringClass().getSimpleName().replace('.', '/') + "$"
        + method.getName() + "$" + Math.abs(method.hashCode()) + "$" + (++classLoadCounter);
    logger.debug("Trying to make class for " + newTypeName);

    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);

    cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, newTypeName, null, "java/lang/Object", new String[] {"java/io/Serializable"});

    {
      MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
      mv.visitCode();
      mv.visitVarInsn(ALOAD, 0);
      mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
      mv.visitInsn(RETURN);
      mv.visitMaxs(1, 1);
      mv.visitEnd();
    }
    StringBuilder valueLists = new StringBuilder();
    java.lang.reflect.Type[] types = method.getGenericParameterTypes();
    String[] names = provider.parameterNamesFor(method);
    for (int i = 0; i < names.length; i++) {
      names[i] = Info.capitalize(names[i]);
    }
    if (logger.isDebugEnabled()) {
      logger.debug("Parameter names found for creating type are: " + Arrays.toString(names));
    }
    for (int i = 0; i < types.length; i++) {
      java.lang.reflect.Type type = types[i];
      if (type instanceof ParameterizedType) {
        parse(cw, (ParameterizedType) type, valueLists, newTypeName, names[i]);
      } else if (type instanceof Class<?>) {
        parse(cw, (Class<?>) type, valueLists, newTypeName, names[i]);
      } else if (type instanceof TypeVariable<?>) {
        ParameterizedType superclass = (ParameterizedType) resourceMethod.getResource().getType().getGenericSuperclass();
        parse(cw, (Class<?>) superclass.getActualTypeArguments()[0], valueLists, newTypeName, names[i]);
      } else {
        throw new IllegalArgumentException("Unable to identify field " + type + " of type "
            + type.getClass().getName());
      }

    }
    cw.visitEnd();
    final byte[] bytes = cw.toByteArray();

    ClassLoader loader = new ClassLoader(this.getClass().getClassLoader()) {
      @Override
      public Class<?> loadClass(String name) throws ClassNotFoundException {
        if (name.equals(newTypeName)) {
View Full Code Here

Examples of com.alibaba.citrus.asm.ClassWriter

    private final class ClassRule extends Rule {

        public final void begin(final String name, final Attributes attrs) {
            int major = Integer.parseInt(attrs.getValue("major"));
            int minor = Integer.parseInt(attrs.getValue("minor"));
            cw = new ClassWriter(computeMax ? ClassWriter.COMPUTE_MAXS : 0);
            Map vals = new HashMap();
            vals.put("version", new Integer(minor << 16 | major));
            vals.put("access", attrs.getValue("access"));
            vals.put("name", attrs.getValue("name"));
            vals.put("parent", attrs.getValue("parent"));
View Full Code Here

Examples of com.alibaba.fastjson.asm.ClassWriter

            throw new IllegalArgumentException("not support type :" + clazz.getName());
        }

        String className = getGenClassName(clazz);

        ClassWriter cw = new ClassWriter();
        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, className, getType(ASMJavaBeanDeserializer.class), null);

        DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz);

        _init(cw, new Context(className, config, beanInfo, 3));
        _createInstance(cw, new Context(className, config, beanInfo, 3));
        _deserialze(cw, new Context(className, config, beanInfo, 4));

        byte[] code = cw.toByteArray();

        // org.apache.commons.io.IOUtils.write(code, new java.io.FileOutputStream(
        // "/usr/alibaba/workspace-3.7/fastjson-asm/target/classes/"
        // + className + ".class"));
View Full Code Here

Examples of com.antlersoft.classwriter.ClassWriter

        public void run()
        {
            Stack directoryStack=new Stack();
            directoryStack.push( classUrl);
            Filesystem system=classUrl.getFilesystem();
            ClassWriter classwriter=new ClassWriter();
            final long startTime=System.currentTimeMillis();
            try
            {
                while ( ! directoryStack.isEmpty())
                {
                    Url currentDirectory=(Url)directoryStack.pop();
                    Url[] contents=system.getChildren( currentDirectory, null,
                        Filesystem.TYPE_BOTH);
                    for ( int i=0; i<contents.length; i++)
                    {
                        if ( system.isDirectory( contents[i]))
                            directoryStack.push( contents[i]);
                        else
                        {
                            if ( contents[i].getFileExtension().
                                equals( "class") &&
                                system.getLastModified( contents[i])>
                                lastModified)
                            {
System.out.println( "Analyzing "+contents[i].toString());
                                BufferedInputStream bis=
                                    new BufferedInputStream(
                                    system.getInputStream( contents[i]));
                                classwriter.readClass( bis);
                                DBClass.addClassToDB( classwriter,
                                    db);
                                bis.close();
                            }
                        }
View Full Code Here

Examples of com.cloudera.sqoop.orm.ClassWriter

          + " will be generated.");
      return null;
    }
    LOG.info("Beginning code generation");
    CompilationManager compileMgr = new CompilationManager(options);
    ClassWriter classWriter = new ClassWriter(options, manager, tableName,
        compileMgr);
    classWriter.generate();
    compileMgr.compile();
    compileMgr.jar();
    String jarFile = compileMgr.getJarFilename();
    this.generatedJarFiles.add(jarFile);
    return jarFile;
View Full Code Here

Examples of com.edb.os.xstream.writer.ClassWriter

     *
     * This gets called with special stuff such as the inner list for a list implementation
     */
    public void startNode(String name) {
        // get the current parent to create the correct class writer for this element
        ClassWriter childWriter = currentParent.createChildWriter(name, currentDepth++);
        stack.add(childWriter);
    }
View Full Code Here

Examples of com.google.gwt.dev.asm.ClassWriter

      byte[] classBytes, Map<String, String> anonymousClassMap) {
    String desc = toDescriptor(className);
    assert (!jsoIntfDescs.contains(desc));

    // The ASM model is to chain a bunch of visitors together.
    ClassWriter writer = new ClassWriter(0);
    ClassVisitor v = writer;

    // v = new CheckClassAdapter(v);
    // v = new TraceClassVisitor(v, new PrintWriter(System.out));

    v = new RewriteSingleJsoImplDispatches(v, typeOracle, jsoData);

    v = new RewriteRefsToJsoClasses(v, jsoIntfDescs, mapper);

    if (jsoImplDescs.contains(desc)) {
      v = WriteJsoImpl.create(v, desc, jsoIntfDescs, mapper, jsoData);
    }

    v = new RewriteJsniMethods(v, anonymousClassMap);

    if (Double.parseDouble(System.getProperty("java.class.version")) < Opcodes.V1_6) {
      v = new ForceClassVersion15(v);
    }

    new ClassReader(classBytes).accept(v, 0);
    return writer.toByteArray();
  }
View Full Code Here

Examples of com.googlecode.aviator.asm.ClassWriter

    private final class ClassRule extends Rule {

        public final void begin(final String name, final Attributes attrs) {
            int major = Integer.parseInt(attrs.getValue("major"));
            int minor = Integer.parseInt(attrs.getValue("minor"));
            cw = new ClassWriter(computeMax ? ClassWriter.COMPUTE_MAXS : 0);
            HashMap vals = new HashMap();
            vals.put("version", new Integer(minor << 16 | major));
            vals.put("access", attrs.getValue("access"));
            vals.put("name", attrs.getValue("name"));
            vals.put("parent", attrs.getValue("parent"));
View Full Code Here

Examples of com.jd.glowworm.asm.ClassWriter

            throw new IllegalArgumentException("not support type :" + clazz.getName());
        }

        String className = getGenClassName(clazz);

        ClassWriter cw = new ClassWriter();
        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, className, getType(ASMJavaBeanDeserializer.class), null);

        DeserializeBeanInfo beanInfo = DeserializeBeanInfo.computeSetters(clazz, type);

        _init(cw, new Context(className, config, beanInfo, 3));
        _createInstance(cw, new Context(className, config, beanInfo, 3));
        _deserialze(cw, new Context(className, config, beanInfo, 4));

        byte[] code = cw.toByteArray();

        /*org.apache.commons.io.IOUtils.write(code, new java.io.FileOutputStream(
          "d:/"+ className + ".class"));*/

        Class<?> exampleClass = classLoader.defineClassPublic(className, code, 0, code.length);
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.