JDK-8213756 : SingleInstance runtime improvements
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: internal
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-12
  • Updated: 2019-03-22
  • Resolved: 2018-11-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
internalFixed
Related Reports
Relates :  
Description
JPackager's SingleInstanceImplementation has a 2 arg version of registerSingleInstance(), containing a setFileHandler flag whose only effect is on macosx.

0.) Since this functionality is marginally useful at best, is not cross-platform, and requires jdk.jpackager.runtime to require java.destop we would like to remove it, at least for the initial delivery in JDK12.

There are other problems in SingleInstanceService that should be addressed.
1.) each call to registerSingleInstance calls:
        instance = new SingleInstanceServiceImpl();
which should have been wrapped in a synchronized null check.
2.) some of the comments are misleading and need rewording.
such as :
  36     /**
  37      * This method should be implemented by the application to
  38      * handle the single instance behaviour - how should the application
  39      * handle the arguments when another instance of the application is
  40      * invoked with params.
3.) NewActivation() is only called if there are arguments, otherwise an attempt to launch a second instance just exits.
This is undocumented behavior and is just wrong. NewActivation should be called before exiting.
4.) The method getTmpDir is overly complex in an attempt to cover unsupported platforms.
It should just have cases for "windows", "macosx", and anything else case covering "linux".
Additionally the "Oracle" (on Mac) and "Sun" will be removed from path elements bother here and in native launcher matching place.
5.) it has been suggested that registerSingleInstance() should be paired with "deregisterSingleInstance()' instead of "unregisterSingleInstance()'.
I would rather suggest that the names be changed back to the original names in the jnlp specification: "addSingleInstanceListener()" and "removeSingleInstanceListener()"
6.) also fix gramatical errors in javadoc.
examples: 
 "-singleton" must be specified on jpackager command line" should be " --singleton" must be specified on the jpackager command line."
"for current process" should be "for the current process".
7.) final request is to change LocalLow to Local  in Ttemp path on windows. - this was left overe from deployment code that could run in low integrity mode