ROSE 2.23.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility Class Referencefinal

Description

a stateless mapping of JVM related nodes to fundamental functions of the class hierarchy analysis.

Definition at line 16 of file JvmCompatibility.h.

#include <Rose/BinaryAnalysis/ByteCode/ClassHierarchy/JvmCompatibility.h>

Inheritance diagram for Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility:
Collaboration graph
[legend]

Public Member Functions

std::string nameOf (Rose::Common::Analysis::FunctionKeyType key) const override
 returns the source name of the function represented by key.
 
std::string nameOf (Rose::Common::Analysis::ClassKeyType key) const override
 returns the source name of the class represented by key.
 
bool isAbstract (Rose::Common::Analysis::ClassKeyType key) const override
 returns true if the class represented by key is an abstract class.
 
bool isPureVirtual (Rose::Common::Analysis::FunctionKeyType key) const override
 returns true if the class represented by key is an abstract function.
 
int compareNames (Rose::Common::Analysis::FunctionKeyType lhs, Rose::Common::Analysis::FunctionKeyType rhs) const override
 compares the source name of the functions lhs and rhs.
 
int compareFunctionsByType (Rose::Common::Analysis::FunctionKeyType lhs, Rose::Common::Analysis::FunctionKeyType rhs, bool exclReturnType=true) const override
 compares the canonical types of functions lhs and rhs
 
Rose::Common::Analysis::FunctionTypeRelation haveSameOrCovariantReturn (const Rose::Common::Analysis::ClassAnalysis &classes, Rose::Common::Analysis::FunctionKeyType basId, Rose::Common::Analysis::FunctionKeyType drvId) const override
 tests if drvId has the same or covariant return type with respect to basId
 
void extractFromMemoryPool (Rose::Common::Analysis::ClassAnalysis &classes) const override
 extracts class information from the memory pool if available
 
void extractFromProject (Rose::Common::Analysis::ClassAnalysis &classes, Rose::Common::Analysis::ASTRootType root) const override
 extracts class by walking the AST rooted at root.
 
Rose::Common::Analysis::LanguageSpecificFn languageSpecificProcessing () const override
 returns JVM-specific class post-processing.
 
bool inheritedMethodsImplementVirtualBaseMethods () const override
 returns true: in Java a method inherited from a superclass implements an interface method of a subclass (JLS 8.4.8.1, JVMS 5.4.6).
 
bool isInheritableImplementation (Rose::Common::Analysis::FunctionKeyType fnkey) const override
 returns whether an inherited method qualifies as implementation of an interface method.
 
bool canOverride (Rose::Common::Analysis::FunctionKeyType drv, Rose::Common::Analysis::FunctionKeyType bas) const override
 applies the access rules of JVMS 5.4.5 to a signature match.
 
void inheritanceEdges (Rose::Common::Analysis::ClassKeyType clkey, std::function< void(Rose::Common::Analysis::ClassKeyType, Rose::Common::Analysis::ClassKeyType, bool)> fn) const override
 calls the callback function fn(derived, base, isvirtual) for all direct base classes of clkey
 
Rose::Common::Analysis::DataMemberType typeOf (Rose::Common::Analysis::VariableKeyType var) const override
 returns the type of a non-static data member var.
 
- Public Member Functions inherited from Rose::Common::Analysis::AbstractCompatibilityBridge
 AbstractCompatibilityBridge ()=default
 Constructs a stateless compatibility bridge.
 
virtual ~AbstractCompatibilityBridge ()=default
 Destroys a compatibility bridge through the base type.
 
virtual void inheritanceEdges (ClassKeyType clkey, std::function< void(ClassKeyType, ClassKeyType, bool)> fn) const =0
 calls the callback function fn(derived, base, isvirtual) for all direct base classes of clkey
 
virtual bool isAutoGeneratable (const ClassAnalysis &classes, ClassKeyType clkey, FunctionKeyType fnkey) const
 returns whether a function with fnkey's signature can be implicitly generated in clkey.
 
virtual std::uint32_t languageStandard () const
 returns the active language standard as a C++ __cplusplus-style value when available.
 
