I'd like to disclaim that since I'm not an OpenJDK developer, the upstream decision may very-well be to attempt to load Gtk when the system is anything other than Windows or MacOS. I can't speak on behalf of the end-strategy of OpenJDK and I do not represent them or their solution to this problem.
That said, for reasons mentioned above as well as evidence in Gnome's codebase, Debian's codebase and Java's codebase, I observe a valid use-case for asking if the desktop environment is Gtk-based. To deny that suggests that solutions which check are invalid, or contain no value and I believe this perspective to be short-sighted as admittingly my sight is as well.
-Tres
Not a Gnome/GTK/OpenJDK developer but it sounds like you're
asking for the wrong thing. What you need is standard way of
getting a list of UI toolkits(GTK/QT/whatever) installed. It
doesn't matter what the desktop is, only that GTK is installed.
Good luck with that, by the by. Even if you could somehow get
Gnome/KDE/whomever to agree to implement such a thing(ha!),
distros will find a way to break it somehow.