dk.brics.string
Class RuntimeResolver

java.lang.Object
  extended by dk.brics.string.RuntimeResolver
All Implemented Interfaces:
Resolver

public class RuntimeResolver
extends Object
implements Resolver

Encapsulation of the analysis of a program using the string analysis runtime library.

This class serves two purposes:

The following code will analyze a program with respect to the runtime methods. The resolver is added to the list of active resolvers to make the analysis aware of the results of Strings.cast calls, and the hotspots used in the analysis are the expressions occurring as the first argument to Strings.analyze and Strings.check calls.

  RuntimeResolver rr = new RuntimeResolver();
  StringAnalysis.addResolver(rr);
  StringAnalysis sa = new StringAnalysis(rr.getHotspotExps());
 
The StringAnalysis object sa will now contain the results of the analysis. Run through the set of RuntimeHotspot objects returned by the getHotspots method and compare the result given by the string analysis to the expected result given for the hotspot.

See Also:
StringAnalysis.addResolver, RuntimeHotspot, AnalyzeRuntime, InvalidRuntimeUseException

Constructor Summary
RuntimeResolver()
           
RuntimeResolver(BindingAutomatonProvider bindings)
          Initializes a RuntimeResolver for the current application classes.
 
Method Summary
 List<ValueBox> getHotspotExps()
          Returns the string expressions corresponding to the runtime method hotspots for the program.
 List<RuntimeHotspot> getHotspots()
          Returns the runtime method hotspots for the program.
 FieldResolution resolveField(FieldRef expr)
          No special fields are resolved.
 MethodResolution resolveMethod(InvokeExpr expr, SootMethod target)
          If the given target method is Strings.cast, returns the automaton given as a regular expression or automaton URL in the cast.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RuntimeResolver

public RuntimeResolver()

RuntimeResolver

public RuntimeResolver(BindingAutomatonProvider bindings)
Initializes a RuntimeResolver for the current application classes.

First, all Strings.bind calls in the program are collected, so that the regular expressions occurring in runtime method calls can be correctly resolved.
Second, all Strings.analyze and Strings.check calls are internally marked as hotspots. These can be queried using the getHotspots and getHotspotExps methods.

Throws:
InvalidRuntimeUseException - if some invalid use of the runtime library is encountered.
Method Detail

getHotspotExps

public List<ValueBox> getHotspotExps()
Returns the string expressions corresponding to the runtime method hotspots for the program.

Returns:
a list of ValueBox objects indicating the expressions marked as hotspots.

getHotspots

public List<RuntimeHotspot> getHotspots()
Returns the runtime method hotspots for the program.

Returns:
a list of RuntimeHotspot objects describing the runtime method hotspots.

resolveField

public FieldResolution resolveField(FieldRef expr)
No special fields are resolved.

Specified by:
resolveField in interface Resolver
Parameters:
expr - the field to be resolved.
Returns:
null.
See Also:
FieldResolution

resolveMethod

public MethodResolution resolveMethod(InvokeExpr expr,
                                      SootMethod target)
If the given target method is Strings.cast, returns the automaton given as a regular expression or automaton URL in the cast.

If the given target method is Strings.analyze, returns the value box for the first argument.

Specified by:
resolveMethod in interface Resolver
Parameters:
expr - the invocation to be resolved.
target - the target method.
Returns:
the automaton given in the cast, or null.
Throws:
InvalidRuntimeUseException - if some invalid use of the runtime library is encountered.
See Also:
MethodResolution


Copyright © 2003-2009 Anders Møller, Aske Simon Christensen, Asger Feldthaus.