com.google.security.fences.InheritanceGraphExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fences-maven-enforcer-rule Show documentation
Show all versions of fences-maven-enforcer-rule Show documentation
Augments Java's access control by checking that a Maven Project and all its
dependencies conform to a policy that specifies which classes/packages can
link to which others.
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 extends ClassRoot> classRoots)
throws IOException {
InheritanceGraphExtractor extractor = new InheritanceGraphExtractor();
extractor.visitAll(classRoots);
return extractor.builder.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy