dk.brics.xact.analysis.config
Class StandardConfiguration

java.lang.Object
  extended by dk.brics.xact.analysis.config.StandardConfiguration
All Implemented Interfaces:
Configuration

public class StandardConfiguration
extends Object
implements Configuration


Constructor Summary
StandardConfiguration()
           
 
Method Summary
 boolean canCallExtern(InvokeExpr expr)
          Returns true if the specified invocation may lead to a non-application class
 Collection<URL> getAdditionalSchemas()
          Returns the locations of some additional schemas that should be accesible to the application classes.
 String getBasedir()
           
 ExecutorService getExecutorService()
           
 String getFieldType(SootField field, String annotation)
          Returns the type of XML allowed in the specified field.
 Set<ValueBox> getHotspots()
          Expressions in the analyzed program whose XML graph should be available so they can be analyzed outside the XACT analysis.
 String getMethodParameterType(SootMethod method, int param, String annotation)
          Returns the type of XML required by the specified method parameter, or null if any XML may be given as parameter.
 String getMethodReturnType(SootMethod method, String annotation)
          Returns the type of XML returned by the specified method, or null if any XML may be returned.
 boolean hasExternalSubtypes(SootClass clazz)
          Returns true if the specified class or interface may have implementations in non-application code.
 boolean isExternallyCallable(SootMethod method)
          Returns true if the specified method can be called from the VM or from a non-application class.
 boolean isNormalCollection(String qualifiedName)
          Returns true if the specified non-abstract class denotes a collection that can be expected to behave as a normal collection.
 void modifyNamespaces(Map<String,String> namespaces)
          Lets the configuration modify the namespace prefix map.
 dk.brics.automaton.Automaton resolveToString(SootClass clazz)
          Returns the strings that may be returned by the specified type's toString method, or null if nothing special is known about the toString method.
 String resolveToXML(SootMethod toXmlMethod)
          Models the behaviour of toXML methods declared in non-application classes.
 void setBasedir(String basedir)
           
 String translateSchemaLocation(String location)
          Translates a schema location to another URL string (possibly the same).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardConfiguration

public StandardConfiguration()
Method Detail

canCallExtern

public boolean canCallExtern(InvokeExpr expr)
Description copied from interface: Configuration
Returns true if the specified invocation may lead to a non-application class

Specified by:
canCallExtern in interface Configuration
Parameters:
expr - an invocation expression
Returns:
false for precision, true for soundness

getAdditionalSchemas

public Collection<URL> getAdditionalSchemas()
Description copied from interface: Configuration
Returns the locations of some additional schemas that should be accesible to the application classes. Null may be returned instead of an empty collection.

Specified by:
getAdditionalSchemas in interface Configuration
Returns:
a collection with URLs to schemas, or null

getBasedir

public String getBasedir()

getExecutorService

public ExecutorService getExecutorService()

getFieldType

public String getFieldType(SootField field,
                           String annotation)
Description copied from interface: Configuration
Returns the type of XML allowed in the specified field.

Specified by:
getFieldType in interface Configuration
Parameters:
field - a field
annotation - the type placed with a @Type annotation, or null if no @Type annotation is present
Returns:
a type string (expanded or using a namespace prefix) or null if no type should be used

getHotspots

public Set<ValueBox> getHotspots()
Description copied from interface: Configuration
Expressions in the analyzed program whose XML graph should be available so they can be analyzed outside the XACT analysis.

Specified by:
getHotspots in interface Configuration
Returns:
set of soot expression

getMethodParameterType

public String getMethodParameterType(SootMethod method,
                                     int param,
                                     String annotation)
Description copied from interface: Configuration
Returns the type of XML required by the specified method parameter, or null if any XML may be given as parameter.

Specified by:
getMethodParameterType in interface Configuration
Parameters:
method - a non-application or application method
param - index of a parameter whose type is a subtype of XML
annotation - the type placed with a @Type annotation, or null if no @Type annotation is present
Returns:
a type string (expanded or using a namespace prefix) or null if no type should be used

getMethodReturnType

public String getMethodReturnType(SootMethod method,
                                  String annotation)
Description copied from interface: Configuration
Returns the type of XML returned by the specified method, or null if any XML may be returned.

Specified by:
getMethodReturnType in interface Configuration
Parameters:
method - a non-application or application method returning a subtype of XML.
annotation - the type placed with a @Type annotation, or null if no @Type annotation is present
Returns:
a type string (expanded or using a namespace prefix) or null if no type should be used

hasExternalSubtypes

public boolean hasExternalSubtypes(SootClass clazz)
Description copied from interface: Configuration
Returns true if the specified class or interface may have implementations in non-application code.

Note that types like java.lang.Object are also queried with this method, so the implementation should not be too optimistic.

Specified by:
hasExternalSubtypes in interface Configuration
Parameters:
clazz - a class or interface
Returns:
false for precision, true for soundness

isExternallyCallable

public boolean isExternallyCallable(SootMethod method)
Description copied from interface: Configuration
Returns true if the specified method can be called from the VM or from a non-application class.

Note that this should take class initializers (<clinit>) into account! Class initializers are generally always externally callable.

Specified by:
isExternallyCallable in interface Configuration
Parameters:
method - an application method
Returns:
false for precision, true for soundness

isNormalCollection

public boolean isNormalCollection(String qualifiedName)
Description copied from interface: Configuration
Returns true if the specified non-abstract class denotes a collection that can be expected to behave as a normal collection. A normal collection in this sense is a collection that only contains elements added with the add and addAll methods from the Collection and List interfaces and those added in a non-empty constructor. Additionally, all its methods must adhere to their specifications in Collection and List.

Specified by:
isNormalCollection in interface Configuration
Parameters:
qualifiedName - fully qualified name of a non-abstract class implementing Collection . Eg. java.util.ArrayList.
Returns:
true for precision, false for soundness

modifyNamespaces

public void modifyNamespaces(Map<String,String> namespaces)
Description copied from interface: Configuration
Lets the configuration modify the namespace prefix map. The given map will initially contain all the prefixes the analysis found declared in the application classes.

Specified by:
modifyNamespaces in interface Configuration
Parameters:
namespaces - map from namespace prefixes to namespaces. May be modified.

resolveToString

public dk.brics.automaton.Automaton resolveToString(SootClass clazz)
Description copied from interface: Configuration
Returns the strings that may be returned by the specified type's toString method, or null if nothing special is known about the toString method.

Specified by:
resolveToString in interface Configuration
Parameters:
clazz - a class
Returns:
an automaton or null

resolveToXML

public String resolveToXML(SootMethod toXmlMethod)
Description copied from interface: Configuration
Models the behaviour of toXML methods declared in non-application classes.

The resulting string should be the name of a type using a namespace preferably declared with Configuration.modifyNamespaces(Map) and defined in a schema referred to by Configuration.getAdditionalSchemas().

This method should return null if nothing is known about the method.

Specified by:
resolveToXML in interface Configuration
Parameters:
toXmlMethod - a toXML method declared in a non-application class
Returns:
null if nothing is known about the method, or a type string denoting the schema type of the result

setBasedir

public void setBasedir(String basedir)

translateSchemaLocation

public String translateSchemaLocation(String location)
Description copied from interface: Configuration
Translates a schema location to another URL string (possibly the same).

The analyzed program would often be executed from a different base directory than the one used to run the analysis; so to find the correct schema location the analysis needs to know what base directory to search in.

Specified by:
translateSchemaLocation in interface Configuration
Returns:
an URL string, not null


Copyright © 2005-2011 Aarhus University.