Triplea: com.apple.eawt not working for Java 9+

Created on 18 Mar 2018  路  21Comments  路  Source: triplea-game/triplea

Engine version

1.9.0.0.9687

My Operating System

macOS 10.13.3 (High Sierra)

Map name

WW2 classic 3E

Can you describe how to trigger the error? (eg: what sequence of actions will recreate it?)

Start a local game, configure AI players, click "Play"

Do you have the exact error text? Please copy/paste if so

TripleA engine version 1.9.0.0.9687
Loading map: world_war_ii_classic, from: /Users/dmoles/triplea/downloadedMaps/world_war_ii_classic-master.zip
Loading resources from the following paths: [/Users/dmoles/triplea/downloadedMaps/world_war_ii_classic-master.zip, /Applications/TripleA.app/Contents/java/app/assets]
Loading map: world_war_ii_classic, from: /Users/dmoles/triplea/downloadedMaps/world_war_ii_classic-master.zip
Loading resources from the following paths: [/Users/dmoles/triplea/downloadedMaps/world_war_ii_classic-master.zip, /Applications/TripleA.app/Contents/java/app/assets]
Error: com/apple/eawt/QuitHandler
java.lang.NoClassDefFoundError: com/apple/eawt/QuitHandler
    at games.strategy.triplea.ui.menubar.FileMenu.addExitMenu(FileMenu.java:104)
    at games.strategy.triplea.ui.menubar.FileMenu.<init>(FileMenu.java:45)
    at games.strategy.triplea.ui.menubar.TripleAMenuBar.<init>(TripleAMenuBar.java:35)
    at games.strategy.triplea.ui.TripleAFrame.<init>(TripleAFrame.java:247)
    at games.strategy.triplea.TripleA.lambda$startGame$0(TripleA.java:121)
    at games.strategy.ui.SwingAction.lambda$invokeAndWait$0(SwingAction.java:86)
    at games.strategy.ui.SwingAction.lambda$invokeAndWaitResult$1(SwingAction.java:114)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.EventQueue.access$500(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.apple.eawt.QuitHandler
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    ... 21 more

Instead of this error, what should have happened?

Game should start

Any additional information that may help

$ java -version
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
Problem

Most helpful comment

Just my 2垄 as a developer鈥攖he reflection hack used in keystore-explorer doesn't seem completely horrible, bearing in mind there's likely to be a transition period when you need to support <= 1.8 as well as 9+, even after Oracle drops support for Java 8 next year.

All 21 comments

Just to be sure: Does this error happen using java 8 as well?

@RoiEXLab Guessing its the same problem reported here: https://github.com/kaikramer/keystore-explorer/issues/102

Release 9824
macOS 10.12.6
Java 8
No problems

Found the reason: http://openjdk.java.net/jeps/272
The good news: We no longer need to depend on this stupid legacy library
The bad news: It doesn't look like this feature will be backported to java 8, so we'll have to rely on reflection if we don't want to upgrade to java 9.

As a side note: The official release date of java 10 is tomorrow.
See http://openjdk.java.net/projects/jdk/10/
Oracle announced that "Java SE 9 will be a short term release, and users should immediately transition to the next release (18.3) when available."
So if Java 10 will be available at java.com we could consider moving to a newer version of Java

Assigning you all @DanVanAtta @ron-murhammer @ssoloff to get your opinion on how to handle this issue.
Please read my comments above to get a good picture of what's going on.

We basically have 3 options:

  1. Just ignore this for now, and wait until we can upgrade the java version and use the Desktop API from there.
  2. Try some dark reflection magic and check if TripleA is running with Java 9 or higher (too bad the version comparison classes are a java 9 feature ^^) i.e. the required methods exists and invoke them if they do.
  3. Just drop the dependency on orange-extensions, and use reflection for everything instead of partial reflection and partial "polyfilling" (not sure if this is the right term, but it reminds me of JavaScript)

Just my 2垄 as a developer鈥攖he reflection hack used in keystore-explorer doesn't seem completely horrible, bearing in mind there's likely to be a transition period when you need to support <= 1.8 as well as 9+, even after Oracle drops support for Java 8 next year.

@chronodm Agreed, however we currently require users to use java 8 or higher, so incrementing the version required might not be a huge deal at all.

@RoiEXLab I'd probably prefer to be able to support Java 8 and 9 for a while. And wait to force users to upgrade to Java 9 after a good portion have already done so through Oracle updates/etc. Otherwise we are either going to keep getting bug reports like this or we need to force Java 9 very soon which is a bit early IMO.

Java 9 isn鈥檛 considered a long-term support release, I don鈥檛 think, so it might be a bit harsh to force casual users to upgrade to it now.

@RoiEXLab I think a pure reflection-based solution similar to what @chronodm linked would be acceptable until we dropped Java 8 support (i.e. your option (3)).

We currently bundle a JDK8 for Mac+Windows with the installer. @chronodm was this reproduced by running the game after installing with the mac installer, or launching from a jar file or source? If from an installed TripleA, it would mean our bundled JDK is not being used.

Interesting. That was running the game after installing with the Mac installer. I'm away from that machine at the moment but when I get back to it I'll see if I can find any other configuration information that might help.

Technically we don't bundle a JRE.
The installer is just configured to download one if the system it runs on doesn't have a JRE preinstalled.
Because we currently don't have a maximum java version, the java 9 JRE is treated as perfectly fine and therefore no additional JRE will be downloaded and the existing JRE will be used.

@RoiEXLab Should we temporarily revert the portion of 8913692bb that removed Java 8 as the max version supported by the installer? We have several issues at the moment that prevent the application from running correctly on Java 9+ (most notably JDK-8199664). We can always direct users to the portable install for Java 9+ testing.

@ssoloff probably the best option for now.

@ssoloff We should probably also consider changing the second travis build to java 10 to ensure the code still compiles.

@ssoloff #3304

@RoiEXLab @ssoloff ; is this mitigated? Anything left to do? A new issue to track any open items I think would be useful to keep our task list clean. Otherwise perhaps we would want a summary of the things we would need to be java 9 / java 10 ready.

Sorry, don't have access to a Mac, so I don't know if this is still an issue. Regardless, labeling as a Java 9+ blocker.

I'm pretty sure this is still an issue, simply because in java 9+ there's an official API for this and the inofficial one we use via a hack was removed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

General-Dru-Zod picture General-Dru-Zod  路  5Comments

DanVanAtta picture DanVanAtta  路  4Comments

ZjelcoP picture ZjelcoP  路  5Comments

DanVanAtta picture DanVanAtta  路  5Comments

panther2 picture panther2  路  5Comments