[Soot-list] couldn't find class printouts
Andrey_Poliektov at amat.com
Andrey_Poliektov at amat.com
Mon Sep 19 19:21:47 EDT 2005
Hi,
It would be nice to show who's referencing the class which could not be
found.
In my case there were some references from the code which was never
executed.
The following change to SootResolver.java seems to be working.
private HashMap classFromReferences = new HashMap(); // refName => HashMap
of refereeNames
private void bringToHierarchy(SootClass sc) {
if(sc.resolvingLevel() >= SootClass.HIERARCHY ) return;
if(Options.v().debug_resolver())
G.v().out.println("bringing to HIERARCHY: "+sc);
sc.setResolvingLevel(SootClass.HIERARCHY);
String className = sc.getName();
ClassSource is = SourceLocator.v().getClassSource(className);
if( is == null ) {
if(!Scene.v().allowsPhantomRefs())
{
String s = "";
HashMap hm = (HashMap)classFromReferences.get(className);
if ( hm != null )
for( Iterator i = hm.keySet().iterator(); i.hasNext(); )
s += " referenced by " + i.next() + "; ";
// There must be an exception here, but I left it as a
printout to see all the unresolved references at once
System.out.println( "FATAL ERROR: couldn't find class: " +
className + s + " (is your soot-class-path set
properly?) ");
} else {
G.v().out.println(
"Warning: " + className + " is a phantom class!");
sc.setPhantomClass();
classToReferences.put( sc, new ArrayList() );
}
} else {
Collection references = is.resolve(sc);
classToReferences.put( sc, new ArrayList(new
HashSet(references)) );
for( Iterator i = references.iterator(); i.hasNext(); )
{
Object o = i.next();
String name = null;
if ( o instanceof String )
name = (String)o;
else
if ( o instanceof ArrayType )
o = ((ArrayType)o).baseType;
if ( o instanceof RefType )
name = o.toString();
if ( name != null )
{ HashMap entry = (HashMap)classFromReferences.get( name );
if ( entry == null )
{ entry = new HashMap();
classFromReferences.put( name, entry );
}
entry.put( sc.getName(), Boolean.TRUE );
}
}
}
reResolveHierarchy(sc);
}
Thank you,
Andrey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20050919/4eb4e2d9/attachment.htm
More information about the Soot-list
mailing list