Skip to content

UtMethod removal #862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 7, 2022
Merged

UtMethod removal #862

merged 7 commits into from
Sep 7, 2022

Conversation

sergeypospelov
Copy link
Member

@sergeypospelov sergeypospelov commented Sep 6, 2022

Description

  • Substituted UtMethod with ExecutableId.
  • Changed Kotlin Reflection to Java Reflection almost everywhere.
  • Refactored util functions a bit. Now functions such as Method.isStatic, Class.isAbstract are located in the ReflectionUtil.kt.
  • Cleaned up imports somewhere.
  • Change some entry points to our test generation, more specifically, the actual code of receiving methods under test in CLI and Contest.
  • Some local refactorings.

Some context:

UtMethod is a vestigial class which was used for passing method under test to our TestCaseGenerator. Now we use ExecutableId for identifying method, so it's unnecessary to have one more entity. We can simply build ExecutableId from java.reflect.Method and KCallable<*> by calling .executableId extension function, assuming we have UtContext initialized.

ExecutableId has two main inheritors: MethodId and ConstructorId. We also have our own wrappers ClassId and FieldId for java classes and fields respectively.

Please note, that some reflection dependent parts of FieldId, ClassId and ExecutableId API, e.g. MethodId.method, ClassId.isPublic, etc., require UtContext to be set. It's very implicit and to be refactored in the next PRs.

Type of Change

  • Refactoring (typos and non-functional changes)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

Manual Scenario

  • Run test generation with Intellij plugin (nested and anonymous classes)

Checklist:

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • All tests pass locally with my changes

Copy link
Collaborator

@SBOne-Kenobi SBOne-Kenobi left a comment

Choose a reason for hiding this comment

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

Good PR! There is some suggestions for a future replacement SootMethod: we can introduce ReflectionWrapper that will wrap ExecutableId and provide reflection methods for its and ReflectionWrapperBuilder that will create instances of ReflectionWrappers depending on specified implementation such as Soot or JCDB.

Copy link
Collaborator

@EgorkaKulikov EgorkaKulikov left a comment

Choose a reason for hiding this comment

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

Comments discussed verbally

@sergeypospelov sergeypospelov force-pushed the sergey/utmethod_removal branch from e690398 to 0f3edf8 Compare September 7, 2022 11:58
@sergeypospelov sergeypospelov force-pushed the sergey/utmethod_removal branch from eb24366 to 7c67a69 Compare September 7, 2022 13:31
@sergeypospelov sergeypospelov enabled auto-merge (squash) September 7, 2022 20:33
@sergeypospelov sergeypospelov merged commit 4446a9d into main Sep 7, 2022
@sergeypospelov sergeypospelov deleted the sergey/utmethod_removal branch September 7, 2022 21:10
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.

5 participants