JDK-8263154 : [macos] DMG builds have finder errors
  • Type: Bug
  • Component: tools
  • Sub-Component: jpackage
  • Affected Version: 15
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86_64
  • Submitted: 2021-03-04
  • Updated: 2025-03-06
  • Resolved: 2021-04-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.
JDK 17
17 b19Fixed
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
macOS Catalina 10.15.7

openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)

WARNING: Using incubator modules: jdk.incubator.jpackage
15.0.2

A DESCRIPTION OF THE PROBLEM :
An AppleScript is included to put an alias to the Application folder in the DMG which errors. The osascript error ends up an IOException and shows in the build as that. The resulting DMG is missing the Application folder icon and alias. So there is an application icon and a arrow icon indicating 'drag to' but no application folder icon/alias to perform the drag.
This is a nice jpackage touch, making for a typical Mac application appearing install DMG. It would be good to have it working correctly.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See...
https://bugs.openjdk.java.net/browse/JDK-8226542
https://bugs.openjdk.java.net/browse/JDK-8250615
Pretty much seems to happen on all DMG builds right now.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The osascript runs and creates a Application folder alias and the mounted DMG image shows an Application folder icon to drag the user application icon to. 
ACTUAL -
This error in a verbose jpackage dmg build...

Running [osascript, /var/folders/dh/91wmrk0n6lzfmr4tjhjmcfp40000gn/T/jdk.incubator.jpackage17385828093712223986/config/SundaySudokuSolver-dmg-setup.scpt]
/var/folders/dh/91wmrk0n6lzfmr4tjhjmcfp40000gn/T/jdk.incubator.jpackage17385828093712223986/config/SundaySudokuSolver-dmg-setup.scpt:1108:1330: execution error: Finder got an error: Can’t make class alias file. (-2710)
java.io.IOException: Command [osascript, /var/folders/dh/91wmrk0n6lzfmr4tjhjmcfp40000gn/T/jdk.incubator.jpackage17385828093712223986/config/SundaySudokuSolver-dmg-setup.scpt] exited with 1 code
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Executor.executeExpectSuccess(Executor.java:75)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.IOUtils.exec(IOUtils.java:167)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.IOUtils.exec(IOUtils.java:135)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.MacDmgBundler.buildDMG(MacDmgBundler.java:393)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.MacDmgBundler.bundle(MacDmgBundler.java:91)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.MacDmgBundler.execute(MacDmgBundler.java:535)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Arguments.generateBundle(Arguments.java:680)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.internal.Arguments.processArguments(Arguments.java:549)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.main.Main.execute(Main.java:98)
	at jdk.incubator.jpackage/jdk.incubator.jpackage.main.Main.main(Main.java:52)

and an icon for the Applications folder is missing in the mounted dmg image.

From an email I sent to core-libs-dev...

It seems it could possibly be the path for the Applications folder. Say if you want something nice to get a name without a forward slash.
Based on DMGSetup.scpt…

tell application "Finder"
	set DEPLOY_VOLUME_PATH to "/Volumes/TestImage/"
	set DEPLOY_INSTALL_LOCATION to "Applications"
	set DEPLOY_INSTALL_NAME to "Applications"
	make new alias file at POSIX file DEPLOY_VOLUME_PATH to POSIX file DEPLOY_INSTALL_LOCATION with properties {name:DEPLOY_INSTALL_LOCATION}
end tell

tell application "Finder"
	make new alias file at file "TestImage:" to file ":Applications" with properties {name:"Applications"}
Result:
error "Finder got an error: Can’t make class alias file." number -2710 from alias file to class

You get the same error. Note INSTALL_LOCATION is used for both destination and name.

If you make that a correct path with forward slash but have a separate name variable without forward slash for the name.

tell application "Finder"
	make new alias file at file "TestImage:" to file "Macintosh HD:Applications:" with properties {name:"Applications"}
end tell
Result:
alias file "Applications" of disk "TestImage" of application “Finder”

It works. I’m not sure unless something changed why that would suddenly be broke but it does seem to be for DMG’s. 

<end of email>

CUSTOMER SUBMITTED WORKAROUND :
From an email I sent to core-libs-dev...

It seems it could possibly be the path for the Applications folder. Say if you want something nice to get a name without a forward slash.
Based on DMGSetup.scpt…

tell application "Finder"
	set DEPLOY_VOLUME_PATH to "/Volumes/TestImage/"
	set DEPLOY_INSTALL_LOCATION to "Applications"
	set DEPLOY_INSTALL_NAME to "Applications"
	make new alias file at POSIX file DEPLOY_VOLUME_PATH to POSIX file DEPLOY_INSTALL_LOCATION with properties {name:DEPLOY_INSTALL_LOCATION}
end tell

tell application "Finder"
	make new alias file at file "TestImage:" to file ":Applications" with properties {name:"Applications"}
Result:
error "Finder got an error: Can’t make class alias file." number -2710 from alias file to class

You get the same error. Note INSTALL_LOCATION is used for both destination and name.

If you make that a correct path with forward slash but have a separate name variable without forward slash for the name.

tell application "Finder"
	make new alias file at file "TestImage:" to file "Macintosh HD:Applications:" with properties {name:"Applications"}
end tell
Result:
alias file "Applications" of disk "TestImage" of application “Finder”

It works. I’m not sure unless something changed why that would suddenly be broke but it does seem to be for DMG’s. 

<end of email>