virtual bool isFinal (FunctionKeyType fnkey) const
 returns whether the virtual function fnkey cannot be overridden.
 
virtual void explicitOverrides (const ClassAnalysis &classes, ClassKeyType cls, std::function< void(FunctionKeyType, FunctionKeyType)> fn) const
 reports override relations that are declared explicitly instead of being derived from names and signatures.
 
virtual bool canOverrideInContext (const ClassAnalysis &classes, ClassKeyType drvClass, FunctionKeyType drv, ClassKeyType basClass, FunctionKeyType bas) const
 returns whether drv, declared in drvClass, may override bas, declared in basClass, with knowledge of the classes in between.
 

Member Function Documentation

◆ nameOf() [1/2]

std::string Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::nameOf ( Rose::Common::Analysis::FunctionKeyType  key) const
overridevirtual

returns the source name of the function represented by key.

Parameters
keyJVM function key to name.
Returns
source name for key.

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ nameOf() [2/2]

std::string Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::nameOf ( Rose::Common::Analysis::ClassKeyType  key) const
overridevirtual

returns the source name of the class represented by key.

Parameters
keyJVM class key to name.
Returns
source name for key.

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ isAbstract()

bool Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::isAbstract ( Rose::Common::Analysis::ClassKeyType  key) const
overridevirtual

returns true if the class represented by key is an abstract class.

Parameters
keyJVM class key to inspect.
Returns
true if key denotes an abstract class.

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ isPureVirtual()

bool Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::isPureVirtual ( Rose::Common::Analysis::FunctionKeyType  key) const
overridevirtual

returns true if the class represented by key is an abstract function.

Parameters
keyJVM function key to inspect.
Returns
true if key denotes an abstract function.
Note
abstract member functions are called pure virtual in C++

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ compareNames()

int Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::compareNames ( Rose::Common::Analysis::FunctionKeyType  lhs,
Rose::Common::Analysis::FunctionKeyType  rhs 
) const
overridevirtual

compares the source name of the functions lhs and rhs.

Parameters
lhsleft-hand side function
rhsright-hand side function
Returns
-1 iff nameOf(lhs) < nameOf(rhs) 0 iff nameOf(lhs) == nameOf(rhs) 1 iff nameOf(lhs) > nameOf(rhs)
Note
abstract member functions are called pure virtual in C++

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ compareFunctionsByType()

int Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::compareFunctionsByType ( Rose::Common::Analysis::FunctionKeyType  lhs,
Rose::Common::Analysis::FunctionKeyType  rhs,
bool  exclReturnType = true 
) const
overridevirtual

compares the canonical types of functions lhs and rhs

Parameters
lhsleft-hand side function
rhsright-hand side function
exclReturnTypeif true the return types of lhs and rhs are not considered (though the return types of potential arguments and return types are). This can be useful for obtaining equality of functions that have covariant return types.
Returns
0 iff lhs and rhs have the same type 1 iff lhs > rhs -1 iff lhs < rhs

if lhs and rhs are not equal, the ordering is not specified but produces consistent results

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ haveSameOrCovariantReturn()

Rose::Common::Analysis::FunctionTypeRelation Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::haveSameOrCovariantReturn ( const Rose::Common::Analysis::ClassAnalysis &  classes,
Rose::Common::Analysis::FunctionKeyType  basId,
Rose::Common::Analysis::FunctionKeyType  drvId 
) const
overridevirtual

tests if drvId has the same or covariant return type with respect to basId

Parameters
classesthe extracted class analysis
basIdID of a function in a base class
drvIdID of a function in a derived class
Returns
the return-type relationship between basId and drvId.

The function only checks the return type, and does not check whether the classes in which the functions drvId and basId are defined are in a inheritance relationship.

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ extractFromMemoryPool()

void Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::extractFromMemoryPool ( Rose::Common::Analysis::ClassAnalysis &  classes) const
overridevirtual

extracts class information from the memory pool if available

Parameters
classesanalysis object to populate.
Returns
nothing.
  1. For each class in the memory pool an entry in classes is created
  2. Adds all member functions declared in a class to the class representation CRep
  3. Adds all data members declared in a class to the class representation CRep

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ extractFromProject()

void Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::extractFromProject ( Rose::Common::Analysis::ClassAnalysis &  classes,
Rose::Common::Analysis::ASTRootType  root 
) const
overridevirtual

extracts class by walking the AST rooted at root.

Parameters
classesanalysis object to populate.
rootabstract key for the AST root to traverse.
Returns
nothing.
  1. For each known class an entry in classes is created
  2. Adds all member functions declared in a class to the class representation CRep
  3. Adds all data members declared in a class to the class representation CRep

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ languageSpecificProcessing()

Rose::Common::Analysis::LanguageSpecificFn Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::languageSpecificProcessing ( ) const
overridevirtual

returns JVM-specific class post-processing.

Returns
callback for JVM-specific post-processing.

JVM currently does not need additional processing after the common class hierarchy analysis. The JVM-specific override rule for inherited methods is handled through inheritedMethodsImplementVirtualBaseMethods.

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ inheritedMethodsImplementVirtualBaseMethods()

bool Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::inheritedMethodsImplementVirtualBaseMethods ( ) const
overridevirtual

returns true: in Java a method inherited from a superclass implements an interface method of a subclass (JLS 8.4.8.1, JVMS 5.4.6).

Returns
true.

The common analysis pairs only methods declared by a class with methods of its ancestors, which is the C++ rule. Java adds the implied overrider:

interface I { void m(); }
class B { public void m() {} }
class C extends B implements I {} // concrete; C inherits B.m
I obj = new C();
obj.m(); // invokeinterface I.m -> B.m

With this query returning true, analyzeVirtualFunctions records B.m as an implied overrider of I.m with witness C. The same rule covers an inherited superclass method beating an interface default method. Default method specificity among interfaces is resolved by the inheritance edges between the interfaces, as for C++ abstract base classes.

Reimplemented from Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ isInheritableImplementation()

bool Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::isInheritableImplementation ( Rose::Common::Analysis::FunctionKeyType  fnkey) const
overridevirtual

returns whether an inherited method qualifies as implementation of an interface method.

Parameters
fnkeyJVM method key.
Returns
true if the method is public and not abstract.

JLS 8.4.8.4: an inherited abstract method does not implement an interface method. Interface methods are public, so the implementing method must be public as well.

Reimplemented from Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ canOverride()

bool Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::canOverride ( Rose::Common::Analysis::FunctionKeyType  drv,
Rose::Common::Analysis::FunctionKeyType  bas 
) const
overridevirtual

applies the access rules of JVMS 5.4.5 to a signature match.

Parameters
drvmethod in (or inherited by) the derived class.
basmethod in the ancestor class.
Returns
false if either method is private; true if bas is public or protected; otherwise true iff both methods are declared in the same package.

Run-time packages also depend on the defining class loader, which the analysis does not represent; a single loader is assumed. The transitive rule of JVMS 5.4.5 (b) is applied by the common analysis.

Reimplemented from Rose::Common::Analysis::AbstractCompatibilityBridge.

◆ inheritanceEdges()

void Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::inheritanceEdges ( Rose::Common::Analysis::ClassKeyType  clkey,
std::function< void(Rose::Common::Analysis::ClassKeyType, Rose::Common::Analysis::ClassKeyType, bool)>  fn 
) const
override

calls the callback function fn(derived, base, isvirtual) for all direct base classes of clkey

Parameters
clkeyclass whose direct inheritance edges are requested.
fncallback invoked for each edge as (derived, base, isVirtual).
Returns
nothing.

◆ typeOf()

Rose::Common::Analysis::DataMemberType Rose::BinaryAnalysis::ByteCode::ClassHierarchy::JvmCompatibility::typeOf ( Rose::Common::Analysis::VariableKeyType  var) const
overridevirtual

returns the type of a non-static data member var.

Parameters
vardata member key to inspect.
Returns
summarized data member type properties.

Implements Rose::Common::Analysis::AbstractCompatibilityBridge.


The documentation for this class was generated from the following file: