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

String::indent method - CLI throws "No such field byte coder found in UtString" #375

Closed
alisevych opened this issue Jul 1, 2022 · 1 comment · Fixed by #392
Closed
Assignees
Labels
ctg-bug Issue is a bug priority-top-focus Top priority chosen by dev team

Comments

@alisevych
Copy link
Member

alisevych commented Jul 1, 2022

Description

CLI with JDK 13
Class using String::indent method (introduced in Java 12)
CLI throws "No such field byte coder found in org.utbot.engine.overrides.strings.UtString"

To Reproduce

Steps to reproduce the behavior:

  1. Define JDK-13 as primary (Path, JAVA_HOME)
  2. Download one of the latest CLI from master
  3. For simplicity in the folder where utbot-cli*.jar is located :
    Create ExampleString.java using String::indent method (introduced in Java 12)
public class ExampleString {

    public void stringNewMethod() {
        var text = "Hello!\nThis is String used with indent method.";

        text = text.indent(-3);
        System.out.println(text);

        text = text.indent(-5);
        System.out.println(text);
    }
}
  1. Compile your files with JDK-13

javac -version

javac ExampleString.class

  1. Run utbot-cli to generate tests for it, like that:

java -jar utbot-cli-2022.7.jar generate --source ExampleString.java --classpath "D:\Current\Java" -o ExampleStringTest.java ExampleString

Expected behavior

Tests are supposed to be generated.

Actual behavior

There is the following output in console:

var adn String::indent nethod is used (12), compiled and executed with JDK-13


WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
16:03:45.474 | INFO  | AllInMemoryClassProvider | Loaded: 2 path entries, 46 classes, 194922 bytes
16:03:46.718 | INFO  | UtBotTestCaseGenerator | |> Resuming method ExampleString.stringNewMethod()
16:03:47.189 | ERROR | UtBotSymbolicEngine | Test generation failed on stmt $b0 = r0.<java.lang.String: byte coder>, symbolic stack trace:
<java.lang.String: boolean isLatin1()>
<java.lang.String: java.util.stream.Stream lines()>
<java.lang.String: java.lang.String indent(int)>
<ExampleString: void stringNewMethod()>
java.lang.IllegalStateException: No such field byte coder found in org.utbot.engine.overrides.strings.UtString
        at org.utbot.engine.Hierarchy.chunkIdForField(Hierarchy.kt:33) ~[utbot-cli-2022.7.jar:?]
        at org.utbot.engine.UtBotSymbolicEngine.createFieldOrMock(UtBotSymbolicEngine.kt:2217) ~[utbot-cli-2022.7.jar:?]
        at org.utbot.engine.UtBotSymbolicEngine.resolve(UtBotSymbolicEngine.kt:2027) ~[utbot-cli-2022.7.jar:?]
        at org.utbot.engine.UtBotSymbolicEngine.traverseAssignStmt(UtBotSymbolicEngine.kt:1069) ~[utbot-cli-2022.7.jar:?]
        at org.utbot.engine.UtBotSymbolicEngine.traverseStmt(UtBotSymbolicEngine.kt:696) ~[utbot-cli-2022.7.jar:?]
        at org.utbot.engine.UtBotSymbolicEngine$traverseImpl$1.invokeSuspend(UtBotSymbolicEngine.kt:551) [utbot-cli-2022.7.jar:?]
        at org.utbot.engine.UtBotSymbolicEngine$traverseImpl$1.invoke(UtBotSymbolicEngine.kt) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:212) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.flow.FlowKt__EmittersKt$onStart$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:120) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.flow.FlowKt__EmittersKt$onCompletion$$inlined$unsafeFlow$1.collect(SafeCollector.common.kt:114) [utbot-cli-2022.7.jar:?]
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator$generateForSeveralMethods$4$1$1.invokeSuspend(UtBotTestCaseGenerator.kt:447) [utbot-cli-2022.7.jar:?]
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38) [utbot-cli-2022.7.jar:?]
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) [utbot-cli-2022.7.jar:?]
        at org.utbot.common.ConcurrencyKt.runBlockingWithCancellationPredicate(Concurrency.kt:38) [utbot-cli-2022.7.jar:?]
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator$generateForSeveralMethods$4.invoke(UtBotTestCaseGenerator.kt:279) [utbot-cli-2022.7.jar:?]
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator$generateForSeveralMethods$4.invoke(UtBotTestCaseGenerator.kt:56) [utbot-cli-2022.7.jar:?]
        at org.utbot.common.ConcurrencyKt.runIgnoringCancellationException(Concurrency.kt:47) [utbot-cli-2022.7.jar:?]
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator.generateForSeveralMethods(UtBotTestCaseGenerator.kt:278) [utbot-cli-2022.7.jar:?]
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator.generateForSeveralMethods$default(UtBotTestCaseGenerator.kt:265) [utbot-cli-2022.7.jar:?]
        at org.utbot.cli.GenerateTestsAbstractCommand.generateTestCases(GenerateTestsAbstractCommand.kt:163) [utbot-cli-2022.7.jar:?]
        at org.utbot.cli.GenerateTestsCommand.run(GenerateTestsCommand.kt:102) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:204) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:213) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:17) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:396) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:393) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:411) [utbot-cli-2022.7.jar:?]
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:436) [utbot-cli-2022.7.jar:?]
        at org.utbot.cli.ApplicationKt.main(Application.kt:31) [utbot-cli-2022.7.jar:?]
16:03:47.236 | INFO  | Summarization | Diversity execution path percentage: 100
16:03:47.236 | INFO  | Summarization | No execution traces found in test case for method ExampleString,     public void stringNewMethod()
    {
        java.io.PrintStream $r0, $r1;
        ExampleString r2;
        java.lang.String r3, r4, r5;

        r2 := @this: ExampleString;

        r3 = "Hello Baeldung!\nThis is Java 12 article.";

        r4 = virtualinvoke r3.<java.lang.String: java.lang.String indent(int)>(-4);

        $r0 = <java.lang.System: java.io.PrintStream out>;

        virtualinvoke $r0.<java.io.PrintStream: void println(java.lang.String)>(r4);

        r5 = virtualinvoke r4.<java.lang.String: java.lang.String indent(int)>(-10);

        $r1 = <java.lang.System: java.io.PrintStream out>;

        virtualinvoke $r1.<java.io.PrintStream: void println(java.lang.String)>(r5);

        return;
    }

@alisevych alisevych added ctg-bug Issue is a bug priority-top-focus Top priority chosen by dev team labels Jul 1, 2022
@alisevych alisevych changed the title String::indent (JAVA 12 feature) - CLI throws "No such field byte coder found in UtString" String::indent method - CLI throws "No such field byte coder found in UtString" Jul 1, 2022
@dtim dtim assigned dtim and unassigned sergeypospelov Jul 2, 2022
@alisevych
Copy link
Member Author

alisevych commented Jul 4, 2022

Additional context
IDEA plugin
JDK 11
Same error is reproducing for String methods - lines, strip, stripLeading, stripTrailing, repeat, isBlank, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-bug Issue is a bug priority-top-focus Top priority chosen by dev team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants