[Soot-list] How to obtain try and catch block

csytang csytang at comp.polyu.edu.hk
Mon Oct 5 05:03:04 EDT 2015


 

Hi all, 

 I am kind of confused how to solve exception and try-catch in Soot. I
find this cuz my program doesn't process the exception and try-catch
block instead it deems it as method invocation. 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;
> }

 As you can find that there is a method invocation in the second last
line. 

 Back to source code. 

> 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); 
> 
> }

 It is fully an exception statement from source code aspect. Therefore,
how to resolve this ambiguous case and distinguish THE
EXCEPTION/TRY-CATACH with METHOD INVOCATION. 

 Thanks 

Best 

Chris. 

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20151005/c5585eef/attachment.html 


More information about the Soot-list mailing list