1 package jp.sourceforge.stigmata.birthmarks.is;
7 import java.io.IOException;
8 import java.io.InputStream;
10 import jp.sourceforge.stigmata.Birthmark;
11 import jp.sourceforge.stigmata.BirthmarkContext;
12 import jp.sourceforge.stigmata.BirthmarkElementClassNotFoundException;
13 import jp.sourceforge.stigmata.BirthmarkExtractionFailedException;
14 import jp.sourceforge.stigmata.ExtractionUnit;
15 import jp.sourceforge.stigmata.birthmarks.AbstractBirthmarkExtractor;
16 import jp.sourceforge.stigmata.birthmarks.BirthmarkExtractVisitor;
17 import jp.sourceforge.stigmata.spi.BirthmarkSpi;
19 import org.objectweb.asm.ClassReader;
20 import org.objectweb.asm.ClassWriter;
25 * @author Haruaki TAMADA
27 public class InheritanceStructureBirthmarkExtractor extends AbstractBirthmarkExtractor{
28 public InheritanceStructureBirthmarkExtractor(BirthmarkSpi spi){
32 @SuppressWarnings("deprecation")
33 public InheritanceStructureBirthmarkExtractor(){
38 public Birthmark extract(Birthmark birthmark, InputStream in, BirthmarkContext context) throws BirthmarkExtractionFailedException{
39 BirthmarkElementClassNotFoundException e = new BirthmarkElementClassNotFoundException();
42 ClassReader reader = new ClassReader(in);
43 ClassWriter writer = new ClassWriter(0);
44 BirthmarkExtractVisitor visitor = new InheritanceStructureBirthmarkExtractVisitor(writer, birthmark, context);
45 reader.accept(visitor, 0);
47 if(!visitor.isSuccess()){
48 for(Throwable t: visitor.getCauses()){
49 if(t instanceof ClassNotFoundException){
50 e.addClassName(t.getMessage());
57 } catch(IOException ee){
61 System.out.printf("fail: %s%n", e.getMessage());
69 public ExtractionUnit[] getAcceptableUnits(){
70 return new ExtractionUnit[] { ExtractionUnit.CLASS, };