Kotlin VerifyError: Uninitialized object exists on

2020-04-05 01:28发布

问题:

I am using the Kotlin getting started guide to setup Kotlin for the first time on IntelliJ IDEA with the following configuration:

IntelliJ IDEA 2017.2.5
Build #IC-172.4343.14, built on September 26, 2017
JRE: 1.8.0_152-release-915-b12 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6

I created an App.kt file in a new Kotlin project with the following code:

fun main(args: Array<String>) {
    println("hello")
}

On running the code through the IDE, I get the following error:

Error:Internal error: (java.lang.VerifyError) Uninitialized object exists on backward branch 90
Exception Details:
  Location:
    org/jetbrains/kotlin/jps/build/KotlinBuilder.createCompileEnvironment(Ljava/util/Map;Lorg/jetbrains/kotlin/incremental/components/LookupTracker;Lorg/jetbrains/jps/incremental/CompileContext;Lorg/jetbrains/kotlin/jps/build/KotlinBuilder$MessageCollectorAdapter;)Lorg/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment; @171: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: bb03 fe59 b703 ff3a 0619 063a 0719 0713
    0000010: 02d7 2cb6 0403 5719 0713 0405 bb04 0759
    0000020: 2b3a 083a 093a 0a3a 0b3a 0c19 083a 0dbb
    0000030: 0409 5919 08b9 040a 0100 b804 10b7 0411
    0000040: c002 893a 0e19 0db9 028c 0100 c000 b03a
    0000050: 0f19 0fb9 00b9 0100 3a10 1910 b900 be01
    0000060: 0099 004d 1910 b900 c201 003a 1119 0e19
    0000070: 11c0 028e 3a12 3a13 1912 b902 9101 00c0
    0000080: 00c4 b804 173a 1419 1319 1419 11c0 028e
    0000090: 3a15 3a16 3a17 1915 b902 9401 003a 1819
    00000a0: 1719 1619 18b9 041b 0300 57a7 ffaf 190e
    00000b0: 0000 3a13 190c 190b 190a 1909 1913 b704
    00000c0: 1eb6 0403 5719 0713 0420 bb04 2259 2c2b
    00000d0: 2db7 0425 b604 0357 1907 b604 283a 052a
    00000e0: b704 2c3a 0619 06c6 0010 1906 b904 3101
    00000f0: 00b6 013c 9a00 1319 04b2 0216 1304 3301
    0000100: 0701 b801 fa01 b0bb 0262 5919 0619 05b2
    0000110: 002e b604 3719 04c0 01c7 bb04 3959 b704
    0000120: 3ab7 043d b0                           
  Stackmap Table:
    full_frame(@90,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Top,Object[#1022],Object[#1022],Object[#649],Uninitialized[#28],Uninitialized[#28],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187]},{})
    same_frame_extended(@174)
    full_frame(@247,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Object[#1102],Object[#1070],Object[#1022],Object[#649],Object[#1031],Object[#1031],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187],Top,Top,Object[#649]},{})
    same_frame(@263)
java.lang.VerifyError: Uninitialized object exists on backward branch 90
Exception Details:
  Location:
    org/jetbrains/kotlin/jps/build/KotlinBuilder.createCompileEnvironment(Ljava/util/Map;Lorg/jetbrains/kotlin/incremental/components/LookupTracker;Lorg/jetbrains/jps/incremental/CompileContext;Lorg/jetbrains/kotlin/jps/build/KotlinBuilder$MessageCollectorAdapter;)Lorg/jetbrains/kotlin/compilerRunner/JpsCompilerEnvironment; @171: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: bb03 fe59 b703 ff3a 0619 063a 0719 0713
    0000010: 02d7 2cb6 0403 5719 0713 0405 bb04 0759
    0000020: 2b3a 083a 093a 0a3a 0b3a 0c19 083a 0dbb
    0000030: 0409 5919 08b9 040a 0100 b804 10b7 0411
    0000040: c002 893a 0e19 0db9 028c 0100 c000 b03a
    0000050: 0f19 0fb9 00b9 0100 3a10 1910 b900 be01
    0000060: 0099 004d 1910 b900 c201 003a 1119 0e19
    0000070: 11c0 028e 3a12 3a13 1912 b902 9101 00c0
    0000080: 00c4 b804 173a 1419 1319 1419 11c0 028e
    0000090: 3a15 3a16 3a17 1915 b902 9401 003a 1819
    00000a0: 1719 1619 18b9 041b 0300 57a7 ffaf 190e
    00000b0: 0000 3a13 190c 190b 190a 1909 1913 b704
    00000c0: 1eb6 0403 5719 0713 0420 bb04 2259 2c2b
    00000d0: 2db7 0425 b604 0357 1907 b604 283a 052a
    00000e0: b704 2c3a 0619 06c6 0010 1906 b904 3101
    00000f0: 00b6 013c 9a00 1319 04b2 0216 1304 3301
    0000100: 0701 b801 fa01 b0bb 0262 5919 0619 05b2
    0000110: 002e b604 3719 04c0 01c7 bb04 3959 b704
    0000120: 3ab7 043d b0                           
  Stackmap Table:
    full_frame(@90,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Top,Object[#1022],Object[#1022],Object[#649],Uninitialized[#28],Uninitialized[#28],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187]},{})
    same_frame_extended(@174)
    full_frame(@247,{Object[#2],Object[#649],Object[#727],Object[#98],Object[#428],Object[#1102],Object[#1070],Object[#1022],Object[#649],Object[#1031],Object[#1031],Object[#1005],Object[#1022],Object[#649],Object[#649],Object[#176],Object[#187],Top,Top,Object[#649]},{})
    same_frame(@263)
    at org.jetbrains.kotlin.jps.build.KotlinBuilderService.createModuleLevelBuilders(KotlinBuilderService.java:30)
    at org.jetbrains.jps.incremental.BuilderRegistry.<init>(BuilderRegistry.java:54)
    at org.jetbrains.jps.incremental.BuilderRegistry.<init>(BuilderRegistry.java:33)
    at org.jetbrains.jps.incremental.BuilderRegistry$Holder.<clinit>(BuilderRegistry.java:36)
    at org.jetbrains.jps.incremental.BuilderRegistry.getInstance(BuilderRegistry.java:43)
    at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:133)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$$Lambda$3/1147174008.run(Unknown Source)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$$Lambda$1/684874119.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

回答1:

This is due to a bug in earlier JDK 8 versions. Open up the project structure for your project and change your project SDK to a more recent version.

Upgrading from JDK 1.8.0_11 to 1.80_72 solved the problem for me.



回答2:

Just check "Use embedded JDK" in File>Project Structure>SDK Location> JDK Location