kotlin-graphics / imgui

Bloat-free Immediate Mode Graphical User interface for JVM with minimal dependencies (rewrite of dear imgui)
MIT License
604 stars 36 forks source link

Unable to load ForwardDeclarationsKt when using Java modules #174

Open LapisSea opened 3 years ago

LapisSea commented 3 years ago

The title pretty much says it all. When modules are enabled, imgui.static.ForwardDeclarationsKt can not be loaded and an NoClassDefFoundError exception is thrown.

Relevant stack trace:

java.lang.NoClassDefFoundError: imgui/static/ForwardDeclarationsKt
    at com.github.kotlin_graphics.imgui.core/imgui.classes.IO.<init>(IO.kt:136)
    at com.github.kotlin_graphics.imgui.core/imgui.classes.Context.<init>(Context.kt:34)
    at com.github.kotlin_graphics.imgui.core/imgui.classes.Context.<init>(Context.kt:27)
    at com.github.kotlin_graphics.imgui.core/imgui.classes.Context.<init>(Context.kt)

I am using java OpenJDK 17.0.1 and maven.

To produce the error all that is needed is

public static void main(String[] args){
    new Context();
}

and modules file

module your.module {
    requires com.github.kotlin_graphics.imgui.core;
}

I'm no modules expert but it looks like the imgui.static is not being exported in the core and that might be causing the issue.

elect86 commented 3 years ago

Modules are giving me so much troubles I think I'm gonna disable them for the moment until everything mature a little more (Gradle + Java-Kotlin mixed project + JPMS)

I'll let you know

LapisSea commented 3 years ago

Thanks for the quick response! Yes... modules are a pain in this sorts of environments. I share your pain.

Also if anyone else is reading this and the issue is not resolved by then, exception goes away when modules are disabled on the client (my) side so that is a solution if anyone else is in a pinch.