soot-oss / soot

Soot - A Java optimization framework
GNU Lesser General Public License v2.1
2.85k stars 706 forks source link

Points-to Analysis by SPARK PTS of String Object Concat is empty #1993

Closed HP-Allen closed 1 year ago

HP-Allen commented 1 year ago

I am using SPARK to work for Points-to Analysis, when I define a variable of String such as String s = "string", the variable s could point to StringConstantNode 47 string, but when I write code like: String s2 = s + "string2", the point-to set of variable s2 is empty.

It influenced the result of interprocedure return and a variable to receive this return. For example: public static void main(){ String input = "inputString"; String s = singleReturn(input); }

public static String singleReturn(String s) { String singleS = "getString" + s; return singleS; } Well, the point-to sets of variable singleS and variable s are empty. The reason may be the context of String object can not be modified? But I wonder if there is any way to solve it to make sure the singleS could point to a object?

HP-Allen commented 1 year ago

This is because that String could not be changed, so when it will call a function when concatenating two constant String.