https://kotlinlang.org logo
Title
d

dancancro

08/27/2017, 6:27 PM
Hi everyone. I am brand new to Kotlin and having the following problem with my JHipster app in which I mix java and kotlin: https://github.com/dancancro/great-big-example-application/tree/blogwithkotlin/src/main/kotlin/org/exampleapps/greatbig
2017-08-27 14:12:33.623  WARN 62423 --- [  XNIO-2 task-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.VerifyError: Uninitialized object exists on backward branch 82
Exception Details:
  Location:
    org/exampleapps/greatbig/domain/inout/Article$Companion.fromModel(Lorg/exampleapps/greatbig/domain/Article;Lorg/exampleapps/greatbig/domain/Author;)Lorg/exampleapps/greatbig/domain/inout/Article; @129: goto
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: 2b12 39b8 000f 2c12 3bb8 000f bb00 3d59
    0000010: 2bb6 0043 2bb6 0046 2bb6 0049 2bb6 004c
    0000020: 2bb6 0050 c000 524e 3a12 3a11 3a10 3a0f
    0000030: 3a0e 3a0d 2d3a 04bb 0054 592d 100a b800
    0000040: 5ab7 005e c000 603a 0519 04b9 0064 0100
    0000050: 3a06 1906 b900 6a01 0099 002b 1906 b900
    0000060: 6e01 003a 0719 0519 07c0 0070 3a08 3a13
    0000070: 1908 b600 733a 1419 1319 14b9 0077 0200
    0000080: 57a7 ffd1 1905 c000 793a 1319 0d19 0e19
    0000090: 0f19 1019 1119 1219 132a c000 022b b600
    00000a0: 7db6 007f 2ac0 0002 2bb6 0082 b600 7fb2
    00000b0: 0088 2bb6 008c 2cb6 0092 2bb6 0095 2cb9
    00000c0: 0098 0200 2bb6 0095 b900 9c01 003e 3604
    00000d0: 3a05 3a06 3a07 3a08 3a09 3a0a 3a0b 3a0c
    00000e0: 190b 190a 1909 1908 190c 1907 1906 1905
    00000f0: 1504 1db7 009f b0
  Stackmap Table:
    full_frame(@82,{Object[#2],Object[#63],Object[#176],Object[#82],Object[#82],Object[#96],Object[#102],Top,Top,Top,Top,Top,Top,Uninitialized[#12],Uninitialized[#12],Object[#178],Object[#178],Object[#178],Object[#178]},{})
    same_frame(@132)
o

orangy

08/27/2017, 9:08 PM
Please submit an issue to kotl.in/issue
d

dancancro

08/27/2017, 9:18 PM
Okay. I guess I'm not off to such a great start with Kotlin. Other than this I do like it. Hopefully this isn't too hard to fix.
o

orangy

08/27/2017, 9:26 PM
What version of Kotlin do you use? There is a request similar to yours, but it is marked with 1.2-M2, a pre-release build. https://youtrack.jetbrains.com/issue/KT-19660
I do remember something about a lambda in a constructor of some complicated case… Does it help to extract
model.tagList.map { it.name }
to a local variable?
d

dancancro

08/27/2017, 9:42 PM
I'm using Kotlin 1.1.2
I will try doing that
That might have worked. I'm now getting something else
An unexpected error occurred: failed to lazily initialize a collection of role: org.exampleapps.greatbig.domain.Article.tagList, could not initialize proxy - no Session
Do you want me to still submit an issue?
o

orangy

08/27/2017, 9:54 PM
Yes, please. We have few reports like this, but no repro. Yours seems a good candidate. Thanks!
Btw, 1.1.4-2 is already released and it has lots of fixes compared to 1.1.2 😉
d

dancancro

08/27/2017, 10:03 PM
okay. i'll give that a try
o

orangy

08/27/2017, 10:07 PM
could not initialize proxy - no Session
looks like a runtime error from Spring, you might ask in #spring
Scratch that, it seems to be error reported by Hibernate
d

dancancro

08/28/2017, 1:47 AM
Adding
@Transactional
seems to have made it work. I wonder why that is so. The original demo didn't have that. I have much to learn about many different things.
o

orangy

08/28/2017, 8:31 AM
Thanks for details in the issue! Did you try upgrading Java? 1.8.0_05 is pretty old… Also note, that something similar was fixed in JVM in some more recent build: https://bugs.openjdk.java.net/browse/JDK-8046233
d

dancancro

08/28/2017, 1:43 PM
Can you explain the best way to fix my java versions? I seem to have three
[09:34:26] JavaVirtualMachines
// ♥ pwd
/Library/Java/JavaVirtualMachines
[09:34:35] JavaVirtualMachines
// ♥ ls
jdk1.8.0_05.jdk		jdk1.8.0_131.jdk
[09:34:42] JavaVirtualMachines
// ♥ grep 'JAVA_HOME' ~/.bashrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home
I have those two versions and when I open the java control panel it says I have 141 too.
That was the problem. I pointed JAVA_HOME to jdk1.8.0_131 and tested the original demo and my app. The bytecode problem is no longer happening.
o

orangy

08/28/2017, 4:56 PM
Nice, at least “I guess I’m not off to such a great start with Kotlin” has nothing to do with Kotlin after all 😉
d

dancancro

08/28/2017, 7:20 PM
👍