Changeset 8817 in josm for trunk/src


Ignore:
Timestamp:
2015-10-03T01:23:15+02:00 (9 years ago)
Author:
Don-vip
Message:

see #11924 - JDK9 Jigsaw: do not run code in headless environment (for jenkins unit tests)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r8816 r8817  
    55
    66import java.awt.Color;
     7import java.awt.GraphicsEnvironment;
    78import java.awt.Toolkit;
    89import java.io.BufferedReader;
     
    14851486        // Force AWT toolkit to update its internal preferences (fix #6345).
    14861487        // This ugly hack comes from Sun bug database: https://bugs.openjdk.java.net/browse/JDK-6292739
    1487         try {
    1488             Field field = Toolkit.class.getDeclaredField("resources");
    1489             field.setAccessible(true);
    1490             field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
    1491         } catch (Exception | InternalError e) {
    1492             // Ignore all exceptions, including internal error raised by Java 9 Jigsaw EA:
    1493             // java.lang.InternalError: legacy getBundle can't be used to find sun.awt.resources.awt in module java.desktop
    1494             // InternalError catch to remove when https://bugs.openjdk.java.net/browse/JI-9025152 is resolved
    1495             if (Main.isTraceEnabled()) {
    1496                 Main.trace(e.getMessage());
     1488        if (!GraphicsEnvironment.isHeadless()) {
     1489            try {
     1490                Field field = Toolkit.class.getDeclaredField("resources");
     1491                field.setAccessible(true);
     1492                field.set(null, ResourceBundle.getBundle("sun.awt.resources.awt"));
     1493            } catch (Exception | InternalError e) {
     1494                // Ignore all exceptions, including internal error raised by Java 9 Jigsaw EA:
     1495                // java.lang.InternalError: legacy getBundle can't be used to find sun.awt.resources.awt in module java.desktop
     1496                // InternalError catch to remove when https://bugs.openjdk.java.net/browse/JI-9025152 is resolved
     1497                if (Main.isTraceEnabled()) {
     1498                    Main.trace(e.getMessage());
     1499                }
    14971500            }
    14981501        }
Note: See TracChangeset for help on using the changeset viewer.