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

Fuzzer ignores generics of class StringMap extends HashMap<String, String> #2571

Open
Assignees
Labels
comp-codegenIssue is related to code generator comp-fuzzingIssue is related to the fuzzing ctg-bugIssue is a bug lang-javaIssue is related to Java support
@IlyaMuravjov

Description

Description

Fuzzer tries to put arbitrary Objects into StringMap

To Reproduce

  • Set fuzzing to 100%
  • Generate tests for the following class
public class StringMap extends HashMap<String, String> {
 public String getAnyString() {
 return keySet().iterator().next();
 }
}

Expected behavior

There's one passing and one failing test.

Actual behavior

No passing tests are generated, one of the tests fails to compile with the following error: "incompatible types: Object cannot be converted to String stringMap.put(object, object1);".

Visual proofs (screenshots, logs, images)

/**
 * @utbot.classUnderTest {@link StringMap}
 * @utbot.methodUnderTest {@link StringMap#getAnyString()}
 */
@Test
@DisplayName("getAnyString: -> throw ClassCastException")
public void testGetAnyStringThrowsCCE() {
 StringMap stringMap = new StringMap();
 Object object = new Object();
 Object object1 = new Object();
 stringMap.put(object, object1);
 
 /* This test fails because method [org.example.StringMap.getAnyString] produces [java.lang.ClassCastException: class java.lang.Object cannot be cast to class java.lang.String (java.lang.Object and java.lang.String are in module java.base of loader 'bootstrap')]
 org.example.StringMap.getAnyString(StringMap.java:7) */
 stringMap.getAnyString();
}

Metadata

Metadata

Labels

comp-codegenIssue is related to code generator comp-fuzzingIssue is related to the fuzzing ctg-bugIssue is a bug lang-javaIssue is related to Java support

Type

No type

Projects

Status

In Progress

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /