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
28 public class InheritanceStructureBirthmarkExtractor extends AbstractBirthmarkExtractor{
29 public InheritanceStructureBirthmarkExtractor(BirthmarkSpi spi){
33 @SuppressWarnings("deprecation")
34 public InheritanceStructureBirthmarkExtractor(){
39 public Birthmark extract(Birthmark birthmark, InputStream in, BirthmarkContext context) throws BirthmarkExtractionFailedException{
40 BirthmarkElementClassNotFoundException e = new BirthmarkElementClassNotFoundException();
43 ClassReader reader = new ClassReader(in);
44 ClassWriter writer = new ClassWriter(0);
45 BirthmarkExtractVisitor visitor = new InheritanceStructureBirthmarkExtractVisitor(writer, birthmark, context);
46 reader.accept(visitor, 0);
48 if(!visitor.isSuccess()){
49 for(Throwable t: visitor.getCauses()){
50 if(t instanceof ClassNotFoundException){
51 e.addClassName(t.getMessage());
58 } catch(IOException ee){
62 System.out.printf("fail: %s%n", e.getMessage());
70 public ExtractionUnit[] getAcceptableUnits(){
71 return new ExtractionUnit[] { ExtractionUnit.CLASS, };