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
classSignature, classSource, sourcePath
-
Constructor Summary
ConstructorDescriptionOverridingJavaClassSource
(AnalysisInputLocation srcNamespace, Path sourcePath, JavaClassType classType, JavaClassType superClass, Set<JavaClassType> interfaces, JavaClassType outerClass, Set<JavaSootField> sootFields, Set<JavaSootMethod> sootMethods, Position position, EnumSet<ClassModifier> modifiers, Iterable<AnnotationUsage> annotations, Iterable<AnnotationUsage> methodAnnotations, Iterable<AnnotationUsage> fieldAnnotations) Class source where all information already availableOverridingJavaClassSource
(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 Iterable<AnnotationUsage>
Reads from the source to retrieve its fields.Reads from the source to retrieve its directly implemented interfaces.Reads from the source to retrieve its methods.Reads from the source to retrieve its modifiers.Reads from the source to retrieve its outer class, if this is an inner class.Reads from the source to retrieve its position in the source code.Reads from the source to retrieve its superclass, if present.toString()
withFields
(Collection<JavaSootField> overriddenSootFields) withInterfaces
(Set<JavaClassType> overriddenInterfaces) withMethods
(Collection<JavaSootMethod> overriddenSootMethods) withModifiers
(Set<ClassModifier> overriddenModifiers) withOuterClass
(Optional<JavaClassType> overriddenOuterClass) withPosition
(Position position) withReplacedField
(JavaSootField toReplace, JavaSootField replacement) withReplacedMethod
(JavaSootMethod toReplace, JavaSootMethod replacement) withSuperclass
(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
@Nonnull public OverridingJavaClassSource withReplacedMethod(@Nonnull JavaSootMethod toReplace, @Nonnull JavaSootMethod replacement) -
withMethods
@Nonnull public OverridingJavaClassSource withMethods(@Nonnull Collection<JavaSootMethod> overriddenSootMethods) -
withReplacedField
@Nonnull public OverridingJavaClassSource withReplacedField(@Nonnull JavaSootField toReplace, @Nonnull JavaSootField replacement) -
withFields
@Nonnull public OverridingJavaClassSource withFields(@Nonnull Collection<JavaSootField> overriddenSootFields) -
withModifiers
@Nonnull public OverridingJavaClassSource withModifiers(@Nonnull Set<ClassModifier> overriddenModifiers) -
withInterfaces
@Nonnull public OverridingJavaClassSource withInterfaces(@Nonnull Set<JavaClassType> overriddenInterfaces) -
withSuperclass
@Nonnull public OverridingJavaClassSource withSuperclass(@Nonnull Optional<JavaClassType> overriddenSuperclass) -
withOuterClass
@Nonnull public OverridingJavaClassSource withOuterClass(@Nonnull Optional<JavaClassType> overriddenOuterClass) -
withPosition
-