Package sootup.java.core
Class OverridingJavaClassSource
java.lang.Object
sootup.java.core.JavaSootClassSource
sootup.java.core.OverridingJavaClassSource
- All Implemented Interfaces:
SootClassSource
Allows for replacing specific parts of a class, such as fields and methods or, allows to resolve
classes that are batchparsed like .java files using wala java source frontend or in tests where
all information is already existing.
When replacing specific parts of a class by default, it delegates to the SootClassSource delegate provided in the constructor.
To alter the results of invocations to e.g. resolveFields(), simply call withFields(Collection) to obtain a new OverridingJavaClassSource. The new instance will
then use the supplied value instead of calling resolveFields() on the delegate.
- Author:
- Christian Brüggemann, Hasitha Rajapakse
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefines aOverridingJavaClassSource.OverridingJavaClassSourceBuilderbuilder. -
Field Summary
Fields inherited from class sootup.java.core.JavaSootClassSource
analysisInputLocation, classSignature, sourcePath -
Constructor Summary
ConstructorsConstructorDescriptionOverridingJavaClassSource(@NonNull Set<JavaSootMethod> sootMethods, @NonNull Set<JavaSootField> sootFields, @NonNull EnumSet<ClassModifier> modifiers, @NonNull Set<JavaClassType> interfaces, @NonNull JavaClassType superClass, @NonNull JavaClassType outerClass, @NonNull Position position, @NonNull Path sourcePath, @NonNull ClassType classType, @NonNull AnalysisInputLocation srcNamespace) OverridingJavaClassSource(@NonNull AnalysisInputLocation srcNamespace, @NonNull Path sourcePath, @NonNull ClassType classType, @Nullable JavaClassType superClass, @NonNull Set<JavaClassType> interfaces, @Nullable JavaClassType outerClass, @NonNull Set<JavaSootField> sootFields, @NonNull Set<JavaSootMethod> sootMethods, @NonNull Position position, @NonNull EnumSet<ClassModifier> modifiers, @NonNull Iterable<AnnotationUsage> annotations, @NonNull Iterable<AnnotationUsage> methodAnnotations, @Nullable Iterable<AnnotationUsage> fieldAnnotations) Class source where all information already availableOverridingJavaClassSource(@NonNull JavaSootClassSource delegate) -
Method Summary
Modifier and TypeMethodDescriptionbooleanEven if a the signature changes, the classource remains the same, e.g., if it is associated to an automatic module sinthashCode()@NonNull Iterable<AnnotationUsage>@NonNull Collection<? extends SootField>Reads from the source to retrieve its fields.Reads from the source to retrieve its directly implemented interfaces.@NonNull Collection<? extends SootMethod>Reads from the source to retrieve its methods.@NonNull Set<ClassModifier>Reads from the source to retrieve its modifiers.Reads from the source to retrieve its outer class, if this is an inner class.@NonNull PositionReads from the source to retrieve its position in the source code.Reads from the source to retrieve its superclass, if present.toString()@NonNull OverridingJavaClassSourcewithFields(@NonNull Collection<JavaSootField> overriddenSootFields) @NonNull OverridingJavaClassSourcewithInterfaces(@NonNull Set<JavaClassType> overriddenInterfaces) @NonNull OverridingJavaClassSourcewithMethods(@NonNull Collection<JavaSootMethod> overriddenSootMethods) @NonNull OverridingJavaClassSourcewithModifiers(@NonNull Set<ClassModifier> overriddenModifiers) @NonNull OverridingJavaClassSourcewithOuterClass(@NonNull Optional<JavaClassType> overriddenOuterClass) @NonNull OverridingJavaClassSourcewithPosition(@Nullable Position position) @NonNull OverridingJavaClassSourcewithReplacedField(@NonNull JavaSootField toReplace, @NonNull JavaSootField replacement) @NonNull OverridingJavaClassSourcewithReplacedMethod(@NonNull JavaSootMethod toReplace, @NonNull JavaSootMethod replacement) @NonNull OverridingJavaClassSourcewithSuperclass(@NonNull Optional<JavaClassType> overriddenSuperclass) Methods inherited from class sootup.java.core.JavaSootClassSource
buildClass, getAnalysisInputLocation, getClassType, getSourcePath
-
Constructor Details
-
OverridingJavaClassSource
-
OverridingJavaClassSource
public OverridingJavaClassSource(@NonNull AnalysisInputLocation srcNamespace, @NonNull Path sourcePath, @NonNull ClassType classType, @Nullable JavaClassType superClass, @NonNull Set<JavaClassType> interfaces, @Nullable JavaClassType outerClass, @NonNull Set<JavaSootField> sootFields, @NonNull Set<JavaSootMethod> sootMethods, @NonNull Position position, @NonNull EnumSet<ClassModifier> modifiers, @NonNull Iterable<AnnotationUsage> annotations, @NonNull Iterable<AnnotationUsage> methodAnnotations, @Nullable Iterable<AnnotationUsage> fieldAnnotations) Class source where all information already available -
OverridingJavaClassSource
public OverridingJavaClassSource(@NonNull Set<JavaSootMethod> sootMethods, @NonNull Set<JavaSootField> sootFields, @NonNull EnumSet<ClassModifier> modifiers, @NonNull Set<JavaClassType> interfaces, @NonNull JavaClassType superClass, @NonNull JavaClassType outerClass, @NonNull Position position, @NonNull Path sourcePath, @NonNull ClassType classType, @NonNull AnalysisInputLocation srcNamespace)
-
-
Method Details
-
resolveMethods
Description copied from interface:SootClassSourceReads from the source to retrieve its methods. This may be an expensive operation.- Throws:
ResolveException
-
resolveFields
Description copied from interface:SootClassSourceReads from the source to retrieve its fields. This may be an expensive operation.- Throws:
ResolveException
-
resolveModifiers
Description copied from interface:SootClassSourceReads from the source to retrieve its modifiers. This may be an expensive operation. -
resolveInterfaces
Description copied from interface:SootClassSourceReads from the source to retrieve its directly implemented interfaces. This may be an expensive operation. -
resolveSuperclass
Description copied from interface:SootClassSourceReads from the source to retrieve its superclass, if present. This may be an expensive operation. -
resolveOuterClass
Description copied from interface:SootClassSourceReads from the source to retrieve its outer class, if this is an inner class. This may be an expensive operation.- Returns:
-
resolvePosition
Description copied from interface:SootClassSourceReads from the source to retrieve its position in the source code. This may be an expensive operation. -
resolveAnnotations
- Specified by:
resolveAnnotationsin classJavaSootClassSource
-
equals
Description copied from class:JavaSootClassSourceEven if a the signature changes, the classource remains the same, e.g., if it is associated to an automatic module s- Overrides:
equalsin classJavaSootClassSource- Parameters:
o- the object to compare with- Returns:
- both objects are logically equal
-
hashCode
public int hashCode()- Overrides:
hashCodein classJavaSootClassSource
-
toString
-
withReplacedMethod
public @NonNull OverridingJavaClassSource withReplacedMethod(@NonNull JavaSootMethod toReplace, @NonNull JavaSootMethod replacement) -
withMethods
public @NonNull OverridingJavaClassSource withMethods(@NonNull Collection<JavaSootMethod> overriddenSootMethods) -
withReplacedField
public @NonNull OverridingJavaClassSource withReplacedField(@NonNull JavaSootField toReplace, @NonNull JavaSootField replacement) -
withFields
public @NonNull OverridingJavaClassSource withFields(@NonNull Collection<JavaSootField> overriddenSootFields) -
withModifiers
public @NonNull OverridingJavaClassSource withModifiers(@NonNull Set<ClassModifier> overriddenModifiers) -
withInterfaces
public @NonNull OverridingJavaClassSource withInterfaces(@NonNull Set<JavaClassType> overriddenInterfaces) -
withSuperclass
public @NonNull OverridingJavaClassSource withSuperclass(@NonNull Optional<JavaClassType> overriddenSuperclass) -
withOuterClass
public @NonNull OverridingJavaClassSource withOuterClass(@NonNull Optional<JavaClassType> overriddenOuterClass) -
withPosition
-