Package sootup.java.core
Class OverridingJavaClassSource
java.lang.Object
sootup.core.frontend.AbstractClassSource
sootup.core.frontend.SootClassSource
sootup.java.core.JavaSootClassSource
sootup.java.core.OverridingJavaClassSource
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
-
Field Summary
Fields inherited from class sootup.core.frontend.AbstractClassSource
analysisInputLocation, classSignature, sourcePath
-
Constructor Summary
ConstructorsConstructorDescriptionOverridingJavaClassSource
(@NonNull AnalysisInputLocation srcNamespace, @NonNull Path sourcePath, @NonNull JavaClassType 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 TypeMethodDescriptionboolean
Even if a the signature changes, the classource remains the same, e.g., if it is associated to an automatic module sint
hashCode()
protected @NonNull Iterable<AnnotationUsage>
@NonNull Collection<JavaSootField>
Reads from the source to retrieve its fields.Reads from the source to retrieve its directly implemented interfaces.@NonNull Collection<JavaSootMethod>
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 Position
Reads from the source to retrieve its position in the source code.Reads from the source to retrieve its superclass, if present.toString()
@NonNull OverridingJavaClassSource
withFields
(@NonNull Collection<JavaSootField> overriddenSootFields) @NonNull OverridingJavaClassSource
withInterfaces
(@NonNull Set<JavaClassType> overriddenInterfaces) @NonNull OverridingJavaClassSource
withMethods
(@NonNull Collection<JavaSootMethod> overriddenSootMethods) @NonNull OverridingJavaClassSource
withModifiers
(@NonNull Set<ClassModifier> overriddenModifiers) @NonNull OverridingJavaClassSource
withOuterClass
(@NonNull Optional<JavaClassType> overriddenOuterClass) @NonNull OverridingJavaClassSource
withPosition
(@Nullable Position position) @NonNull OverridingJavaClassSource
withReplacedField
(@NonNull JavaSootField toReplace, @NonNull JavaSootField replacement) @NonNull OverridingJavaClassSource
withReplacedMethod
(@NonNull JavaSootMethod toReplace, @NonNull JavaSootMethod replacement) @NonNull OverridingJavaClassSource
withSuperclass
(@NonNull Optional<JavaClassType> overriddenSuperclass) Methods inherited from class sootup.java.core.JavaSootClassSource
buildClass
Methods inherited from class sootup.core.frontend.AbstractClassSource
getAnalysisInputLocation, getClassType, getSourcePath
-
Constructor Details
-
OverridingJavaClassSource
-
OverridingJavaClassSource
public OverridingJavaClassSource(@NonNull AnalysisInputLocation srcNamespace, @NonNull Path sourcePath, @NonNull JavaClassType 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
-
-
Method Details
-
resolveMethods
Description copied from class:SootClassSource
Reads from the source to retrieve its methods. This may be an expensive operation.- Specified by:
resolveMethods
in classSootClassSource
- Throws:
ResolveException
-
resolveFields
Description copied from class:SootClassSource
Reads from the source to retrieve its fields. This may be an expensive operation.- Specified by:
resolveFields
in classSootClassSource
- Throws:
ResolveException
-
resolveModifiers
Description copied from class:SootClassSource
Reads from the source to retrieve its modifiers. This may be an expensive operation.- Specified by:
resolveModifiers
in classSootClassSource
-
resolveInterfaces
Description copied from class:SootClassSource
Reads from the source to retrieve its directly implemented interfaces. This may be an expensive operation.- Specified by:
resolveInterfaces
in classSootClassSource
-
resolveSuperclass
Description copied from class:SootClassSource
Reads from the source to retrieve its superclass, if present. This may be an expensive operation.- Specified by:
resolveSuperclass
in classSootClassSource
-
resolveOuterClass
Description copied from class:SootClassSource
Reads from the source to retrieve its outer class, if this is an inner class. This may be an expensive operation.- Specified by:
resolveOuterClass
in classSootClassSource
- Returns:
-
resolvePosition
Description copied from class:SootClassSource
Reads from the source to retrieve its position in the source code. This may be an expensive operation.- Specified by:
resolvePosition
in classSootClassSource
-
resolveAnnotations
- Specified by:
resolveAnnotations
in classJavaSootClassSource
-
equals
Description copied from class:AbstractClassSource
Even if a the signature changes, the classource remains the same, e.g., if it is associated to an automatic module s- Overrides:
equals
in classAbstractClassSource
- Parameters:
o
- the object to compare with- Returns:
- both objects are logically equal
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractClassSource
-
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
-