Skip to content

Adapt Class validators to SootUp#863

Closed
Momo-Not-Emo wants to merge 2 commits intosoot-oss:developfrom
Momo-Not-Emo:class-validator
Closed

Adapt Class validators to SootUp#863
Momo-Not-Emo wants to merge 2 commits intosoot-oss:developfrom
Momo-Not-Emo:class-validator

Conversation

@Momo-Not-Emo
Copy link
Copy Markdown
Contributor

This pull request modifies the MethodDeclarationValidator and ClassFlagsValidator classes to be compatible with SootUp.

  • The changes include the addition of a boolean isAllowedInFinalCode() method to the Type class and its subclasses for MethodDeclarationValidator.
  • Additionally, sc.isSuper() is now used in ClassFlagsValidator instead of sc.isSynchronized() due to a method renaming.

However, the adaptation of OuterClassValidator remains incomplete. This validator is designed to check for cycles in the outer class chain, but adapting it is challenging because the return type of SootClass::getOuterClass has changed from SootClass to ClassType. I am uncertain about how to obtain the SootClass object from the ClassType.

Note: There are no test cases included in this pull request, as these class validators are not currently utilized in SootUp. They are typically invoked through PackManager in Soot, but it appears that SootUp has not yet ported PackManager.

@swissiety
Copy link
Copy Markdown
Collaborator

thx for your contribution! It seems like a duplicate of #860 ? Lets merge the best of both approaches.

how to obtain the SootClass object from the ClassType

you can get it via view.getClass( classType ).get()

I think isAllowedInFinalCode() should not be necessary (and thats the reason we have/need a validator) / I am not sure we should have an API for it. Maybe lets have an interface for the all allowed types and check via instanceof that interface? like an interface for non-void types, "Method returnable types" including void?

Copy link
Copy Markdown
Contributor

@akshitad11 akshitad11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly refer to my pull request : 860.
I have already made changes to MethodDeclarationValidator in much more detail there. Let's merge these changes as suggested by @swissiety.
Also, my changes for ClassFlagsValidator(now renamed to ClassModifierValidator) are merged in develop, please take the latest version of develop and you will see the changes.

@Momo-Not-Emo
Copy link
Copy Markdown
Contributor Author

how to obtain the SootClass object from the ClassType

you can get it via view.getClass( classType ).get()

However, it seems view is not available in the validator. Should it be passed as a parameter of void validate(...)?

@Momo-Not-Emo Momo-Not-Emo deleted the class-validator branch February 21, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants