JDK-8181568 : [macos] Manipulating of dock icon under OSX in Java 9
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: os_x
  • CPU: x86
  • Submitted: 2017-06-05
  • Updated: 2018-04-03
  • Resolved: 2017-06-12
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+172)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+172, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Darwin pegasos.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64

EXTRA RELEVANT SYSTEM CONFIGURATION :
not relevant

A DESCRIPTION OF THE PROBLEM :
With previous versions of Java it was possible to manipulating of dock icon under OSX was possible with something like 

com.apple.eawt.Application.getApplication().setDockIconImage(image);

but unfortunately not any more with Java 9. In JEP 272 this change is mentioned, as well as the idea that Dock is too much Apple-oriented (for me all are Apple oriented) and there is no clear explanation about it.

For all other tasks found in Application class, the java.awt.Desktop class took this functionality, all but the Dock manipulation. 

It is a bug which was correct in previous versions of Java, but not any more. Moreover the issue was known but closed as done - which is not the case. There is even discussion on how the dock-related methods should be named, and apart from these specific methods, all other are there intact.


REGRESSION.  Last worked in version 8u131

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Not being able to use 
Application.getApplication().setDockIconImage(image);
any more and at the same time no equivalent 
Desktop.getDesktop().setDockIconImage(image);
exists

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Either way to be able to change the dock icon
ACTUAL -
No way to change the dock icon

ERROR MESSAGES/STACK TRACES THAT OCCUR :
no crash logs

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
 com.apple.eawt.Application.getApplication().setDockIconImage(image);
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
No work around


Comments
http://download.java.net/java/jdk9/docs/api/java/awt/Taskbar.html
13-09-2017

It is a part of the java.awt.Taskbar class now, use setIconImage() and other methods in this class.
12-06-2017

Additional Information from submitter: ============================================================: Following you will find a test code which displays which methods have vanished. As an example I present two methods (among many) that exist in Desktop. public static void main(String[] args) throws IOException { com.apple.eawt.Application app = com.apple.eawt.Application.getApplication(); // These exist in Application and Desktop app.setQuitStrategy(null); app.disableSuddenTermination(); // These are only on Application and are inaccessible in Java 9 app.setDockIconProgress(1); app.setDockIconBadge("badge"); Image dockimage = app.getDockIconImage(); app.setDockIconImage(dockimage); PopupMenu dockMenu = app.getDockMenu(); app.setDockMenu(dockMenu); java.awt.Desktop desk = java.awt.Desktop.getDesktop(); // As mentioned, these have been transformed and are accessible in Java 9 desk.setQuitStrategy(null); desk.disableSuddenTermination(); // From now on all methods are wrong, these are the methods missing desk.setDockIconProgress(1); desk.setDockIconBadge("badge"); Image dockimage2 = desk.getDockIconImage(); desk.setDockIconImage(dockimage2); PopupMenu dockMenu2 = desk.getDockMenu(); desk.setDockMenu(dockMenu2); } ===================================================================
12-06-2017

According to JEP 272 - http://openjdk.java.net/jeps/272, it is mentioned that internal APIs such as those in the Mac OS X com.apple.eawt package will no longer be accessible and is handled by java.awt.Desktop class instead. Submitter made a mention of manipulating the dock icon in OS X. We need more information from the submitter about the tasks expected that covers manipulation of the dock according to him, preferably with a test case.
05-06-2017