提交 5d8bcde4 编写于 作者: L lana

Merge

...@@ -82,3 +82,7 @@ d58354a69011f3d3354765fa3167567c4c4a9612 jdk7-b101 ...@@ -82,3 +82,7 @@ d58354a69011f3d3354765fa3167567c4c4a9612 jdk7-b101
3b0abcb512807bb6f6d27755bc50103211bde6ee jdk7-b105 3b0abcb512807bb6f6d27755bc50103211bde6ee jdk7-b105
b91ef6b60f4e19bf4592c6dd594c9bac62487519 jdk7-b106 b91ef6b60f4e19bf4592c6dd594c9bac62487519 jdk7-b106
882103f334bb23745d3fd70fb7928c347478b0f4 jdk7-b107 882103f334bb23745d3fd70fb7928c347478b0f4 jdk7-b107
17a5d84b75610255a3527e8ede1da19c91ba7a7e jdk7-b108
ab0d3f54a63f2aadfcdd2e14b81f79362ce454e2 jdk7-b109
176586cd040e4dd17a5ff6e91f72df10d7442453 jdk7-b110
fb63a2688db807a73e2a3de7d9bab298f1bff0e8 jdk7-b111
...@@ -61,6 +61,7 @@ endif ...@@ -61,6 +61,7 @@ endif
# Get compiler version # Get compiler version
_CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1) _CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1)
CC_VER :=$(call GetVersion,"$(_CC_VER)") CC_VER :=$(call GetVersion,"$(_CC_VER)")
CC_MINORVER :=$(call MinorVersion,$(CC_VER))
# Name of compilers being used # Name of compilers being used
COMPILER_VERSION-5.7 = SS10 COMPILER_VERSION-5.7 = SS10
...@@ -69,8 +70,10 @@ COMPILER_VERSION-5.8 = SS11 ...@@ -69,8 +70,10 @@ COMPILER_VERSION-5.8 = SS11
COMPILER_NAME-5.8 = Sun Studio 11 COMPILER_NAME-5.8 = Sun Studio 11
COMPILER_VERSION-5.9 = SS12 COMPILER_VERSION-5.9 = SS12
COMPILER_NAME-5.9 = Sun Studio 12 COMPILER_NAME-5.9 = Sun Studio 12
COMPILER_VERSION-5.10 = SS13 COMPILER_VERSION-5.10 = SS12u1
COMPILER_NAME-5.10 = Sun Studio 13 COMPILER_NAME-5.10 = Sun Studio 12 Update 1
COMPILER_VERSION-5.11 = OSS12u2
COMPILER_NAME-5.11 = Oracle Solaris Studio 12 Update 2
COMPILER_VERSION = $(COMPILER_VERSION-$(CC_VER)) COMPILER_VERSION = $(COMPILER_VERSION-$(CC_VER))
COMPILER_NAME = $(COMPILER_NAME-$(CC_VER)) COMPILER_NAME = $(COMPILER_NAME-$(CC_VER))
...@@ -112,8 +115,8 @@ ifeq ($(ARCH_FAMILY), i586) ...@@ -112,8 +115,8 @@ ifeq ($(ARCH_FAMILY), i586)
XARCH_OPTION_OLD/64 += -xarch=amd64 XARCH_OPTION_OLD/64 += -xarch=amd64
LINT_XARCH_OPTION_OLD/64 += -Xarch=amd64 LINT_XARCH_OPTION_OLD/64 += -Xarch=amd64
endif endif
# Pick the options we want based on the compiler being used. # Pick the options we want based on the compiler being used. (5.9 or newer)
ifeq ($(shell expr $(CC_VER) \>= 5.9), 1) ifeq ($(shell expr $(CC_MINORVER) \>= 9), 1)
XARCH_OPTION/32 = $(XARCH_OPTION_NEW/32) XARCH_OPTION/32 = $(XARCH_OPTION_NEW/32)
XARCH_OPTION/64 = $(XARCH_OPTION_NEW/64) XARCH_OPTION/64 = $(XARCH_OPTION_NEW/64)
LINT_XARCH_OPTION/32 = $(LINT_XARCH_OPTION_NEW/32) LINT_XARCH_OPTION/32 = $(LINT_XARCH_OPTION_NEW/32)
......
...@@ -120,10 +120,10 @@ ifeq ($(PLATFORM), solaris) ...@@ -120,10 +120,10 @@ ifeq ($(PLATFORM), solaris)
else else
REQUIRED_FREE_SPACE = 1040000 REQUIRED_FREE_SPACE = 1040000
endif endif
REQUIRED_COMPILER_NAME = Sun Studio 12 REQUIRED_COMPILER_NAME = Sun Studio 12 Update 1
REQUIRED_COMPILER_VERSION = SS12 REQUIRED_COMPILER_VERSION = SS12u1
ifeq ($(CC_VERSION),sun) ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.9 REQUIRED_CC_VER = 5.10
endif endif
ifeq ($(CC_VERSION),gcc) ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 3.4.3 REQUIRED_CC_VER = 3.4.3
...@@ -145,7 +145,7 @@ ifeq ($(PLATFORM), linux) ...@@ -145,7 +145,7 @@ ifeq ($(PLATFORM), linux)
REQUIRED_CC_VER = 4.3.0 REQUIRED_CC_VER = 4.3.0
endif endif
ifeq ($(CC_VERSION),sun) ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.9 REQUIRED_CC_VER = 5.10
endif endif
endif endif
......
...@@ -183,10 +183,22 @@ JAVA_JAVA_java = \ ...@@ -183,10 +183,22 @@ JAVA_JAVA_java = \
java/util/MissingFormatWidthException.java \ java/util/MissingFormatWidthException.java \
java/util/UnknownFormatConversionException.java \ java/util/UnknownFormatConversionException.java \
java/util/UnknownFormatFlagsException.java \ java/util/UnknownFormatFlagsException.java \
java/util/IllformedLocaleException.java \
java/util/FormatterClosedException.java \ java/util/FormatterClosedException.java \
java/util/ListResourceBundle.java \ java/util/ListResourceBundle.java \
sun/util/EmptyListResourceBundle.java \ sun/util/EmptyListResourceBundle.java \
java/util/Locale.java \ java/util/Locale.java \
sun/util/locale/AsciiUtil.java \
sun/util/locale/BaseLocale.java \
sun/util/locale/Extension.java \
sun/util/locale/InternalLocaleBuilder.java \
sun/util/locale/LanguageTag.java \
sun/util/locale/LocaleExtensions.java \
sun/util/locale/LocaleObjectCache.java \
sun/util/locale/LocaleSyntaxException.java \
sun/util/locale/ParseStatus.java \
sun/util/locale/StringTokenIterator.java \
sun/util/locale/UnicodeLocaleExtension.java \
java/util/LocaleISOData.java \ java/util/LocaleISOData.java \
sun/util/LocaleServiceProviderPool.java \ sun/util/LocaleServiceProviderPool.java \
sun/util/LocaleDataMetaInfo.java \ sun/util/LocaleDataMetaInfo.java \
......
...@@ -43,6 +43,7 @@ SERVER_LOCATION = server ...@@ -43,6 +43,7 @@ SERVER_LOCATION = server
CLIENT_LOCATION = client CLIENT_LOCATION = client
DB_SUFFIX = _db DB_SUFFIX = _db
DTRACE_SUFFIX = _dtrace
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
LIB_LOCATION = $(BINDIR) LIB_LOCATION = $(BINDIR)
...@@ -56,6 +57,7 @@ JVMMAP_NAME = $(LIB_PREFIX)jvm.map ...@@ -56,6 +57,7 @@ JVMMAP_NAME = $(LIB_PREFIX)jvm.map
JVMPDB_NAME = $(LIB_PREFIX)jvm.pdb JVMPDB_NAME = $(LIB_PREFIX)jvm.pdb
LIBJSIG_NAME = $(LIB_PREFIX)jsig.$(LIBRARY_SUFFIX) LIBJSIG_NAME = $(LIB_PREFIX)jsig.$(LIBRARY_SUFFIX)
JVMDB_NAME = $(LIB_PREFIX)jvm$(DB_SUFFIX).$(LIBRARY_SUFFIX) JVMDB_NAME = $(LIB_PREFIX)jvm$(DB_SUFFIX).$(LIBRARY_SUFFIX)
JVMDTRACE_NAME = $(LIB_PREFIX)jvm$(DTRACE_SUFFIX).$(LIBRARY_SUFFIX)
CLASSSHARINGDATA_DIR = $(BUILDDIR)/tools/sharing CLASSSHARINGDATA_DIR = $(BUILDDIR)/tools/sharing
...@@ -161,6 +163,12 @@ IMPORT_LIST += \ ...@@ -161,6 +163,12 @@ IMPORT_LIST += \
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME) IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME)
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/$(JVMDB_NAME) not found!)
endif
endif endif
ifneq ($(ZERO_BUILD), true) ifneq ($(ZERO_BUILD), true)
...@@ -171,14 +179,29 @@ IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME) ...@@ -171,14 +179,29 @@ IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(LIBJSIG_NAME)
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
# solaris vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv solaris # solaris vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv solaris
ifeq ($(ARCH), sparc)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
endif
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME) IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDB_NAME)
ifeq ($(ARCH), sparc) # The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME) IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDB_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME) not found!)
endif
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) not found!)
endif
# The conditional can be removed when import JDKs contain these files.
ifneq ($(wildcard $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)),)
IMPORT_LIST += $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME)
else
$(warning WARNING: $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME) not found!)
endif endif
# For backwards compatability, make a link of the 32-bit client JVM to $(LIBDIR) # For backwards compatability, make a link of the 32-bit client JVM to $(LIBDIR)
...@@ -224,6 +247,18 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB ...@@ -224,6 +247,18 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDB
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME) $(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDB_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDB_NAME)
$(install-import-file) $(install-import-file)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(CLIENT_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_CLIENT_PATH)/64/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(SERVER_LOCATION)/64/$(JVMDTRACE_NAME): $(HOTSPOT_SERVER_PATH)/64/$(JVMDTRACE_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAME) $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVM_NAME): $(HOTSPOT_SERVER_PATH)/$(JVM_NAME)
$(install-import-file) $(install-import-file)
......
# #
# Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -29,6 +29,7 @@ FILES_java = \ ...@@ -29,6 +29,7 @@ FILES_java = \
java/text/AttributedString.java \ java/text/AttributedString.java \
java/text/BreakDictionary.java \ java/text/BreakDictionary.java \
java/text/BreakIterator.java \ java/text/BreakIterator.java \
java/text/CalendarBuilder.java \
java/text/CharacterIterator.java \ java/text/CharacterIterator.java \
java/text/CharacterIteratorFieldDelegate.java \ java/text/CharacterIteratorFieldDelegate.java \
java/text/ChoiceFormat.java \ java/text/ChoiceFormat.java \
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
FILES_c = \ FILES_c = \
cmscam02.c \ cmscam02.c \
cmscam97.c \
cmscgats.c \ cmscgats.c \
cmscnvrt.c \ cmscnvrt.c \
cmserr.c \ cmserr.c \
...@@ -35,13 +34,17 @@ FILES_c = \ ...@@ -35,13 +34,17 @@ FILES_c = \
cmsio0.c \ cmsio0.c \
cmsio1.c \ cmsio1.c \
cmslut.c \ cmslut.c \
cmsmatsh.c \ cmsmd5.c \
cmsmtrx.c \ cmsmtrx.c \
cmsnamed.c \ cmsnamed.c \
cmsopt.c \
cmspack.c \ cmspack.c \
cmspcs.c \ cmspcs.c \
cmsplugin.c \
cmsps2.c \ cmsps2.c \
cmssamp.c \ cmssamp.c \
cmssm.c \
cmstypes.c \
cmsvirt.c \ cmsvirt.c \
cmswtpnt.c \ cmswtpnt.c \
cmsxform.c \ cmsxform.c \
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
FILES_c = \ FILES_c = \
cmscam02.c \ cmscam02.c \
cmscam97.c \
cmscgats.c \ cmscgats.c \
cmscnvrt.c \ cmscnvrt.c \
cmserr.c \ cmserr.c \
...@@ -35,13 +34,17 @@ FILES_c = \ ...@@ -35,13 +34,17 @@ FILES_c = \
cmsio0.c \ cmsio0.c \
cmsio1.c \ cmsio1.c \
cmslut.c \ cmslut.c \
cmsmatsh.c \ cmsmd5.c \
cmsmtrx.c \ cmsmtrx.c \
cmsnamed.c \ cmsnamed.c \
cmsopt.c \
cmspack.c \ cmspack.c \
cmspcs.c \ cmspcs.c \
cmsplugin.c \
cmsps2.c \ cmsps2.c \
cmssamp.c \ cmssamp.c \
cmssm.c \
cmstypes.c \
cmsvirt.c \ cmsvirt.c \
cmswtpnt.c \ cmswtpnt.c \
cmsxform.c \ cmsxform.c \
......
...@@ -80,8 +80,8 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR) ...@@ -80,8 +80,8 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR)
vpath %.c $(SHARE_SRC)/native/sun/java2d vpath %.c $(SHARE_SRC)/native/sun/java2d
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
OTHER_CFLAGS += -DCMS_IS_WINDOWS_ -Dsqrtf=sqrt
OTHER_LDLIBS = user32.lib version.lib $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib
OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \ OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \
-I$(SHARE_SRC)/native/sun/awt/debug -I$(SHARE_SRC)/native/sun/awt/debug
......
...@@ -17,6 +17,6 @@ You should have received a copy of the GNU General Public License version ...@@ -17,6 +17,6 @@ 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, 2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
CA 95054 USA or visit www.sun.com if you need additional information or or visit www.oracle.com if you need additional information or have any
have any questions. questions.
...@@ -15,6 +15,6 @@ You should have received a copy of the GNU General Public License version ...@@ -15,6 +15,6 @@ 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, 2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
CA 95054 USA or visit www.sun.com if you need additional information or or visit www.oracle.com if you need additional information or have any
have any questions. questions.
/* /*
* Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,13 +31,14 @@ import java.util.Collections; ...@@ -31,13 +31,14 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.applet.Applet;
import java.awt.AWTEvent; import java.awt.AWTEvent;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.Window;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.RepaintManager; import javax.swing.RepaintManager;
import javax.swing.SwingUtilities;
/** /**
* A collection of utility methods for Swing. * A collection of utility methods for Swing.
...@@ -91,7 +92,7 @@ public class SwingUtilities3 { ...@@ -91,7 +92,7 @@ public class SwingUtilities3 {
*/ */
public static void setVsyncRequested(Container rootContainer, public static void setVsyncRequested(Container rootContainer,
boolean isRequested) { boolean isRequested) {
assert SwingUtilities.getRoot(rootContainer) == rootContainer; assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
if (isRequested) { if (isRequested) {
vsyncedMap.put(rootContainer, Boolean.TRUE); vsyncedMap.put(rootContainer, Boolean.TRUE);
} else { } else {
...@@ -106,7 +107,7 @@ public class SwingUtilities3 { ...@@ -106,7 +107,7 @@ public class SwingUtilities3 {
* @return {@code true} if vsync painting is requested for {@code rootContainer} * @return {@code true} if vsync painting is requested for {@code rootContainer}
*/ */
public static boolean isVsyncRequested(Container rootContainer) { public static boolean isVsyncRequested(Container rootContainer) {
assert SwingUtilities.getRoot(rootContainer) == rootContainer; assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
return Boolean.TRUE == vsyncedMap.get(rootContainer); return Boolean.TRUE == vsyncedMap.get(rootContainer);
} }
......
/* /*
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -399,7 +399,7 @@ class GTKPainter extends SynthPainter { ...@@ -399,7 +399,7 @@ class GTKPainter extends SynthPainter {
} }
String detail = "arrow"; String detail = "arrow";
if (name == "ScrollBar.button") { if ((name == "ScrollBar.button") || (name == "TabbedPane.button")) {
if (arrowType == ArrowType.UP || arrowType == ArrowType.DOWN) { if (arrowType == ArrowType.UP || arrowType == ArrowType.DOWN) {
detail = "vscrollbar"; detail = "vscrollbar";
} else { } else {
...@@ -409,7 +409,7 @@ class GTKPainter extends SynthPainter { ...@@ -409,7 +409,7 @@ class GTKPainter extends SynthPainter {
name == "Spinner.previousButton") { name == "Spinner.previousButton") {
detail = "spinbutton"; detail = "spinbutton";
} else if (name != "ComboBox.arrowButton") { } else if (name != "ComboBox.arrowButton") {
assert false; assert false : "unexpected name: " + name;
} }
int gtkState = GTKLookAndFeel.synthStateToGTKState( int gtkState = GTKLookAndFeel.synthStateToGTKState(
...@@ -436,7 +436,7 @@ class GTKPainter extends SynthPainter { ...@@ -436,7 +436,7 @@ class GTKPainter extends SynthPainter {
String name = button.getName(); String name = button.getName();
String detail = "button"; String detail = "button";
int direction = SwingConstants.CENTER; int direction = SwingConstants.CENTER;
if (name == "ScrollBar.button") { if ((name == "ScrollBar.button") || (name == "TabbedPane.button")) {
Integer prop = (Integer) Integer prop = (Integer)
button.getClientProperty("__arrow_direction__"); button.getClientProperty("__arrow_direction__");
direction = (prop != null) ? direction = (prop != null) ?
...@@ -457,7 +457,7 @@ class GTKPainter extends SynthPainter { ...@@ -457,7 +457,7 @@ class GTKPainter extends SynthPainter {
} else if (name == "Spinner.nextButton") { } else if (name == "Spinner.nextButton") {
detail = "spinbutton_up"; detail = "spinbutton_up";
} else if (name != "ComboBox.arrowButton") { } else if (name != "ComboBox.arrowButton") {
assert false; assert false : "unexpected name: " + name;
} }
int state = context.getComponentState(); int state = context.getComponentState();
......
...@@ -150,11 +150,6 @@ class PangoFonts { ...@@ -150,11 +150,6 @@ class PangoFonts {
* case for it to be a problem the values would have to be different. * case for it to be a problem the values would have to be different.
* It also seems unlikely to arise except when a user explicitly * It also seems unlikely to arise except when a user explicitly
* deletes the X resource database entry. * deletes the X resource database entry.
* 3) Because of rounding errors sizes may differ very slightly
* between JDK and GTK. To fix that would at the very least require
* Swing to specify floating pt font sizes.
* Eg "10 pts" for GTK at 96 dpi to get the same size at Java 2D's
* 72 dpi you'd need to specify exactly 13.33.
* There also some other issues to be aware of for the future: * There also some other issues to be aware of for the future:
* GTK specifies the Xft.dpi value as server-wide which when used * GTK specifies the Xft.dpi value as server-wide which when used
* on systems with 2 distinct X screens with different physical DPI * on systems with 2 distinct X screens with different physical DPI
...@@ -197,11 +192,16 @@ class PangoFonts { ...@@ -197,11 +192,16 @@ class PangoFonts {
String fcFamilyLC = family.toLowerCase(); String fcFamilyLC = family.toLowerCase();
if (FontUtilities.mapFcName(fcFamilyLC) != null) { if (FontUtilities.mapFcName(fcFamilyLC) != null) {
/* family is a Fc/Pango logical font which we need to expand. */ /* family is a Fc/Pango logical font which we need to expand. */
return FontUtilities.getFontConfigFUIR(fcFamilyLC, style, size); Font font = FontUtilities.getFontConfigFUIR(fcFamilyLC, style, size);
font = font.deriveFont(style, (float)dsize);
return new FontUIResource(font);
} else { } else {
/* It's a physical font which we will create with a fallback */ /* It's a physical font which we will create with a fallback */
Font font = new FontUIResource(family, style, size); Font font = new Font(family, style, size);
return FontUtilities.getCompositeFontUIResource(font); /* a roundabout way to set the font size in floating points */
font = font.deriveFont(style, (float)dsize);
FontUIResource fuir = new FontUIResource(font);
return FontUtilities.getCompositeFontUIResource(fuir);
} }
} }
......
/* /*
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,8 +40,6 @@ import java.awt.Insets; ...@@ -40,8 +40,6 @@ import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.io.Serializable;
/** /**
* Factory object that can vend Icons appropriate for the basic L & F. * Factory object that can vend Icons appropriate for the basic L & F.
* <p> * <p>
...@@ -99,7 +97,7 @@ public class MotifBorders { ...@@ -99,7 +97,7 @@ public class MotifBorders {
} }
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
if (((JComponent)c).hasFocus()) { if (c.hasFocus()) {
g.setColor(focus); g.setColor(focus);
g.drawRect(x, y, w-1, h-1); g.drawRect(x, y, w-1, h-1);
} else { } else {
...@@ -233,6 +231,9 @@ public class MotifBorders { ...@@ -233,6 +231,9 @@ public class MotifBorders {
} }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if (!(c instanceof JMenuBar)) {
return;
}
JMenuBar menuBar = (JMenuBar)c; JMenuBar menuBar = (JMenuBar)c;
if (menuBar.isBorderPainted() == true) { if (menuBar.isBorderPainted() == true) {
// this draws the MenuBar border // this draws the MenuBar border
...@@ -658,6 +659,9 @@ public class MotifBorders { ...@@ -658,6 +659,9 @@ public class MotifBorders {
* @param height the height of the painted border * @param height the height of the painted border
*/ */
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if (!(c instanceof JPopupMenu)) {
return;
}
Font origFont = g.getFont(); Font origFont = g.getFont();
Color origColor = g.getColor(); Color origColor = g.getColor();
...@@ -701,6 +705,9 @@ public class MotifBorders { ...@@ -701,6 +705,9 @@ public class MotifBorders {
* @param insets the object to be reinitialized * @param insets the object to be reinitialized
*/ */
public Insets getBorderInsets(Component c, Insets insets) { public Insets getBorderInsets(Component c, Insets insets) {
if (!(c instanceof JPopupMenu)) {
return insets;
}
FontMetrics fm; FontMetrics fm;
int descent = 0; int descent = 0;
int ascent = 16; int ascent = 16;
......
/* /*
* Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -32,12 +32,8 @@ import javax.swing.plaf.basic.*; ...@@ -32,12 +32,8 @@ import javax.swing.plaf.basic.*;
import java.awt.Component; import java.awt.Component;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics; import java.awt.Graphics;
import java.io.Serializable;
import static com.sun.java.swing.plaf.windows.TMSchema.*; import static com.sun.java.swing.plaf.windows.TMSchema.*;
import static com.sun.java.swing.plaf.windows.XPStyle.Skin; import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
...@@ -159,6 +155,9 @@ public class WindowsBorders { ...@@ -159,6 +155,9 @@ public class WindowsBorders {
public void paintBorder(Component c, Graphics g, int x, int y, public void paintBorder(Component c, Graphics g, int x, int y,
int width, int height) { int width, int height) {
if (!(c instanceof JToolBar)) {
return;
}
g.translate(x, y); g.translate(x, y);
XPStyle xp = XPStyle.getXP(); XPStyle xp = XPStyle.getXP();
...@@ -190,33 +189,33 @@ public class WindowsBorders { ...@@ -190,33 +189,33 @@ public class WindowsBorders {
} else { } else {
if (!vertical) { if (!vertical) {
if (c.getComponentOrientation().isLeftToRight()) { if (c.getComponentOrientation().isLeftToRight()) {
g.setColor(shadow);
g.drawLine(4, 3, 4, height - 4);
g.drawLine(4, height - 4, 2, height - 4);
g.setColor(highlight);
g.drawLine(2, 3, 3, 3);
g.drawLine(2, 3, 2, height - 5);
} else {
g.setColor(shadow);
g.drawLine(width - 3, 3, width - 3, height - 4);
g.drawLine(width - 4, height - 4, width - 4, height - 4);
g.setColor(highlight);
g.drawLine(width - 5, 3, width - 4, 3);
g.drawLine(width - 5, 3, width - 5, height - 5);
}
} else { // Vertical
g.setColor(shadow); g.setColor(shadow);
g.drawLine(4, 3, 4, height - 4); g.drawLine(3, 4, width - 4, 4);
g.drawLine(4, height - 4, 2, height - 4); g.drawLine(width - 4, 2, width - 4, 4);
g.setColor(highlight); g.setColor(highlight);
g.drawLine(2, 3, 3, 3); g.drawLine(3, 2, width - 4, 2);
g.drawLine(2, 3, 2, height - 5); g.drawLine(3, 2, 3, 3);
} else {
g.setColor(shadow);
g.drawLine(width - 3, 3, width - 3, height - 4);
g.drawLine(width - 4, height - 4, width - 4, height - 4);
g.setColor(highlight);
g.drawLine(width - 5, 3, width - 4, 3);
g.drawLine(width - 5, 3, width - 5, height - 5);
} }
} else { // Vertical
g.setColor(shadow);
g.drawLine(3, 4, width - 4, 4);
g.drawLine(width - 4, 2, width - 4, 4);
g.setColor(highlight);
g.drawLine(3, 2, width - 4, 2);
g.drawLine(3, 2, 3, 3);
}
} }
} }
...@@ -225,6 +224,9 @@ public class WindowsBorders { ...@@ -225,6 +224,9 @@ public class WindowsBorders {
public Insets getBorderInsets(Component c, Insets insets) { public Insets getBorderInsets(Component c, Insets insets) {
insets.set(1,1,1,1); insets.set(1,1,1,1);
if (!(c instanceof JToolBar)) {
return insets;
}
if (((JToolBar)c).isFloatable()) { if (((JToolBar)c).isFloatable()) {
int gripInset = (XPStyle.getXP() != null) ? 12 : 9; int gripInset = (XPStyle.getXP() != null) ? 12 : 9;
if (((JToolBar)c).getOrientation() == HORIZONTAL) { if (((JToolBar)c).getOrientation() == HORIZONTAL) {
......
...@@ -474,7 +474,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice ...@@ -474,7 +474,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
This is necessary for Receivers retrieved via MidiSystem.getReceiver() This is necessary for Receivers retrieved via MidiSystem.getReceiver()
(which opens the device implicitely). (which opens the device implicitely).
*/ */
protected abstract class AbstractReceiver implements Receiver { protected abstract class AbstractReceiver implements MidiDeviceReceiver {
private boolean open = true; private boolean open = true;
...@@ -508,6 +508,10 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice ...@@ -508,6 +508,10 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
AbstractMidiDevice.this.closeInternal(this); AbstractMidiDevice.this.closeInternal(this);
} }
public MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
protected boolean isOpen() { protected boolean isOpen() {
return open; return open;
} }
...@@ -529,7 +533,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice ...@@ -529,7 +533,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
* Also, it has some optimizations regarding sending to the Receivers, * Also, it has some optimizations regarding sending to the Receivers,
* for known Receivers, and managing itself in the TransmitterList. * for known Receivers, and managing itself in the TransmitterList.
*/ */
protected class BasicTransmitter implements Transmitter { protected class BasicTransmitter implements MidiDeviceTransmitter {
private Receiver receiver = null; private Receiver receiver = null;
TransmitterList tlist = null; TransmitterList tlist = null;
...@@ -568,6 +572,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice ...@@ -568,6 +572,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
} }
} }
public MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
} // class BasicTransmitter } // class BasicTransmitter
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -40,8 +40,6 @@ import javax.sound.sampled.AudioFormat.Encoding; ...@@ -40,8 +40,6 @@ import javax.sound.sampled.AudioFormat.Encoding;
*/ */
public abstract class AudioFloatConverter { public abstract class AudioFloatConverter {
public static final Encoding PCM_FLOAT = new Encoding("PCM_FLOAT");
/*************************************************************************** /***************************************************************************
* *
* LSB Filter, used filter least significant byte in samples arrays. * LSB Filter, used filter least significant byte in samples arrays.
...@@ -982,7 +980,7 @@ public abstract class AudioFloatConverter { ...@@ -982,7 +980,7 @@ public abstract class AudioFloatConverter {
format.getSampleSizeInBits() + 7) / 8) - 4); format.getSampleSizeInBits() + 7) / 8) - 4);
} }
} }
} else if (format.getEncoding().equals(PCM_FLOAT)) { } else if (format.getEncoding().equals(Encoding.PCM_FLOAT)) {
if (format.getSampleSizeInBits() == 32) { if (format.getSampleSizeInBits() == 32) {
if (format.isBigEndian()) if (format.isBigEndian())
conv = new AudioFloatConversion32B(); conv = new AudioFloatConversion32B();
......
/* /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -175,7 +175,6 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -175,7 +175,6 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
for (int c = 0; c < targetChannels; c++) { for (int c = 0; c < targetChannels; c++) {
for (int i = 0, ix = off + c; i < len2; i++, ix += cs) { for (int i = 0, ix = off + c; i < len2; i++, ix += cs) {
b[ix] = conversion_buffer[i]; b[ix] = conversion_buffer[i];
;
} }
} }
} else if (targetChannels == 1) { } else if (targetChannels == 1) {
...@@ -186,7 +185,6 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -186,7 +185,6 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
for (int c = 1; c < sourceChannels; c++) { for (int c = 1; c < sourceChannels; c++) {
for (int i = c, ix = off; i < len2; i += cs, ix++) { for (int i = c, ix = off; i < len2; i += cs, ix++) {
b[ix] += conversion_buffer[i]; b[ix] += conversion_buffer[i];
;
} }
} }
float vol = 1f / ((float) sourceChannels); float vol = 1f / ((float) sourceChannels);
...@@ -390,6 +388,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -390,6 +388,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
return -1; return -1;
if (len < 0) if (len < 0)
return 0; return 0;
int offlen = off + len;
int remain = len / nrofchannels; int remain = len / nrofchannels;
int destPos = 0; int destPos = 0;
int in_end = ibuffer_len; int in_end = ibuffer_len;
...@@ -423,7 +422,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -423,7 +422,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
for (int c = 0; c < nrofchannels; c++) { for (int c = 0; c < nrofchannels; c++) {
int ix = 0; int ix = 0;
float[] buff = cbuffer[c]; float[] buff = cbuffer[c];
for (int i = c; i < b.length; i += nrofchannels) { for (int i = c + off; i < offlen; i += nrofchannels) {
b[i] = buff[ix++]; b[i] = buff[ix++];
} }
} }
...@@ -447,7 +446,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -447,7 +446,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
} }
public long skip(long len) throws IOException { public long skip(long len) throws IOException {
if (len > 0) if (len < 0)
return 0; return 0;
if (skipbuffer == null) if (skipbuffer == null)
skipbuffer = new float[1024 * targetFormat.getFrameSize()]; skipbuffer = new float[1024 * targetFormat.getFrameSize()];
...@@ -470,7 +469,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -470,7 +469,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
} }
private Encoding[] formats = { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, private Encoding[] formats = { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
AudioFloatConverter.PCM_FLOAT }; Encoding.PCM_FLOAT };
public AudioInputStream getAudioInputStream(Encoding targetEncoding, public AudioInputStream getAudioInputStream(Encoding targetEncoding,
AudioInputStream sourceStream) { AudioInputStream sourceStream) {
...@@ -482,7 +481,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -482,7 +481,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
float samplerate = format.getSampleRate(); float samplerate = format.getSampleRate();
int bits = format.getSampleSizeInBits(); int bits = format.getSampleSizeInBits();
boolean bigendian = format.isBigEndian(); boolean bigendian = format.isBigEndian();
if (targetEncoding.equals(AudioFloatConverter.PCM_FLOAT)) if (targetEncoding.equals(Encoding.PCM_FLOAT))
bits = 32; bits = 32;
AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits, AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits,
channels, channels * bits / 8, samplerate, bigendian); channels, channels * bits / 8, samplerate, bigendian);
...@@ -521,19 +520,19 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -521,19 +520,19 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
public Encoding[] getSourceEncodings() { public Encoding[] getSourceEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
AudioFloatConverter.PCM_FLOAT }; Encoding.PCM_FLOAT };
} }
public Encoding[] getTargetEncodings() { public Encoding[] getTargetEncodings() {
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
AudioFloatConverter.PCM_FLOAT }; Encoding.PCM_FLOAT };
} }
public Encoding[] getTargetEncodings(AudioFormat sourceFormat) { public Encoding[] getTargetEncodings(AudioFormat sourceFormat) {
if (AudioFloatConverter.getConverter(sourceFormat) == null) if (AudioFloatConverter.getConverter(sourceFormat) == null)
return new Encoding[0]; return new Encoding[0];
return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
AudioFloatConverter.PCM_FLOAT }; Encoding.PCM_FLOAT };
} }
public AudioFormat[] getTargetFormats(Encoding targetEncoding, public AudioFormat[] getTargetFormats(Encoding targetEncoding,
...@@ -572,17 +571,17 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { ...@@ -572,17 +571,17 @@ public class AudioFloatFormatConverter extends FormatConversionProvider {
} }
} }
if (targetEncoding.equals(AudioFloatConverter.PCM_FLOAT)) { if (targetEncoding.equals(Encoding.PCM_FLOAT)) {
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, false)); AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, true)); AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, false)); AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, true)); AudioSystem.NOT_SPECIFIED, true));
} }
......
...@@ -42,11 +42,14 @@ public class AudioSynthesizerPropertyInfo { ...@@ -42,11 +42,14 @@ public class AudioSynthesizerPropertyInfo {
*/ */
public AudioSynthesizerPropertyInfo(String name, Object value) { public AudioSynthesizerPropertyInfo(String name, Object value) {
this.name = name; this.name = name;
this.value = value;
if (value instanceof Class) if (value instanceof Class)
valueClass = (Class)value; valueClass = (Class)value;
else if (value != null) else
valueClass = value.getClass(); {
this.value = value;
if (value != null)
valueClass = value.getClass();
}
} }
/** /**
* The name of the property. * The name of the property.
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -781,7 +781,7 @@ public class DLSSoundbank implements Soundbank { ...@@ -781,7 +781,7 @@ public class DLSSoundbank implements Soundbank {
} }
if (sampleformat == 3) { if (sampleformat == 3) {
audioformat = new AudioFormat( audioformat = new AudioFormat(
AudioFloatConverter.PCM_FLOAT, samplerate, bits, Encoding.PCM_FLOAT, samplerate, bits,
channels, framesize, samplerate, false); channels, framesize, samplerate, false);
} }
...@@ -965,7 +965,7 @@ public class DLSSoundbank implements Soundbank { ...@@ -965,7 +965,7 @@ public class DLSSoundbank implements Soundbank {
sampleformat = 1; sampleformat = 1;
else if (audioformat.getEncoding().equals(Encoding.PCM_SIGNED)) else if (audioformat.getEncoding().equals(Encoding.PCM_SIGNED))
sampleformat = 1; sampleformat = 1;
else if (audioformat.getEncoding().equals(AudioFloatConverter.PCM_FLOAT)) else if (audioformat.getEncoding().equals(Encoding.PCM_FLOAT))
sampleformat = 3; sampleformat = 3;
fmt_chunk.writeUnsignedShort(sampleformat); fmt_chunk.writeUnsignedShort(sampleformat);
......
/*
* Copyright (c) 2010, 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 com.sun.media.sound;
import javax.sound.midi.*;
/**
* Helper class which allows to convert {@code Receiver}
* to {@code MidiDeviceReceiver}.
*
* @author Alex Menkov
*/
public class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver {
private final MidiDevice device;
private final Receiver receiver;
/**
* Creates a new {@code MidiDeviceReceiverEnvelope} object which
* envelops the specified {@code Receiver}
* and is owned by the specified {@code MidiDevice}.
*
* @param device the owner {@code MidiDevice}
* @param receiver the {@code Receiver} to be enveloped
*/
public MidiDeviceReceiverEnvelope(MidiDevice device, Receiver receiver) {
if (device == null || receiver == null) {
throw new NullPointerException();
}
this.device = device;
this.receiver = receiver;
}
// Receiver implementation
public void close() {
receiver.close();
}
public void send(MidiMessage message, long timeStamp) {
receiver.send(message, timeStamp);
}
// MidiDeviceReceiver implementation
public MidiDevice getMidiDevice() {
return device;
}
/**
* Obtains the receiver enveloped
* by this {@code MidiDeviceReceiverEnvelope} object.
*
* @return the enveloped receiver
*/
public Receiver getReceiver() {
return receiver;
}
}
/*
* Copyright (c) 2010, 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 com.sun.media.sound;
import javax.sound.midi.*;
/**
* Helper class which allows to convert {@code Transmitter}
* to {@code MidiDeviceTransmitter}.
*
* @author Alex Menkov
*/
public class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter {
private final MidiDevice device;
private final Transmitter transmitter;
/**
* Creates a new {@code MidiDeviceTransmitterEnvelope} object which
* envelops the specified {@code Transmitter}
* and is owned by the specified {@code MidiDevice}.
*
* @param device the owner {@code MidiDevice}
* @param transmitter the {@code Transmitter} to be enveloped
*/
public MidiDeviceTransmitterEnvelope(MidiDevice device, Transmitter transmitter) {
if (device == null || transmitter == null) {
throw new NullPointerException();
}
this.device = device;
this.transmitter = transmitter;
}
// Transmitter implementation
public void setReceiver(Receiver receiver) {
transmitter.setReceiver(receiver);
}
public Receiver getReceiver() {
return transmitter.getReceiver();
}
public void close() {
transmitter.close();
}
// MidiDeviceReceiver implementation
public MidiDevice getMidiDevice() {
return device;
}
/**
* Obtains the transmitter enveloped
* by this {@code MidiDeviceTransmitterEnvelope} object.
*
* @return the enveloped transmitter
*/
public Transmitter getTransmitter() {
return transmitter;
}
}
...@@ -205,7 +205,8 @@ public class ModelByteBufferWavetable implements ModelWavetable { ...@@ -205,7 +205,8 @@ public class ModelByteBufferWavetable implements ModelWavetable {
} }
if (buffer.array() == null) { if (buffer.array() == null) {
return AudioFloatInputStream.getInputStream(new AudioInputStream( return AudioFloatInputStream.getInputStream(new AudioInputStream(
buffer.getInputStream(), format, buffer.capacity())); buffer.getInputStream(), format,
buffer.capacity() / format.getFrameSize()));
} }
if (buffer8 != null) { if (buffer8 != null) {
if (format.getEncoding().equals(Encoding.PCM_SIGNED) if (format.getEncoding().equals(Encoding.PCM_SIGNED)
......
...@@ -56,7 +56,7 @@ public abstract class ModelInstrument extends Instrument { ...@@ -56,7 +56,7 @@ public abstract class ModelInstrument extends Instrument {
public ModelDirector getDirector(ModelPerformer[] performers, public ModelDirector getDirector(ModelPerformer[] performers,
MidiChannel channel, ModelDirectedPlayer player) { MidiChannel channel, ModelDirectedPlayer player) {
return new ModelStandardDirector(performers, player); return new ModelStandardIndexedDirector(performers, player);
} }
public ModelPerformer[] getPerformers() { public ModelPerformer[] getPerformers() {
......
/*
* Copyright (c) 2010, 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 com.sun.media.sound;
/**
* A standard indexed director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties.
*
* @author Karl Helgason
*/
public class ModelStandardIndexedDirector implements ModelDirector {
ModelPerformer[] performers;
ModelDirectedPlayer player;
boolean noteOnUsed = false;
boolean noteOffUsed = false;
// Variables needed for index
byte[][] trantables;
int[] counters;
int[][] mat;
public ModelStandardIndexedDirector(ModelPerformer[] performers,
ModelDirectedPlayer player) {
this.performers = performers;
this.player = player;
for (int i = 0; i < performers.length; i++) {
ModelPerformer p = performers[i];
if (p.isReleaseTriggered()) {
noteOffUsed = true;
} else {
noteOnUsed = true;
}
}
buildindex();
}
private int[] lookupIndex(int x, int y) {
if ((x >= 0) && (x < 128) && (y >= 0) && (y < 128)) {
int xt = trantables[0][x];
int yt = trantables[1][y];
if (xt != -1 && yt != -1) {
return mat[xt + yt * counters[0]];
}
}
return null;
}
private int restrict(int value) {
if(value < 0) return 0;
if(value > 127) return 127;
return value;
}
private void buildindex() {
trantables = new byte[2][129];
counters = new int[trantables.length];
for (ModelPerformer performer : performers) {
int keyFrom = performer.getKeyFrom();
int keyTo = performer.getKeyTo();
int velFrom = performer.getVelFrom();
int velTo = performer.getVelTo();
if (keyFrom > keyTo) continue;
if (velFrom > velTo) continue;
keyFrom = restrict(keyFrom);
keyTo = restrict(keyTo);
velFrom = restrict(velFrom);
velTo = restrict(velTo);
trantables[0][keyFrom] = 1;
trantables[0][keyTo + 1] = 1;
trantables[1][velFrom] = 1;
trantables[1][velTo + 1] = 1;
}
for (int d = 0; d < trantables.length; d++) {
byte[] trantable = trantables[d];
int transize = trantable.length;
for (int i = transize - 1; i >= 0; i--) {
if (trantable[i] == 1) {
trantable[i] = -1;
break;
}
trantable[i] = -1;
}
int counter = -1;
for (int i = 0; i < transize; i++) {
if (trantable[i] != 0) {
counter++;
if (trantable[i] == -1)
break;
}
trantable[i] = (byte) counter;
}
counters[d] = counter;
}
mat = new int[counters[0] * counters[1]][];
int ix = 0;
for (ModelPerformer performer : performers) {
int keyFrom = performer.getKeyFrom();
int keyTo = performer.getKeyTo();
int velFrom = performer.getVelFrom();
int velTo = performer.getVelTo();
if (keyFrom > keyTo) continue;
if (velFrom > velTo) continue;
keyFrom = restrict(keyFrom);
keyTo = restrict(keyTo);
velFrom = restrict(velFrom);
velTo = restrict(velTo);
int x_from = trantables[0][keyFrom];
int x_to = trantables[0][keyTo + 1];
int y_from = trantables[1][velFrom];
int y_to = trantables[1][velTo + 1];
if (x_to == -1)
x_to = counters[0];
if (y_to == -1)
y_to = counters[1];
for (int y = y_from; y < y_to; y++) {
int i = x_from + y * counters[0];
for (int x = x_from; x < x_to; x++) {
int[] mprev = mat[i];
if (mprev == null) {
mat[i] = new int[] { ix };
} else {
int[] mnew = new int[mprev.length + 1];
mnew[mnew.length - 1] = ix;
for (int k = 0; k < mprev.length; k++)
mnew[k] = mprev[k];
mat[i] = mnew;
}
i++;
}
}
ix++;
}
}
public void close() {
}
public void noteOff(int noteNumber, int velocity) {
if (!noteOffUsed)
return;
int[] plist = lookupIndex(noteNumber, velocity);
if(plist == null) return;
for (int i : plist) {
ModelPerformer p = performers[i];
if (p.isReleaseTriggered()) {
player.play(i, null);
}
}
}
public void noteOn(int noteNumber, int velocity) {
if (!noteOnUsed)
return;
int[] plist = lookupIndex(noteNumber, velocity);
if(plist == null) return;
for (int i : plist) {
ModelPerformer p = performers[i];
if (!p.isReleaseTriggered()) {
player.play(i, null);
}
}
}
}
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -116,7 +116,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { ...@@ -116,7 +116,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
protected int tuning_program = 0; protected int tuning_program = 0;
protected SoftInstrument current_instrument = null; protected SoftInstrument current_instrument = null;
protected ModelChannelMixer current_mixer = null; protected ModelChannelMixer current_mixer = null;
private ModelDirector current_director = null; protected ModelDirector current_director = null;
// Controller Destination Settings // Controller Destination Settings
protected int cds_control_number = -1; protected int cds_control_number = -1;
...@@ -1264,13 +1264,16 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { ...@@ -1264,13 +1264,16 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
} }
public void programChange(int bank, int program) { public void programChange(int bank, int program) {
bank = restrict7Bit(bank); bank = restrict14Bit(bank);
program = restrict7Bit(program); program = restrict7Bit(program);
synchronized (control_mutex) { synchronized (control_mutex) {
mainmixer.activity(); mainmixer.activity();
this.bank = bank; if(this.bank != bank || this.program != program)
this.program = program; {
current_instrument = null; this.bank = bank;
this.program = program;
current_instrument = null;
}
} }
} }
......
/* /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -118,16 +118,16 @@ public class SoftMixingMixer implements Mixer { ...@@ -118,16 +118,16 @@ public class SoftMixingMixer implements Mixer {
AudioSystem.NOT_SPECIFIED, bits, channels, channels AudioSystem.NOT_SPECIFIED, bits, channels, channels
* bits / 8, AudioSystem.NOT_SPECIFIED, true)); * bits / 8, AudioSystem.NOT_SPECIFIED, true));
} }
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, false)); AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4,
AudioSystem.NOT_SPECIFIED, true)); AudioSystem.NOT_SPECIFIED, true));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, false)); AudioSystem.NOT_SPECIFIED, false));
formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, formats.add(new AudioFormat(Encoding.PCM_FLOAT,
AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8,
AudioSystem.NOT_SPECIFIED, true)); AudioSystem.NOT_SPECIFIED, true));
} }
......
...@@ -27,6 +27,7 @@ package com.sun.media.sound; ...@@ -27,6 +27,7 @@ package com.sun.media.sound;
import java.util.TreeMap; import java.util.TreeMap;
import javax.sound.midi.MidiDevice; import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiDeviceReceiver;
import javax.sound.midi.MidiMessage; import javax.sound.midi.MidiMessage;
import javax.sound.midi.ShortMessage; import javax.sound.midi.ShortMessage;
......
...@@ -279,9 +279,12 @@ public class SoftVoice extends VoiceStatus { ...@@ -279,9 +279,12 @@ public class SoftVoice extends VoiceStatus {
} }
protected void updateTuning(SoftTuning newtuning) { protected void updateTuning(SoftTuning newtuning) {
tuning = newtuning;
tunedKey = tuning.getTuning(note) / 100.0; tunedKey = tuning.getTuning(note) / 100.0;
if (!portamento) { if (!portamento) {
co_noteon_keynumber[0] = tunedKey * (1.0 / 128.0); co_noteon_keynumber[0] = tunedKey * (1.0 / 128.0);
if(performer == null)
return;
int[] c = performer.midi_connections[4]; int[] c = performer.midi_connections[4];
if (c == null) if (c == null)
return; return;
...@@ -433,6 +436,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -433,6 +436,8 @@ public class SoftVoice extends VoiceStatus {
} }
protected void setPolyPressure(int pressure) { protected void setPolyPressure(int pressure) {
if(performer == null)
return;
int[] c = performer.midi_connections[2]; int[] c = performer.midi_connections[2];
if (c == null) if (c == null)
return; return;
...@@ -441,6 +446,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -441,6 +446,8 @@ public class SoftVoice extends VoiceStatus {
} }
protected void setChannelPressure(int pressure) { protected void setChannelPressure(int pressure) {
if(performer == null)
return;
int[] c = performer.midi_connections[1]; int[] c = performer.midi_connections[1];
if (c == null) if (c == null)
return; return;
...@@ -449,6 +456,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -449,6 +456,8 @@ public class SoftVoice extends VoiceStatus {
} }
protected void controlChange(int controller, int value) { protected void controlChange(int controller, int value) {
if(performer == null)
return;
int[] c = performer.midi_ctrl_connections[controller]; int[] c = performer.midi_ctrl_connections[controller];
if (c == null) if (c == null)
return; return;
...@@ -457,6 +466,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -457,6 +466,8 @@ public class SoftVoice extends VoiceStatus {
} }
protected void nrpnChange(int controller, int value) { protected void nrpnChange(int controller, int value) {
if(performer == null)
return;
int[] c = performer.midi_nrpn_connections.get(controller); int[] c = performer.midi_nrpn_connections.get(controller);
if (c == null) if (c == null)
return; return;
...@@ -465,6 +476,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -465,6 +476,8 @@ public class SoftVoice extends VoiceStatus {
} }
protected void rpnChange(int controller, int value) { protected void rpnChange(int controller, int value) {
if(performer == null)
return;
int[] c = performer.midi_rpn_connections.get(controller); int[] c = performer.midi_rpn_connections.get(controller);
if (c == null) if (c == null)
return; return;
...@@ -473,6 +486,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -473,6 +486,8 @@ public class SoftVoice extends VoiceStatus {
} }
protected void setPitchBend(int bend) { protected void setPitchBend(int bend) {
if(performer == null)
return;
int[] c = performer.midi_connections[0]; int[] c = performer.midi_connections[0];
if (c == null) if (c == null)
return; return;
...@@ -499,6 +514,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -499,6 +514,8 @@ public class SoftVoice extends VoiceStatus {
co_noteon_on[0] = -1; co_noteon_on[0] = -1;
if(performer == null)
return;
int[] c = performer.midi_connections[3]; int[] c = performer.midi_connections[3];
if (c == null) if (c == null)
return; return;
...@@ -527,6 +544,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -527,6 +544,8 @@ public class SoftVoice extends VoiceStatus {
co_noteon_on[0] = 0; co_noteon_on[0] = 0;
if(performer == null)
return;
int[] c = performer.midi_connections[3]; int[] c = performer.midi_connections[3];
if (c == null) if (c == null)
return; return;
...@@ -543,6 +562,8 @@ public class SoftVoice extends VoiceStatus { ...@@ -543,6 +562,8 @@ public class SoftVoice extends VoiceStatus {
sustain = true; sustain = true;
co_noteon_on[0] = 1; co_noteon_on[0] = 1;
if(performer == null)
return;
int[] c = performer.midi_connections[3]; int[] c = performer.midi_connections[3];
if (c == null) if (c == null)
return; return;
...@@ -555,6 +576,11 @@ public class SoftVoice extends VoiceStatus { ...@@ -555,6 +576,11 @@ public class SoftVoice extends VoiceStatus {
active = false; active = false;
stopping = false; stopping = false;
audiostarted = false; audiostarted = false;
instrument = null;
performer = null;
connections = null;
extendedConnectionBlocks = null;
channelmixer = null;
if (osc_stream != null) if (osc_stream != null)
try { try {
osc_stream.close(); osc_stream.close();
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -271,7 +271,7 @@ public class WaveExtensibleFileReader extends AudioFileReader { ...@@ -271,7 +271,7 @@ public class WaveExtensibleFileReader extends AudioFileReader {
bits, channels, framesize, samplerate, false, p); bits, channels, framesize, samplerate, false, p);
} }
} else if (subFormat.equals(SUBTYPE_IEEE_FLOAT)) { } else if (subFormat.equals(SUBTYPE_IEEE_FLOAT)) {
audioformat = new AudioFormat(AudioFloatConverter.PCM_FLOAT, audioformat = new AudioFormat(Encoding.PCM_FLOAT,
samplerate, bits, channels, framesize, samplerate, false, p); samplerate, bits, channels, framesize, samplerate, false, p);
} else } else
throw new UnsupportedAudioFileException(); throw new UnsupportedAudioFileException();
......
/* /*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,6 +33,7 @@ import java.net.URL; ...@@ -33,6 +33,7 @@ import java.net.URL;
import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException; import javax.sound.sampled.UnsupportedAudioFileException;
...@@ -102,7 +103,7 @@ public class WaveFloatFileReader extends AudioFileReader { ...@@ -102,7 +103,7 @@ public class WaveFloatFileReader extends AudioFileReader {
throw new UnsupportedAudioFileException(); throw new UnsupportedAudioFileException();
AudioFormat audioformat = new AudioFormat( AudioFormat audioformat = new AudioFormat(
AudioFloatConverter.PCM_FLOAT, samplerate, bits, channels, Encoding.PCM_FLOAT, samplerate, bits, channels,
framesize, samplerate, false); framesize, samplerate, false);
AudioFileFormat fileformat = new AudioFileFormat( AudioFileFormat fileformat = new AudioFileFormat(
AudioFileFormat.Type.WAVE, audioformat, AudioFileFormat.Type.WAVE, audioformat,
......
/* /*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -30,6 +30,7 @@ import java.io.OutputStream; ...@@ -30,6 +30,7 @@ import java.io.OutputStream;
import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.AudioFileFormat.Type;
...@@ -48,8 +49,7 @@ public class WaveFloatFileWriter extends AudioFileWriter { ...@@ -48,8 +49,7 @@ public class WaveFloatFileWriter extends AudioFileWriter {
public Type[] getAudioFileTypes(AudioInputStream stream) { public Type[] getAudioFileTypes(AudioInputStream stream) {
if (!stream.getFormat().getEncoding().equals( if (!stream.getFormat().getEncoding().equals(Encoding.PCM_FLOAT))
AudioFloatConverter.PCM_FLOAT))
return new Type[0]; return new Type[0];
return new Type[] { Type.WAVE }; return new Type[] { Type.WAVE };
} }
...@@ -58,8 +58,7 @@ public class WaveFloatFileWriter extends AudioFileWriter { ...@@ -58,8 +58,7 @@ public class WaveFloatFileWriter extends AudioFileWriter {
if (!Type.WAVE.equals(type)) if (!Type.WAVE.equals(type))
throw new IllegalArgumentException("File type " + type throw new IllegalArgumentException("File type " + type
+ " not supported."); + " not supported.");
if (!stream.getFormat().getEncoding().equals( if (!stream.getFormat().getEncoding().equals(Encoding.PCM_FLOAT))
AudioFloatConverter.PCM_FLOAT))
throw new IllegalArgumentException("File format " throw new IllegalArgumentException("File format "
+ stream.getFormat() + " not supported."); + stream.getFormat() + " not supported.");
} }
......
...@@ -277,10 +277,8 @@ public class Dialog extends Window { ...@@ -277,10 +277,8 @@ public class Dialog extends Window {
*/ */
String title; String title;
private transient volatile boolean keepBlockingEDT = false;
private transient volatile boolean keepBlockingCT = false;
private transient ModalEventFilter modalFilter; private transient ModalEventFilter modalFilter;
private transient volatile SecondaryLoop secondaryLoop;
/* /*
* Indicates that this dialog is being hidden. This flag is set to true at * Indicates that this dialog is being hidden. This flag is set to true at
...@@ -1005,12 +1003,6 @@ public class Dialog extends Window { ...@@ -1005,12 +1003,6 @@ public class Dialog extends Window {
super.setVisible(b); super.setVisible(b);
} }
/**
* Stores the app context on which event dispatch thread the dialog
* is being shown. Initialized in show(), used in hideAndDisposeHandler()
*/
transient private AppContext showAppContext;
/** /**
* Makes the {@code Dialog} visible. If the dialog and/or its owner * Makes the {@code Dialog} visible. If the dialog and/or its owner
* are not yet displayable, both are made displayable. The * are not yet displayable, both are made displayable. The
...@@ -1037,39 +1029,18 @@ public class Dialog extends Window { ...@@ -1037,39 +1029,18 @@ public class Dialog extends Window {
if (!isModal()) { if (!isModal()) {
conditionalShow(null, null); conditionalShow(null, null);
} else { } else {
// Set this variable before calling conditionalShow(). That AppContext showAppContext = AppContext.getAppContext();
// way, if the Dialog is hidden right after being shown, we
// won't mistakenly block this thread.
keepBlockingEDT = true;
keepBlockingCT = true;
// Store the app context on which this dialog is being shown.
// Event dispatch thread of this app context will be sleeping until
// we wake it by any event from hideAndDisposeHandler().
showAppContext = AppContext.getAppContext();
AtomicLong time = new AtomicLong(); AtomicLong time = new AtomicLong();
Component predictedFocusOwner = null; Component predictedFocusOwner = null;
try { try {
predictedFocusOwner = getMostRecentFocusOwner(); predictedFocusOwner = getMostRecentFocusOwner();
if (conditionalShow(predictedFocusOwner, time)) { if (conditionalShow(predictedFocusOwner, time)) {
// We have two mechanisms for blocking: 1. If we're on the
// EventDispatchThread, start a new event pump. 2. If we're
// on any other thread, call wait() on the treelock.
modalFilter = ModalEventFilter.createFilterForDialog(this); modalFilter = ModalEventFilter.createFilterForDialog(this);
Conditional cond = new Conditional() {
final Runnable pumpEventsForFilter = new Runnable() { @Override
public void run() { public boolean evaluate() {
EventDispatchThread dispatchThread = return windowClosingException == null;
(EventDispatchThread)Thread.currentThread();
dispatchThread.pumpEventsForFilter(new Conditional() {
public boolean evaluate() {
synchronized (getTreeLock()) {
return keepBlockingEDT && windowClosingException == null;
}
}
}, modalFilter);
} }
}; };
...@@ -1096,44 +1067,10 @@ public class Dialog extends Window { ...@@ -1096,44 +1067,10 @@ public class Dialog extends Window {
modalityPushed(); modalityPushed();
try { try {
if (EventQueue.isDispatchThread()) { EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
/* secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000);
* dispose SequencedEvent we are dispatching on current if (!secondaryLoop.enter()) {
* AppContext, to prevent us from hang. secondaryLoop = null;
*
*/
// BugId 4531693 (son@sparc.spb.su)
SequencedEvent currentSequencedEvent = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
if (currentSequencedEvent != null) {
currentSequencedEvent.dispose();
}
/*
* Event processing is done inside doPrivileged block so that
* it wouldn't matter even if user code is on the stack
* Fix for BugId 6300270
*/
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
pumpEventsForFilter.run();
return null;
}
});
} else {
synchronized (getTreeLock()) {
Toolkit.getEventQueue().postEvent(new PeerEvent(this,
pumpEventsForFilter,
PeerEvent.PRIORITY_EVENT));
while (keepBlockingCT && windowClosingException == null) {
try {
getTreeLock().wait();
} catch (InterruptedException e) {
break;
}
}
}
} }
} finally { } finally {
modalityPopped(); modalityPopped();
...@@ -1194,18 +1131,11 @@ public class Dialog extends Window { ...@@ -1194,18 +1131,11 @@ public class Dialog extends Window {
windowClosingException = null; windowClosingException = null;
} }
} }
final class WakingRunnable implements Runnable {
public void run() {
synchronized (getTreeLock()) {
keepBlockingCT = false;
getTreeLock().notifyAll();
}
}
}
private void hideAndDisposePreHandler() { private void hideAndDisposePreHandler() {
isInHide = true; isInHide = true;
synchronized (getTreeLock()) { synchronized (getTreeLock()) {
if (keepBlockingEDT) { if (secondaryLoop != null) {
modalHide(); modalHide();
// dialog can be shown and then disposed before its // dialog can be shown and then disposed before its
// modal filter is created // modal filter is created
...@@ -1217,20 +1147,9 @@ public class Dialog extends Window { ...@@ -1217,20 +1147,9 @@ public class Dialog extends Window {
} }
} }
private void hideAndDisposeHandler() { private void hideAndDisposeHandler() {
synchronized (getTreeLock()) { if (secondaryLoop != null) {
if (keepBlockingEDT) { secondaryLoop.exit();
keepBlockingEDT = false; secondaryLoop = null;
PeerEvent wakingEvent = new PeerEvent(getToolkit(), new WakingRunnable(), PeerEvent.PRIORITY_EVENT);
AppContext curAppContext = AppContext.getAppContext();
if (showAppContext != curAppContext) {
// Wake up event dispatch thread on which the dialog was
// initially shown
SunToolkit.postEvent(showAppContext, wakingEvent);
showAppContext = null;
} else {
Toolkit.getEventQueue().postEvent(wakingEvent);
}
}
} }
isInHide = false; isInHide = false;
} }
......
...@@ -113,8 +113,7 @@ class EventDispatchThread extends Thread { ...@@ -113,8 +113,7 @@ class EventDispatchThread extends Thread {
pumpEventsForHierarchy(id, cond, null); pumpEventsForHierarchy(id, cond, null);
} }
void pumpEventsForHierarchy(int id, Conditional cond, Component modalComponent) void pumpEventsForHierarchy(int id, Conditional cond, Component modalComponent) {
{
pumpEventsForFilter(id, cond, new HierarchyEventFilter(modalComponent)); pumpEventsForFilter(id, cond, new HierarchyEventFilter(modalComponent));
} }
...@@ -124,6 +123,7 @@ class EventDispatchThread extends Thread { ...@@ -124,6 +123,7 @@ class EventDispatchThread extends Thread {
void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) { void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
addEventFilter(filter); addEventFilter(filter);
doDispatch = true;
while (doDispatch && cond.evaluate()) { while (doDispatch && cond.evaluate()) {
if (isInterrupted() || !pumpOneEventForFilters(id)) { if (isInterrupted() || !pumpOneEventForFilters(id)) {
doDispatch = false; doDispatch = false;
...@@ -133,6 +133,7 @@ class EventDispatchThread extends Thread { ...@@ -133,6 +133,7 @@ class EventDispatchThread extends Thread {
} }
void addEventFilter(EventFilter filter) { void addEventFilter(EventFilter filter) {
eventLog.finest("adding the event filter: " + filter);
synchronized (eventFilters) { synchronized (eventFilters) {
if (!eventFilters.contains(filter)) { if (!eventFilters.contains(filter)) {
if (filter instanceof ModalEventFilter) { if (filter instanceof ModalEventFilter) {
...@@ -156,6 +157,7 @@ class EventDispatchThread extends Thread { ...@@ -156,6 +157,7 @@ class EventDispatchThread extends Thread {
} }
void removeEventFilter(EventFilter filter) { void removeEventFilter(EventFilter filter) {
eventLog.finest("removing the event filter: " + filter);
synchronized (eventFilters) { synchronized (eventFilters) {
eventFilters.remove(filter); eventFilters.remove(filter);
} }
......
...@@ -883,6 +883,41 @@ public class EventQueue { ...@@ -883,6 +883,41 @@ public class EventQueue {
} }
} }
/**
* Creates a new {@code secondary loop} associated with this
* event queue. Use the {@link SecondaryLoop#enter} and
* {@link SecondaryLoop#exit} methods to start and stop the
* event loop and dispatch the events from this queue.
*
* @return secondaryLoop A new secondary loop object, which can
* be used to launch a new nested event
* loop and dispatch events from this queue
*
* @see SecondaryLoop#enter
* @see SecondaryLoop#exit
*
* @since 1.7
*/
public SecondaryLoop createSecondaryLoop() {
return createSecondaryLoop(null, null, 0);
}
SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) {
pushPopLock.lock();
try {
if (nextQueue != null) {
// Forward the request to the top of EventQueue stack
return nextQueue.createSecondaryLoop(cond, filter, interval);
}
if (dispatchThread == null) {
initDispatchThread();
}
return new WaitDispatchSupport(dispatchThread, cond, filter, interval);
} finally {
pushPopLock.unlock();
}
}
/** /**
* Returns true if the calling thread is * Returns true if the calling thread is
* {@link Toolkit#getSystemEventQueue the current AWT EventQueue}'s * {@link Toolkit#getSystemEventQueue the current AWT EventQueue}'s
......
/*
* Copyright (c) 2010, 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 java.awt;
/**
* A helper interface to run the nested event loop.
* <p>
* Objects that implement this interface are created with the
* {@link EventQueue#createSecondaryLoop} method. The interface
* provides two methods, {@link enter} and {@link exit},
* which can be used to start and stop the event loop.
* <p>
* When the {@link enter} method is called, the current
* thread is blocked until the loop is terminated by the
* {@link exit} method. Also, a new event loop is started
* on the event dispatch thread, which may or may not be
* the current thread. The loop can be terminated on any
* thread by calling its {@link exit} method. After the
* loop is terminated, the {@code SecondaryLoop} object can
* be reused to run a new nested event loop.
* <p>
* A typical use case of applying this interface is AWT
* and Swing modal dialogs. When a modal dialog is shown on
* the event dispatch thread, it enters a new secondary loop.
* Later, when the dialog is hidden or disposed, it exits
* the loop, and the thread continues its execution.
* <p>
* The following example illustrates a simple use case of
* secondary loops:
*
* <pre>
* SecondaryLoop loop;
*
* JButton jButton = new JButton("Button");
* jButton.addActionListener(new ActionListener() {
* {@code @Override}
* public void actionPerformed(ActionEvent e) {
* Toolkit tk = Toolkit.getDefaultToolkit();
* EventQueue eq = tk.getSystemEventQueue();
* loop = eq.createSecondaryLoop();
*
* // Spawn a new thread to do the work
* Thread worker = new WorkerThread();
* worker.start();
*
* // Enter the loop to block the current event
* // handler, but leave UI responsive
* if (!loop.enter()) {
* // Report an error
* }
* }
* });
*
* class WorkerThread extends Thread {
* {@code @Override}
* public void run() {
* // Perform calculations
* doSomethingUseful();
*
* // Exit the loop
* loop.exit();
* }
* }
* </pre>
*
* @see Dialog#show
* @see EventQueue#createSecondaryLoop
* @see Toolkit#getSystemEventQueue
*
* @author Anton Tarasov, Artem Ananiev
*
* @since 1.7
*/
public interface SecondaryLoop {
/**
* Blocks the execution of the current thread and enters a new
* secondary event loop on the event dispatch thread.
* <p>
* This method can be called by any thread including the event
* dispatch thread. This thread will be blocked until the {@link
* exit} method is called or the loop is terminated. A new
* secondary loop will be created on the event dispatch thread
* for dispatching events in either case.
* <p>
* This method can only start one new event loop at a time per
* object. If a secondary event loop has already been started
* by this object and is currently still running, this method
* returns {@code false} to indicate that it was not successful
* in starting a new event loop. Otherwise, this method blocks
* the calling thread and later returns {@code true} when the
* new event loop is terminated. At such time, this object can
* again be used to start another new event loop.
*
* @return {@code true} after termination of the secondary loop,
* if the secondary loop was started by this call,
* {@code false} otherwise
*/
public boolean enter();
/**
* Unblocks the execution of the thread blocked by the {@link
* enter} method and exits the secondary loop.
* <p>
* This method resumes the thread that called the {@link enter}
* method and exits the secondary loop that was created when
* the {@link enter} method was invoked.
* <p>
* Note that if any other secondary loop is started while this
* loop is running, the blocked thread will not resume execution
* until the nested loop is terminated.
* <p>
* If this secondary loop has not been started with the {@link
* enter} method, or this secondary loop has already finished
* with the {@link exit} method, this method returns {@code
* false}, otherwise {@code true} is returned.
*
* @return {@code true} if this loop was previously started and
* has not yet been finished with the {@link exit} method,
* {@code false} otherwise
*/
public boolean exit();
}
/*
* Copyright (c) 2010, 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 java.awt;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicBoolean;
import java.security.PrivilegedAction;
import java.security.AccessController;
import sun.awt.PeerEvent;
import sun.util.logging.PlatformLogger;
/**
* This utility class is used to suspend execution on a thread
* while still allowing {@code EventDispatchThread} to dispatch events.
* The API methods of the class are thread-safe.
*
* @author Anton Tarasov, Artem Ananiev
*
* @since 1.7
*/
class WaitDispatchSupport implements SecondaryLoop {
private final static PlatformLogger log =
PlatformLogger.getLogger("java.awt.event.WaitDispatchSupport");
private EventDispatchThread dispatchThread;
private EventFilter filter;
private volatile Conditional extCondition;
private volatile Conditional condition;
private long interval;
// Use a shared daemon timer to serve all the WaitDispatchSupports
private static Timer timer;
// When this WDS expires, we cancel the timer task leaving the
// shared timer up and running
private TimerTask timerTask;
private AtomicBoolean keepBlockingEDT = new AtomicBoolean(false);
private AtomicBoolean keepBlockingCT = new AtomicBoolean(false);
private static synchronized void initializeTimer() {
if (timer == null) {
timer = new Timer("AWT-WaitDispatchSupport-Timer", true);
}
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
*
* @since 1.7
*/
public WaitDispatchSupport(EventDispatchThread dispatchThread) {
this(dispatchThread, null);
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
* @param extCondition A conditional object used to determine
* if the loop should be terminated
*
* @since 1.7
*/
public WaitDispatchSupport(EventDispatchThread dispatchThread,
Conditional extCond)
{
if (dispatchThread == null) {
throw new IllegalArgumentException("The dispatchThread can not be null");
}
this.dispatchThread = dispatchThread;
this.extCondition = extCond;
this.condition = new Conditional() {
@Override
public boolean evaluate() {
if (log.isLoggable(PlatformLogger.FINEST)) {
log.finest("evaluate(): blockingEDT=" + keepBlockingEDT.get() +
", blockingCT=" + keepBlockingCT.get());
}
boolean extEvaluate =
(extCondition != null) ? extCondition.evaluate() : true;
if (!keepBlockingEDT.get() || !extEvaluate) {
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
return false;
}
return true;
}
};
}
/**
* Creates a {@code WaitDispatchSupport} instance to
* serve the given event dispatch thread.
* <p>
* The {@link EventFilter} is set on the {@code dispatchThread}
* while waiting. The filter is removed on completion of the
* waiting process.
* <p>
*
*
* @param dispatchThread An event dispatch thread that
* should not stop dispatching events while waiting
* @param filter {@code EventFilter} to be set
* @param interval A time interval to wait for. Note that
* when the waiting process takes place on EDT
* there is no guarantee to stop it in the given time
*
* @since 1.7
*/
public WaitDispatchSupport(EventDispatchThread dispatchThread,
Conditional extCondition,
EventFilter filter, long interval)
{
this(dispatchThread, extCondition);
this.filter = filter;
if (interval < 0) {
throw new IllegalArgumentException("The interval value must be >= 0");
}
this.interval = interval;
if (interval != 0) {
initializeTimer();
}
}
/**
* @inheritDoc
*/
@Override
public boolean enter() {
log.fine("enter(): blockingEDT=" + keepBlockingEDT.get() +
", blockingCT=" + keepBlockingCT.get());
if (!keepBlockingEDT.compareAndSet(false, true)) {
log.fine("The secondary loop is already running, aborting");
return false;
}
final Runnable run = new Runnable() {
public void run() {
log.fine("Starting a new event pump");
if (filter == null) {
dispatchThread.pumpEvents(condition);
} else {
dispatchThread.pumpEventsForFilter(condition, filter);
}
}
};
// We have two mechanisms for blocking: if we're on the
// dispatch thread, start a new event pump; if we're
// on any other thread, call wait() on the treelock
Thread currentThread = Thread.currentThread();
if (currentThread == dispatchThread) {
log.finest("On dispatch thread: " + dispatchThread);
if (interval != 0) {
log.finest("scheduling the timer for " + interval + " ms");
timer.schedule(timerTask = new TimerTask() {
@Override
public void run() {
if (keepBlockingEDT.compareAndSet(true, false)) {
wakeupEDT();
}
}
}, interval);
}
// Dispose SequencedEvent we are dispatching on the the current
// AppContext, to prevent us from hang - see 4531693 for details
SequencedEvent currentSE = KeyboardFocusManager.
getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
if (currentSE != null) {
log.fine("Dispose current SequencedEvent: " + currentSE);
currentSE.dispose();
}
// In case the exit() method is called before starting
// new event pump it will post the waking event to EDT.
// The event will be handled after the the new event pump
// starts. Thus, the enter() method will not hang.
//
// Event pump should be privileged. See 6300270.
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
run.run();
return null;
}
});
} else {
log.finest("On non-dispatch thread: " + currentThread);
synchronized (getTreeLock()) {
if (filter != null) {
dispatchThread.addEventFilter(filter);
}
try {
EventQueue eq = dispatchThread.getEventQueue();
eq.postEvent(new PeerEvent(this, run, PeerEvent.PRIORITY_EVENT));
keepBlockingCT.set(true);
if (interval > 0) {
long currTime = System.currentTimeMillis();
while (keepBlockingCT.get() &&
((extCondition != null) ? extCondition.evaluate() : true) &&
(currTime + interval > System.currentTimeMillis()))
{
getTreeLock().wait(interval);
}
} else {
while (keepBlockingCT.get() &&
((extCondition != null) ? extCondition.evaluate() : true))
{
getTreeLock().wait();
}
}
log.fine("waitDone " + keepBlockingEDT.get() + " " + keepBlockingCT.get());
} catch (InterruptedException e) {
log.fine("Exception caught while waiting: " + e);
} finally {
if (filter != null) {
dispatchThread.removeEventFilter(filter);
}
}
// If the waiting process has been stopped because of the
// time interval passed or an exception occurred, the state
// should be changed
keepBlockingEDT.set(false);
keepBlockingCT.set(false);
}
}
return true;
}
/**
* @inheritDoc
*/
public boolean exit() {
log.fine("exit(): blockingEDT=" + keepBlockingEDT.get() +
", blockingCT=" + keepBlockingCT.get());
if (keepBlockingEDT.compareAndSet(true, false)) {
wakeupEDT();
return true;
}
return false;
}
private final static Object getTreeLock() {
return Component.LOCK;
}
private final Runnable wakingRunnable = new Runnable() {
public void run() {
log.fine("Wake up EDT");
synchronized (getTreeLock()) {
keepBlockingCT.set(false);
getTreeLock().notifyAll();
}
log.fine("Wake up EDT done");
}
};
private void wakeupEDT() {
log.finest("wakeupEDT(): EDT == " + dispatchThread);
EventQueue eq = dispatchThread.getEventQueue();
eq.postEvent(new PeerEvent(this, wakingRunnable, PeerEvent.PRIORITY_EVENT));
}
}
...@@ -595,7 +595,6 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -595,7 +595,6 @@ class Character implements java.io.Serializable, Comparable<Character> {
/** /**
* Constructs a new <code>Subset</code> instance. * Constructs a new <code>Subset</code> instance.
* *
* @exception NullPointerException if name is <code>null</code>
* @param name The name of this subset * @param name The name of this subset
* @exception NullPointerException if name is <code>null</code> * @exception NullPointerException if name is <code>null</code>
*/ */
......
/* /*
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this * published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided * particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code. * by Oracle in the LICENSE file that accompanied this code.
* *
* This code is distributed in the hope that it will be useful, but WITHOUT * This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
* 2 along with this work; if not, write to the Free Software Foundation, * 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
* *
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* CA 95054 USA or visit www.sun.com if you need additional information or * or visit www.oracle.com if you need additional information or have any
* have any questions. * questions.
*/ */
package java.lang; package java.lang;
......
/*
* Copyright (c) 2010, 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 java.text;
import java.util.Calendar;
import static java.util.GregorianCalendar.*;
/**
* {@code CalendarBuilder} keeps field-value pairs for setting
* the calendar fields of the given {@code Calendar}. It has the
* {@link Calendar#FIELD_COUNT FIELD_COUNT}-th field for the week year
* support. Also {@code ISO_DAY_OF_WEEK} is used to specify
* {@code DAY_OF_WEEK} in the ISO day of week numbering.
*
* <p>{@code CalendarBuilder} retains the semantic of the pseudo
* timestamp for fields. {@code CalendarBuilder} uses a single
* int array combining fields[] and stamp[] of {@code Calendar}.
*
* @author Masayoshi Okutsu
*/
class CalendarBuilder {
/*
* Pseudo time stamp constants used in java.util.Calendar
*/
private static final int UNSET = 0;
private static final int COMPUTED = 1;
private static final int MINIMUM_USER_STAMP = 2;
private static final int MAX_FIELD = FIELD_COUNT + 1;
public static final int WEEK_YEAR = FIELD_COUNT;
public static final int ISO_DAY_OF_WEEK = 1000; // pseudo field index
// stamp[] (lower half) and field[] (upper half) combined
private final int[] field;
private int nextStamp;
private int maxFieldIndex;
CalendarBuilder() {
field = new int[MAX_FIELD * 2];
nextStamp = MINIMUM_USER_STAMP;
maxFieldIndex = -1;
}
CalendarBuilder set(int index, int value) {
if (index == ISO_DAY_OF_WEEK) {
index = DAY_OF_WEEK;
value = toCalendarDayOfWeek(value);
}
field[index] = nextStamp++;
field[MAX_FIELD + index] = value;
if (index > maxFieldIndex && index < FIELD_COUNT) {
maxFieldIndex = index;
}
return this;
}
CalendarBuilder addYear(int value) {
field[MAX_FIELD + YEAR] += value;
field[MAX_FIELD + WEEK_YEAR] += value;
return this;
}
boolean isSet(int index) {
if (index == ISO_DAY_OF_WEEK) {
index = DAY_OF_WEEK;
}
return field[index] > UNSET;
}
Calendar establish(Calendar cal) {
boolean weekDate = isSet(WEEK_YEAR)
&& field[WEEK_YEAR] > field[YEAR];
if (weekDate && !cal.isWeekDateSupported()) {
// Use YEAR instead
if (!isSet(YEAR)) {
set(YEAR, field[MAX_FIELD + WEEK_YEAR]);
}
weekDate = false;
}
cal.clear();
// Set the fields from the min stamp to the max stamp so that
// the field resolution works in the Calendar.
for (int stamp = MINIMUM_USER_STAMP; stamp < nextStamp; stamp++) {
for (int index = 0; index <= maxFieldIndex; index++) {
if (field[index] == stamp) {
cal.set(index, field[MAX_FIELD + index]);
break;
}
}
}
if (weekDate) {
int weekOfYear = isSet(WEEK_OF_YEAR) ? field[MAX_FIELD + WEEK_OF_YEAR] : 1;
int dayOfWeek = isSet(DAY_OF_WEEK) ?
field[MAX_FIELD + DAY_OF_WEEK] : cal.getFirstDayOfWeek();
if (!isValidDayOfWeek(dayOfWeek) && cal.isLenient()) {
if (dayOfWeek >= 8) {
dayOfWeek--;
weekOfYear += dayOfWeek / 7;
dayOfWeek = (dayOfWeek % 7) + 1;
} else {
while (dayOfWeek <= 0) {
dayOfWeek += 7;
weekOfYear--;
}
}
dayOfWeek = toCalendarDayOfWeek(dayOfWeek);
}
cal.setWeekDate(field[MAX_FIELD + WEEK_YEAR], weekOfYear, dayOfWeek);
}
return cal;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("CalendarBuilder:[");
for (int i = 0; i < field.length; i++) {
if (isSet(i)) {
sb.append(i).append('=').append(field[MAX_FIELD + i]).append(',');
}
}
int lastIndex = sb.length() - 1;
if (sb.charAt(lastIndex) == ',') {
sb.setLength(lastIndex);
}
sb.append(']');
return sb.toString();
}
static int toISODayOfWeek(int calendarDayOfWeek) {
return calendarDayOfWeek == SUNDAY ? 7 : calendarDayOfWeek - 1;
}
static int toCalendarDayOfWeek(int isoDayOfWeek) {
if (!isValidDayOfWeek(isoDayOfWeek)) {
// adjust later for lenient mode
return isoDayOfWeek;
}
return isoDayOfWeek == 7 ? SUNDAY : isoDayOfWeek + 1;
}
static boolean isValidDayOfWeek(int dayOfWeek) {
return dayOfWeek > 0 && dayOfWeek <= 7;
}
}
...@@ -443,7 +443,7 @@ public abstract class DateFormat extends Format { ...@@ -443,7 +443,7 @@ public abstract class DateFormat extends Format {
*/ */
public final static DateFormat getTimeInstance() public final static DateFormat getTimeInstance()
{ {
return get(DEFAULT, 0, 1, Locale.getDefault()); return get(DEFAULT, 0, 1, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -455,7 +455,7 @@ public abstract class DateFormat extends Format { ...@@ -455,7 +455,7 @@ public abstract class DateFormat extends Format {
*/ */
public final static DateFormat getTimeInstance(int style) public final static DateFormat getTimeInstance(int style)
{ {
return get(style, 0, 1, Locale.getDefault()); return get(style, 0, 1, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -479,7 +479,7 @@ public abstract class DateFormat extends Format { ...@@ -479,7 +479,7 @@ public abstract class DateFormat extends Format {
*/ */
public final static DateFormat getDateInstance() public final static DateFormat getDateInstance()
{ {
return get(0, DEFAULT, 2, Locale.getDefault()); return get(0, DEFAULT, 2, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -491,7 +491,7 @@ public abstract class DateFormat extends Format { ...@@ -491,7 +491,7 @@ public abstract class DateFormat extends Format {
*/ */
public final static DateFormat getDateInstance(int style) public final static DateFormat getDateInstance(int style)
{ {
return get(0, style, 2, Locale.getDefault()); return get(0, style, 2, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -515,7 +515,7 @@ public abstract class DateFormat extends Format { ...@@ -515,7 +515,7 @@ public abstract class DateFormat extends Format {
*/ */
public final static DateFormat getDateTimeInstance() public final static DateFormat getDateTimeInstance()
{ {
return get(DEFAULT, DEFAULT, 3, Locale.getDefault()); return get(DEFAULT, DEFAULT, 3, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -530,7 +530,7 @@ public abstract class DateFormat extends Format { ...@@ -530,7 +530,7 @@ public abstract class DateFormat extends Format {
public final static DateFormat getDateTimeInstance(int dateStyle, public final static DateFormat getDateTimeInstance(int dateStyle,
int timeStyle) int timeStyle)
{ {
return get(timeStyle, dateStyle, 3, Locale.getDefault()); return get(timeStyle, dateStyle, 3, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
......
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -118,7 +118,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { ...@@ -118,7 +118,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
*/ */
public DateFormatSymbols() public DateFormatSymbols()
{ {
initializeData(Locale.getDefault()); initializeData(Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -226,7 +226,30 @@ public class DateFormatSymbols implements Serializable, Cloneable { ...@@ -226,7 +226,30 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* Unlocalized date-time pattern characters. For example: 'y', 'd', etc. * Unlocalized date-time pattern characters. For example: 'y', 'd', etc.
* All locales use the same these unlocalized pattern characters. * All locales use the same these unlocalized pattern characters.
*/ */
static final String patternChars = "GyMdkHmsSEDFwWahKzZ"; static final String patternChars = "GyMdkHmsSEDFwWahKzZYuX";
static final int PATTERN_ERA = 0; // G
static final int PATTERN_YEAR = 1; // y
static final int PATTERN_MONTH = 2; // M
static final int PATTERN_DAY_OF_MONTH = 3; // d
static final int PATTERN_HOUR_OF_DAY1 = 4; // k
static final int PATTERN_HOUR_OF_DAY0 = 5; // H
static final int PATTERN_MINUTE = 6; // m
static final int PATTERN_SECOND = 7; // s
static final int PATTERN_MILLISECOND = 8; // S
static final int PATTERN_DAY_OF_WEEK = 9; // E
static final int PATTERN_DAY_OF_YEAR = 10; // D
static final int PATTERN_DAY_OF_WEEK_IN_MONTH = 11; // F
static final int PATTERN_WEEK_OF_YEAR = 12; // w
static final int PATTERN_WEEK_OF_MONTH = 13; // W
static final int PATTERN_AM_PM = 14; // a
static final int PATTERN_HOUR1 = 15; // h
static final int PATTERN_HOUR0 = 16; // K
static final int PATTERN_ZONE_NAME = 17; // z
static final int PATTERN_ZONE_VALUE = 18; // Z
static final int PATTERN_WEEK_YEAR = 19; // Y
static final int PATTERN_ISO_DAY_OF_WEEK = 20; // u
static final int PATTERN_ISO_ZONE = 21; // X
/** /**
* Localized date-time pattern characters. For example, a locale may * Localized date-time pattern characters. For example, a locale may
...@@ -282,7 +305,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { ...@@ -282,7 +305,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @since 1.6 * @since 1.6
*/ */
public static final DateFormatSymbols getInstance() { public static final DateFormatSymbols getInstance() {
return getInstance(Locale.getDefault()); return getInstance(Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -505,7 +528,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { ...@@ -505,7 +528,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* @return the localized date-time pattern characters. * @return the localized date-time pattern characters.
*/ */
public String getLocalPatternChars() { public String getLocalPatternChars() {
return new String(localPatternChars); return localPatternChars;
} }
/** /**
...@@ -514,7 +537,8 @@ public class DateFormatSymbols implements Serializable, Cloneable { ...@@ -514,7 +537,8 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* pattern characters. * pattern characters.
*/ */
public void setLocalPatternChars(String newLocalPatternChars) { public void setLocalPatternChars(String newLocalPatternChars) {
localPatternChars = new String(newLocalPatternChars); // Call toString() to throw an NPE in case the argument is null
localPatternChars = newLocalPatternChars.toString();
} }
/** /**
...@@ -699,7 +723,7 @@ public class DateFormatSymbols implements Serializable, Cloneable { ...@@ -699,7 +723,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
} else { } else {
dst.zoneStrings = null; dst.zoneStrings = null;
} }
dst.localPatternChars = new String (src.localPatternChars); dst.localPatternChars = src.localPatternChars;
} }
/** /**
......
...@@ -392,7 +392,7 @@ public class DecimalFormat extends NumberFormat { ...@@ -392,7 +392,7 @@ public class DecimalFormat extends NumberFormat {
* @see java.text.NumberFormat#getPercentInstance * @see java.text.NumberFormat#getPercentInstance
*/ */
public DecimalFormat() { public DecimalFormat() {
Locale def = Locale.getDefault(); Locale def = Locale.getDefault(Locale.Category.FORMAT);
// try to get the pattern from the cache // try to get the pattern from the cache
String pattern = (String) cachedLocaleData.get(def); String pattern = (String) cachedLocaleData.get(def);
if (pattern == null) { /* cache miss */ if (pattern == null) { /* cache miss */
...@@ -430,7 +430,7 @@ public class DecimalFormat extends NumberFormat { ...@@ -430,7 +430,7 @@ public class DecimalFormat extends NumberFormat {
*/ */
public DecimalFormat(String pattern) { public DecimalFormat(String pattern) {
// Always applyPattern after the symbols are set // Always applyPattern after the symbols are set
this.symbols = new DecimalFormatSymbols(Locale.getDefault()); this.symbols = new DecimalFormatSymbols(Locale.getDefault(Locale.Category.FORMAT));
applyPattern(pattern, false); applyPattern(pattern, false);
} }
......
/* /*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,10 +43,10 @@ import java.io.ObjectInputStream; ...@@ -43,10 +43,10 @@ import java.io.ObjectInputStream;
import java.io.Serializable; import java.io.Serializable;
import java.text.spi.DecimalFormatSymbolsProvider; import java.text.spi.DecimalFormatSymbolsProvider;
import java.util.Currency; import java.util.Currency;
import java.util.Hashtable;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.spi.LocaleServiceProvider; import java.util.concurrent.ConcurrentHashMap;
import sun.util.LocaleServiceProviderPool; import sun.util.LocaleServiceProviderPool;
import sun.util.resources.LocaleData; import sun.util.resources.LocaleData;
...@@ -76,7 +76,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { ...@@ -76,7 +76,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
* {@link #getInstance(Locale) getInstance} method. * {@link #getInstance(Locale) getInstance} method.
*/ */
public DecimalFormatSymbols() { public DecimalFormatSymbols() {
initialize( Locale.getDefault() ); initialize( Locale.getDefault(Locale.Category.FORMAT) );
} }
/** /**
...@@ -125,7 +125,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { ...@@ -125,7 +125,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
* @since 1.6 * @since 1.6
*/ */
public static final DecimalFormatSymbols getInstance() { public static final DecimalFormatSymbols getInstance() {
return getInstance(Locale.getDefault()); return getInstance(Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -527,10 +527,17 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { ...@@ -527,10 +527,17 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
// get resource bundle data - try the cache first // get resource bundle data - try the cache first
boolean needCacheUpdate = false; boolean needCacheUpdate = false;
Object[] data = (Object[]) cachedLocaleData.get(locale); Object[] data = cachedLocaleData.get(locale);
if (data == null) { /* cache miss */ if (data == null) { /* cache miss */
// When numbering system is thai (Locale's extension contains u-nu-thai),
// we read the data from th_TH_TH.
Locale lookupLocale = locale;
String numberType = locale.getUnicodeLocaleType("nu");
if (numberType != null && numberType.equals("thai")) {
lookupLocale = new Locale("th", "TH", "TH");
}
data = new Object[3]; data = new Object[3];
ResourceBundle rb = LocaleData.getNumberFormatData(locale); ResourceBundle rb = LocaleData.getNumberFormatData(lookupLocale);
data[0] = rb.getStringArray("NumberElements"); data[0] = rb.getStringArray("NumberElements");
needCacheUpdate = true; needCacheUpdate = true;
} }
...@@ -586,7 +593,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { ...@@ -586,7 +593,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
monetarySeparator = decimalSeparator; monetarySeparator = decimalSeparator;
if (needCacheUpdate) { if (needCacheUpdate) {
cachedLocaleData.put(locale, data); cachedLocaleData.putIfAbsent(locale, data);
} }
} }
...@@ -806,7 +813,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { ...@@ -806,7 +813,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
* cache to hold the NumberElements and the Currency * cache to hold the NumberElements and the Currency
* of a Locale. * of a Locale.
*/ */
private static final Hashtable cachedLocaleData = new Hashtable(3); private static final ConcurrentHashMap<Locale, Object[]> cachedLocaleData = new ConcurrentHashMap<Locale, Object[]>(3);
/** /**
* Obtains a DecimalFormatSymbols instance from a DecimalFormatSymbolsProvider * Obtains a DecimalFormatSymbols instance from a DecimalFormatSymbolsProvider
......
...@@ -363,7 +363,7 @@ public class MessageFormat extends Format { ...@@ -363,7 +363,7 @@ public class MessageFormat extends Format {
* @exception IllegalArgumentException if the pattern is invalid * @exception IllegalArgumentException if the pattern is invalid
*/ */
public MessageFormat(String pattern) { public MessageFormat(String pattern) {
this.locale = Locale.getDefault(); this.locale = Locale.getDefault(Locale.Category.FORMAT);
applyPattern(pattern); applyPattern(pattern);
} }
......
...@@ -381,7 +381,7 @@ public abstract class NumberFormat extends Format { ...@@ -381,7 +381,7 @@ public abstract class NumberFormat extends Format {
* {@link #getNumberInstance() getNumberInstance()}. * {@link #getNumberInstance() getNumberInstance()}.
*/ */
public final static NumberFormat getInstance() { public final static NumberFormat getInstance() {
return getInstance(Locale.getDefault(), NUMBERSTYLE); return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE);
} }
/** /**
...@@ -397,7 +397,7 @@ public abstract class NumberFormat extends Format { ...@@ -397,7 +397,7 @@ public abstract class NumberFormat extends Format {
* Returns a general-purpose number format for the current default locale. * Returns a general-purpose number format for the current default locale.
*/ */
public final static NumberFormat getNumberInstance() { public final static NumberFormat getNumberInstance() {
return getInstance(Locale.getDefault(), NUMBERSTYLE); return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE);
} }
/** /**
...@@ -420,7 +420,7 @@ public abstract class NumberFormat extends Format { ...@@ -420,7 +420,7 @@ public abstract class NumberFormat extends Format {
* @since 1.4 * @since 1.4
*/ */
public final static NumberFormat getIntegerInstance() { public final static NumberFormat getIntegerInstance() {
return getInstance(Locale.getDefault(), INTEGERSTYLE); return getInstance(Locale.getDefault(Locale.Category.FORMAT), INTEGERSTYLE);
} }
/** /**
...@@ -443,7 +443,7 @@ public abstract class NumberFormat extends Format { ...@@ -443,7 +443,7 @@ public abstract class NumberFormat extends Format {
* Returns a currency format for the current default locale. * Returns a currency format for the current default locale.
*/ */
public final static NumberFormat getCurrencyInstance() { public final static NumberFormat getCurrencyInstance() {
return getInstance(Locale.getDefault(), CURRENCYSTYLE); return getInstance(Locale.getDefault(Locale.Category.FORMAT), CURRENCYSTYLE);
} }
/** /**
...@@ -457,7 +457,7 @@ public abstract class NumberFormat extends Format { ...@@ -457,7 +457,7 @@ public abstract class NumberFormat extends Format {
* Returns a percentage format for the current default locale. * Returns a percentage format for the current default locale.
*/ */
public final static NumberFormat getPercentInstance() { public final static NumberFormat getPercentInstance() {
return getInstance(Locale.getDefault(), PERCENTSTYLE); return getInstance(Locale.getDefault(Locale.Category.FORMAT), PERCENTSTYLE);
} }
/** /**
...@@ -471,7 +471,7 @@ public abstract class NumberFormat extends Format { ...@@ -471,7 +471,7 @@ public abstract class NumberFormat extends Format {
* Returns a scientific format for the current default locale. * Returns a scientific format for the current default locale.
*/ */
/*public*/ final static NumberFormat getScientificInstance() { /*public*/ final static NumberFormat getScientificInstance() {
return getInstance(Locale.getDefault(), SCIENTIFICSTYLE); return getInstance(Locale.getDefault(Locale.Category.FORMAT), SCIENTIFICSTYLE);
} }
/** /**
......
/* /*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -119,7 +119,7 @@ import sun.util.resources.LocaleData; ...@@ -119,7 +119,7 @@ import sun.util.resources.LocaleData;
* calculating its time or calendar field values if any out-of-range field * calculating its time or calendar field values if any out-of-range field
* value has been set. * value has been set.
* *
* <h4>First Week</h4> * <h4><a name="first_week">First Week</a></h4>
* *
* <code>Calendar</code> defines a locale-specific seven day week using two * <code>Calendar</code> defines a locale-specific seven day week using two
* parameters: the first day of the week and the minimal days in first week * parameters: the first day of the week and the minimal days in first week
...@@ -933,7 +933,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca ...@@ -933,7 +933,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/ */
protected Calendar() protected Calendar()
{ {
this(TimeZone.getDefaultRef(), Locale.getDefault()); this(TimeZone.getDefaultRef(), Locale.getDefault(Locale.Category.FORMAT));
sharedZone = true; sharedZone = true;
} }
...@@ -962,7 +962,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca ...@@ -962,7 +962,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/ */
public static Calendar getInstance() public static Calendar getInstance()
{ {
Calendar cal = createCalendar(TimeZone.getDefaultRef(), Locale.getDefault()); Calendar cal = createCalendar(TimeZone.getDefaultRef(), Locale.getDefault(Locale.Category.FORMAT));
cal.sharedZone = true; cal.sharedZone = true;
return cal; return cal;
} }
...@@ -977,7 +977,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca ...@@ -977,7 +977,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
*/ */
public static Calendar getInstance(TimeZone zone) public static Calendar getInstance(TimeZone zone)
{ {
return createCalendar(zone, Locale.getDefault()); return createCalendar(zone, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -1013,19 +1013,30 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca ...@@ -1013,19 +1013,30 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
private static Calendar createCalendar(TimeZone zone, private static Calendar createCalendar(TimeZone zone,
Locale aLocale) Locale aLocale)
{ {
// If the specified locale is a Thai locale, returns a BuddhistCalendar Calendar cal = null;
// instance.
if ("th".equals(aLocale.getLanguage()) String caltype = aLocale.getUnicodeLocaleType("ca");
&& ("TH".equals(aLocale.getCountry()))) { if (caltype == null) {
return new sun.util.BuddhistCalendar(zone, aLocale); // Calendar type is not specified.
} else if ("JP".equals(aLocale.getVariant()) // If the specified locale is a Thai locale,
&& "JP".equals(aLocale.getCountry()) // returns a BuddhistCalendar instance.
&& "ja".equals(aLocale.getLanguage())) { if ("th".equals(aLocale.getLanguage())
return new JapaneseImperialCalendar(zone, aLocale); && ("TH".equals(aLocale.getCountry()))) {
cal = new BuddhistCalendar(zone, aLocale);
} else {
cal = new GregorianCalendar(zone, aLocale);
}
} else if (caltype.equals("japanese")) {
cal = new JapaneseImperialCalendar(zone, aLocale);
} else if (caltype.equals("buddhist")) {
cal = new BuddhistCalendar(zone, aLocale);
} else {
// Unsupported calendar type.
// Use Gregorian calendar as a fallback.
cal = new GregorianCalendar(zone, aLocale);
} }
// else create the default calendar return cal;
return new GregorianCalendar(zone, aLocale);
} }
/** /**
...@@ -2195,6 +2206,101 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca ...@@ -2195,6 +2206,101 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
return minimalDaysInFirstWeek; return minimalDaysInFirstWeek;
} }
/**
* Returns whether this {@code Calendar} supports week dates.
*
* <p>The default implementation of this method returns {@code false}.
*
* @return {@code true} if this {@code Calendar} supports week dates;
* {@code false} otherwise.
* @see #getWeekYear()
* @see #setWeekDate(int,int,int)
* @see #getWeeksInWeekYear()
* @since 1.7
*/
public boolean isWeekDateSupported() {
return false;
}
/**
* Returns the week year represented by this {@code Calendar}. The
* week year is in sync with the week cycle. The {@linkplain
* #getFirstDayOfWeek() first day of the first week} is the first
* day of the week year.
*
* <p>The default implementation of this method throws an
* {@link UnsupportedOperationException}.
*
* @return the week year of this {@code Calendar}
* @exception UnsupportedOperationException
* if any week year numbering isn't supported
* in this {@code Calendar}.
* @see #isWeekDateSupported()
* @see #getFirstDayOfWeek()
* @see #getMinimalDaysInFirstWeek()
* @since 1.7
*/
public int getWeekYear() {
throw new UnsupportedOperationException();
}
/**
* Sets the date of this {@code Calendar} with the the given date
* specifiers - week year, week of year, and day of week.
*
* <p>Unlike the {@code set} method, all of the calendar fields
* and {@code time} values are calculated upon return.
*
* <p>If {@code weekOfYear} is out of the valid week-of-year range
* in {@code weekYear}, the {@code weekYear} and {@code
* weekOfYear} values are adjusted in lenient mode, or an {@code
* IllegalArgumentException} is thrown in non-lenient mode.
*
* <p>The default implementation of this method throws an
* {@code UnsupportedOperationException}.
*
* @param weekYear the week year
* @param weekOfYear the week number based on {@code weekYear}
* @param dayOfWeek the day of week value: one of the constants
* for the {@link #DAY_OF_WEEK} field: {@link
* #SUNDAY}, ..., {@link #SATURDAY}.
* @exception IllegalArgumentException
* if any of the given date specifiers is invalid
* or any of the calendar fields are inconsistent
* with the given date specifiers in non-lenient mode
* @exception UnsupportedOperationException
* if any week year numbering isn't supported in this
* {@code Calendar}.
* @see #isWeekDateSupported()
* @see #getFirstDayOfWeek()
* @see #getMinimalDaysInFirstWeek()
* @since 1.7
*/
public void setWeekDate(int weekYear, int weekOfYear, int dayOfWeek) {
throw new UnsupportedOperationException();
}
/**
* Returns the number of weeks in the week year represented by this
* {@code Calendar}.
*
* <p>The default implementation of this method throws an
* {@code UnsupportedOperationException}.
*
* @return the number of weeks in the week year.
* @exception UnsupportedOperationException
* if any week year numbering isn't supported in this
* {@code Calendar}.
* @see #WEEK_OF_YEAR
* @see #isWeekDateSupported()
* @see #getWeekYear()
* @see #getActualMaximum(int)
* @since 1.7
*/
public int getWeeksInWeekYear() {
throw new UnsupportedOperationException();
}
/** /**
* Returns the minimum value for the given calendar field of this * Returns the minimum value for the given calendar field of this
* <code>Calendar</code> instance. The minimum value is defined as * <code>Calendar</code> instance. The minimum value is defined as
......
...@@ -452,7 +452,7 @@ public final class Currency implements Serializable { ...@@ -452,7 +452,7 @@ public final class Currency implements Serializable {
* @return the symbol of this currency for the default locale * @return the symbol of this currency for the default locale
*/ */
public String getSymbol() { public String getSymbol() {
return getSymbol(Locale.getDefault()); return getSymbol(Locale.getDefault(Locale.Category.DISPLAY));
} }
/** /**
...@@ -528,7 +528,7 @@ public final class Currency implements Serializable { ...@@ -528,7 +528,7 @@ public final class Currency implements Serializable {
* @since 1.7 * @since 1.7
*/ */
public String getDisplayName() { public String getDisplayName() {
return getDisplayName(Locale.getDefault()); return getDisplayName(Locale.getDefault(Locale.Category.DISPLAY));
} }
/** /**
......
...@@ -1866,7 +1866,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -1866,7 +1866,7 @@ public final class Formatter implements Closeable, Flushable {
* virtual machine. * virtual machine.
*/ */
public Formatter() { public Formatter() {
init(new StringBuilder(), Locale.getDefault()); init(new StringBuilder(), Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -1882,7 +1882,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -1882,7 +1882,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(Appendable a) { public Formatter(Appendable a) {
if (a == null) if (a == null)
a = new StringBuilder(); a = new StringBuilder();
init(a, Locale.getDefault()); init(a, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -1949,7 +1949,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -1949,7 +1949,7 @@ public final class Formatter implements Closeable, Flushable {
*/ */
public Formatter(String fileName) throws FileNotFoundException { public Formatter(String fileName) throws FileNotFoundException {
init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName))), init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName))),
Locale.getDefault()); Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -1985,7 +1985,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -1985,7 +1985,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(String fileName, String csn) public Formatter(String fileName, String csn)
throws FileNotFoundException, UnsupportedEncodingException throws FileNotFoundException, UnsupportedEncodingException
{ {
this(fileName, csn, Locale.getDefault()); this(fileName, csn, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -2057,7 +2057,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -2057,7 +2057,7 @@ public final class Formatter implements Closeable, Flushable {
*/ */
public Formatter(File file) throws FileNotFoundException { public Formatter(File file) throws FileNotFoundException {
init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))), init(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))),
Locale.getDefault()); Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -2093,7 +2093,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -2093,7 +2093,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(File file, String csn) public Formatter(File file, String csn)
throws FileNotFoundException, UnsupportedEncodingException throws FileNotFoundException, UnsupportedEncodingException
{ {
this(file, csn, Locale.getDefault()); this(file, csn, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -2152,7 +2152,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -2152,7 +2152,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(PrintStream ps) { public Formatter(PrintStream ps) {
if (ps == null) if (ps == null)
throw new NullPointerException(); throw new NullPointerException();
init((Appendable)ps, Locale.getDefault()); init((Appendable)ps, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -2171,7 +2171,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -2171,7 +2171,7 @@ public final class Formatter implements Closeable, Flushable {
*/ */
public Formatter(OutputStream os) { public Formatter(OutputStream os) {
init(new BufferedWriter(new OutputStreamWriter(os)), init(new BufferedWriter(new OutputStreamWriter(os)),
Locale.getDefault()); Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -2195,7 +2195,7 @@ public final class Formatter implements Closeable, Flushable { ...@@ -2195,7 +2195,7 @@ public final class Formatter implements Closeable, Flushable {
public Formatter(OutputStream os, String csn) public Formatter(OutputStream os, String csn)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
this(os, csn, Locale.getDefault()); this(os, csn, Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
......
/*
* Copyright (c) 2010, 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.
*/
/*
*******************************************************************************
* Copyright (C) 2009-2010, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package java.util;
/**
* Thrown by methods in {@link Locale} and {@link Locale.Builder} to
* indicate that an argument is not a well-formed BCP 47 tag.
*
* @see Locale
* @since 1.7
*/
public class IllformedLocaleException extends RuntimeException {
private static final long serialVersionUID = -5245986824925681401L;
private int _errIdx = -1;
/**
* Constructs a new <code>IllformedLocaleException</code> with no
* detail message and -1 as the error index.
*/
public IllformedLocaleException() {
super();
}
/**
* Constructs a new <code>IllformedLocaleException</code> with the
* given message and -1 as the error index.
*
* @param message the message
*/
public IllformedLocaleException(String message) {
super(message);
}
/**
* Constructs a new <code>IllformedLocaleException</code> with the
* given message and the error index. The error index is the approximate
* offset from the start of the ill-formed value to the point where the
* parse first detected an error. A negative error index value indicates
* either the error index is not applicable or unknown.
*
* @param message the message
* @param errorIndex the index
*/
public IllformedLocaleException(String message, int errorIndex) {
super(message + ((errorIndex < 0) ? "" : " [at index " + errorIndex + "]"));
_errIdx = errorIndex;
}
/**
* Returns the index where the error was found. A negative value indicates
* either the error index is not applicable or unknown.
*
* @return the error index
*/
public int getErrorIndex() {
return _errIdx;
}
}
...@@ -582,7 +582,7 @@ public final class Scanner implements Iterator<String>, Closeable { ...@@ -582,7 +582,7 @@ public final class Scanner implements Iterator<String>, Closeable {
matcher = delimPattern.matcher(buf); matcher = delimPattern.matcher(buf);
matcher.useTransparentBounds(true); matcher.useTransparentBounds(true);
matcher.useAnchoringBounds(false); matcher.useAnchoringBounds(false);
useLocale(Locale.getDefault()); useLocale(Locale.getDefault(Locale.Category.FORMAT));
} }
/** /**
...@@ -2642,7 +2642,7 @@ public final class Scanner implements Iterator<String>, Closeable { ...@@ -2642,7 +2642,7 @@ public final class Scanner implements Iterator<String>, Closeable {
*/ */
public Scanner reset() { public Scanner reset() {
delimPattern = WHITESPACE_PATTERN; delimPattern = WHITESPACE_PATTERN;
useLocale(Locale.getDefault()); useLocale(Locale.getDefault(Locale.Category.FORMAT));
useRadix(10); useRadix(10);
clearCaches(); clearCaches();
return this; return this;
......
...@@ -312,7 +312,7 @@ abstract public class TimeZone implements Serializable, Cloneable { ...@@ -312,7 +312,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @since 1.2 * @since 1.2
*/ */
public final String getDisplayName() { public final String getDisplayName() {
return getDisplayName(false, LONG, Locale.getDefault()); return getDisplayName(false, LONG, Locale.getDefault(Locale.Category.DISPLAY));
} }
/** /**
...@@ -342,7 +342,7 @@ abstract public class TimeZone implements Serializable, Cloneable { ...@@ -342,7 +342,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
* @since 1.2 * @since 1.2
*/ */
public final String getDisplayName(boolean daylight, int style) { public final String getDisplayName(boolean daylight, int style) {
return getDisplayName(daylight, style, Locale.getDefault()); return getDisplayName(daylight, style, Locale.getDefault(Locale.Category.DISPLAY));
} }
/** /**
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -44,22 +44,23 @@ public abstract class LocaleNameProvider extends LocaleServiceProvider { ...@@ -44,22 +44,23 @@ public abstract class LocaleNameProvider extends LocaleServiceProvider {
} }
/** /**
* Returns a localized name for the given ISO 639 language code and the * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
* given locale that is appropriate for display to the user. * IETF BCP47</a> language code and the given locale that is appropriate for
* display to the user.
* For example, if <code>languageCode</code> is "fr" and <code>locale</code> * For example, if <code>languageCode</code> is "fr" and <code>locale</code>
* is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code> * is en_US, getDisplayLanguage() will return "French"; if <code>languageCode</code>
* is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais". * is "en" and <code>locale</code> is fr_FR, getDisplayLanguage() will return "anglais".
* If the name returned cannot be localized according to <code>locale</code>, * If the name returned cannot be localized according to <code>locale</code>,
* (say, the provider does not have a Japanese name for Croatian), * (say, the provider does not have a Japanese name for Croatian),
* this method returns null. * this method returns null.
* @param languageCode the ISO 639 language code string in the form of two * @param languageCode the language code string in the form of two to eight
* lower-case letters between 'a' (U+0061) and 'z' (U+007A) * lower-case letters between 'a' (U+0061) and 'z' (U+007A)
* @param locale the desired locale * @param locale the desired locale
* @return the name of the given language code for the specified locale, or null if it's not * @return the name of the given language code for the specified locale, or null if it's not
* available. * available.
* @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null * @exception NullPointerException if <code>languageCode</code> or <code>locale</code> is null
* @exception IllegalArgumentException if <code>languageCode</code> is not in the form of * @exception IllegalArgumentException if <code>languageCode</code> is not in the form of
* two lower-case letters, or <code>locale</code> isn't * two or three lower-case letters, or <code>locale</code> isn't
* one of the locales returned from * one of the locales returned from
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
* getAvailableLocales()}. * getAvailableLocales()}.
...@@ -68,22 +69,52 @@ public abstract class LocaleNameProvider extends LocaleServiceProvider { ...@@ -68,22 +69,52 @@ public abstract class LocaleNameProvider extends LocaleServiceProvider {
public abstract String getDisplayLanguage(String languageCode, Locale locale); public abstract String getDisplayLanguage(String languageCode, Locale locale);
/** /**
* Returns a localized name for the given ISO 3166 country code and the * Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
* given locale that is appropriate for display to the user. * IETF BCP47</a> script code and the given locale that is appropriate for
* display to the user.
* For example, if <code>scriptCode</code> is "Latn" and <code>locale</code>
* is en_US, getDisplayScript() will return "Latin"; if <code>scriptCode</code>
* is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique".
* If the name returned cannot be localized according to <code>locale</code>,
* (say, the provider does not have a Japanese name for Cyrillic),
* this method returns null.
* @param scriptCode the four letter script code string in the form of title-case
* letters (the first letter is upper-case character between 'A' (U+0041) and
* 'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
* and 'z' (U+007A)).
* @param locale the desired locale
* @return the name of the given script code for the specified locale, or null if it's not
* available.
* @exception NullPointerException if <code>scriptCode</code> or <code>locale</code> is null
* @exception IllegalArgumentException if <code>scriptCode</code> is not in the form of
* four title case letters, or <code>locale</code> isn't
* one of the locales returned from
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
* getAvailableLocales()}.
* @see java.util.Locale#getDisplayScript(java.util.Locale)
* @since 1.7
*/
public abstract String getDisplayScript(String scriptCode, Locale locale);
/**
* Returns a localized name for the given <a href="http://www.rfc-editor.org/rfc/bcp/bcp47.txt">
* IETF BCP47</a> region code (either ISO 3166 country code or UN M.49 area
* codes) and the given locale that is appropriate for display to the user.
* For example, if <code>countryCode</code> is "FR" and <code>locale</code> * For example, if <code>countryCode</code> is "FR" and <code>locale</code>
* is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code> * is en_US, getDisplayCountry() will return "France"; if <code>countryCode</code>
* is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis". * is "US" and <code>locale</code> is fr_FR, getDisplayCountry() will return "Etats-Unis".
* If the name returned cannot be localized according to <code>locale</code>, * If the name returned cannot be localized according to <code>locale</code>,
* (say, the provider does not have a Japanese name for Croatia), * (say, the provider does not have a Japanese name for Croatia),
* this method returns null. * this method returns null.
* @param countryCode the ISO 3166 country code string in the form of two * @param countryCode the country(region) code string in the form of two
* upper-case letters between 'A' (U+0041) and 'Z' (U+005A) * upper-case letters between 'A' (U+0041) and 'Z' (U+005A) or the UN M.49 area code
* in the form of three digit letters between '0' (U+0030) and '9' (U+0039).
* @param locale the desired locale * @param locale the desired locale
* @return the name of the given country code for the specified locale, or null if it's not * @return the name of the given country code for the specified locale, or null if it's not
* available. * available.
* @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null * @exception NullPointerException if <code>countryCode</code> or <code>locale</code> is null
* @exception IllegalArgumentException if <code>countryCode</code> is not in the form of * @exception IllegalArgumentException if <code>countryCode</code> is not in the form of
* two upper-case letters, or <code>locale</code> isn't * two upper-case letters or three digit letters, or <code>locale</code> isn't
* one of the locales returned from * one of the locales returned from
* {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales()
* getAvailableLocales()}. * getAvailableLocales()}.
......
...@@ -86,18 +86,19 @@ import java.util.Locale; ...@@ -86,18 +86,19 @@ import java.util.Locale;
* Otherwise, they call the <code>getAvailableLocales()</code> methods of * Otherwise, they call the <code>getAvailableLocales()</code> methods of
* installed providers for the appropriate interface to find one that * installed providers for the appropriate interface to find one that
* supports the requested locale. If such a provider is found, its other * supports the requested locale. If such a provider is found, its other
* methods are called to obtain the requested object or name. If neither * methods are called to obtain the requested object or name. When checking
* the Java runtime environment itself nor an installed provider supports * whether a locale is supported, the locale's extensions are ignored.
* the requested locale, a fallback locale is constructed by replacing the * If neither the Java runtime environment itself nor an installed provider
* first of the variant, country, or language strings of the locale that's * supports the requested locale, the methods go through a list of candidate
* not an empty string with an empty string, and the lookup process is * locales and repeat the availability check for each until a match is found.
* restarted. In the case that the variant contains one or more '_'s, the * The algorithm used for creating a list of candidate locales is same as
* fallback locale is constructed by replacing the variant with a new variant * the one used by <code>ResourceBunlde</code> by default (see
* which eliminates the last '_' and the part following it. Even if a * {@link java.util.ResourceBundle.Control#getCandidateLocales getCandidateLocales}
* fallback occurs, methods that return requested objects or name are * for the details). Even if a locale is resolved from the candidate list,
* invoked with the original locale before the fallback.The Java runtime * methods that return requested objects or names are invoked with the original
* environment must support the root locale for all locale sensitive services * requested locale including extensions. The Java runtime environment must
* in order to guarantee that this process terminates. * support the root locale for all locale sensitive services in order to
* guarantee that this process terminates.
* <p> * <p>
* Providers of names (but not providers of other objects) are allowed to * Providers of names (but not providers of other objects) are allowed to
* return null for some name requests even for locales that they claim to * return null for some name requests even for locales that they claim to
...@@ -124,6 +125,11 @@ public abstract class LocaleServiceProvider { ...@@ -124,6 +125,11 @@ public abstract class LocaleServiceProvider {
/** /**
* Returns an array of all locales for which this locale service provider * Returns an array of all locales for which this locale service provider
* can provide localized objects or names. * can provide localized objects or names.
* <p>
* <b>Note:</b> Extensions in a <code>Locale</code> are ignored during
* service provider lookup. So the array returned by this method should
* not include two or more <code>Locale</code> objects only differing in
* their extensions.
* *
* @return An array of all locales for which this locale service provider * @return An array of all locales for which this locale service provider
* can provide localized objects or names. * can provide localized objects or names.
......
...@@ -204,6 +204,9 @@ public interface MidiDevice extends AutoCloseable { ...@@ -204,6 +204,9 @@ public interface MidiDevice extends AutoCloseable {
* MIDI data. The returned receiver must be closed when the application * MIDI data. The returned receiver must be closed when the application
* has finished using it. * has finished using it.
* *
* <p>Usually the returned receiver implements
* the {@code MidiDeviceReceiver} interface.
*
* <p>Obtaining a <code>Receiver</code> with this method does not * <p>Obtaining a <code>Receiver</code> with this method does not
* open the device. To be able to use the device, it has to be * open the device. To be able to use the device, it has to be
* opened explicitly by calling {@link #open}. Also, closing the * opened explicitly by calling {@link #open}. Also, closing the
...@@ -223,6 +226,10 @@ public interface MidiDevice extends AutoCloseable { ...@@ -223,6 +226,10 @@ public interface MidiDevice extends AutoCloseable {
* connected with this MidiDevice. * connected with this MidiDevice.
* A receiver can be removed * A receiver can be removed
* from the device by closing it. * from the device by closing it.
*
* <p>Usually the returned receivers implement
* the {@code MidiDeviceReceiver} interface.
*
* @return an unmodifiable list of the open receivers * @return an unmodifiable list of the open receivers
* @since 1.5 * @since 1.5
*/ */
...@@ -234,6 +241,9 @@ public interface MidiDevice extends AutoCloseable { ...@@ -234,6 +241,9 @@ public interface MidiDevice extends AutoCloseable {
* MIDI data The returned transmitter must be closed when the application * MIDI data The returned transmitter must be closed when the application
* has finished using it. * has finished using it.
* *
* <p>Usually the returned transmitter implements
* the {@code MidiDeviceTransmitter} interface.
*
* <p>Obtaining a <code>Transmitter</code> with this method does not * <p>Obtaining a <code>Transmitter</code> with this method does not
* open the device. To be able to use the device, it has to be * open the device. To be able to use the device, it has to be
* opened explicitly by calling {@link #open}. Also, closing the * opened explicitly by calling {@link #open}. Also, closing the
...@@ -253,6 +263,10 @@ public interface MidiDevice extends AutoCloseable { ...@@ -253,6 +263,10 @@ public interface MidiDevice extends AutoCloseable {
* connected with this MidiDevice. * connected with this MidiDevice.
* A transmitter can be removed * A transmitter can be removed
* from the device by closing it. * from the device by closing it.
*
* <p>Usually the returned transmitters implement
* the {@code MidiDeviceTransmitter} interface.
*
* @return an unmodifiable list of the open transmitters * @return an unmodifiable list of the open transmitters
* @since 1.5 * @since 1.5
*/ */
......
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -22,20 +22,18 @@ ...@@ -22,20 +22,18 @@
* or visit www.oracle.com if you need additional information or have any * or visit www.oracle.com if you need additional information or have any
* questions. * questions.
*/ */
package com.sun.media.sound;
import javax.sound.midi.MidiDevice; package javax.sound.midi;
import javax.sound.midi.Receiver;
/** /**
* A Receiver with reference to it's MidiDevice object. * <p>{@code MidiDeviceReceiver} is a {@code Receiver} which represents
* a MIDI input connector of a {@code MidiDevice}
* (see {@link MidiDevice#getReceiver()}).
* *
* @author Karl Helgason * @since 1.7
*/ */
public interface MidiDeviceReceiver extends Receiver { public interface MidiDeviceReceiver extends Receiver {
/** Obtains a MidiDevice object which is an owner of this Receiver.
/** Obtains the MidiDevice object associated with this Receiver.
*/ */
public MidiDevice getMidiDevice(); public MidiDevice getMidiDevice();
} }
...@@ -27,13 +27,11 @@ package javax.swing; ...@@ -27,13 +27,11 @@ package javax.swing;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.beans.*;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import javax.swing.colorchooser.*; import javax.swing.colorchooser.*;
import javax.swing.plaf.ColorChooserUI; import javax.swing.plaf.ColorChooserUI;
import javax.swing.event.*;
import javax.accessibility.*; import javax.accessibility.*;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
...@@ -95,7 +93,7 @@ public class JColorChooser extends JComponent implements Accessible { ...@@ -95,7 +93,7 @@ public class JColorChooser extends JComponent implements Accessible {
private ColorSelectionModel selectionModel; private ColorSelectionModel selectionModel;
private JComponent previewPanel; private JComponent previewPanel = ColorChooserComponentFactory.getPreviewPanel();
private AbstractColorChooserPanel[] chooserPanels = new AbstractColorChooserPanel[0]; private AbstractColorChooserPanel[] chooserPanels = new AbstractColorChooserPanel[0];
......
/* /*
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -914,6 +914,7 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI ...@@ -914,6 +914,7 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
UIResource { UIResource {
public SynthScrollableTabButton(int direction) { public SynthScrollableTabButton(int direction) {
super(direction); super(direction);
setName("TabbedPane.button");
} }
} }
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册