Skip to content
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

Using util method via reflection #2711

Open
Damtev opened this issue Dec 7, 2023 · 0 comments
Open

Using util method via reflection #2711

Damtev opened this issue Dec 7, 2023 · 0 comments
Assignees
Labels
comp-codegen Issue is related to code generator ctg-bug Issue is a bug

Comments

@Damtev
Copy link
Member

Damtev commented Dec 7, 2023

Consider the following class com.google.common.primitives.Booleans$LexicographicalComparator in guava-26.0:

private static enum LexicographicalComparator implements Comparator<boolean[]> { ... }

In tests for methods of this class in some specific conditions we generate the following code:

        Class booleansLexicographicalComparatorTestClazz = Class.forName("com.google.common.primitives.Booleans_LexicographicalComparatorTest");
        Class classType = Class.forName("java.lang.Class");
        Class stringType = Class.forName("java.lang.String");
        Method getStaticFieldValueMethod = booleansLexicographicalComparatorTestClazz.getDeclaredMethod("getStaticFieldValue", classType, stringType);
        getStaticFieldValueMethod.setAccessible(true);
        java.lang.Object[] getStaticFieldValueMethodArguments = new java.lang.Object[2];
        getStaticFieldValueMethodArguments[0] = "com.google.common.primitives.Booleans$LexicographicalComparator";
        getStaticFieldValueMethodArguments[1] = "INSTANCE";
        Object lexicographicalComparator = getStaticFieldValueMethod.invoke(null, getStaticFieldValueMethodArguments);

Steps to reproduce:

  1. Checkout to usvm_competitions_2024 branch, at least one reproducable commit 5503f43
  2. Use the following settings in ContestEstimator:
        val timeLimit = 120
        methodFilter = "com.google.common.primitives.Booleans\$LexicographicalComparator.toString"
        projectFilter = listOf("guava-26.0")
  3. Add the following line com.google.common.primitives.Booleans$LexicographicalComparator to the utbot-junit-contest/src/main/resources/classes/guava-26.0/list
  4. Always use symbolicResult and ignore concreteResult in org.utbot.contest.usvm.jc.JcTestExecutor#execute
@Damtev Damtev added ctg-bug Issue is a bug comp-codegen Issue is related to code generator labels Dec 7, 2023
@EgorkaKulikov EgorkaKulikov assigned tepa46 and unassigned EgorkaKulikov Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator ctg-bug Issue is a bug
Projects
Status: Todo
Development

No branches or pull requests

3 participants