```In Book.kt: data class Book(val isbn: ISBN, va...
# getting-started
t
Copy code
In Book.kt:

data class Book(val isbn: ISBN, val title: Title)
@JvmInline value class ISBN(val value: String)
@JvmInline value class Title(val value: String)

Somewhere in BookDAO.java:
new Book("123","Thundercats");
When I'm looking at the code in IntelliJ, it's simply compiling (no red squiggly lines). When I run a
mvn clean install
it also just compiles. But when I do a build (ctrl+F9), I'm getting this:
java: Book(java.lang.String,java.lang.String) has private access in Book
When I define book as
data class Book(val isbn: String, val title: String)
compilation does succeed. What is going on? It smells like intelliJ is using an older Kotlin version to compile or something? In the build output I'm getting this:
Copy code
...
Kotlin: kotlinc-jvm 1.7.20 (JRE 17.0.2+8)
...
javac 11.0.9 was used to compile java sources
I'd like to try to get kotlinc-jvm to use JRE 11 to compile, but don't know how.
t
Thanks for the very fast response @ephemient! So, works as intended I guess 😅 Why is it that there's not squiggly line in IntelliJ's edit window?
e
I don't know, that seems like a bug
👍 1
t
Follow up questions:
Copy code
in Book.kt
data class Book(private val _isbn: String, private val _title: String){
    val isbn: ISBN
        @JvmName("getIsbn") get() = ISBN(_isbn)
    val title: Title = Title(_title)
}
@JvmInline value class ISBN(val value: String)
@JvmInline value class Title(val value: String)

Somewhere in BookDAO.java:
book.getIsbn()
book.getTitle()
Same issue, IntelliJ the editor is not showing any issues, and even provides auto-completion hints for both .getIsbn() and .getTitle(). Build Output:
Copy code
java: cannot find symbol
  symbol:   method getTitle()
  location: variable book of type Book
The culprit was actually
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
in my pom.xml. Setting it to false actually produces a publically visible constructor with the value classes inlined, like you'd expect, and also generates the correct getters, during compilation (build output).