--- old/make/sun/osxapp/Makefile 2012-08-14 18:05:15.000000000 +0400 +++ new/make/sun/osxapp/Makefile 2012-08-14 18:05:15.000000000 +0400 @@ -28,6 +28,11 @@ PRODUCT = sun include $(BUILDDIR)/common/Defs.gmk +GEN_DIR=$(GENSRCDIR)/sun/osxapp +ICON_DATA = $(GEN_DIR)/AWTIconData.h + +CLASSES_INIT += $(ICON_DATA) + # # Files # @@ -63,6 +68,7 @@ -framework QuartzCore CPPFLAGS += \ + -I$(GEN_DIR) \ $(call NativeSrcDirList,-I,/native/sun/osxapp) @@ -70,6 +76,34 @@ CPPFLAGS += -DINTERNAL_BUILD endif -clean clobber:: +TEMPDIR_CLASSES = $(TEMPDIR)/classes + +$(TEMPDIR_CLASSES)/sun/osxapp/ToBin.class: ToBin.java + @$(prep-target) + $(BOOT_JAVAC_CMD) -d $(TEMPDIR_CLASSES) $< + +ifdef OPENJDK + ICONS_PATH_PREFIX=$(PLATFORM_SRC_MACOS) +else + ICONS_PATH_PREFIX=$(CLOSED_SRC)/macosx +endif + +generated.clean: + $(RM) -r $(GEN_DIR)/*.h + +ICONPATH=$(ICONS_PATH_PREFIX)/native/sun/osxapp/resource/icons +ICON = $(ICONPATH)/JavaApp.icns + +$(GEN_DIR)/AWTIconData.h: $(TEMPDIR_CLASSES)/sun/osxapp/ToBin.class $(ICON) + $(prep-target) + $(RM) $(ICON_DATA) + $(ECHO) "static unsigned char sAWTIconData[] = { " >> $(ICON_DATA); \ + $(CAT) $(ICON) | \ + $(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES) -Djava.awt.headless=true \ + sun.osxapp.ToBin >> $(ICON_DATA); \ + $(ECHO) "};" >> $(ICON_DATA); + + +clean clobber:: generated.clean -.PHONY: +.PHONY: generated.clean --- old/src/macosx/native/sun/osxapp/NSApplicationAWT.m 2012-08-14 18:05:16.000000000 +0400 +++ new/src/macosx/native/sun/osxapp/NSApplicationAWT.m 2012-08-14 18:05:16.000000000 +0400 @@ -31,6 +31,7 @@ #import "PropertiesUtilities.h" #import "ThreadUtilities.h" #import "QueuingApplicationDelegate.h" +#import "AWTIconData.h" static BOOL sUsingDefaultNIB = YES; @@ -255,25 +256,26 @@ theIconPath = [PropertiesUtilities javaSystemPropertyForKey:@"apple.awt.application.icon" withEnv:env]; } - // If the icon file wasn't specified as an argument and we need to get an icon - // we'll use the generic java app icon. - NSString *defaultIconPath = [NSString stringWithFormat:@"%@%@", SHARED_FRAMEWORK_BUNDLE, @"/Resources/GenericApp.icns"]; - if (theIconPath == nil) { + // Use the path specified to get the icon image + NSImage* iconImage = nil; + if (theIconPath != nil) { + iconImage = [[NSImage alloc] initWithContentsOfFile:theIconPath]; + } + + // If no icon file was specified or we failed to get the icon image + // and we need to get an icon, then use the default icon + if (iconImage == nil) { NSString* bundleIcon = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIconFile"]; if (bundleIcon == nil) { - theIconPath = defaultIconPath; + NSData* iconData; + iconData = [[NSData alloc] initWithBytesNoCopy: sAWTIconData length: sizeof(sAWTIconData) freeWhenDone: NO]; + iconImage = [[NSImage alloc] initWithData: iconData]; + [iconData release]; } } - // Set up the dock icon if we have an icon name. - if (theIconPath != nil) { - NSImage *iconImage = [[NSImage alloc] initWithContentsOfFile:theIconPath]; - - // If we failed for some reason fall back to the default icon. - if (iconImage == nil) { - iconImage = [[NSImage alloc] initWithContentsOfFile:defaultIconPath]; - } - + // Set up the dock icon if we have an icon image. + if (iconImage != nil) { [NSApp setApplicationIconImage:iconImage]; [iconImage release]; } --- /dev/null 2012-08-14 18:05:17.000000000 +0400 +++ new/make/sun/osxapp/ToBin.java 2012-08-14 18:05:17.000000000 +0400 @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.osxapp; + +import java.io.*; + +public class ToBin { + public static void main(String[] args) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int nRead; + byte[] data = new byte[4096]; + + while ((nRead = System.in.read(data, 0, data.length)) != -1) { + baos.write(data, 0, nRead); + } + + baos.flush(); + + byte[] buf = baos.toByteArray(); + for (int i = 0; i < buf.length; i++) { + System.out.print(String.format("0x%1$02X", buf[i]) + ", "); + if (i % 20 == 0) { + System.out.println(); + } + } + } +} Binary files /dev/null and new/src/macosx/native/sun/osxapp/resource/icons/JavaApp.icns differ