dk.brics.xact.analysis.config
Interface Configuration

All Known Implementing Classes:
StandardConfiguration

public interface Configuration

The customizable settings of the analysis. This interface controls the assumptions made by the analysis and affects precision, soundness, and efficiency.

It is generally assumed that an instance of XMLAnalysis has its own Configuration instance that is not shared with other analyses.

All methods can be called concurrently by threads spawned by the ExecutorService assigned with XMLAnalysis.setExecutorService(ExecutorService) in addition to the thread that started the analysis with XMLAnalysis.analyze(). A safe way around this is always to declare all methods synchronized (though probably not the optimal solution).

See Also:
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 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.
 String translateSchemaLocation(String location)
          Translates a schema location to another URL string (possibly the same).
 

Method Detail

canCallExtern

boolean canCallExtern(InvokeExpr expr)
Returns true if the specified invocation may lead to a non-application class

Parameters:
expr - an invocation expression
Returns:
false for precision, true for soundness

getAdditionalSchemas

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

Returns:
a collection with URLs to schemas, or null

getFieldType

String getFieldType(SootField field,
                    String annotation)
Returns the type of XML allowed in the specified field.

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

Set<ValueBox> getHotspots()
Expressions in the analyzed program whose XML graph should be available so they can be analyzed outside the XACT analysis.

Returns:
set of soot expression

getMethodParameterType

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.

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

String getMethodReturnType(SootMethod method,
                           String annotation)
Returns the type of XML returned by the specified method, or null if any XML may be returned.

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

boolean hasExternalSubtypes(SootClass clazz)
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.

Parameters:
clazz - a class or interface
Returns:
false for precision, true for soundness

isExternallyCallable

boolean isExternallyCallable(SootMethod method)
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.

Parameters:
method - an application method
Returns:
false for precision, true for soundness

isNormalCollection

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. 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.

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

modifyNamespaces

void modifyNamespaces(Map<String,String> namespaces)
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.

Parameters:
namespaces - map from namespace prefixes to namespaces. May be modified.

resolveToString

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.

Parameters:
clazz - a class
Returns:
an automaton or null

resolveToXML

String resolveToXML(SootMethod toXmlMethod)
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 modifyNamespaces(Map) and defined in a schema referred to by getAdditionalSchemas().

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

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

translateSchemaLocation

String translateSchemaLocation(String location)
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.

Parameters:
location -
Returns:
an URL string, not null


Copyright © 2005-2011 Aarhus University.