All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.security.fences.InheritanceGraphExtractor Maven / Gradle / Ivy

There is a newer version: 1.9-beta
Show newest version
package com.google.security.fences;

import java.io.IOException;

import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;

import com.google.security.fences.inheritance.ClassNodeFromClassFileVisitor;
import com.google.security.fences.inheritance.InheritanceGraph;

/**
 * Walks all classes in class roots to build an inheritance graph.
 */
final class InheritanceGraphExtractor extends AbstractClassesVisitor {
  private final InheritanceGraph.Builder builder = InheritanceGraph.builder();

  @Override
  protected ClassVisitor makeVisitorForClass(
      ClassRoot root, String relPath, ClassReader r) throws IOException {
    return new ClassNodeFromClassFileVisitor(builder);
  }

  static InheritanceGraph fromClassRoots(
      Iterable classRoots)
  throws IOException {
    InheritanceGraphExtractor extractor = new InheritanceGraphExtractor();
    extractor.visitAll(classRoots);
    return extractor.builder.build();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy