Package org.objectweb.asm

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


    className = className.substring(className.lastIndexOf('.') + 1) + ".class";
       
    //Load the class bytes and copy methods across
    ClassReader cReader = new ClassReader(c.getResourceAsStream(className));

    cReader.accept(adapter, ClassReader.SKIP_CODE |
        ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
  }

  /**
   * Generate an instance field that should be "invisible" to normal code
View Full Code Here


        // to process only methods on that class that are in the list
        ClassReader cr = new ClassReader(loader.getResourceAsStream(currentlyAnalysedClass
            .getName().replaceAll("\\.", "/")
            + ".class"));
        ClassVisitor hierarchyAdapter = new ProxySubclassHierarchyAdapter(this, setOfFoundMethods);
        cr.accept(hierarchyAdapter, ClassReader.SKIP_DEBUG);
      } catch (IOException e) {
        throw new TypeNotPresentException(currentlyAnalysedClassName, e);
      }
      // now add the foundMethods to the overall list of observed methods
      setOfObservedMethods.addAll(setOfFoundMethods);
View Full Code Here

        //a standard writer
        writer =   new ClassWriter(reader, 0) ;
        ClassVisitor cv = new CustomClassVisitor((ClassVisitor)writer);
        //call accept on the reader to start the visits
        //using the writer we created as the visitor
        reader.accept(cv, 0);
      } finally {
        //close the InputStream if it is hanging around
        if (classInStream != null) classInStream.close();
      }
      FileOutputStream classOutStream = null;
View Full Code Here

    //Wrap our outer layer to add the original SerialVersionUID if it was previously being defaulted
    ClassVisitor weavingAdapter = new SyntheticSerialVerUIDAdder(
                               new WovenProxyAdapter(cv, cReader.getClassName(), loader));
   
    // If we are Java 1.6 + then we need to skip frames as they will be recomputed
    cReader.accept(weavingAdapter, AbstractWovenProxyAdapter.IS_AT_LEAST_JAVA_6 ? ClassReader.SKIP_FRAMES : 0);
   
    return cWriter.toByteArray();
  }
}
View Full Code Here

        if (forInstrumenting) {
            ClassReader cr = new ClassReader(bytes);
            ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS/* | ClassWriter.COMPUTE_FRAMES*/);
            try {
                ClassVisitor ci = (ClassVisitor) INSTRUMENTER_CONSTRUCTOR.newInstance(projectData, cw, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
                cr.accept(ci, 0);
                if (((Boolean) IS_INSTRUMENTED_METHOD.invoke(ci)).booleanValue()) {
                    return cw.toByteArray();
                }
            } catch (Throwable t) {
                throw (IOException) new IOException(t.getMessage()).initCause(t);
View Full Code Here

            URL resource = classLoaderInterface.getResource(className);
            if (resource != null) {
                InputStream in = resource.openStream();
                try {
                    ClassReader classReader = new ClassReader(in);
                    classReader.accept(new InfoBuildingVisitor(), ClassReader.SKIP_DEBUG);
                } finally {
                    in.close();
                }
            } else {
                throw new XWorkException("Could not load " + className);
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 {
        public boolean isEnum = false;
View Full Code Here

  private void findExtendedArtemisTypes(FileInputStream stream) {
    ClassReader cr;
    try {
      cr = new ClassReader(stream);
      ParentChainFinder artemisTypeFinder = new ParentChainFinder(parentChildrenMap);
      cr.accept(artemisTypeFinder, 0);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (stream != null) try {
        stream.close();
View Full Code Here

  private void findArtemisTypes(FileInputStream stream) {
    ClassReader cr;
    try {
      cr = new ClassReader(stream);
      ArtemisTypeFinder artemisTypeFinder = new ArtemisTypeFinder(this, typeConfiguration);
      cr.accept(artemisTypeFinder, 0);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (stream != null) try {
        stream.close();
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.