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

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

Closed
alisevych opened this issue Jul 1, 2022 · 3 comments · Fixed by #890
Closed

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

alisevych opened this issue Jul 1, 2022 · 3 comments · Fixed by #890
Assignees
Labels
ctg-bug Issue is a bug priority-top-focus Top priority chosen by dev team status-verified Bug fix is verified

Comments

@alisevych
Copy link
Member

alisevych commented Jul 1, 2022

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)
@alisevych alisevych added ctg-bug Issue is a bug priority-top-focus Top priority chosen by dev team labels Jul 1, 2022
@sergeypospelov
Copy link
Member

sergeypospelov commented Jul 4, 2022

Some investigation on #373:

It happens, because our Soot has a low dependency on ASM library.

Potential fix:

  • add a dependency on a higher ASM version

Will try this out

@alexeyfridman alexeyfridman moved this to Todo in UTBot Java Jul 6, 2022
@alexeyfridman alexeyfridman moved this from Todo to Done in UTBot Java Jul 6, 2022
@alexeyfridman alexeyfridman moved this from Done to In Progress in UTBot Java Jul 6, 2022
@dtim
Copy link
Collaborator

dtim commented Jul 8, 2022

Related: UnitTestBot does not work on Idea 2022.2 EAP, as it uses JBR 17 as its runtime.

Environment
IntelliJ IDEA 2022.2 Beta (Ultimate Edition)
Build #IU-222.3345.16, built on July 7, 2022
Expiration date: August 6, 2022
Runtime version: 17.0.3+7-b469.19 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.13.0-52-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 16384M
Cores: 16
Non-Bundled Plugins:
com.jetbrains.grayTheme (1.3)
org.utbot.intellij.plugin.id (2022.7-beta)

Kotlin: 222-1.7.0-release-282-IJ3345.16
Current Desktop: ubuntu:GNOME

Actual behavior
No tests are generated, the following exception is thrown:

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:80)
	at org.utbot.framework.plugin.api.UtBotTestCaseGenerator.init(UtBotTestCaseGenerator.kt:111)
	at org.utbot.intellij.plugin.generator.CodeGenerator.<init>(CodeGenerator.kt:44)
	at org.utbot.intellij.plugin.generator.CodeGenerator.<init>(CodeGenerator.kt:36)
	at org.utbot.intellij.plugin.ui.UtTestsDialogProcessor$createTests$2$1.run(UtTestsDialogProcessor.kt:157)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:442)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$5(CoreProgressManager.java:493)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:833)

rudolf101 added a commit that referenced this issue Jul 8, 2022
commit 31fbc83
Author: Andrey Tarbeev <[email protected]>
Date:   Fri Jul 8 10:50:52 2022 +0300

    Minimize exceptions in signature (#418)

    * Minimize exceptions in test methods signatures

commit 63eb9b0
Author: Yury Kamenev <[email protected]>
Date:   Thu Jul 7 15:13:45 2022 +0300

    Removed always used coverage-based minimization strategy (#450)

commit fe0f7f8
Author: Yury Kamenev <[email protected]>
Date:   Thu Jul 7 14:19:53 2022 +0300

    Disabled NPE checks for non-public library fields by default (#353)

commit d1b51fe
Author: Yury Kamenev <[email protected]>
Date:   Thu Jul 7 13:44:46 2022 +0300

    Fixed NPE for processing static field as first statement in MUT (#433)

commit acc2fff
Author: Nikita Vlaev <[email protected]>
Date:   Wed Jul 6 15:37:28 2022 +0300

    Added ForceStaticMockListener to run "configure mockito-inline" action.
    Refactored url listener in notifications.

commit 80c2328
Author: Nikita Stroganov <[email protected]>
Date:   Thu Jul 7 11:21:13 2022 +0300

    Support -P parameters in the utbot-gradle (#377)

commit a92e289
Author: Sergey Pospelov <[email protected]>
Date:   Tue Jul 5 10:29:45 2022 +0300

    Fix searching of modifiers field for JDK 8-17

commit 9a3acb6
Author: Amandel Pie <[email protected]>
Date:   Wed Jul 6 14:16:09 2022 +0300

    Disabled clustering of tests generated by Fuzzer (#431)

    * Disabled clustering of tests generated by Fuzzer

    * Refactored the multiple calls

commit c09568f
Author: Vassiliy Kudryashov <[email protected]>
Date:   Wed Jul 6 10:21:52 2022 +0300

    Existing test file without test class obstruct generation #160 (#425)

commit 2ec8fb3
Author: Denis Fokin <[email protected]>
Date:   Tue Jul 5 16:52:42 2022 +0300

    Better naming

commit 68c66ef
Author: Vassiliy Kudryashov <[email protected]>
Date:   Tue Jul 5 19:51:55 2022 +0300

    SVG logo contains 'inaccurate' holes #330 (#411)

commit 1d48789
Author: Dmitrii Timofeev <[email protected]>
Date:   Tue Jul 5 17:08:38 2022 +0300

    Workaround: run concrete execution for invokedynamic

commit 65d95c1
Author: Vassiliy Kudryashov <[email protected]>
Date:   Tue Jul 5 19:42:55 2022 +0300

    Plugin fails with an exception if no SDK is configured for the test module #399 (#424)

commit 6f9f2d8
Author: Maksim Pelevin <[email protected]>
Date:   Tue Jul 5 17:49:58 2022 +0300

    Fix CNFE: kotlin.collections.ArrayDeque in ContestEstimator (#419)

commit 67cc7d9
Author: Denis Fokin <[email protected]>
Date:   Tue Jul 5 11:58:40 2022 +0300

    Put concrete executor jar in resources for contest estimator

commit 63e2252
Author: Alena Lisevych <[email protected]>
Date:   Tue Jul 5 15:48:29 2022 +0300

    Tooltips correction for #343 (#410)

    Co-authored-by: Alena Lisevych <>

commit 8b3defa
Author: Vassiliy Kudryashov <[email protected]>
Date:   Tue Jul 5 13:22:31 2022 +0300

    Write access exception on test generating in Idea project with JDK 11 #350 (#409)

commit c02883c
Author: Amandel Pie <[email protected]>
Date:   Tue Jul 5 11:21:21 2022 +0300

    Enables 40 tests for utbot-summary module (#389)

    * Repair testPow

    * Repaired ReturnExampleTest tests

    * Restored SummaryCycleTest.kt

    * Restored all the tests

commit 65c07f8
Author: Victoria <[email protected]>
Date:   Tue Jul 5 09:51:44 2022 +0300

    Update Dockerfile_java_cli (#396)

commit 3b21112
Author: Alexey Menshutin <[email protected]>
Date:   Mon Jul 4 21:16:53 2022 +0300

    ToString support for abstract collection using makeSymbolic #391

commit c2673df
Author: Vassiliy Kudryashov <[email protected]>
Date:   Mon Jul 4 21:56:43 2022 +0300

    IDE fatal error during tests generation #68 (#379)

commit 43693fb
Author: Nikita Vlaev <[email protected]>
Date:   Mon Jul 4 18:59:57 2022 +0300

    Bring back test class generation (#403)

commit 1c01193
Author: Yury Kamenev <[email protected]>
Date:   Mon Jul 4 20:24:03 2022 +0300

    Added the wrapper for static methods of java.util.List (#400)

commit a805f31
Author: Nikita Vlaev <[email protected]>
Date:   Fri Jul 1 20:16:28 2022 +0300

    Add title pane with unsupported jdk notification (#373)

commit 16c13fb
Author: Dmitrii Timofeev <[email protected]>
Date:   Mon Jul 4 18:35:36 2022 +0300

    Initiate concrete execution if a wrapper method is missing (#392)

    If a JVM class is overridden but a method is missing from the wrapper,
    the engine will discard the path and fall back to concrete execution
    instead of analysing the real JVM code graph.

    This approach fixes the problem with methods that have been introduced
    in newer JDKs. Now wrappers are mostly limited to Java 1.8 interfaces
    and fail to analyze methods like `String::isBlank` or `String::lines`
    when the code runs under JDK 11. Building graphs from the real JDK code
    fails because the wrapper does not have private fields that the original
    code uses.

    TODO: to allow symbolic analysis of the code, missing methods should be
    actually implemented in corresponding wrappers.
@alisevych alisevych added this to the Release preparation milestone Sep 7, 2022
Repository owner moved this from In Progress to Done in UTBot Java Sep 14, 2022
@alisevych alisevych added status-verified Bug fix is verified and removed status-verified Bug fix is verified labels Sep 15, 2022
@alisevych
Copy link
Member Author

alisevych commented Sep 15, 2022

The issue with "Unsupported class file major version" is not reproducing with JDK 13 / 17 - with same code samples.
Code examples are processed without errors and tests are generated.

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 status-verified Bug fix is verified
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants