You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to build my application with JDK 10 EAP b45 because it going to be released this month and noticed that my Mac OS app have default app icon. I have dig deeper and found that jdk.packager.internal.legacy.builders.AbstractAppImageBuilder#locateResource doesn't load resources from class path by default anymore. Look at this code and my comments:
protected InputStream locateResource(String publicName, String category,
String defaultName, File customFile,
boolean verbose, File publicRoot) throws IOException {
InputStream is = null;
boolean customFromClasspath = false;
boolean customFromFile = false;
if (publicName != null) {
if (publicRoot != null) { // <=== This is value from `dropinResourcesRoot` parameter and by default it equla to `.` (seems like it mean project root)
File publicResource = new File(publicRoot, publicName);
if (publicResource.exists() && publicResource.isFile()) {
is = new FileInputStream(publicResource);
}
} else {
is = getResourceAsStream(publicName); // <=== This method can load icon from class path but looks like new JDK doesn't allow it
}
customFromClasspath = (is != null);
}
if (is == null && customFile != null) {
is = new FileInputStream(customFile);
customFromFile = (is != null);
}
if (is == null && defaultName != null) {
is = getResourceAsStream(defaultName); // <=== Here is loading default icon
}
String msg = null;
if (customFromClasspath) {
msg = MessageFormat.format(I18N.getString("message.using-custom-resource-from-classpath"), category == null ? "" : "[" + category + "] ", publicName);
} else if (customFromFile) {
msg = MessageFormat.format(I18N.getString("message.using-custom-resource-from-file"), category == null ? "" : "[" + category + "] ", customFile.getAbsoluteFile());
} else if (is != null) {
msg = MessageFormat.format(I18N.getString("message.using-default-resource-from-classpath"), category == null ? "" : "[" + category + "] ", publicName);
} else {
msg = MessageFormat.format(I18N.getString("message.using-default-resource"), category == null ? "" : "[" + category + "] ", publicName);
}
if (verbose) {
Log.info(msg);
}
return is;
}
This method is called from jdk.packager.internal.legacy.builders.mac.MacAppImageBuilder#prepareApplicationFiles:
...
/*********** Take care of "config" files *******/
// Copy icon to Resources folder
File icon = ICON_ICNS.fetchFrom(params);
InputStream in = locateResource("package/macosx/" + APP_NAME.fetchFrom(params) + ".icns",
"icon",
DEFAULT_ICNS_ICON.fetchFrom(params),
icon,
VERBOSE.fetchFrom(params),
DROP_IN_RESOURCES_ROOT.fetchFrom(params));
Files.copy(in, resourcesDir.resolve(APP_NAME.fetchFrom(params) + ".icns"));
...
So, to fix this problem need to specify path to src/main/deploy in dropinResourcesRoot parameter:
As well I think initialization of class path here is not required anymore. Moreover it print the following warnings:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.zenjava.javafx.maven.plugin.AbstractJfxToolsMojo (file:/Users/closer/.m2/repository/com/zenjava/javafx-maven-plugin/8.9.0-SNAPSHOT/javafx-maven-plugin-8.9.0-SNAPSHOT.jar) to method java.net.URLClassLoader.addURL(java.net.URL)
WARNING: Please consider reporting this to the maintainers of com.zenjava.javafx.maven.plugin.AbstractJfxToolsMojo
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
So, looks like it should be removed it in the future.
The text was updated successfully, but these errors were encountered:
I have tried to build my application with JDK 10 EAP b45 because it going to be released this month and noticed that my Mac OS app have default app icon. I have dig deeper and found that
jdk.packager.internal.legacy.builders.AbstractAppImageBuilder#locateResource
doesn't load resources from class path by default anymore. Look at this code and my comments:This method is called from
jdk.packager.internal.legacy.builders.mac.MacAppImageBuilder#prepareApplicationFiles
:So, to fix this problem need to specify path to
src/main/deploy
indropinResourcesRoot
parameter:As well I think initialization of class path here is not required anymore. Moreover it print the following warnings:
So, looks like it should be removed it in the future.
The text was updated successfully, but these errors were encountered: