Package org.objectweb.asm

Examples of org.objectweb.asm.ClassReader.accept()


    String classResource = "/" + klazz.getName().replace('.', '/') + ".class";
   
    InputStream stream = MetaScannerTest.class.getResourceAsStream(classResource);
    ClassReader cr = new ClassReader(stream);
    ClassMetadata info = new ClassMetadata();
    cr.accept(new MetaScanner(info), 0);
    stream.close();
    return info;
  }
}
View Full Code Here


            new SimpleRemapper( HELP_MOJO_CLASS_NAME, packageAsDirectory + '/' + HELP_MOJO_CLASS_NAME );
        ClassVisitor cv = new RemappingClassAdapter( cw, packageRemapper );

        try
        {
            cr.accept( cv, ClassReader.EXPAND_FRAMES );
        }
        catch ( Throwable e )
        {
            throw new GeneratorException( "ASM issue processing class-file " + helpClassFile.getPath(), e );
        }
View Full Code Here

    * annotation class.
    */
   private static boolean isAnnotationClass(byte[] bytes) {
       IsAnnotationVisitor isAnnotationVisitor = new IsAnnotationVisitor();
       ClassReader classReader = new ClassReader(bytes);
       classReader.accept(isAnnotationVisitor, ClassReader.SKIP_DEBUG);
       return isAnnotationVisitor.isAnnotation;
   }

   public static class IsAnnotationVisitor extends EmptyVisitor {
       public boolean isAnnotation = false;
View Full Code Here

       * enum class.
         */
    private static boolean isEnum(byte[] bytes) {
        IsEnumVisitor isEnumVisitor = new IsEnumVisitor();
        ClassReader classReader = new ClassReader(bytes);
        classReader.accept(isEnumVisitor, ClassReader.SKIP_DEBUG);
        return isEnumVisitor.isEnum;
    }

    public static class IsEnumVisitor extends EmptyVisitor {

View Full Code Here

  @Override
  public byte[] transform(String name, String transformedName, byte[] bytes)
  {
    ClassReader cr = new ClassReader(bytes);
    ClassNode cn = new ClassNode();
    cr.accept(cn, 0);

    workingPath.add(transformedName);

    if (this.implement(cn))
    {
View Full Code Here

                log.trace("Weaving " + className + " by ASM4.1");
            }
            ClassReader reader = new ClassReader(result);
            ClassWriter writer = new ClassWriter(WeavingConfigUtil.INSTANCE.isDebug() ? ClassWriter.COMPUTE_FRAMES : ClassWriter.COMPUTE_MAXS);
            ClassVisitor adapter = new UnitClassWeavingAdapter(writer, className);
            reader.accept(adapter, WeavingConfigUtil.INSTANCE.isDebug() ? ClassReader.SKIP_FRAMES : ClassReader.SKIP_DEBUG);

            result = writer.toByteArray();
        }

        return result; //返回新的字节码
View Full Code Here

                return false;
            }

            ClassReader reader = new ClassReader(is);
            ConfigurationAnnotationScanner scanner = new ConfigurationAnnotationScanner();
            reader.accept(scanner, 0);

            // Only class with the @Configuration are considered, parent classes are not analyzed.
            // Indeed, we have to detect when the parent must be considered independently,
            // or when only the daughter needs too (to avoid creating the instances twice).
View Full Code Here

        ClassWriter classWriter = new ClassWriter(true);

        FieldAdderClassVisitor visitor = new FieldAdderClassVisitor(classWriter);

        ClassReader classReader = new ClassReader(origBytes);
        classReader.accept(visitor, false);

        byte[] newBytes = classWriter.toByteArray();
        return newBytes;
    }
View Full Code Here

        RuleCheckAdapter checkAdapter = handlerLocation.getRuleCheckAdapter(dummy, this);
        try {
            // insert a local scope adapter between the reader and the adapter so
            // we see info about vars going in and out of scope
            BMLocalScopeAdapter localScopeAdapter = new BMLocalScopeAdapter(checkAdapter);
            cr.accept(localScopeAdapter, ClassReader.EXPAND_FRAMES);
        } catch (TransformFailure te) {
            // will already be notified
            return targetClassBytes;
        } catch (Throwable th) {
            // hmm, unexpected error
View Full Code Here

        RuleTriggerAdapter adapter = handlerLocation.getRuleAdapter(cw, this);
        // insert a JSR inliner between the reader and the adapter so we don't see JSR/RET sequences
        // we use a specialised version which provides us with info about vars going in and out of scope
        BMJSRInliner jsrInliner = new BMJSRInliner(adapter);
        try {
            cr.accept(jsrInliner, ClassReader.EXPAND_FRAMES);
        } catch (TransformFailure te) {
            // will already be notified
            return targetClassBytes;
        } catch (Throwable th) {
            if (Transformer.isVerbose()) {
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.