[Soot-list] How to obtain try and catch block
Y.T. Chris TANG
chris.yttang at gmail.com
Mon Oct 5 04:53:49 EDT 2015
Hi all,
How do you detect the try-catch-finally block in the method body?
Today, I find my program does not process try-catch block instead it deems
try-catch as a method invoke. I check the jimple code
public void reduce(org.apache.hadoop.io.Text, java.lang.Iterable, org.apache
.hadoop.mapreduce.Reducer$Context) throws java.io.IOException, java.lang.
InterruptedException
{
WordCount2$IntSumReducer r0;
org.apache.hadoop.io.Text r1;
java.lang.Iterable r2;
org.apache.hadoop.mapreduce.Reducer$Context r3;
org.apache.hadoop.io.IntWritable r4, $r7, $r8;
java.util.Iterator r5;
boolean $z0;
java.lang.Object $r6;
int $i0, i1;
r0 := @this: WordCount2$IntSumReducer;
r1 := @parameter0: org.apache.hadoop.io.Text;
r2 := @parameter1: java.lang.Iterable;
r3 := @parameter2: org.apache.hadoop.mapreduce.Reducer$Context;
i1 = 0;
r5 = interfaceinvoke r2.<java.lang.Iterable: java.util.Iterator
iterator()>();
goto label2;
label1:
$r6 = interfaceinvoke r5.<java.util.Iterator: java.lang.Object next
()>();
r4 = (org.apache.hadoop.io.IntWritable) $r6;
$i0 = virtualinvoke r4.<org.apache.hadoop.io.IntWritable: int get
()>();
i1 = i1 + $i0;
label2:
$z0 = interfaceinvoke r5.<java.util.Iterator: boolean hasNext()>();
if $z0 != 0 goto label1;
$r7 = r0.<WordCount2$IntSumReducer: org.apache.hadoop.io.IntWritable
result>;
virtualinvoke $r7.<org.apache.hadoop.io.IntWritable: void set(int)>(
i1);
$r8 = r0.<WordCount2$IntSumReducer: org.apache.hadoop.io.IntWritable
result>;
virtualinvoke r3.<org.apache.hadoop.mapreduce.Reducer$Context: void
write(java.lang.Object,java.lang.Object)>(r1, $r8);
return;
}
public volatile void reduce(java.lang.Object, java.lang.Iterable, org.
apache.hadoop.mapreduce.Reducer$Context) throws java.io.IOException, java.
lang.InterruptedException
{
WordCount2$IntSumReducer r0;
java.lang.Object r1;
java.lang.Iterable r2, $r5;
org.apache.hadoop.mapreduce.Reducer$Context r3, $r4;
org.apache.hadoop.io.Text $r6;
r0 := @this: WordCount2$IntSumReducer;
r1 := @parameter0: java.lang.Object;
r2 := @parameter1: java.lang.Iterable;
r3 := @parameter2: org.apache.hadoop.mapreduce.Reducer$Context;
$r6 = (org.apache.hadoop.io.Text) r1;
$r5 = (java.lang.Iterable) r2;
$r4 = (org.apache.hadoop.mapreduce.Reducer$Context) r3;
virtualinvoke r0.<WordCount2$IntSumReducer: void reduce(org.apache.
hadoop.io.Text,java.lang.Iterable,org.apache.hadoop.mapreduce.
Reducer$Context)>($r6, $r5, $r4);
return;
}
When back to my source code it is a try-catch block instead of method
invocation.
public void reduce(Text key, Iterable<IntWritable> values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
Therefore, you can see that regard this piece of code as a method
invoke seems incorrect.
How to distinguish the *try-catch block* with *the method invocation*.
Thanks
Best
Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20151005/b6fb0a6e/attachment-0001.html
More information about the Soot-list
mailing list