Skip to content

CLI with JDK 17 throws Unsupported class file major version 61 #373

Closed
@alisevych

Description

@alisevych

Description

CLI with JDK 17
Soot throws "IllegalArgumentException: Unsupported class file major version 61" when called from CLI with JDK 17.

To Reproduce

Steps to reproduce the behavior:

  1. Define JDK-17 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 var (feature introduced in Java 9)
public class ExampleString {

    public void stringNewMethod() {
        var text = "Hello! This is String defined with var";

        text = text.toLowerCase();
        System.out.println(text);

        text = text.toUpperCase();
        System.out.println(text);
    }
}
  1. Create ExampleRecord.java using record (feature introduced in Java 16)
public class ExampleRecord {

    public record Person(String name, int age) {
        public Person {
            if(age < 0) {
                throw new IllegalArgumentException("Age cannot be negative");
            }
        }
    }
}

  1. Compile your files with JDK-17

javac ExampleRecord.java
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

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

Expected behavior

Tests are supposed to be generated.

Actual behavior

There is the following output in console:

WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
16:14:54.331 | INFO  | AllInMemoryClassProvider | Loaded: 2 path entries, 48 classes, 196740 bytes
16:14:54.378 | ERROR | GenerateTestsCommand | An error has occurred while generating test for snippet ExampleRecord : java.lang.IllegalArgumentException: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:196)
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:177)
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:163)
        at org.objectweb.asm.ClassReader.<init>(ClassReader.java:284)
        at soot.asm.AsmClassSource.resolve(AsmClassSource.java:64)
        at soot.SootResolver.bringToHierarchyUnchecked(SootResolver.java:253)
        at soot.SootResolver.bringToHierarchy(SootResolver.java:221)
        at soot.SootResolver.bringToSignatures(SootResolver.java:292)
        at soot.SootResolver.bringToBodies(SootResolver.java:332)
        at soot.SootResolver.processResolveWorklist(SootResolver.java:171)
        at soot.SootResolver.resolveClass(SootResolver.java:141)
        at soot.Scene.tryLoadClass(Scene.java:965)
        at soot.Scene.loadBasicClasses(Scene.java:1670)
        at soot.Scene.loadNecessaryClasses(Scene.java:1770)
        at org.utbot.framework.plugin.api.SootUtilsKt.runSoot(SootUtils.kt:77)
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator.init(UtBotTestCaseGenerator.kt:111)
        at org.utbot.framework.plugin.api.UtBotTestCaseGenerator.init(UtBotTestCaseGenerator.kt:75)
        at org.utbot.cli.GenerateTestsAbstractCommand.initializeEngine(GenerateTestsAbstractCommand.kt:202)
        at org.utbot.cli.GenerateTestsCommand.run(GenerateTestsCommand.kt:95)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:204)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:213)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:17)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:396)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:393)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:411)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:436)
        at org.utbot.cli.ApplicationKt.main(Application.kt:31)

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions