Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make fuzzer use static methods to create arbitrary objects#2440

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
IlyaMuravjov wants to merge2 commits intomain
base:main
Choose a base branch
Loading
fromilya_m/fuzz_objects_with_static_method

Conversation

@IlyaMuravjov
Copy link
Collaborator

Description

Now fuzzer can use both static methods and constructors to create instances of arbitrary types.

Fixes#2437

How to test

Automated tests

The proposed changes are verified with tests:
utbot-java-fuzzing/src/test/kotlin/org/utbot/fuzzing/JavaFuzzingTest.kt

Self-check list

  • I've set the properlabels for my PR (at least, for category and component).
  • PRtitle anddescription are clear and intelligible.
  • I've added enoughcomments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered withautomated tests.
  • Manual tests have been provided optionally.
  • Thedocumentation for the functionality I've been working on is up-to-date.


privatefunfindAccessibleCreators(description:FuzzedDescription,classId:ClassId):Sequence<ExecutableId>=
(classId.allConstructors+ (classId.jClass.methods
.filter { it.isStatic&& it.returnType.id.isSubtypeOf(classId) }
Copy link
Collaborator

@MarkoutteMarkoutteJul 25, 2023
edited
Loading

Choose a reason for hiding this comment

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

Could you, please, check what will happen if generics are used? Something like:

classA<T> {publicstaticA<String>getStringTyped() {returnnewA<>("Test") }privateA(Tvalue) {};}...publicvoidtestedMethod(A<Integer>expected) { ... }

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

It will erroneously usegetStringTyped() to createA<Integer>. I was assuming that java fuzzer doesn't attempt to fully respect generic types here, since similar issue could have been reproduced even before this pull request:

interfaceA<T> {Tget();}classAImplimplementsA<String> {@OverridepublicStringget() {return"Test";    } }...publicvoidtestedMethod(A<Integer>expected) { ... }

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough, I tried to fix it with#2451. Please, review it when it is possible. I think same can be done for this PR when 2451 is merged.

@IlyaMuravjovIlyaMuravjovforce-pushed theilya_m/fuzz_objects_with_static_method branch from6d93b45 to400f616CompareJuly 26, 2023 13:53
@MarkoutteMarkoutte self-requested a reviewJuly 31, 2023 07:37
@IlyaMuravjovIlyaMuravjov marked this pull request as draftAugust 4, 2023 09:55
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@MarkoutteMarkoutteMarkoutte approved these changes

At least 2 approving reviews are required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Java fuzzer can't create any values for types with no public constructor (e.g.LocalDateTime)

3 participants

@IlyaMuravjov@Markoutte

[8]ページ先頭

©2009-2025 Movatter.jp