Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 906708 - dev-java/openjdk-bin-17.0.6_p10 cannot start Java apps with DISPLAY=0.n
Summary: dev-java/openjdk-bin-17.0.6_p10 cannot start Java apps with DISPLAY=0.n
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Georgy Yakovlev
URL: https://bugs.freebsd.org/bugzilla/sho...
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2023-05-18 23:15 UTC by Hank Leininger
Modified: 2023-05-20 06:28 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hank Leininger 2023-05-18 23:15:33 UTC
Same seems to apply to dev-java/openjdk-17.0.6_p10

Using a multihead display, java apps fail to start whenever DISPLAY is something other than :0 or :0.0.

openjdk-15 worked fine.

Example below using just jconsole; first encountered this using some proprietary Java apps.

$ eselect java-vm show user
Current user-vm
  openjdk-bin-17


$ DISPLAY=:0 jconsole
[GUI starts fine]

$ DISPLAY=:0.3 jconsole
Exception in thread "main" java.lang.ExceptionInInitializerError
        at java.desktop/java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:106)
        at java.desktop/sun.awt.X11.XToolkit.<clinit>(XToolkit.java:224)
        at java.desktop/sun.awt.PlatformGraphicsInfo.createToolkit(PlatformGraphicsInfo.java:40)
        at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:599)
        at java.desktop/javax.swing.UIManager.getSystemLookAndFeelClassName(UIManager.java:668)
        at jdk.jconsole/sun.tools.jconsole.JConsole.<clinit>(JConsole.java:60)
Caused by: java.lang.NullPointerException: Cannot read the array length because "this.screens" is null
        at java.desktop/sun.awt.X11GraphicsEnvironment.initDevices(X11GraphicsEnvironment.java:235)
        at java.desktop/sun.awt.X11GraphicsEnvironment.rebuildDevices(X11GraphicsEnvironment.java:216)
        at java.desktop/sun.awt.X11GraphicsEnvironment.<init>(X11GraphicsEnvironment.java:201)
        at java.desktop/sun.awt.PlatformGraphicsInfo.createGE(PlatformGraphicsInfo.java:36)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.createGE(GraphicsEnvironment.java:93)
        at java.desktop/java.awt.GraphicsEnvironment$LocalGE.<clinit>(GraphicsEnvironment.java:84)
        ... 6 more

The 'Cannot read the array length because "this.screens" is null' error is actually helpful. The first Java program I encountered this with gave no such useful error message at startup :/

From it I found an existing FreeBSD bug (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264356) and ultimately, a minimal upstream patch that is apparently included in openjdk-17.0.7:

https://github.com/openjdk/jdk19/commit/cfc9a881afd300bd7c1ce784287d1669308e89fc

Rebuilt openjdk-17.0.6 with that locally and it seems to fix the issue, will submit a PR.
Comment 1 Larry the Git Cow gentoo-dev 2023-05-20 06:28:11 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=141ab9e4fa81526f4f05e319329e2943a2e7d5a5

commit 141ab9e4fa81526f4f05e319329e2943a2e7d5a5
Author:     Hank Leininger <hlein@korelogic.com>
AuthorDate: 2023-05-18 23:18:23 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-05-20 06:27:47 +0000

    dev-java/openjdk: fix multi-screen bug
    
    See $BUG, https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264356, https://bugs.openjdk.org/browse/JDK-8299417
    Cherry-picked the fix that has landed in the next openjdk release.
    
    Signed-off-by: Hank Leininger <hlein@korelogic.com>
    Closes: https://bugs.gentoo.org/906708
    Closes: https://github.com/gentoo/gentoo/pull/31091
    Signed-off-by: Sam James <sam@gentoo.org>

 .../files/openjdk-17.0.6-multihead-fix.patch       |  24 ++
 dev-java/openjdk/openjdk-17.0.6_p10-r1.ebuild      | 325 +++++++++++++++++++++
 2 files changed, 349 insertions(+)