protected int dfsVisit(int start, SootClass c) { Interval r = new Interval(); r.lower = start++; Collection<SootClass> col = classToSubclasses.get(c); if (col != null) { for (SootClass sc : col) { // For some awful reason, Soot thinks interface are subclasses // of java.lang.Object if (sc.isInterface()) { continue; } start = dfsVisit(start, sc); } } r.upper = start++; if (c.isInterface()) { throw new RuntimeException("Attempt to dfs visit interface " + c); } if (!classToInterval.containsKey(c)) { classToInterval.put(c, r); } return start; }
protected int dfsVisit( int start, SootClass c ) { Interval r = new Interval(); r.lower = start++; Collection col = classToSubclasses.get(c); if( col != null ) { Iterator it = col.iterator(); while( it.hasNext() ) { SootClass sc = (SootClass) it.next(); // For some awful reason, Soot thinks interface are subclasses // of java.lang.Object if( sc.isInterface() ) continue; start = dfsVisit( start, sc ); } } r.upper = start++; if( c.isInterface() ) { throw new RuntimeException( "Attempt to dfs visit interface "+c ); } if(!classToInterval.containsKey(c)) classToInterval.put( c, r ); return start; }
protected int dfsVisit( int start, SootClass c ) { Interval r = new Interval(); r.lower = start++; Collection col = classToSubclasses.get(c); if( col != null ) { Iterator it = col.iterator(); while( it.hasNext() ) { SootClass sc = (SootClass) it.next(); // For some awful reason, Soot thinks interface are subclasses // of java.lang.Object if( sc.isInterface() ) continue; start = dfsVisit( start, sc ); } } r.upper = start++; if( c.isInterface() ) { throw new RuntimeException( "Attempt to dfs visit interface "+c ); } if(!classToInterval.containsKey(c)) classToInterval.put( c, r ); return start; }
/** Constructs a hierarchy from the current scene. */ public FastHierarchy() { this.sc = Scene.v(); /* First build the inverse maps. */ for( Iterator clIt = sc.getClasses().iterator(); clIt.hasNext(); ) { final SootClass cl = (SootClass) clIt.next(); if( cl.resolvingLevel() < SootClass.HIERARCHY ) continue; if( !cl.isInterface() && cl.hasSuperclass() ) { put( classToSubclasses, cl.getSuperclass(), cl ); } for( Iterator superclIt = cl.getInterfaces().iterator(); superclIt.hasNext(); ) { final SootClass supercl = (SootClass) superclIt.next(); if( cl.isInterface() ) { interfaceToSubinterfaces.put( supercl, cl ); } else { interfaceToImplementers.put( supercl, cl ); } } } /* Now do a dfs traversal to get the Interval numbers. */ dfsVisit( 0, Scene.v().getSootClass( "java.lang.Object" ) ); /* also have to traverse for all phantom classes because they also * can be roots of the type hierarchy */ for(SootClass phantomClass: Scene.v().getPhantomClasses()) { if(!phantomClass.isInterface()) dfsVisit( 0, phantomClass ); } }
/** Constructs a hierarchy from the current scene. */ public FastHierarchy() { this.sc = Scene.v(); /* First build the inverse maps. */ for( Iterator clIt = sc.getClasses().iterator(); clIt.hasNext(); ) { final SootClass cl = (SootClass) clIt.next(); if( cl.resolvingLevel() < SootClass.HIERARCHY ) continue; if( !cl.isInterface() && cl.hasSuperclass() ) { put( classToSubclasses, cl.getSuperclass(), cl ); } for( Iterator superclIt = cl.getInterfaces().iterator(); superclIt.hasNext(); ) { final SootClass supercl = (SootClass) superclIt.next(); if( cl.isInterface() ) { interfaceToSubinterfaces.put( supercl, cl ); } else { interfaceToImplementers.put( supercl, cl ); } } } /* Now do a dfs traversal to get the Interval numbers. */ dfsVisit( 0, Scene.v().getSootClass( "java.lang.Object" ) ); /* also have to traverse for all phantom classes because they also * can be roots of the type hierarchy */ for(SootClass phantomClass: Scene.v().getPhantomClasses()) { if(!phantomClass.isInterface()) dfsVisit( 0, phantomClass ); } }