add models for System.getProperty() methods to fix bug reported by Ravi Chandran on mailing list

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@4002 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
msridhar1 2010-11-23 17:39:19 +00:00
parent 37acebc7be
commit 88eaba4ee7
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2008 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package staticInit;
public class TestSystemProperties {
public static void main(String[] args) {
@SuppressWarnings("unused")
char sep = System.getProperty("file.separator").toCharArray()[0];
}
}

View File

@ -31,6 +31,8 @@ import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.ipa.callgraph.Entrypoint;
import com.ibm.wala.ipa.callgraph.impl.AllApplicationEntrypoints;
import com.ibm.wala.ipa.callgraph.impl.DefaultEntrypoint;
import com.ibm.wala.ipa.callgraph.impl.Util;
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
import com.ibm.wala.ipa.cfg.BasicBlockInContext;
import com.ibm.wala.ipa.cfg.InterproceduralCFG;
import com.ibm.wala.ipa.cha.ClassHierarchy;
@ -41,6 +43,7 @@ import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.Iterator2Iterable;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.GraphIntegrity;
@ -141,6 +144,30 @@ public class CallGraphTest extends WalaTestCase {
}
}
@Test public void testSystemProperties() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
ClassHierarchy cha = ClassHierarchy.make(scope);
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
"LstaticInit/TestSystemProperties");
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(options, new AnalysisCache(), cha, scope);
CallGraph cg = builder.makeCallGraph(options);
for (CGNode n : cg) {
if (n.toString().equals("Node: < Application, LstaticInit/TestSystemProperties, main([Ljava/lang/String;)V > Context: Everywhere")) {
boolean foundToCharArray = false;
for (CGNode callee : Iterator2Iterable.make(cg.getSuccNodes(n))) {
if (callee.getMethod().getName().toString().equals("toCharArray")) {
foundToCharArray = true;
break;
}
}
Assert.assertTrue(foundToCharArray);
break;
}
}
}
@Test public void testRecursion() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
CallGraphTestUtil.REGRESSION_EXCLUSIONS);

View File

@ -429,6 +429,19 @@
<new def="x" class="Ljava/util/Properties" />
<return value="x" />
</method>
<method name="getProperty"
descriptor="(Ljava/lang/String;)Ljava/lang/String;"
static="true">
<new def="x" class="Ljava/lang/String" />
<return value="x" />
</method>
<method name="getProperty"
descriptor="(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"
static="true">
<return value="arg1" />
<new def="x" class="Ljava/lang/String" />
<return value="x" />
</method>
<method name="mapLibraryName"
descriptor="(Ljava/lang/String;)Ljava/lang/String;"
static="true">