Unresolved Reference: [any sun package]

Hey guys when i’m trying to build my project with gradle, kotlin compile crashed with unresolved reference error for every com.sun - Package. If i run the project it works very well


  • MacOS: 10.14.1
  • Intelij-Ultimate-2018.2.5 — IU-182.4892.20, built on October 16, 2018
  • SDK: jdk1.8.0_172.jdk
  • Gradle 4.4
Build time:   2017-12-06 09:05:06 UTC
Revision:     cf7821a6f79f8e2a598df21780e3ff7ce8db2b82

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM:          1.8.0_172 (Oracle Corporation 25.172-b11)
OS:           Mac OS X 10.14.1 x86_64

My goal is to write a debugger. So i need some classes from the jdi


plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.0'

group 'de.test.rev'
version '1.0-SNAPSHOT'

repositories {

jar {
    manifest {
        attributes 'Main-Class': 'de.test.rev.MainKt'

    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0'


compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"

e: /pathToProject/src/main/kotlin/de/test/rev/debug/facade/DebugFacade.kt: (3, 16): Unresolved reference: jdi

followed by a ton of errors for other com.sun. packages.

What I have tried so far

  • removed ./idea, .gradle and build Folder
  • create a new project

It is possible that for some reason, the build process does use the openjdk? If I rembered correct, sun packages are not be in that package

I solved it by myself by adding the sun librariers to the jar.

Adding the following to the dependencies block:

compile files("${System.getProperty('java.home')}/../lib/tools.jar")