-
Notifications
You must be signed in to change notification settings - Fork 47
ClassCastException when processing UtEnumConstantModel #230
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
Labels
Comments
This was referenced Jul 5, 2022
Related to #414 |
dtim
added a commit
that referenced
this issue
Jul 27, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as obe of enum constants to implement reference equality for enums.
dtim
added a commit
that referenced
this issue
Jul 27, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as obe of enum constants to implement reference equality for enums.
dtim
added a commit
that referenced
this issue
Jul 27, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as any one of enum constants to implement reference equality for enums.
dtim
added a commit
that referenced
this issue
Jul 28, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as any one of enum constants to implement reference equality for enums.
dtim
added a commit
that referenced
this issue
Jul 29, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as any one of enum constants to implement reference equality for enums.
dtim
added a commit
that referenced
this issue
Jul 29, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as any one of enum constants to implement reference equality for enums. Fixes #414, #230
dtim
added a commit
that referenced
this issue
Jul 29, 2022
Historically `UtEnumConstModel` and `UtClassRefModel` have been processed not as other reference models but in a special way, more like to primitive types. This approach leads to several problems, especially to class cast errors when processing generic collections with enums or class references as elements. This commit makes `UtEnumConstModel` and `UtClassRefModel` subtypes of `UtReferenceModel`. * Concrete executor is modified to respect the identity of static fields to avoid rewriting enum values and `Class<?>` instances. * Special processing for enums is implemented. When a new enum value is created, or an `Object` is being cast to the enum type, static values for the enum class are initialized, and the set of hard constraint is added to require that the new instance has the same address and ordinal as any one of enum constants to implement reference equality for enums. Fixes #414, #230, #300
7 tasks
Repository owner
moved this from In Progress
to Done
in UTBot Java
Aug 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Description
Processing of
Enum
types may result inClassCastException
, asUtEnumConstantModel
is incorrectly cast toUtReferenceModel
in several situations, in particular:ArrayObjectWrappers.kt
:AssociativeArrayWrapper.value()
(the location related to the reproducible example below).CollectionWrappers.kt
:constructKeysAndValues()
(a similar type cast).To Reproduce
Generate the test suite for the
MapExamples
class.Color.java
:MapExamples.java
:Expected behavior
Test suite is generated, no
ClassCastException
errors are reported.Actual behavior
No tests are generated, the plugin fails with the following exception:
It is possible that some tests are generated, but a non-empty error suite is generated as well (I encountered this case once but it seems hard to reproduce). See Additional context below for details.
Environment
Mock strategy: Other packages: Mockito
Mock static: No static mocking
Test framework: JUnit5
Additional context
I somehow managed to generate a non-empty test suite with several reported
ClassCastException
errors. It seems hard to reproduce (usually the generator just fails, so I am not sure that it is not a version mismatch from my side), but it might be useful to have this log.The text was updated successfully, but these errors were encountered: