1 package jp.sourceforge.stigmata.birthmarks.is;
3 import java.io.IOException;
4 import java.io.InputStream;
6 import jp.sourceforge.stigmata.Birthmark;
7 import jp.sourceforge.stigmata.BirthmarkContext;
8 import jp.sourceforge.stigmata.BirthmarkElementClassNotFoundException;
9 import jp.sourceforge.stigmata.BirthmarkExtractionFailedException;
10 import jp.sourceforge.stigmata.ExtractionUnit;
11 import jp.sourceforge.stigmata.birthmarks.AbstractBirthmarkExtractor;
12 import jp.sourceforge.stigmata.birthmarks.BirthmarkExtractVisitor;
13 import jp.sourceforge.stigmata.spi.BirthmarkSpi;
15 import org.objectweb.asm.ClassReader;
16 import org.objectweb.asm.ClassWriter;
21 * @author Haruaki TAMADA
23 public class InheritanceStructureBirthmarkExtractor extends AbstractBirthmarkExtractor{
24 public InheritanceStructureBirthmarkExtractor(BirthmarkSpi spi){
28 @SuppressWarnings("deprecation")
29 public InheritanceStructureBirthmarkExtractor(){
34 public Birthmark extract(Birthmark birthmark, InputStream in, BirthmarkContext context) throws BirthmarkExtractionFailedException{
35 BirthmarkElementClassNotFoundException e = new BirthmarkElementClassNotFoundException();
38 ClassReader reader = new ClassReader(in);
39 ClassWriter writer = new ClassWriter(0);
40 BirthmarkExtractVisitor visitor = new InheritanceStructureBirthmarkExtractVisitor(writer, birthmark, context);
41 reader.accept(visitor, 0);
43 if(!visitor.isSuccess()){
44 for(Throwable t: visitor.getCauses()){
45 if(t instanceof ClassNotFoundException){
46 e.addClassName(t.getMessage());
53 } catch(IOException ee){
57 System.out.printf("fail: %s%n", e.getMessage());
65 public ExtractionUnit[] getAcceptableUnits(){
66 return new ExtractionUnit[] { ExtractionUnit.CLASS, };