Skip to content

Duplicated UtUtils class in Kotlin/Java mixed projects #1080

Closed
@volivan239

Description

@volivan239

Description

We have two different implementations of UtUtils, one is needed for codegen in Java and one -- for codegen in Kotlin. Both classes has fqn org.utbot.runtime.utils.UtUtils which leads to duplicated class error in projects where Java and Kotlin are used simultaneously.

To Reproduce

Create a Java class that would need reflection to be tested, for example

public class JavaClass {
    private int x;
    int f() {
        return x;
    }
}

Then, create a Kotlin class that would need reflection, for example:

class KotlinClass {
    private val x = 0
    fun f(): Int {
        return x
    }
}

Launch action on both of these classes sequentially.

Expected behavior

Tests are generated correctly and are compilable, utils classes are not duplicated.

Actual behavior

You receive compilation error due to duplication of UtUtils class.

Additional context

I think that the most convenient solution would be to rewrite declared functions from UtUtils.kt as high-order functions and import them like import org.utbot.runtime.utils.getFieldValue. Or just rename UtUtils used for Kotlin codegen to something like UtUtilsKt and make it Object.

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a buglang-kotlinIssue is related to Kotlin language support

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions