[Soot-list] getDeclaringClass query

Ankur Sinha sanjay.ankur at gmail.com
Mon Jun 28 06:13:33 EDT 2010


hello,

I have a minor query regarding the functioning of the
getDeclaringClass. 

This is what I'm trying to do:

I'm analysing concurrent Java Programs (extending either Thread or
implementing Runnable) to find the class that declares the thread
variable. i.e., 

I'm looking for the class type of t1 in the statement 
(This one is done by implementing Runnable)

> Thread t1 = new Thread(new threadTrial());

This is what I've done:


> protected void internalTransform(String phase, Map options)
> 			{
> 				CallGraph cg = Scene.v().getCallGraph();
> 								
> 				SootMethod mainMethod = Scene.v().getMainMethod();
> 				Iterator <Edge> targets = cg.edgesOutOf(mainMethod);
> 				
> 				while(targets.hasNext())
> 				{
> 					Edge currentEdge = targets.next();
> 					
> 					if(currentEdge.kind() == Kind.THREAD)
> 					{
> 						G.v().out.println("Found a thread edge");
> 						SootMethod src = currentEdge.src();
> 						G.v().out.println(src.getDeclaringClass());
> 																																							
> 					}
> 				}
> 			}
> 

The query:

For both types of Programs, (extending Thread and implementing
Runnable), this correctly returns the class where the variable was
declared, i.e., it's *not* giving me Thread for t1, but "threadTrial".

This is where I'm a little unsure :

Shouldn't it return "Thread" for a program that implements Runnable
(like the example statement above), since the declaring class of the
variable t1 is a variable of the Thread class?

(My terminology may not be correct, I hope you get what I mean)

Thanks, 
regards,
Ankur



More information about the Soot-list mailing list