So basically you would need to pass the osascript (AppleScript) both a Applications folder path and a separate name parameter that being "Application" and change the one line in the script to something like...
make new alias file at POSIX file DEPLOY_VOLUME_PATH to POSIX file DEPLOY_INSTALL_LOCATION with properties {name:DEPLOY_INSTALL_NAME}
with the new additional parameter of DEPLOY_INSTALL_NAME = "Applications" it should work as expected.
I'm not sure how this might be done as a workaround though.

FREQUENCY : always



Comments
There has been no response from the submitter after 14 days. Closing the bug.
25-05-2021

Requested the submitter to see if the bug is fixed in the latest build at https://jdk.java.net/17/ b21 and provide the feedback.
11-05-2021

Changeset: 5b43b39e Author: Alexander Matveev <almatvee@openjdk.org> Date: 2021-04-19 18:17:24 +0000 URL: https://git.openjdk.java.net/jdk/commit/5b43b39e
19-04-2021

Yes, issue is only reproducible when relative path or some dummy path is specified. If it is valid path, then it works fine.
14-04-2021

Try a fully specified path to outputdir (relative path makes no sense to an installer ?) I now get the problem (I upgraded to BigSur) if I say just "--install-dir LocalApplications", but it works fine if I say "--install-dir ~/LocalApplications"
14-04-2021

I was able to reproduce issue. Simplified command line which I used: jpackage --type dmg -i input -n Test --main-class components.DynamicTreeDemo --main-jar DynamicTreeDemo.jar --verbose --install-dir outputdir If --install-dir is not specified issue is not reproducible.
14-04-2021

[~almatvee] can you please try to reproduce the issue?
29-03-2021

I cannot reproduce the original reported problem where apple script fails with: ...dmg-setup.scpt:1108:1330: execution error: Finder got an error: Can’t make class alias file. (-2710) If I set automation permission off in security preferences I can get a similar problem with apple script error: ...dmg-setup.scpt:301:343; execution error: Not authorized to send Apple events to Finder. (-1743) this was red-herring unrelated to the original customers problem. A failure running this dmg-setup.scpt script is intentionally non-fatal because: 1.) the automated tests may run on headless systems for which this will fail. 2.) the dmg image is still created (just without convenient way to drop image in appropriate install-dir Basically I cannot reproduce the original problem.
22-03-2021

reverting all code to original now works fine ? It seems the original problem was only the environmental problem of not allowing System Events and Finder to control other apps in System Preferences/Security & Privacy/Automation Looking into if we can test for this in the script ?
17-03-2021

First of all, in order to run osascript with either the default or app supplied setup.scpt, you need to set the System preferences/Security and Privacy/Automation to allow "Finder" and "System Events" to control other apps. This should probably be mentioned in the doc under DMG section. I tried variations on the suggestion to make the NAME different from the LOCATION in scpt line that makes alias : "make new alias at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name: "DEPLOY_INSTSTALL_NAME"] and that helped get a little further, but we still cannot generally run this scpt without error. now getting : "Finder got an error: Can't make class alias file" Then dmg window shows background tiff (big Arrow) but no destination Icon to drop app on. This was mainly because, once a dmg for a particular app name (or possibly mac-package-identifier) has it's dmg-setup.scpt run, making changes and then running again may remember at least some of the settings from the original. To accurately test, we must use a new app-name each time. With the original code, and permission to allow Finder and System Events to control other apps I can no longer see any problem.
17-03-2021

We have seen this (or similar problems in dmg's) on several systems then not been able to reproduce on other systems. This report may be providing the additional info required to resolve this issus.
09-03-2021

Additional information received from the submitter ========================================= Looking at this a little more I believe the problem line in the osascript again is… make new alias file at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name:"DEPLOY_INSTALL_LOCATION”} Looking at MacDmgBundler.java line 127 data.put("DEPLOY_APPLICATION_NAME", APP_NAME.fetchFrom(params)); I think the problem is that somehow this parameter is not the one being used for the name. So the above script line should be… make new alias file at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name:DEPLOY_APPLICATION_NAME} This should be the correct fix.
08-03-2021

Reply received from the submitter =========================== I believe this now happens anytime you create an OS X DMG, disk image, installer. It occurs for the following… ${PACKAGER} \ --verbose \ --input ../HalfPipe12.app/Contents/Java \ --icon GenericApp.icns \ --install-dir outputdir \ --resource-dir resources \ --name HalfPipe \ --main-jar halfpipe.jar \ --main-class us.hall.hp.common.LoaderLaunchStub \ --add-modules java.compiler,java.desktop,java.logging,java.management,java.prefs,java.se,java.rmi,java.scripting,java.sql,java.xml,jdk.attach,jdk.jshell,jdk.crypto.ec,jdk.incubator.jpackage \ --java-options '--add-modules jdk.incubator.jpackage -Xmx1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -Djava.library.path=$APPDIR -Djava.security.policy=$APPDIR/all.policy -Dapple.laf.useScreenMenuBar=true -Dcom.apple.mrj.application.apple.menu.about.name=HalfPipe -Dapple.awt.application.name=HalfPipe -Dconsole=pane' \ --mac-package-identifier "org.mik3hall.halfpipe" \ --mac-sign \ --mac-signing-key-user-name "Michael Hall” I have had the same result for a couple other applications as well. As indicated in the issue I think this is a bug in the DMGsetup.scpt script used by jpackage for dmg builds. I also indicate a fix. It should happen for everyone, all the time when these are done now as near as I can tell.
08-03-2021

The issue is related to this: https://bugs.openjdk.java.net/browse/JDK-8226542 However a simple reproducer is required to reproduce the issue. Requested submitter to provide one.
05-03-2021