1 package jp.sourceforge.stigmata.birthmarks.is;
3 import jp.sourceforge.stigmata.Birthmark;
4 import jp.sourceforge.stigmata.BirthmarkContext;
5 import jp.sourceforge.stigmata.BirthmarkElement;
6 import jp.sourceforge.stigmata.birthmarks.BirthmarkExtractVisitor;
7 import jp.sourceforge.stigmata.birthmarks.NullBirthmarkElement;
8 import jp.sourceforge.stigmata.digger.ClassFileEntry;
9 import jp.sourceforge.stigmata.digger.ClasspathContext;
10 import jp.sourceforge.stigmata.utils.WellknownClassManager;
12 import org.objectweb.asm.ClassVisitor;
14 import com.sun.xml.internal.ws.org.objectweb.asm.Opcodes;
20 * @author Haruaki TAMADA
22 public class InheritanceStructureBirthmarkExtractVisitor extends BirthmarkExtractVisitor{
23 public InheritanceStructureBirthmarkExtractVisitor(ClassVisitor visitor, Birthmark birthmark, BirthmarkContext context){
24 super(visitor, birthmark, context);
28 public void visit(int version, int access, String name, String signature,
29 String superName, String[] interfaces){
30 if((access & Opcodes.ACC_INTERFACE) != Opcodes.ACC_INTERFACE){
31 ClasspathContext context = getEnvironment().getClasspathContext();
32 name = name.replace('/', '.');
33 ClassFileEntry entry = context.findEntry(name);
35 superName = superName.replace('/', '.');
36 ClassFileEntry parent = context.findEntry(superName);
39 addIsBirthmark(superName);
42 addFailur(new ClassNotFoundException(superName));
47 Class<?> clazz = context.findClass(name);
48 addISBirthmark(clazz);
49 } catch(ClassNotFoundException e){
56 private void addIsBirthmark(String className){
57 WellknownClassManager wcm = getEnvironment().getWellknownClassManager();
58 BirthmarkElement element;
59 if(wcm.isWellKnownClass(className)){
60 element = new BirthmarkElement(className);
63 element = NullBirthmarkElement.getInstance();
68 private void addISBirthmark(Class<?> c){
69 WellknownClassManager wcm = getEnvironment().getWellknownClassManager();
71 String className = c.getName();
72 BirthmarkElement element = null;
73 if(wcm.isWellKnownClass(className)){
74 element = new BirthmarkElement(className);
77 element = NullBirthmarkElement.getInstance();
81 c = c.getSuperclass();
82 } while(!c.getName().equals("java.lang.Object"));
83 addElement(new BirthmarkElement("java.lang.Object"));