OpenJDK / portola / portola
changeset 6548:382d78ea38b0
Merge
author | lana |
---|---|
date | Fri, 24 Sep 2010 16:41:32 -0700 |
parents | 14db87faa6a7 8dc9b6a31bbc |
children | c185fa717e00 |
files | jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiver.java jdk/src/share/native/sun/java2d/cmm/lcms/cmscam97.c jdk/src/share/native/sun/java2d/cmm/lcms/cmsmatsh.c jdk/src/share/native/sun/java2d/cmm/lcms/icc34.h jdk/src/share/native/sun/java2d/cmm/lcms/lcms.h jdk/src/solaris/classes/sun/net/spi/SdpProvider.java jdk/src/solaris/native/sun/net/spi/SdpProvider.c jdk/test/java/util/Locale/data/deflocale.exe jdk/test/java/util/Locale/data/deflocale.jds3 jdk/test/java/util/Locale/data/deflocale.rhel4 jdk/test/java/util/Locale/data/deflocale.winvista jdk/test/java/util/Locale/data/deflocale.winxp jdk/test/tools/launcher/VerifyExceptions.java |
diffstat | 319 files changed, 60639 insertions(+), 33169 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/make/com/Makefile Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/com/Makefile Fri Sep 24 16:41:32 2010 -0700 @@ -31,7 +31,7 @@ PRODUCT = com include $(BUILDDIR)/common/Defs.gmk -SUBDIRS = sun +SUBDIRS = sun oracle include $(BUILDDIR)/common/Subdirs.gmk all build clean clobber::
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/make/com/oracle/Makefile Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,34 @@ +# +# 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. +# + +BUILDDIR = ../.. +PRODUCT = oracle +include $(BUILDDIR)/common/Defs.gmk + +SUBDIRS = net +include $(BUILDDIR)/common/Subdirs.gmk + +all build clean clobber:: + $(SUBDIRS-loop)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/make/com/oracle/net/Makefile Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,39 @@ +# +# 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. +# + +BUILDDIR = ../../.. +PRODUCT = oracle +include $(BUILDDIR)/common/Defs.gmk + +# +# Files to compile +# +AUTO_FILES_JAVA_DIRS = com/oracle/net + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk +
--- a/jdk/make/common/Release.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/common/Release.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -573,13 +573,13 @@ $(ECHO) "sun/jvmstat/" >> $@ $(ECHO) "sun/nio/cs/ext/" >> $@ $(ECHO) "sun/awt/HKSCS.class" >> $@ - $(ECHO) "sun/awt/motif/X11GB2312$Decoder.class" >> $@ - $(ECHO) "sun/awt/motif/X11GB2312$Encoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11GB2312\$$Decoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11GB2312\$$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11GB2312.class" >> $@ - $(ECHO) "sun/awt/motif/X11GBK$Encoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11GBK\$$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11GBK.class" >> $@ - $(ECHO) "sun/awt/motif/X11KSC5601$Decoder.class" >> $@ - $(ECHO) "sun/awt/motif/X11KSC5601$Encoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11KSC5601\$$Decoder.class" >> $@ + $(ECHO) "sun/awt/motif/X11KSC5601\$$Encoder.class" >> $@ $(ECHO) "sun/awt/motif/X11KSC5601.class" >> $@ $(ECHO) "sun/rmi/rmic/" >> $@ $(ECHO) "sun/tools/asm/" >> $@
--- a/jdk/make/docs/NON_CORE_PKGS.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/docs/NON_CORE_PKGS.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -91,6 +91,8 @@ TRACING_PKGS = com.sun.tracing \ com.sun.tracing.dtrace +ORACLENET_PKGS = com.oracle.net + # non-core packages in rt.jar NON_CORE_PKGS = $(DOMAPI_PKGS) \ $(MGMT_PKGS) \ @@ -101,5 +103,6 @@ $(HTTPSERVER_PKGS) \ $(SMARTCARDIO_PKGS) \ $(TRACING_PKGS) \ - $(SCTPAPI_PKGS) + $(SCTPAPI_PKGS) \ + $(ORACLENET_PKGS)
--- a/jdk/make/java/java/FILES_java.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/java/FILES_java.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -183,10 +183,22 @@ java/util/MissingFormatWidthException.java \ java/util/UnknownFormatConversionException.java \ java/util/UnknownFormatFlagsException.java \ + java/util/IllformedLocaleException.java \ java/util/FormatterClosedException.java \ java/util/ListResourceBundle.java \ sun/util/EmptyListResourceBundle.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 \ sun/util/LocaleServiceProviderPool.java \ sun/util/LocaleDataMetaInfo.java \
--- a/jdk/make/java/net/FILES_c.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/net/FILES_c.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -39,10 +39,6 @@ ResolverConfigurationImpl.c \ DefaultProxySelector.c -ifeq ($(PLATFORM), solaris) - FILES_c += SdpProvider.c -endif - ifeq ($(PLATFORM), linux) FILES_c += linux_close.c endif
--- a/jdk/make/java/net/Makefile Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/net/Makefile Fri Sep 24 16:41:32 2010 -0700 @@ -44,6 +44,8 @@ endif FILES_c += NTLMAuthSequence.c FILES_c += NetworkInterface_winXP.c +else + FILES_c += SdpSupport.c endif FILES_export = \ @@ -84,7 +86,8 @@ # # Find platform specific native code # -vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http/ntlm $(PLATFORM_SRC)/native/sun/net/spi +vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http/ntlm \ + $(PLATFORM_SRC)/native/sun/net/sdp $(PLATFORM_SRC)/native/sun/net/spi # # Include rules
--- a/jdk/make/java/net/mapfile-vers Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/net/mapfile-vers Fri Sep 24 16:41:32 2010 -0700 @@ -88,9 +88,10 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive; Java_sun_net_dns_ResolverConfigurationImpl_localDomain0; Java_sun_net_dns_ResolverConfigurationImpl_fallbackDomain0; + Java_sun_net_sdp_SdpSupport_convert0; + Java_sun_net_sdp_SdpSupport_create0; Java_sun_net_spi_DefaultProxySelector_init; Java_sun_net_spi_DefaultProxySelector_getSystemProxy; - Java_sun_net_spi_SdpProvider_convert; NET_AllocSockaddr; NET_SockaddrToInetAddress; NET_SockaddrEqualsInetAddress;
--- a/jdk/make/java/nio/FILES_java.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/nio/FILES_java.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -83,6 +83,7 @@ java/nio/file/ClosedFileSystemException.java \ java/nio/file/ClosedWatchServiceException.java \ java/nio/file/CopyOption.java \ + java/nio/file/DirectoryIteratorException.java \ java/nio/file/DirectoryNotEmptyException.java \ java/nio/file/DirectoryStream.java \ java/nio/file/FileAlreadyExistsException.java \ @@ -199,6 +200,7 @@ sun/nio/ch/PipeImpl.java \ sun/nio/ch/PollArrayWrapper.java \ sun/nio/ch/Reflect.java \ + sun/nio/ch/Secrets.java \ sun/nio/ch/SelectionKeyImpl.java \ sun/nio/ch/SelectorImpl.java \ sun/nio/ch/SelectorProviderImpl.java \
--- a/jdk/make/java/nio/mapfile-linux Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/nio/mapfile-linux Fri Sep 24 16:41:32 2010 -0700 @@ -89,7 +89,7 @@ Java_sun_nio_ch_IOUtil_drain; Java_sun_nio_ch_IOUtil_fdVal; Java_sun_nio_ch_IOUtil_initIDs; - Java_sun_nio_ch_IOUtil_initPipe; + Java_sun_nio_ch_IOUtil_makePipe; Java_sun_nio_ch_IOUtil_randomBytes; Java_sun_nio_ch_IOUtil_setfdVal; Java_sun_nio_ch_NativeThread_current;
--- a/jdk/make/java/nio/mapfile-solaris Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/nio/mapfile-solaris Fri Sep 24 16:41:32 2010 -0700 @@ -76,7 +76,7 @@ Java_sun_nio_ch_IOUtil_drain; Java_sun_nio_ch_IOUtil_fdVal; Java_sun_nio_ch_IOUtil_initIDs; - Java_sun_nio_ch_IOUtil_initPipe; + Java_sun_nio_ch_IOUtil_makePipe; Java_sun_nio_ch_IOUtil_randomBytes; Java_sun_nio_ch_IOUtil_setfdVal; Java_sun_nio_ch_NativeThread_current;
--- a/jdk/make/java/text/base/FILES_java.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/java/text/base/FILES_java.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ # -# 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. # # This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ java/text/AttributedString.java \ java/text/BreakDictionary.java \ java/text/BreakIterator.java \ + java/text/CalendarBuilder.java \ java/text/CharacterIterator.java \ java/text/CharacterIteratorFieldDelegate.java \ java/text/ChoiceFormat.java \
--- a/jdk/make/sun/cmm/lcms/FILES_c_unix.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/sun/cmm/lcms/FILES_c_unix.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -25,7 +25,6 @@ FILES_c = \ cmscam02.c \ - cmscam97.c \ cmscgats.c \ cmscnvrt.c \ cmserr.c \ @@ -35,13 +34,17 @@ cmsio0.c \ cmsio1.c \ cmslut.c \ - cmsmatsh.c \ + cmsmd5.c \ cmsmtrx.c \ cmsnamed.c \ + cmsopt.c \ cmspack.c \ cmspcs.c \ + cmsplugin.c \ cmsps2.c \ cmssamp.c \ + cmssm.c \ + cmstypes.c \ cmsvirt.c \ cmswtpnt.c \ cmsxform.c \
--- a/jdk/make/sun/cmm/lcms/FILES_c_windows.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/sun/cmm/lcms/FILES_c_windows.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -25,7 +25,6 @@ FILES_c = \ cmscam02.c \ - cmscam97.c \ cmscgats.c \ cmscnvrt.c \ cmserr.c \ @@ -35,13 +34,17 @@ cmsio0.c \ cmsio1.c \ cmslut.c \ - cmsmatsh.c \ + cmsmd5.c \ cmsmtrx.c \ cmsnamed.c \ + cmsopt.c \ cmspack.c \ cmspcs.c \ + cmsplugin.c \ cmsps2.c \ cmssamp.c \ + cmssm.c \ + cmstypes.c \ cmsvirt.c \ cmswtpnt.c \ cmsxform.c \
--- a/jdk/make/sun/cmm/lcms/Makefile Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/sun/cmm/lcms/Makefile Fri Sep 24 16:41:32 2010 -0700 @@ -80,8 +80,8 @@ vpath %.c $(SHARE_SRC)/native/sun/java2d ifeq ($(PLATFORM), windows) - -OTHER_LDLIBS = user32.lib version.lib $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib +OTHER_CFLAGS += -DCMS_IS_WINDOWS_ -Dsqrtf=sqrt +OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \ -I$(SHARE_SRC)/native/sun/awt/debug
--- a/jdk/make/sun/net/FILES_java.gmk Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/make/sun/net/FILES_java.gmk Fri Sep 24 16:41:32 2010 -0700 @@ -53,6 +53,7 @@ sun/net/ftp/FtpProtocolException.java \ sun/net/ftp/impl/FtpClient.java \ sun/net/ftp/impl/DefaultFtpClientProvider.java \ + sun/net/sdp/SdpSupport.java \ sun/net/spi/DefaultProxySelector.java \ sun/net/spi/nameservice/NameServiceDescriptor.java \ sun/net/spi/nameservice/NameService.java \ @@ -136,8 +137,6 @@ ifeq ($(PLATFORM), windows) FILES_java += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java +else + FILES_java += sun/net/sdp/SdpProvider.java endif - -ifeq ($(PLATFORM), solaris) - FILES_java += sun/net/spi/SdpProvider.java -endif
--- a/jdk/src/share/bin/java.c Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/bin/java.c Fri Sep 24 16:41:32 2010 -0700 @@ -712,19 +712,19 @@ struct stat statbuf; /* return if jre/lib/rt.jar exists */ - sprintf(pathname, "%s%slib%srt.jar", jrepath, separator, separator); + JLI_Snprintf(pathname, sizeof(pathname), "%s%slib%srt.jar", jrepath, separator, separator); if (stat(pathname, &statbuf) == 0) { return; } /* return if jre/classes exists */ - sprintf(pathname, "%s%sclasses", jrepath, separator); + JLI_Snprintf(pathname, sizeof(pathname), "%s%sclasses", jrepath, separator); if (stat(pathname, &statbuf) == 0) { return; } /* modularized jre */ - sprintf(pathname, "%s%slib%s*", jrepath, separator, separator); + JLI_Snprintf(pathname, sizeof(pathname), "%s%slib%s*", jrepath, separator, separator); s = (char *) JLI_WildcardExpandClasspath(pathname); def = JLI_MemAlloc(sizeof(format) - 2 /* strlen("%s") */ @@ -1624,11 +1624,8 @@ if (JLI_IsTraceLauncher()) { start = CounterGet(); } - - JLI_StrCpy(jvmCfgName, jrepath); - JLI_StrCat(jvmCfgName, FILESEP "lib" FILESEP); - JLI_StrCat(jvmCfgName, arch); - JLI_StrCat(jvmCfgName, FILESEP "jvm.cfg"); + JLI_Snprintf(jvmCfgName, sizeof(jvmCfgName), "%s%slib%s%s%sjvm.cfg", + jrepath, FILESEP, FILESEP, arch, FILESEP); jvmCfg = fopen(jvmCfgName, "r"); if (jvmCfg == NULL) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/oracle/net/Sdp.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,201 @@ +/* + * 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.oracle.net; + +import java.net.Socket; +import java.net.ServerSocket; +import java.net.SocketImpl; +import java.net.SocketImplFactory; +import java.net.SocketException; +import java.nio.channels.SocketChannel; +import java.nio.channels.ServerSocketChannel; +import java.io.IOException; +import java.io.FileDescriptor; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.lang.reflect.Constructor; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.InvocationTargetException; + +import sun.net.sdp.SdpSupport; + +/** + * This class consists exclusively of static methods that Sockets or Channels to + * sockets that support the InfiniBand Sockets Direct Protocol (SDP). + */ + +public final class Sdp { + private Sdp() { } + + /** + * The package-privage ServerSocket(SocketImpl) constructor + */ + private static final Constructor<ServerSocket> serverSocketCtor; + static { + try { + serverSocketCtor = (Constructor<ServerSocket>) + ServerSocket.class.getDeclaredConstructor(SocketImpl.class); + setAccessible(serverSocketCtor); + } catch (NoSuchMethodException e) { + throw new AssertionError(e); + } + } + + /** + * The package-private SdpSocketImpl() constructor + */ + private static final Constructor<SocketImpl> socketImplCtor; + static { + try { + Class<?> cl = Class.forName("java.net.SdpSocketImpl", true, null); + socketImplCtor = (Constructor<SocketImpl>)cl.getDeclaredConstructor(); + setAccessible(socketImplCtor); + } catch (ClassNotFoundException e) { + throw new AssertionError(e); + } catch (NoSuchMethodException e) { + throw new AssertionError(e); + } + } + + private static void setAccessible(final AccessibleObject o) { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { + o.setAccessible(true); + return null; + } + }); + } + + /** + * SDP enabled Socket. + */ + private static class SdpSocket extends Socket { + SdpSocket(SocketImpl impl) throws SocketException { + super(impl); + } + } + + /** + * Creates a SDP enabled SocketImpl + */ + private static SocketImpl createSocketImpl() { + try { + return socketImplCtor.newInstance(); + } catch (InstantiationException x) { + throw new AssertionError(x); + } catch (IllegalAccessException x) { + throw new AssertionError(x); + } catch (InvocationTargetException x) { + throw new AssertionError(x); + } + } + + /** + * Creates an unconnected and unbound SDP socket. The {@code Socket} is + * associated with a {@link java.net.SocketImpl} of the system-default type. + * + * @return a new Socket + * + * @throws UnsupportedOperationException + * If SDP is not supported + * @throws IOException + * If an I/O error occurs + */ + public static Socket openSocket() throws IOException { + SocketImpl impl = createSocketImpl(); + return new SdpSocket(impl); + } + + /** + * Creates an unbound SDP server socket. The {@code ServerSocket} is + * associated with a {@link java.net.SocketImpl} of the system-default type. + * + * @return a new ServerSocket + * + * @throws UnsupportedOperationException + * If SDP is not supported + * @throws IOException + * If an I/O error occurs + */ + public static ServerSocket openServerSocket() throws IOException { + // create ServerSocket via package-private constructor + SocketImpl impl = createSocketImpl(); + try { + return serverSocketCtor.newInstance(impl); + } catch (IllegalAccessException x) { + throw new AssertionError(x); + } catch (InstantiationException x) { + throw new AssertionError(x); + } catch (InvocationTargetException x) { + Throwable cause = x.getCause(); + if (cause instanceof IOException) + throw (IOException)cause; + if (cause instanceof RuntimeException) + throw (RuntimeException)cause; + throw new RuntimeException(x); + } + } + + /** + * Opens a socket channel to a SDP socket. + * + * <p> The channel will be associated with the system-wide default + * {@link java.nio.channels.spi.SelectorProvider SelectorProvider}. + * + * @return a new SocketChannel + * + * @throws UnsupportedOperationException + * If SDP is not supported or not supported by the default selector + * provider + * @throws IOException + * If an I/O error occurs. + */ + public static SocketChannel openSocketChannel() throws IOException { + FileDescriptor fd = SdpSupport.createSocket(); + return sun.nio.ch.Secrets.newSocketChannel(fd); + } + + /** + * Opens a socket channel to a SDP socket. + * + * <p> The channel will be associated with the system-wide default + * {@link java.nio.channels.spi.SelectorProvider SelectorProvider}. + * + * @return a new ServerSocketChannel + * + * @throws UnsupportedOperationException + * If SDP is not supported or not supported by the default selector + * provider + * @throws IOException + * If an I/O error occurs + */ + public static ServerSocketChannel openServerSocketChannel() + throws IOException + { + FileDescriptor fd = SdpSupport.createSocket(); + return sun.nio.ch.Secrets.newServerSocketChannel(fd); + } +}
--- a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -31,13 +31,14 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.concurrent.Callable; +import java.applet.Applet; import java.awt.AWTEvent; import java.awt.EventQueue; import java.awt.Component; import java.awt.Container; +import java.awt.Window; import javax.swing.JComponent; import javax.swing.RepaintManager; -import javax.swing.SwingUtilities; /** * A collection of utility methods for Swing. @@ -91,7 +92,7 @@ */ public static void setVsyncRequested(Container rootContainer, boolean isRequested) { - assert SwingUtilities.getRoot(rootContainer) == rootContainer; + assert (rootContainer instanceof Applet) || (rootContainer instanceof Window); if (isRequested) { vsyncedMap.put(rootContainer, Boolean.TRUE); } else { @@ -106,7 +107,7 @@ * @return {@code true} if vsync painting is requested for {@code 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); }
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -399,7 +399,7 @@ } String detail = "arrow"; - if (name == "ScrollBar.button") { + if ((name == "ScrollBar.button") || (name == "TabbedPane.button")) { if (arrowType == ArrowType.UP || arrowType == ArrowType.DOWN) { detail = "vscrollbar"; } else { @@ -409,7 +409,7 @@ name == "Spinner.previousButton") { detail = "spinbutton"; } else if (name != "ComboBox.arrowButton") { - assert false; + assert false : "unexpected name: " + name; } int gtkState = GTKLookAndFeel.synthStateToGTKState( @@ -436,7 +436,7 @@ String name = button.getName(); String detail = "button"; int direction = SwingConstants.CENTER; - if (name == "ScrollBar.button") { + if ((name == "ScrollBar.button") || (name == "TabbedPane.button")) { Integer prop = (Integer) button.getClientProperty("__arrow_direction__"); direction = (prop != null) ? @@ -457,7 +457,7 @@ } else if (name == "Spinner.nextButton") { detail = "spinbutton_up"; } else if (name != "ComboBox.arrowButton") { - assert false; + assert false : "unexpected name: " + name; } int state = context.getComponentState();
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/PangoFonts.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/PangoFonts.java Fri Sep 24 16:41:32 2010 -0700 @@ -150,11 +150,6 @@ * 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 * 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: * GTK specifies the Xft.dpi value as server-wide which when used * on systems with 2 distinct X screens with different physical DPI @@ -197,11 +192,16 @@ String fcFamilyLC = family.toLowerCase(); if (FontUtilities.mapFcName(fcFamilyLC) != null) { /* 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 { /* It's a physical font which we will create with a fallback */ - Font font = new FontUIResource(family, style, size); - return FontUtilities.getCompositeFontUIResource(font); + Font font = new Font(family, style, size); + /* 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); } }
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifBorders.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/motif/MotifBorders.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -40,8 +40,6 @@ import java.awt.Point; import java.awt.Rectangle; -import java.io.Serializable; - /** * Factory object that can vend Icons appropriate for the basic L & F. * <p> @@ -99,7 +97,7 @@ } 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.drawRect(x, y, w-1, h-1); } else { @@ -233,6 +231,9 @@ } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + if (!(c instanceof JMenuBar)) { + return; + } JMenuBar menuBar = (JMenuBar)c; if (menuBar.isBorderPainted() == true) { // this draws the MenuBar border @@ -658,6 +659,9 @@ * @param height the height of the painted border */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + if (!(c instanceof JPopupMenu)) { + return; + } Font origFont = g.getFont(); Color origColor = g.getColor(); @@ -701,6 +705,9 @@ * @param insets the object to be reinitialized */ public Insets getBorderInsets(Component c, Insets insets) { + if (!(c instanceof JPopupMenu)) { + return insets; + } FontMetrics fm; int descent = 0; int ascent = 16;
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsBorders.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -32,12 +32,8 @@ import java.awt.Component; import java.awt.Insets; -import java.awt.Dimension; -import java.awt.Image; -import java.awt.Rectangle; import java.awt.Color; 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.XPStyle.Skin; @@ -159,6 +155,9 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + if (!(c instanceof JToolBar)) { + return; + } g.translate(x, y); XPStyle xp = XPStyle.getXP(); @@ -190,33 +189,33 @@ } else { - if (!vertical) { - if (c.getComponentOrientation().isLeftToRight()) { + if (!vertical) { + 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.drawLine(4, 3, 4, height - 4); - g.drawLine(4, height - 4, 2, height - 4); + g.drawLine(3, 4, width - 4, 4); + g.drawLine(width - 4, 2, width - 4, 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); + g.drawLine(3, 2, width - 4, 2); + g.drawLine(3, 2, 3, 3); } - } 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 Insets getBorderInsets(Component c, Insets insets) { insets.set(1,1,1,1); + if (!(c instanceof JToolBar)) { + return insets; + } if (((JToolBar)c).isFloatable()) { int gripInset = (XPStyle.getXP() != null) ? 12 : 9; if (((JToolBar)c).getOrientation() == HORIZONTAL) {
--- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Fri Sep 24 16:41:32 2010 -0700 @@ -474,7 +474,7 @@ This is necessary for Receivers retrieved via MidiSystem.getReceiver() (which opens the device implicitely). */ - protected abstract class AbstractReceiver implements Receiver { + protected abstract class AbstractReceiver implements MidiDeviceReceiver { private boolean open = true; @@ -508,6 +508,10 @@ AbstractMidiDevice.this.closeInternal(this); } + public MidiDevice getMidiDevice() { + return AbstractMidiDevice.this; + } + protected boolean isOpen() { return open; } @@ -529,7 +533,7 @@ * Also, it has some optimizations regarding sending to the Receivers, * for known Receivers, and managing itself in the TransmitterList. */ - protected class BasicTransmitter implements Transmitter { + protected class BasicTransmitter implements MidiDeviceTransmitter { private Receiver receiver = null; TransmitterList tlist = null; @@ -568,6 +572,9 @@ } } + public MidiDevice getMidiDevice() { + return AbstractMidiDevice.this; + } } // class BasicTransmitter
--- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -40,8 +40,6 @@ */ public abstract class AudioFloatConverter { - public static final Encoding PCM_FLOAT = new Encoding("PCM_FLOAT"); - /*************************************************************************** * * LSB Filter, used filter least significant byte in samples arrays. @@ -982,7 +980,7 @@ 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.isBigEndian()) conv = new AudioFloatConversion32B();
--- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -175,7 +175,6 @@ for (int c = 0; c < targetChannels; c++) { for (int i = 0, ix = off + c; i < len2; i++, ix += cs) { b[ix] = conversion_buffer[i]; - ; } } } else if (targetChannels == 1) { @@ -186,7 +185,6 @@ for (int c = 1; c < sourceChannels; c++) { for (int i = c, ix = off; i < len2; i += cs, ix++) { b[ix] += conversion_buffer[i]; - ; } } float vol = 1f / ((float) sourceChannels); @@ -390,6 +388,7 @@ return -1; if (len < 0) return 0; + int offlen = off + len; int remain = len / nrofchannels; int destPos = 0; int in_end = ibuffer_len; @@ -423,7 +422,7 @@ for (int c = 0; c < nrofchannels; c++) { int ix = 0; 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++]; } } @@ -447,7 +446,7 @@ } public long skip(long len) throws IOException { - if (len > 0) + if (len < 0) return 0; if (skipbuffer == null) skipbuffer = new float[1024 * targetFormat.getFrameSize()]; @@ -470,7 +469,7 @@ } private Encoding[] formats = { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, - AudioFloatConverter.PCM_FLOAT }; + Encoding.PCM_FLOAT }; public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { @@ -482,7 +481,7 @@ float samplerate = format.getSampleRate(); int bits = format.getSampleSizeInBits(); boolean bigendian = format.isBigEndian(); - if (targetEncoding.equals(AudioFloatConverter.PCM_FLOAT)) + if (targetEncoding.equals(Encoding.PCM_FLOAT)) bits = 32; AudioFormat targetFormat = new AudioFormat(encoding, samplerate, bits, channels, channels * bits / 8, samplerate, bigendian); @@ -521,19 +520,19 @@ public Encoding[] getSourceEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, - AudioFloatConverter.PCM_FLOAT }; + Encoding.PCM_FLOAT }; } public Encoding[] getTargetEncodings() { return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, - AudioFloatConverter.PCM_FLOAT }; + Encoding.PCM_FLOAT }; } public Encoding[] getTargetEncodings(AudioFormat sourceFormat) { if (AudioFloatConverter.getConverter(sourceFormat) == null) return new Encoding[0]; return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, - AudioFloatConverter.PCM_FLOAT }; + Encoding.PCM_FLOAT }; } public AudioFormat[] getTargetFormats(Encoding targetEncoding, @@ -572,17 +571,17 @@ } } - if (targetEncoding.equals(AudioFloatConverter.PCM_FLOAT)) { - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + if (targetEncoding.equals(Encoding.PCM_FLOAT)) { + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, 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, 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, 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, true)); }
--- a/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java Fri Sep 24 16:41:32 2010 -0700 @@ -42,11 +42,14 @@ */ public AudioSynthesizerPropertyInfo(String name, Object value) { this.name = name; - this.value = value; if (value instanceof Class) valueClass = (Class)value; - else if (value != null) - valueClass = value.getClass(); + else + { + this.value = value; + if (value != null) + valueClass = value.getClass(); + } } /** * The name of the property.
--- a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -781,7 +781,7 @@ } if (sampleformat == 3) { audioformat = new AudioFormat( - AudioFloatConverter.PCM_FLOAT, samplerate, bits, + Encoding.PCM_FLOAT, samplerate, bits, channels, framesize, samplerate, false); } @@ -965,7 +965,7 @@ sampleformat = 1; else if (audioformat.getEncoding().equals(Encoding.PCM_SIGNED)) sampleformat = 1; - else if (audioformat.getEncoding().equals(AudioFloatConverter.PCM_FLOAT)) + else if (audioformat.getEncoding().equals(Encoding.PCM_FLOAT)) sampleformat = 3; fmt_chunk.writeUnsignedShort(sampleformat);
--- a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiver.java Thu Sep 23 17:33:40 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2009, 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.MidiDevice; -import javax.sound.midi.Receiver; - -/** - * A Receiver with reference to it's MidiDevice object. - * - * @author Karl Helgason - */ -public interface MidiDeviceReceiver extends Receiver { - - /** Obtains the MidiDevice object associated with this Receiver. - */ - public MidiDevice getMidiDevice(); - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,80 @@ +/* + * 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; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,85 @@ +/* + * 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; + } +}
--- a/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java Fri Sep 24 16:41:32 2010 -0700 @@ -205,7 +205,8 @@ } if (buffer.array() == null) { return AudioFloatInputStream.getInputStream(new AudioInputStream( - buffer.getInputStream(), format, buffer.capacity())); + buffer.getInputStream(), format, + buffer.capacity() / format.getFrameSize())); } if (buffer8 != null) { if (format.getEncoding().equals(Encoding.PCM_SIGNED)
--- a/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java Fri Sep 24 16:41:32 2010 -0700 @@ -56,7 +56,7 @@ public ModelDirector getDirector(ModelPerformer[] performers, MidiChannel channel, ModelDirectedPlayer player) { - return new ModelStandardDirector(performers, player); + return new ModelStandardIndexedDirector(performers, player); } public ModelPerformer[] getPerformers() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,186 @@ +/* + * 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); + } + } + } +}
--- a/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -116,7 +116,7 @@ protected int tuning_program = 0; protected SoftInstrument current_instrument = null; protected ModelChannelMixer current_mixer = null; - private ModelDirector current_director = null; + protected ModelDirector current_director = null; // Controller Destination Settings protected int cds_control_number = -1; @@ -1264,13 +1264,16 @@ } public void programChange(int bank, int program) { - bank = restrict7Bit(bank); + bank = restrict14Bit(bank); program = restrict7Bit(program); synchronized (control_mutex) { mainmixer.activity(); - this.bank = bank; - this.program = program; - current_instrument = null; + if(this.bank != bank || this.program != program) + { + this.bank = bank; + this.program = program; + current_instrument = null; + } } }
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -118,16 +118,16 @@ AudioSystem.NOT_SPECIFIED, bits, channels, channels * 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, 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, 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, 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, true)); }
--- a/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java Fri Sep 24 16:41:32 2010 -0700 @@ -27,6 +27,7 @@ import java.util.TreeMap; import javax.sound.midi.MidiDevice; +import javax.sound.midi.MidiDeviceReceiver; import javax.sound.midi.MidiMessage; import javax.sound.midi.ShortMessage;
--- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -25,16 +25,25 @@ package com.sun.media.sound; +import java.io.BufferedInputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.lang.ref.WeakReference; -import java.security.AccessControlException; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; +import java.util.StringTokenizer; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; import javax.sound.midi.Instrument; import javax.sound.midi.MidiChannel; @@ -182,6 +191,7 @@ // 1: DLS Voice Allocation protected int voice_allocation_mode = 0; + protected boolean load_default_soundbank = false; protected boolean reverb_light = true; protected boolean reverb_on = true; protected boolean chorus_on = true; @@ -226,8 +236,6 @@ = new HashMap<String, SoftTuning>(); private Map<String, SoftInstrument> inslist = new HashMap<String, SoftInstrument>(); - private Map<String, ModelInstrument> availlist - = new HashMap<String, ModelInstrument>(); private Map<String, ModelInstrument> loadedlist = new HashMap<String, ModelInstrument>(); @@ -275,10 +283,12 @@ synchronized (control_mutex) { if (channels != null) for (SoftChannel c : channels) + { c.current_instrument = null; + c.current_director = null; + } for (Instrument instrument : instruments) { String pat = patchToString(instrument.getPatch()); - availlist.remove(pat); SoftInstrument softins = new SoftInstrument((ModelInstrument) instrument); inslist.put(pat, softins); @@ -341,6 +351,7 @@ number_of_midi_channels = (Integer)items[10].value; jitter_correction = (Boolean)items[11].value; reverb_light = (Boolean)items[12].value; + load_default_soundbank = (Boolean)items[13].value; } private String patchToString(Patch patch) { @@ -578,7 +589,9 @@ c.current_instrument = null; inslist.remove(pat); loadedlist.remove(pat); - availlist.remove(pat); + for (int i = 0; i < channels.length; i++) { + channels[i].allSoundOff(); + } } } @@ -600,7 +613,7 @@ return false; synchronized (control_mutex) { - if (!loadedlist.containsValue(to) && !availlist.containsValue(to)) + if (!loadedlist.containsValue(to)) throw new IllegalArgumentException("Instrument to is not loaded."); unloadInstrument(from); ModelMappedInstrument mfrom = new ModelMappedInstrument( @@ -609,118 +622,155 @@ } } - public synchronized Soundbank getDefaultSoundbank() { - if (defaultSoundBank == null) { - try { - File javahome = new File(System.getProperties().getProperty( - "java.home")); - File libaudio = new File(new File(javahome, "lib"), "audio"); + public Soundbank getDefaultSoundbank() { + synchronized (SoftSynthesizer.class) { + if (defaultSoundBank != null) + return defaultSoundBank; - if (libaudio.exists()) { - File foundfile = null; - File[] files = libaudio.listFiles(); - if (files != null) { - for (int i = 0; i < files.length; i++) { - File file = files[i]; - if (file.isFile()) { - String lname = file.getName().toLowerCase(); - if (lname.endsWith(".sf2") || - lname.endsWith(".dls")) { - if (foundfile == null || (file.length() > - foundfile.length())) { - foundfile = file; + List<PrivilegedAction<InputStream>> actions = + new ArrayList<PrivilegedAction<InputStream>>(); + + actions.add(new PrivilegedAction<InputStream>() { + public InputStream run() { + File javahome = new File(System.getProperties() + .getProperty("java.home")); + File libaudio = new File(new File(javahome, "lib"), "audio"); + if (libaudio.exists()) { + File foundfile = null; + File[] files = libaudio.listFiles(); + if (files != null) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; + if (file.isFile()) { + String lname = file.getName().toLowerCase(); + if (lname.endsWith(".sf2") + || lname.endsWith(".dls")) { + if (foundfile == null + || (file.length() > foundfile + .length())) { + foundfile = file; + } } } } } - } - if (foundfile != null) { - try { - Soundbank sbk = MidiSystem.getSoundbank(foundfile); - defaultSoundBank = sbk; - return defaultSoundBank; - } catch (Exception e) { - //e.printStackTrace(); + if (foundfile != null) { + try { + return new FileInputStream(foundfile); + } catch (IOException e) { + } } } + return null; } + }); - if (System.getProperties().getProperty("os.name") - .startsWith("Windows")) { - File gm_dls = new File(System.getenv("SystemRoot") - + "\\system32\\drivers\\gm.dls"); - if (gm_dls.exists()) { - try { - Soundbank sbk = MidiSystem.getSoundbank(gm_dls); - defaultSoundBank = sbk; - return defaultSoundBank; - } catch (Exception e) { - //e.printStackTrace(); + actions.add(new PrivilegedAction<InputStream>() { + public InputStream run() { + if (System.getProperties().getProperty("os.name") + .startsWith("Windows")) { + File gm_dls = new File(System.getenv("SystemRoot") + + "\\system32\\drivers\\gm.dls"); + if (gm_dls.exists()) { + try { + return new FileInputStream(gm_dls); + } catch (IOException e) { + } } } + return null; } - } catch (AccessControlException e) { - } catch (Exception e) { - //e.printStackTrace(); - } + }); - File userhome = null; - File emg_soundbank_file = null; + actions.add(new PrivilegedAction<InputStream>() { + public InputStream run() { + /* + * Try to load saved generated soundbank + */ + File userhome = new File(System.getProperty("user.home"), + ".gervill"); + File emg_soundbank_file = new File(userhome, + "soundbank-emg.sf2"); + if (emg_soundbank_file.exists()) { + try { + return new FileInputStream(emg_soundbank_file); + } catch (IOException e) { + } + } + return null; + } + }); - /* - * Try to load saved generated soundbank - */ - try { - userhome = new File(System.getProperty("user.home"), - ".gervill"); - emg_soundbank_file = new File(userhome, "soundbank-emg.sf2"); - Soundbank sbk = MidiSystem.getSoundbank(emg_soundbank_file); - defaultSoundBank = sbk; - return defaultSoundBank; - } catch (AccessControlException e) { - } catch (Exception e) { - //e.printStackTrace(); + for (PrivilegedAction<InputStream> action : actions) { + try { + InputStream is = AccessController.doPrivileged(action); + if(is == null) continue; + Soundbank sbk; + try { + sbk = MidiSystem.getSoundbank(new BufferedInputStream(is)); + } finally { + is.close(); + } + if (sbk != null) { + defaultSoundBank = sbk; + return defaultSoundBank; + } + } catch (Exception e) { + } } try { - /* - * Generate emergency soundbank + * Generate emergency soundbank */ defaultSoundBank = EmergencySoundbank.createSoundbank(); - - /* - * Save generated soundbank to disk for faster future use. - */ - if(defaultSoundBank != null) - { - if(!userhome.exists()) userhome.mkdirs(); - if(!emg_soundbank_file.exists()) - ((SF2Soundbank)defaultSoundBank).save(emg_soundbank_file); - } } catch (Exception e) { - //e.printStackTrace(); } + if (defaultSoundBank != null) { + /* + * Save generated soundbank to disk for faster future use. + */ + OutputStream out = AccessController + .doPrivileged(new PrivilegedAction<OutputStream>() { + public OutputStream run() { + try { + File userhome = new File(System + .getProperty("user.home"), + ".gervill"); + if (!userhome.exists()) + userhome.mkdirs(); + File emg_soundbank_file = new File( + userhome, "soundbank-emg.sf2"); + if (emg_soundbank_file.exists()) + return null; + return new FileOutputStream( + emg_soundbank_file); + } catch (IOException e) { + } catch (SecurityException e) { + } + return null; + } + }); + if (out != null) { + try { + ((SF2Soundbank) defaultSoundBank).save(out); + out.close(); + } catch (IOException e) { + } + } + } } return defaultSoundBank; } public Instrument[] getAvailableInstruments() { - if (!isOpen()) { - Soundbank defsbk = getDefaultSoundbank(); - if (defsbk == null) - return new Instrument[0]; - return defsbk.getInstruments(); - } - - synchronized (control_mutex) { - ModelInstrument[] inslist_array = - new ModelInstrument[availlist.values().size()]; - availlist.values().toArray(inslist_array); - Arrays.sort(inslist_array, new ModelInstrumentComparator()); - return inslist_array; - } + Soundbank defsbk = getDefaultSoundbank(); + if (defsbk == null) + return new Instrument[0]; + Instrument[] inslist_array = defsbk.getInstruments(); + Arrays.sort(inslist_array, new ModelInstrumentComparator()); + return inslist_array; } public Instrument[] getLoadedInstruments() { @@ -794,6 +844,31 @@ return info; } + private Properties getStoredProperties() { + return AccessController + .doPrivileged(new PrivilegedAction<Properties>() { + public Properties run() { + Properties p = new Properties(); + String notePath = "/com/sun/media/sound/softsynthesizer"; + try { + Preferences prefroot = Preferences.userRoot(); + if (prefroot.nodeExists(notePath)) { + Preferences prefs = prefroot.node(notePath); + String[] prefs_keys = prefs.keys(); + for (String prefs_key : prefs_keys) { + String val = prefs.get(prefs_key, null); + if (val != null) + p.setProperty(prefs_key, val); + } + } + } catch (BackingStoreException e) { + } catch (SecurityException e) { + } + return p; + } + }); + } + public AudioSynthesizerPropertyInfo[] getPropertyInfo(Map<String, Object> info) { List<AudioSynthesizerPropertyInfo> list = new ArrayList<AudioSynthesizerPropertyInfo>(); @@ -861,17 +936,92 @@ item.description = "Turn light reverb mode on or off"; list.add(item); + item = new AudioSynthesizerPropertyInfo("load default soundbank", o?load_default_soundbank:true); + item.description = "Enabled/disable loading default soundbank"; + list.add(item); + AudioSynthesizerPropertyInfo[] items; items = list.toArray(new AudioSynthesizerPropertyInfo[list.size()]); - if (info != null) - for (AudioSynthesizerPropertyInfo item2: items) { - Object v = info.get(item2.name); + Properties storedProperties = getStoredProperties(); + + for (AudioSynthesizerPropertyInfo item2 : items) { + Object v = (info == null) ? null : info.get(item2.name); + v = (v != null) ? v : storedProperties.getProperty(item2.name); + if (v != null) { Class c = (item2.valueClass); - if (v != null) - if (c.isInstance(v)) - item2.value = v; + if (c.isInstance(v)) + item2.value = v; + else if (v instanceof String) { + String s = (String) v; + if (c == Boolean.class) { + if (s.equalsIgnoreCase("true")) + item2.value = Boolean.TRUE; + if (s.equalsIgnoreCase("false")) + item2.value = Boolean.FALSE; + } else if (c == AudioFormat.class) { + int channels = 2; + boolean signed = true; + boolean bigendian = false; + int bits = 16; + float sampleRate = 44100f; + try { + StringTokenizer st = new StringTokenizer(s, ", "); + String prevToken = ""; + while (st.hasMoreTokens()) { + String token = st.nextToken().toLowerCase(); + if (token.equals("mono")) + channels = 1; + if (token.startsWith("channel")) + channels = Integer.parseInt(prevToken); + if (token.contains("unsigned")) + signed = false; + if (token.equals("big-endian")) + bigendian = true; + if (token.equals("bit")) + bits = Integer.parseInt(prevToken); + if (token.equals("hz")) + sampleRate = Float.parseFloat(prevToken); + prevToken = token; + } + item2.value = new AudioFormat(sampleRate, bits, + channels, signed, bigendian); + } catch (NumberFormatException e) { + } + + } else + try { + if (c == Byte.class) + item2.value = Byte.valueOf(s); + else if (c == Short.class) + item2.value = Short.valueOf(s); + else if (c == Integer.class) + item2.value = Integer.valueOf(s); + else if (c == Long.class) + item2.value = Long.valueOf(s); + else if (c == Float.class) + item2.value = Float.valueOf(s); + else if (c == Double.class) + item2.value = Double.valueOf(s); + } catch (NumberFormatException e) { + } + } else if (v instanceof Number) { + Number n = (Number) v; + if (c == Byte.class) + item2.value = Byte.valueOf(n.byteValue()); + if (c == Short.class) + item2.value = Short.valueOf(n.shortValue()); + if (c == Integer.class) + item2.value = Integer.valueOf(n.intValue()); + if (c == Long.class) + item2.value = Long.valueOf(n.longValue()); + if (c == Float.class) + item2.value = Float.valueOf(n.floatValue()); + if (c == Double.class) + item2.value = Double.valueOf(n.doubleValue()); + } } + } return items; } @@ -1007,11 +1157,12 @@ if (targetFormat != null) setFormat(targetFormat); - Soundbank defbank = getDefaultSoundbank(); - if (defbank != null) { - loadAllInstruments(defbank); - availlist.putAll(loadedlist); - loadedlist.clear(); + if (load_default_soundbank) + { + Soundbank defbank = getDefaultSoundbank(); + if (defbank != null) { + loadAllInstruments(defbank); + } } voices = new SoftVoice[maxpoly]; @@ -1117,7 +1268,6 @@ } inslist.clear(); - availlist.clear(); loadedlist.clear(); tunings.clear();
--- a/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java Fri Sep 24 16:41:32 2010 -0700 @@ -279,9 +279,12 @@ } protected void updateTuning(SoftTuning newtuning) { + tuning = newtuning; tunedKey = tuning.getTuning(note) / 100.0; if (!portamento) { co_noteon_keynumber[0] = tunedKey * (1.0 / 128.0); + if(performer == null) + return; int[] c = performer.midi_connections[4]; if (c == null) return; @@ -433,6 +436,8 @@ } protected void setPolyPressure(int pressure) { + if(performer == null) + return; int[] c = performer.midi_connections[2]; if (c == null) return; @@ -441,6 +446,8 @@ } protected void setChannelPressure(int pressure) { + if(performer == null) + return; int[] c = performer.midi_connections[1]; if (c == null) return; @@ -449,6 +456,8 @@ } protected void controlChange(int controller, int value) { + if(performer == null) + return; int[] c = performer.midi_ctrl_connections[controller]; if (c == null) return; @@ -457,6 +466,8 @@ } protected void nrpnChange(int controller, int value) { + if(performer == null) + return; int[] c = performer.midi_nrpn_connections.get(controller); if (c == null) return; @@ -465,6 +476,8 @@ } protected void rpnChange(int controller, int value) { + if(performer == null) + return; int[] c = performer.midi_rpn_connections.get(controller); if (c == null) return; @@ -473,6 +486,8 @@ } protected void setPitchBend(int bend) { + if(performer == null) + return; int[] c = performer.midi_connections[0]; if (c == null) return; @@ -499,6 +514,8 @@ co_noteon_on[0] = -1; + if(performer == null) + return; int[] c = performer.midi_connections[3]; if (c == null) return; @@ -527,6 +544,8 @@ co_noteon_on[0] = 0; + if(performer == null) + return; int[] c = performer.midi_connections[3]; if (c == null) return; @@ -543,6 +562,8 @@ sustain = true; co_noteon_on[0] = 1; + if(performer == null) + return; int[] c = performer.midi_connections[3]; if (c == null) return; @@ -555,6 +576,11 @@ active = false; stopping = false; audiostarted = false; + instrument = null; + performer = null; + connections = null; + extendedConnectionBlocks = null; + channelmixer = null; if (osc_stream != null) try { osc_stream.close();
--- a/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -271,7 +271,7 @@ bits, channels, framesize, samplerate, false, p); } } 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); } else throw new UnsupportedAudioFileException();
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; @@ -102,7 +103,7 @@ throw new UnsupportedAudioFileException(); AudioFormat audioformat = new AudioFormat( - AudioFloatConverter.PCM_FLOAT, samplerate, bits, channels, + Encoding.PCM_FLOAT, samplerate, bits, channels, framesize, samplerate, false); AudioFileFormat fileformat = new AudioFileFormat( AudioFileFormat.Type.WAVE, audioformat,
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioFileFormat.Type; @@ -48,8 +49,7 @@ public Type[] getAudioFileTypes(AudioInputStream stream) { - if (!stream.getFormat().getEncoding().equals( - AudioFloatConverter.PCM_FLOAT)) + if (!stream.getFormat().getEncoding().equals(Encoding.PCM_FLOAT)) return new Type[0]; return new Type[] { Type.WAVE }; } @@ -58,8 +58,7 @@ if (!Type.WAVE.equals(type)) throw new IllegalArgumentException("File type " + type + " not supported."); - if (!stream.getFormat().getEncoding().equals( - AudioFloatConverter.PCM_FLOAT)) + if (!stream.getFormat().getEncoding().equals(Encoding.PCM_FLOAT)) throw new IllegalArgumentException("File format " + stream.getFormat() + " not supported."); }
--- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -518,7 +518,7 @@ setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); - setTypeMap(null); + //setTypeMap(null); checkTransactionalWriter(); //Instantiating the vector for MatchColumns @@ -679,7 +679,10 @@ } else if (obj instanceof Clob) { obj = new SerialClob((Clob)obj); } else if (obj instanceof java.sql.Array) { - obj = new SerialArray((java.sql.Array)obj, map); + if(map != null) + obj = new SerialArray((java.sql.Array)obj, map); + else + obj = new SerialArray((java.sql.Array)obj); } ((Row)currentRow).initColumnObject(i, obj); @@ -762,7 +765,7 @@ if( conn != null){ // JDBC 4.0 mandates as does the Java EE spec that all DataBaseMetaData methods // must be implemented, therefore, the previous fix for 5055528 is being backed out - dbmslocatorsUpdateCopy = conn.getMetaData().locatorsUpdateCopy(); + dbmslocatorsUpdateCopy = conn.getMetaData().locatorsUpdateCopy(); } } @@ -6322,6 +6325,7 @@ crs.RowSetMD = RowSetMD; crs.numRows = 1; crs.cursorPos = 0; + crs.setTypeMap(this.getTypeMap()); // make sure we don't get someone playing with these // %%% is this now necessary ??? @@ -10114,7 +10118,7 @@ * during the deserialization process * */ - protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // Default state initialization happens here ois.defaultReadObject(); // Initialization of transient Res Bundle happens here . @@ -10125,5 +10129,15 @@ } } - static final long serialVersionUID =1884577171200622428L; + + //------------------------- JDBC 4.1 ----------------------------------- + public <T> T getObject(int columnIndex, Class<T> type) throws SQLException { + throw new SQLFeatureNotSupportedException("Not supported yet."); + } + + public <T> T getObject(String columnLabel, Class<T> type) throws SQLException { + throw new SQLFeatureNotSupportedException("Not supported yet."); + } + + static final long serialVersionUID =1884577171200622428L; }
--- a/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -1746,5 +1746,23 @@ onInsertRow = false; super.insertRow(); } - static final long serialVersionUID = 6178454588413509360L; + + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = 6178454588413509360L; } // end FilteredRowSetImpl class
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -101,7 +101,7 @@ private Vector strMatchColumns; - protected transient JdbcRowSetResourceBundle jdbcResBundle; + protected transient JdbcRowSetResourceBundle resBundle; /** * Constructs a default <code>JdbcRowSet</code> object. @@ -140,7 +140,7 @@ rs = null; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -154,42 +154,42 @@ try { setShowDeleted(false); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setshowdeleted").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setshowdeleted").toString() + sqle.getLocalizedMessage()); } try { setQueryTimeout(0); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + sqle.getLocalizedMessage()); } try { setMaxRows(0); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + sqle.getLocalizedMessage()); } try { setMaxFieldSize(0); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + sqle.getLocalizedMessage()); } try { setEscapeProcessing(true); } catch(SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + sqle.getLocalizedMessage()); } try { setConcurrency(ResultSet.CONCUR_UPDATABLE); } catch (SQLException sqle) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setconcurrency").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setconcurrency").toString() + sqle.getLocalizedMessage()); } @@ -198,7 +198,7 @@ try { setType(ResultSet.TYPE_SCROLL_INSENSITIVE); } catch(SQLException sqle){ - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.settype").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settype").toString() + sqle.getLocalizedMessage()); } @@ -207,7 +207,7 @@ try { setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); } catch(SQLException sqle){ - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.settransactionisolation").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.settransactionisolation").toString() + sqle.getLocalizedMessage()); } @@ -263,7 +263,7 @@ rs = null; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -338,7 +338,7 @@ rs = null; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -430,7 +430,7 @@ rs = res; try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) { throw new RuntimeException(ioe); } @@ -517,7 +517,7 @@ // to the db, implies undesirable state so throw exception if (conn == null && ps == null && rs == null ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.invalstate").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.invalstate").toString()); } } @@ -593,28 +593,28 @@ try { ps.setEscapeProcessing(getEscapeProcessing()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setescapeprocessing").toString() + ex.getLocalizedMessage()); } try { ps.setMaxFieldSize(getMaxFieldSize()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxfieldsize").toString() + ex.getLocalizedMessage()); } try { ps.setMaxRows(getMaxRows()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setmaxrows").toString() + ex.getLocalizedMessage()); } try { ps.setQueryTimeout(getQueryTimeout()); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.setquerytimeout").toString() + ex.getLocalizedMessage()); } @@ -651,7 +651,7 @@ } } catch (javax.naming.NamingException ex) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.connect").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.connect").toString()); } } else if (getUrl() != null) { @@ -681,7 +681,7 @@ } ps = conn.prepareStatement(getCommand(),ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); } catch (SQLException ex) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.prepare").toString() + + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.prepare").toString() + ex.getLocalizedMessage()); if (ps != null) @@ -721,15 +721,15 @@ if (param[0] instanceof java.sql.Date || param[0] instanceof java.sql.Time || param[0] instanceof java.sql.Timestamp) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.detecteddate")); + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.detecteddate")); if (param[1] instanceof java.util.Calendar) { - System.err.println(jdbcResBundle.handleGetObject("jdbcrowsetimpl.detectedcalendar")); + System.err.println(resBundle.handleGetObject("jdbcrowsetimpl.detectedcalendar")); ps.setDate(i + 1, (java.sql.Date)param[0], (java.util.Calendar)param[1]); continue; } else { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); } } @@ -770,7 +770,7 @@ (java.io.InputStream)param[0], ((Integer)param[1]).intValue()); default: - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); } } @@ -784,7 +784,7 @@ continue; } - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString()); } else { // common case - this catches all SQL92 types @@ -3749,7 +3749,7 @@ for( int j= 0 ;j < columnIdxes.length; j++) { i_val = (Integer.parseInt(iMatchColumns.get(j).toString())); if(columnIdxes[j] != i_val) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); } } @@ -3776,7 +3776,7 @@ for(int j = 0 ;j < columnIdxes.length; j++) { if( !columnIdxes[j].equals(strMatchColumns.get(j)) ){ - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols").toString()); } } @@ -3800,7 +3800,7 @@ String []str_temp = new String[strMatchColumns.size()]; if( strMatchColumns.get(0) == null) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); } strMatchColumns.copyInto(str_temp); @@ -3825,7 +3825,7 @@ i_val = ((Integer)iMatchColumns.get(0)).intValue(); if( i_val == -1 ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString()); } @@ -3859,7 +3859,7 @@ for(int j = 0 ; j < columnIdxes.length; j++) { if( columnIdxes[j] < 0 ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); } } for(int i = 0 ;i < columnIdxes.length; i++) { @@ -3886,7 +3886,7 @@ for(int j = 0; j < columnNames.length; j++) { if( columnNames[j] == null || columnNames[j].equals("")) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); } } for( int i = 0; i < columnNames.length; i++) { @@ -3915,7 +3915,7 @@ public void setMatchColumn(int columnIdx) throws SQLException { // validate, if col is ok to be set if(columnIdx < 0) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols1").toString()); } else { // set iMatchColumn iMatchColumns.set(0, new Integer(columnIdx)); @@ -3941,7 +3941,7 @@ public void setMatchColumn(String columnName) throws SQLException { // validate, if col is ok to be set if(columnName.equals(null) || ((columnName = columnName.trim()) == "" )) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.matchcols2").toString()); } else { // set strMatchColumn strMatchColumns.set(0, columnName); @@ -3966,9 +3966,9 @@ public void unsetMatchColumn(int columnIdx) throws SQLException { // check if we are unsetting the SAME column if(! iMatchColumns.get(0).equals(new Integer(columnIdx) ) ) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); } else if(strMatchColumns.get(0) != null) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.usecolname").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.usecolname").toString()); } else { // that is, we are unsetting it. iMatchColumns.set(0, new Integer(-1)); @@ -3995,9 +3995,9 @@ columnName = columnName.trim(); if(!((strMatchColumns.get(0)).equals(columnName))) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString()); } else if( ((Integer)(iMatchColumns.get(0))).intValue() > 0) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.usecolid").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.usecolid").toString()); } else { strMatchColumns.set(0, null); // that is, we are unsetting it. } @@ -4152,7 +4152,7 @@ private void checkTypeConcurrency() throws SQLException { if(rs.getType() == TYPE_FORWARD_ONLY || rs.getConcurrency() == CONCUR_READ_ONLY) { - throw new SQLException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.resnotupd").toString()); + throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.resnotupd").toString()); } } @@ -4642,7 +4642,7 @@ * @since 6.0 */ public SQLXML getSQLXML(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4653,7 +4653,7 @@ * @throws SQLException if a database access error occurs */ public SQLXML getSQLXML(String colName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4668,7 +4668,7 @@ * @since 6.0 */ public RowId getRowId(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4683,7 +4683,7 @@ * @since 6.0 */ public RowId getRowId(String columnName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4699,7 +4699,7 @@ * @since 6.0 */ public void updateRowId(int columnIndex, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4715,7 +4715,7 @@ * @since 6.0 */ public void updateRowId(String columnName, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4725,7 +4725,7 @@ * @since 6.0 */ public int getHoldability() throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4736,7 +4736,7 @@ * @since 6.0 */ public boolean isClosed() throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4748,7 +4748,7 @@ * @since 6.0 */ public void updateNString(int columnIndex, String nString) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4760,7 +4760,7 @@ * @since 6.0 */ public void updateNString(String columnName, String nString) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4773,7 +4773,7 @@ * @since 6.0 */ public void updateNClob(int columnIndex, NClob nClob) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4785,7 +4785,7 @@ * @since 6.0 */ public void updateNClob(String columnName, NClob nClob) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4800,7 +4800,7 @@ * @since 6.0 */ public NClob getNClob(int i) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4816,7 +4816,7 @@ * @since 6.0 */ public NClob getNClob(String colName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException{ @@ -4836,7 +4836,7 @@ * @since 1.6 */ public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4848,7 +4848,7 @@ * @since 1.6 */ public void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4863,7 +4863,7 @@ * @since 1.6 */ public void setRowId(int parameterIndex, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4877,7 +4877,7 @@ * @since 1.6 */ public void setRowId(String parameterName, RowId x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4897,7 +4897,7 @@ * @since 1.6 */ public void setNString(int parameterIndex, String value) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4925,7 +4925,7 @@ * @since 1.6 */ public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4940,7 +4940,7 @@ * @since 1.6 */ public void setNClob(String parameterName, NClob value) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4960,7 +4960,7 @@ * @since 1.6 */ public java.io.Reader getNCharacterStream(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -4980,7 +4980,7 @@ * @since 1.6 */ public java.io.Reader getNCharacterStream(String columnName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -4996,7 +4996,7 @@ * @since 1.6 */ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5013,7 +5013,7 @@ * @since 1.6 */ public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5031,7 +5031,7 @@ * @since 1.6 */ public String getNString(int columnIndex) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5049,7 +5049,7 @@ * @since 1.6 */ public String getNString(String columnName) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5071,7 +5071,7 @@ java.io.Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5093,7 +5093,7 @@ java.io.Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5123,7 +5123,7 @@ */ public void updateNCharacterStream(int columnIndex, java.io.Reader x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5155,7 +5155,7 @@ */ public void updateNCharacterStream(String columnLabel, java.io.Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5188,7 +5188,7 @@ * @since 1.6 */ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5221,7 +5221,7 @@ * @since 1.6 */ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5256,7 +5256,7 @@ * @since 1.6 */ public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5291,7 +5291,7 @@ * @since 1.6 */ public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5323,7 +5323,7 @@ * @since 1.6 */ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5355,7 +5355,7 @@ * @since 1.6 */ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5389,7 +5389,7 @@ * @since 1.6 */ public void updateClob(int columnIndex, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5424,7 +5424,7 @@ * @since 1.6 */ public void updateClob(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5458,7 +5458,7 @@ * @since 1.6 */ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5492,7 +5492,7 @@ * @since 1.6 */ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5528,7 +5528,7 @@ * @since 1.6 */ public void updateNClob(int columnIndex, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5565,7 +5565,7 @@ * @since 1.6 */ public void updateNClob(String columnLabel, Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5590,7 +5590,7 @@ public void updateAsciiStream(int columnIndex, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5614,7 +5614,7 @@ public void updateBinaryStream(int columnIndex, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5638,7 +5638,7 @@ public void updateCharacterStream(int columnIndex, java.io.Reader x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5662,7 +5662,7 @@ public void updateAsciiStream(String columnLabel, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5687,7 +5687,7 @@ */ public void updateAsciiStream(int columnIndex, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5713,7 +5713,7 @@ */ public void updateAsciiStream(String columnLabel, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5738,7 +5738,7 @@ public void updateBinaryStream(String columnLabel, java.io.InputStream x, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5763,7 +5763,7 @@ */ public void updateBinaryStream(int columnIndex, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5790,7 +5790,7 @@ */ public void updateBinaryStream(String columnLabel, java.io.InputStream x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5816,7 +5816,7 @@ public void updateCharacterStream(String columnLabel, java.io.Reader reader, long length) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5841,7 +5841,7 @@ */ public void updateCharacterStream(int columnIndex, java.io.Reader x) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5868,7 +5868,7 @@ */ public void updateCharacterStream(String columnLabel, java.io.Reader reader) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5885,7 +5885,7 @@ * @since 1.4 */ public void setURL(int parameterIndex, java.net.URL x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5914,7 +5914,7 @@ */ public void setNClob(int parameterIndex, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -5942,7 +5942,7 @@ */ public void setNClob(String parameterName, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5969,7 +5969,7 @@ */ public void setNClob(String parameterName, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -5996,7 +5996,7 @@ */ public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6012,7 +6012,7 @@ * @since 1.6 */ public void setNClob(int parameterIndex, NClob value) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6029,7 +6029,7 @@ */ public void setNString(String parameterName, String value) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6046,7 +6046,7 @@ * @since 1.6 */ public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6066,7 +6066,7 @@ */ public void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6092,7 +6092,7 @@ * @since 1.6 */ public void setNCharacterStream(String parameterName, Reader value) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6118,7 +6118,7 @@ */ public void setTimestamp(String parameterName, java.sql.Timestamp x, Calendar cal) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6144,7 +6144,7 @@ */ public void setClob(String parameterName, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6163,7 +6163,7 @@ * @since 1.6 */ public void setClob (String parameterName, Clob x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6188,7 +6188,7 @@ */ public void setClob(String parameterName, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6210,7 +6210,7 @@ */ public void setDate(String parameterName, java.sql.Date x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6236,7 +6236,7 @@ */ public void setDate(String parameterName, java.sql.Date x, Calendar cal) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6256,7 +6256,7 @@ */ public void setTime(String parameterName, java.sql.Time x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6282,7 +6282,7 @@ */ public void setTime(String parameterName, java.sql.Time x, Calendar cal) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6308,7 +6308,7 @@ */ public void setClob(int parameterIndex, Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6333,7 +6333,7 @@ */ public void setClob(int parameterIndex, Reader reader, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6363,7 +6363,7 @@ */ public void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6395,7 +6395,7 @@ */ public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6426,7 +6426,7 @@ */ public void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6444,7 +6444,7 @@ * @since 1.6 */ public void setBlob (String parameterName, Blob x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6470,7 +6470,7 @@ */ public void setBlob(String parameterName, InputStream inputStream) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6516,7 +6516,7 @@ */ public void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6542,7 +6542,7 @@ */ public void setObject(String parameterName, Object x, int targetSqlType) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6582,7 +6582,7 @@ * @since 1.4 */ public void setObject(String parameterName, Object x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6609,7 +6609,7 @@ */ public void setAsciiStream(String parameterName, java.io.InputStream x, int length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6636,7 +6636,7 @@ */ public void setBinaryStream(String parameterName, java.io.InputStream x, int length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6665,7 +6665,7 @@ public void setCharacterStream(String parameterName, java.io.Reader reader, int length) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6692,7 +6692,7 @@ */ public void setAsciiStream(String parameterName, java.io.InputStream x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6719,7 +6719,7 @@ */ public void setBinaryStream(String parameterName, java.io.InputStream x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6748,7 +6748,7 @@ */ public void setCharacterStream(String parameterName, java.io.Reader reader) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6767,7 +6767,7 @@ * @since 1.4 */ public void setBigDecimal(String parameterName, BigDecimal x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6788,7 +6788,7 @@ * @since 1.4 */ public void setString(String parameterName, String x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6810,7 +6810,7 @@ * @since 1.4 */ public void setBytes(String parameterName, byte x[]) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6830,7 +6830,7 @@ */ public void setTimestamp(String parameterName, java.sql.Timestamp x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6847,7 +6847,7 @@ * @since 1.4 */ public void setNull(String parameterName, int sqlType) throws SQLException { - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6884,7 +6884,7 @@ */ public void setNull (String parameterName, int sqlType, String typeName) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6902,7 +6902,7 @@ * @since 1.4 */ public void setBoolean(String parameterName, boolean x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6922,7 +6922,7 @@ * @since 1.4 */ public void setByte(String parameterName, byte x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6941,7 +6941,7 @@ * @since 1.4 */ public void setShort(String parameterName, short x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6960,7 +6960,7 @@ * @since 1.4 */ public void setInt(String parameterName, int x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -6978,7 +6978,7 @@ * @since 1.4 */ public void setLong(String parameterName, long x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } @@ -6997,7 +6997,7 @@ * @since 1.4 */ public void setFloat(String parameterName, float x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -7015,7 +7015,7 @@ * @since 1.4 */ public void setDouble(String parameterName, double x) throws SQLException{ - throw new SQLFeatureNotSupportedException(jdbcResBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); + throw new SQLFeatureNotSupportedException(resBundle.handleGetObject("jdbcrowsetimpl.featnotsupp").toString()); } /** @@ -7023,15 +7023,25 @@ * during the deserialization process * */ - protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // Default state initialization happens here ois.defaultReadObject(); // Initialization of transient Res Bundle happens here . try { - jdbcResBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch(IOException ioe) {} } static final long serialVersionUID = -3591946023893483003L; + + //------------------------- JDBC 4.1 ----------------------------------- + + public <T> T getObject(int columnIndex, Class<T> type) throws SQLException { + throw new SQLFeatureNotSupportedException("Not supported yet."); + } + + public <T> T getObject(String columnLabel, Class<T> type) throws SQLException { + throw new SQLFeatureNotSupportedException("Not supported yet."); + } }
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -153,4 +153,5 @@ return propResBundle.handleGetObject(key); } + static final long serialVersionUID = 436199386225359954L; }
--- a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -127,6 +127,11 @@ strMatchKey = null; supportedJOINs = new boolean[] {false, true, false, false, false}; + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } } @@ -4306,5 +4311,22 @@ return crsInternal.createCopySchema(); } - static final long serialVersionUID = -5590501621560008453L; + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = -5590501621560008453L; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/rowset/RowSetFactoryImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,69 @@ +/* + * 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.rowset; + +import java.sql.SQLException; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.FilteredRowSet; +import javax.sql.rowset.JdbcRowSet; +import javax.sql.rowset.JoinRowSet; +import javax.sql.rowset.WebRowSet; +import javax.sql.rowset.RowSetFactory; + +/** + * This is the implementation specific class for the + * <code>javax.sql.rowset.spi.RowSetFactory</code>. This is the platform + * default implementation for the Java SE platform. + * + * @author Lance Andersen + * + * + * @version 1.7 + */ +public final class RowSetFactoryImpl implements RowSetFactory { + + public CachedRowSet createCachedRowSet() throws SQLException { + return new com.sun.rowset.CachedRowSetImpl(); + } + + public FilteredRowSet createFilteredRowSet() throws SQLException { + return new com.sun.rowset.FilteredRowSetImpl(); + } + + + public JdbcRowSet createJdbcRowSet() throws SQLException { + return new com.sun.rowset.JdbcRowSetImpl(); + } + + public JoinRowSet createJoinRowSet() throws SQLException { + return new com.sun.rowset.JoinRowSetImpl(); + } + + public WebRowSet createWebRowSet() throws SQLException { + return new com.sun.rowset.WebRowSetImpl(); + } + +}
--- a/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -103,6 +103,12 @@ */ public WebRowSetImpl(Hashtable env) throws SQLException { + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + if ( env == null) { throw new SQLException(resBundle.handleGetObject("webrowsetimpl.nullhash").toString()); } @@ -263,5 +269,23 @@ this.writeXml(oStream); } -static final long serialVersionUID = -8771775154092422943L; + + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = -8771775154092422943L; }
--- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -490,4 +490,17 @@ startPosition = pos; } + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID =5049738185801363801L; }
--- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -31,7 +31,13 @@ import java.io.*; import com.sun.rowset.*; +import java.text.MessageFormat; import javax.sql.rowset.*; +import javax.sql.rowset.serial.SQLInputImpl; +import javax.sql.rowset.serial.SerialArray; +import javax.sql.rowset.serial.SerialBlob; +import javax.sql.rowset.serial.SerialClob; +import javax.sql.rowset.serial.SerialStruct; import javax.sql.rowset.spi.*; @@ -53,6 +59,7 @@ * Standard JDBC RowSet implementations provide an object instance of this * writer by invoking the <code>SyncProvider.getRowSetWriter()</code> method. * + * @version 0.2 * @author Jonathan Bruce * @see javax.sql.rowset.spi.SyncProvider * @see javax.sql.rowset.spi.SyncFactory @@ -508,10 +515,11 @@ ResultSet rs = null; rs = pstmt.executeQuery(); - if (rs.next() == true) { + ResultSetMetaData rsmd = rs.getMetaData(); + if (rs.next()) { if (rs.next()) { - /** More than one row conflict. + /** More than one row conflict. * If rs has only one row we are able to * uniquely identify the row where update * have to happen else if more than one @@ -528,7 +536,7 @@ // we require the record in rs to be used. // rs.close(); // pstmt.close(); - rs.first(); + rs.first(); // how many fields need to be updated int colsNotChanged = 0; @@ -552,6 +560,49 @@ orig = origVals.getObject(i); curr = crs.getObject(i); rsval = rs.getObject(i); + /* + * the following block creates equivalent objects + * that would have been created if this rs is populated + * into a CachedRowSet so that comparison of the column values + * from the ResultSet and CachedRowSet are possible + */ + Map map = (crs.getTypeMap() == null)?con.getTypeMap():crs.getTypeMap(); + if (rsval instanceof Struct) { + + Struct s = (Struct)rsval; + + // look up the class in the map + Class c = null; + c = (Class)map.get(s.getSQLTypeName()); + if (c != null) { + // create new instance of the class + SQLData obj = null; + try { + obj = (SQLData)c.newInstance(); + } catch (java.lang.InstantiationException ex) { + throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(), + ex.getMessage())); + } catch (java.lang.IllegalAccessException ex) { + throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(), + ex.getMessage())); + } + // get the attributes from the struct + Object attribs[] = s.getAttributes(map); + // create the SQLInput "stream" + SQLInputImpl sqlInput = new SQLInputImpl(attribs, map); + // read the values... + obj.readSQL(sqlInput, s.getSQLTypeName()); + rsval = obj; + } + } else if (rsval instanceof SQLData) { + rsval = new SerialStruct((SQLData)rsval, map); + } else if (rsval instanceof Blob) { + rsval = new SerialBlob((Blob)rsval); + } else if (rsval instanceof Clob) { + rsval = new SerialClob((Clob)rsval); + } else if (rsval instanceof java.sql.Array) { + rsval = new SerialArray((java.sql.Array)rsval, map); + } // reset boolNull if it had been set boolNull = true; @@ -669,6 +720,9 @@ } } //end for + rs.close(); + pstmt.close(); + this.crsResolve.insertRow(); this.crsResolve.moveToCurrentRow(); @@ -1179,11 +1233,22 @@ private void buildKeyDesc(CachedRowSet crs) throws SQLException { keyCols = crs.getKeyColumns(); + ResultSetMetaData resultsetmd = crs.getMetaData(); if (keyCols == null || keyCols.length == 0) { - keyCols = new int[callerColumnCount]; - for (int i = 0; i < keyCols.length; ) { - keyCols[i] = ++i; + ArrayList<Integer> listKeys = new ArrayList<Integer>(); + + for (int i = 0; i < callerColumnCount; i++ ) { + if(resultsetmd.getColumnType(i+1) != java.sql.Types.CLOB && + resultsetmd.getColumnType(i+1) != java.sql.Types.STRUCT && + resultsetmd.getColumnType(i+1) != java.sql.Types.SQLXML && + resultsetmd.getColumnType(i+1) != java.sql.Types.BLOB && + resultsetmd.getColumnType(i+1) != java.sql.Types.ARRAY && + resultsetmd.getColumnType(i+1) != java.sql.Types.OTHER ) + listKeys.add(i+1); } + keyCols = new int[listKeys.size()]; + for (int i = 0; i < listKeys.size(); i++ ) + keyCols[i] = listKeys.get(i); } params = new Object[keyCols.length]; } @@ -1359,4 +1424,17 @@ } } + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID =-8506030970299413976L; }
--- a/jdk/src/share/classes/com/sun/rowset/internal/InsertRow.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/internal/InsertRow.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -157,4 +157,23 @@ origVals[idx - 1] = val; markColInserted(idx - 1); } + + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = 1066099658102869344L; }
--- a/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -35,6 +35,7 @@ import com.sun.rowset.*; import java.io.IOException; +import java.io.ObjectInputStream; /** * There will be two sets of data which will be maintained by the rowset at the @@ -4837,4 +4838,23 @@ throws SQLException { throw new UnsupportedOperationException("Operation not yet supported"); } + + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = -3345004441725080251L; } //end class
--- a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlReader.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlReader.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -216,4 +216,22 @@ public void readData(RowSetInternal caller) { } + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = -9127058392819008014L; }
--- a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -663,4 +663,23 @@ return s; } + + /** + * This method re populates the resBundle + * during the deserialization process + * + */ + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + + static final long serialVersionUID = 7163134986189677641L; }
--- a/jdk/src/share/classes/com/sun/rowset/providers/RIOptimisticProvider.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/rowset/providers/RIOptimisticProvider.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -245,4 +245,18 @@ public String getVendor() { return this.vendorName; } + + private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { + // Default state initialization happens here + ois.defaultReadObject(); + // Initialization of transient Res Bundle happens here . + try { + resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); + } catch(IOException ioe) { + throw new RuntimeException(ioe); + } + + } + static final long serialVersionUID =-3143367176751761936L; + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/ntlm/Client.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,212 @@ +/* + * 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.security.ntlm; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.Date; +import java.util.Locale; + +/** + * The NTLM client. Not multi-thread enabled.<p> + * Example: + * <pre> + * Client client = new Client(null, "host", "dummy", + * "REALM", "t0pSeCr3t".toCharArray()); + * byte[] type1 = client.type1(); + * // Send type1 to server and receive response as type2 + * byte[] type3 = client.type3(type2, nonce); + * // Send type3 to server + * </pre> + */ +public final class Client extends NTLM { + final private String hostname; + final private String username; + + private String domain; // might be updated by Type 2 msg + private byte[] pw1, pw2; + + /** + * Creates an NTLM Client instance. + * @param version the NTLM version to use, which can be: + * <ul> + * <li>LM/NTLM: Original NTLM v1 + * <li>LM: Original NTLM v1, LM only + * <li>NTLM: Original NTLM v1, NTLM only + * <li>NTLM2: NTLM v1 with Client Challenge + * <li>LMv2/NTLMv2: NTLM v2 + * <li>LMv2: NTLM v2, LM only + * <li>NTLMv2: NTLM v2, NTLM only + * </ul> + * If null, "LMv2/NTLMv2" will be used. + * @param hostname hostname of the client, can be null + * @param username username to be authenticated, must not be null + * @param domain domain of {@code username}, can be null + * @param password password for {@code username}, must not be not null. + * This method does not make any modification to this parameter, it neither + * needs to access the content of this parameter after this method call, + * so you are free to modify or nullify this parameter after this call. + * @throws NullPointerException if {@code username} or {@code password} is null. + * @throws NTLMException if {@code version} is illegal + */ + public Client(String version, String hostname, String username, + String domain, char[] password) throws NTLMException { + super(version); + if ((username == null || password == null)) { + throw new NullPointerException("username/password cannot be null"); + } + this.hostname = hostname; + this.username = username; + this.domain = domain; + this.pw1 = getP1(password); + this.pw2 = getP2(password); + debug("NTLM Client: (h,u,t,version(v)) = (%s,%s,%s,%s(%s))\n", + hostname, username, domain, version, v.toString()); + } + + /** + * Generates the Type 1 message + * @return the message generated + */ + public byte[] type1() { + Writer p = new Writer(1, 32); + int flags = 0x8203; + if (hostname != null) { + flags |= 0x2000; + } + if (domain != null) { + flags |= 0x1000; + } + if (v != Version.NTLM) { + flags |= 0x80000; + } + p.writeInt(12, flags); + p.writeSecurityBuffer(24, hostname, false); + p.writeSecurityBuffer(16, domain, false); + debug("NTLM Client: Type 1 created\n"); + debug(p.getBytes()); + return p.getBytes(); + } + + /** + * Generates the Type 3 message + * @param type2 the responding Type 2 message from server, must not be null + * @param nonce random 8-byte array to be used in message generation, + * must not be null except for original NTLM v1 + * @return the message generated + * @throws NullPointerException if {@code type2} or {@code nonce} is null + * for NTLM v1. + * @throws NTLMException if the incoming message is invalid + */ + public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException { + if (type2 == null || (v != Version.NTLM && nonce == null)) { + throw new NullPointerException("type2 and nonce cannot be null"); + } + debug("NTLM Client: Type 2 received\n"); + debug(type2); + Reader r = new Reader(type2); + byte[] challenge = r.readBytes(24, 8); + int inputFlags = r.readInt(20); + boolean unicode = (inputFlags & 1) == 1; + String domainFromServer = r.readSecurityBuffer(12, unicode); + if (domainFromServer != null) { + domain = domainFromServer; + } + if (domain == null) { + throw new NTLMException(NTLMException.NO_DOMAIN_INFO, + "No domain info"); + } + + int flags = 0x88200 | (inputFlags & 3); + Writer p = new Writer(3, 64); + byte[] lm = null, ntlm = null; + + p.writeSecurityBuffer(28, domain, unicode); + p.writeSecurityBuffer(36, username, unicode); + p.writeSecurityBuffer(44, hostname, unicode); + + if (v == Version.NTLM) { + byte[] lmhash = calcLMHash(pw1); + byte[] nthash = calcNTHash(pw2); + if (writeLM) lm = calcResponse (lmhash, challenge); + if (writeNTLM) ntlm = calcResponse (nthash, challenge); + } else if (v == Version.NTLM2) { + byte[] nthash = calcNTHash(pw2); + lm = ntlm2LM(nonce); + ntlm = ntlm2NTLM(nthash, nonce, challenge); + } else { + byte[] nthash = calcNTHash(pw2); + if (writeLM) lm = calcV2(nthash, + username.toUpperCase(Locale.US)+domain, nonce, challenge); + if (writeNTLM) { + byte[] alist = type2.length > 48 ? + r.readSecurityBuffer(40) : new byte[0]; + byte[] blob = new byte[32+alist.length]; + System.arraycopy(new byte[]{1,1,0,0,0,0,0,0}, 0, blob, 0, 8); + // TS + byte[] time = BigInteger.valueOf(new Date().getTime()) + .add(new BigInteger("11644473600000")) + .multiply(BigInteger.valueOf(10000)) + .toByteArray(); + for (int i=0; i<time.length; i++) { + blob[8+time.length-i-1] = time[i]; + } + System.arraycopy(nonce, 0, blob, 16, 8); + System.arraycopy(new byte[]{0,0,0,0}, 0, blob, 24, 4); + System.arraycopy(alist, 0, blob, 28, alist.length); + System.arraycopy(new byte[]{0,0,0,0}, 0, + blob, 28+alist.length, 4); + ntlm = calcV2(nthash, username.toUpperCase(Locale.US)+domain, + blob, challenge); + } + } + p.writeSecurityBuffer(12, lm); + p.writeSecurityBuffer(20, ntlm); + p.writeSecurityBuffer(52, new byte[0]); + + p.writeInt(60, flags); + debug("NTLM Client: Type 3 created\n"); + debug(p.getBytes()); + return p.getBytes(); + } + + /** + * Returns the domain value provided by server after the authentication + * is complete, or the domain value provided by the client before it. + * @return the domain + */ + public String getDomain() { + return domain; + } + + /** + * Disposes any password-derived information. + */ + public void dispose() { + Arrays.fill(pw1, (byte)0); + Arrays.fill(pw2, (byte)0); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/ntlm/NTLM.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,426 @@ +/* + * 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.security.ntlm; + +import static com.sun.security.ntlm.Version.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.util.Arrays; +import javax.crypto.BadPaddingException; +import javax.crypto.Cipher; +import javax.crypto.IllegalBlockSizeException; +import javax.crypto.Mac; +import javax.crypto.NoSuchPaddingException; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.DESKeySpec; +import javax.crypto.spec.SecretKeySpec; + +/** + * NTLM authentication implemented according to MS-NLMP, version 12.1 + * @since 1.7 + */ +class NTLM { + + private final SecretKeyFactory fac; + private final Cipher cipher; + private final MessageDigest md4; + private final Mac hmac; + private final MessageDigest md5; + private static final boolean DEBUG = + System.getProperty("ntlm.debug") != null; + + final Version v; + + final boolean writeLM; + final boolean writeNTLM; + + protected NTLM(String version) throws NTLMException { + if (version == null) version = "LMv2/NTLMv2"; + switch (version) { + case "LM": v = NTLM; writeLM = true; writeNTLM = false; break; + case "NTLM": v = NTLM; writeLM = false; writeNTLM = true; break; + case "LM/NTLM": v = NTLM; writeLM = writeNTLM = true; break; + case "NTLM2": v = NTLM2; writeLM = writeNTLM = true; break; + case "LMv2": v = NTLMv2; writeLM = true; writeNTLM = false; break; + case "NTLMv2": v = NTLMv2; writeLM = false; writeNTLM = true; break; + case "LMv2/NTLMv2": v = NTLMv2; writeLM = writeNTLM = true; break; + default: throw new NTLMException(NTLMException.BAD_VERSION, + "Unknown version " + version); + } + try { + fac = SecretKeyFactory.getInstance ("DES"); + cipher = Cipher.getInstance ("DES/ECB/NoPadding"); + md4 = sun.security.provider.MD4.getInstance(); + hmac = Mac.getInstance("HmacMD5"); + md5 = MessageDigest.getInstance("MD5"); + } catch (NoSuchPaddingException e) { + throw new AssertionError(); + } catch (NoSuchAlgorithmException e) { + throw new AssertionError(); + } + } + + /** + * Prints out a formatted string, called in various places inside then NTLM + * implementation for debugging/logging purposes. When the system property + * "ntlm.debug" is set, <code>System.out.printf(format, args)</code> is + * called. This method is designed to be overridden by child classes to + * match their own debugging/logging mechanisms. + * @param format a format string + * @param args the arguments referenced by <code>format</code> + * @see java.io.PrintStream#printf(java.lang.String, java.lang.Object[]) + */ + public void debug(String format, Object... args) { + if (DEBUG) { + System.out.printf(format, args); + } + } + + /** + * Prints out the content of a byte array, called in various places inside + * the NTLM implementation for debugging/logging purposes. When the system + * property "ntlm.debug" is set, the hexdump of the array is printed into + * System.out. This method is designed to be overridden by child classes to + * match their own debugging/logging mechanisms. + * @param bytes the byte array to print out + */ + public void debug(byte[] bytes) { + if (DEBUG) { + try { + new sun.misc.HexDumpEncoder().encodeBuffer(bytes, System.out); + } catch (IOException ioe) { + // Impossible + } + } + } + + /** + * Reading an NTLM packet + */ + static class Reader { + + private final byte[] internal; + + Reader(byte[] data) { + internal = data; + } + + int readInt(int offset) throws NTLMException { + try { + return internal[offset] & 0xff + + (internal[offset+1] & 0xff << 8) + + (internal[offset+2] & 0xff << 16) + + (internal[offset+3] & 0xff << 24); + } catch (ArrayIndexOutOfBoundsException ex) { + throw new NTLMException(NTLMException.PACKET_READ_ERROR, + "Input message incorrect size"); + } + } + + int readShort(int offset) throws NTLMException { + try { + return internal[offset] & 0xff + + (internal[offset+1] & 0xff << 8); + } catch (ArrayIndexOutOfBoundsException ex) { + throw new NTLMException(NTLMException.PACKET_READ_ERROR, + "Input message incorrect size"); + } + } + + byte[] readBytes(int offset, int len) throws NTLMException { + try { + return Arrays.copyOfRange(internal, offset, offset + len); + } catch (ArrayIndexOutOfBoundsException ex) { + throw new NTLMException(NTLMException.PACKET_READ_ERROR, + "Input message incorrect size"); + } + } + + byte[] readSecurityBuffer(int offset) throws NTLMException { + int pos = readInt(offset+4); + if (pos == 0) return null; + try { + return Arrays.copyOfRange( + internal, pos, pos + readShort(offset)); + } catch (ArrayIndexOutOfBoundsException ex) { + throw new NTLMException(NTLMException.PACKET_READ_ERROR, + "Input message incorrect size"); + } + } + + String readSecurityBuffer(int offset, boolean unicode) + throws NTLMException { + byte[] raw = readSecurityBuffer(offset); + try { + return raw == null ? null : new String( + raw, unicode ? "UnicodeLittleUnmarked" : "ISO8859_1"); + } catch (UnsupportedEncodingException ex) { + throw new NTLMException(NTLMException.PACKET_READ_ERROR, + "Invalid input encoding"); + } + } + } + + /** + * Writing an NTLM packet + */ + static class Writer { + + private byte[] internal; // buffer + private int current; // current written content interface buffer + + /** + * Starts writing a NTLM packet + * @param type NEGOTIATE || CHALLENGE || AUTHENTICATE + * @param len the base length, without security buffers + */ + Writer(int type, int len) { + assert len < 256; + internal = new byte[256]; + current = len; + System.arraycopy ( + new byte[] {'N','T','L','M','S','S','P',0,(byte)type}, + 0, internal, 0, 9); + } + + void writeShort(int offset, int number) { + internal[offset] = (byte)(number); + internal[offset+1] = (byte)(number >> 8); + } + + void writeInt(int offset, int number) { + internal[offset] = (byte)(number); + internal[offset+1] = (byte)(number >> 8); + internal[offset+2] = (byte)(number >> 16); + internal[offset+3] = (byte)(number >> 24); + } + + void writeBytes(int offset, byte[] data) { + System.arraycopy(data, 0, internal, offset, data.length); + } + + void writeSecurityBuffer(int offset, byte[] data) { + if (data == null) { + writeShort(offset+4, current); + } else { + int len = data.length; + if (current + len > internal.length) { + internal = Arrays.copyOf(internal, current + len + 256); + } + writeShort(offset, len); + writeShort(offset+2, len); + writeShort(offset+4, current); + System.arraycopy(data, 0, internal, current, len); + current += len; + } + } + + void writeSecurityBuffer(int offset, String str, boolean unicode) { + try { + writeSecurityBuffer(offset, str == null ? null : str.getBytes( + unicode ? "UnicodeLittleUnmarked" : "ISO8859_1")); + } catch (UnsupportedEncodingException ex) { + assert false; + } + } + + byte[] getBytes() { + return Arrays.copyOf(internal, current); + } + } + + // LM/NTLM + + /* Convert a 7 byte array to an 8 byte array (for a des key with parity) + * input starts at offset off + */ + byte[] makeDesKey (byte[] input, int off) { + int[] in = new int [input.length]; + for (int i=0; i<in.length; i++ ) { + in[i] = input[i]<0 ? input[i]+256: input[i]; + } + byte[] out = new byte[8]; + out[0] = (byte)in[off+0]; + out[1] = (byte)(((in[off+0] << 7) & 0xFF) | (in[off+1] >> 1)); + out[2] = (byte)(((in[off+1] << 6) & 0xFF) | (in[off+2] >> 2)); + out[3] = (byte)(((in[off+2] << 5) & 0xFF) | (in[off+3] >> 3)); + out[4] = (byte)(((in[off+3] << 4) & 0xFF) | (in[off+4] >> 4)); + out[5] = (byte)(((in[off+4] << 3) & 0xFF) | (in[off+5] >> 5)); + out[6] = (byte)(((in[off+5] << 2) & 0xFF) | (in[off+6] >> 6)); + out[7] = (byte)((in[off+6] << 1) & 0xFF); + return out; + } + + byte[] calcLMHash (byte[] pwb) { + byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; + byte[] pwb1 = new byte [14]; + int len = pwb.length; + if (len > 14) + len = 14; + System.arraycopy (pwb, 0, pwb1, 0, len); /* Zero padded */ + + try { + DESKeySpec dks1 = new DESKeySpec (makeDesKey (pwb1, 0)); + DESKeySpec dks2 = new DESKeySpec (makeDesKey (pwb1, 7)); + + SecretKey key1 = fac.generateSecret (dks1); + SecretKey key2 = fac.generateSecret (dks2); + cipher.init (Cipher.ENCRYPT_MODE, key1); + byte[] out1 = cipher.doFinal (magic, 0, 8); + cipher.init (Cipher.ENCRYPT_MODE, key2); + byte[] out2 = cipher.doFinal (magic, 0, 8); + byte[] result = new byte [21]; + System.arraycopy (out1, 0, result, 0, 8); + System.arraycopy (out2, 0, result, 8, 8); + return result; + } catch (InvalidKeyException ive) { + // Will not happen, all key material are 8 bytes + assert false; + } catch (InvalidKeySpecException ikse) { + // Will not happen, we only feed DESKeySpec to DES factory + assert false; + } catch (IllegalBlockSizeException ibse) { + // Will not happen, we encrypt 8 bytes + assert false; + } catch (BadPaddingException bpe) { + // Will not happen, this is encryption + assert false; + } + return null; // will not happen, we returned already + } + + byte[] calcNTHash (byte[] pw) { + byte[] out = md4.digest (pw); + byte[] result = new byte [21]; + System.arraycopy (out, 0, result, 0, 16); + return result; + } + + /* key is a 21 byte array. Split it into 3 7 byte chunks, + * Convert each to 8 byte DES keys, encrypt the text arg with + * each key and return the three results in a sequential [] + */ + byte[] calcResponse (byte[] key, byte[] text) { + try { + assert key.length == 21; + DESKeySpec dks1 = new DESKeySpec(makeDesKey(key, 0)); + DESKeySpec dks2 = new DESKeySpec(makeDesKey(key, 7)); + DESKeySpec dks3 = new DESKeySpec(makeDesKey(key, 14)); + SecretKey key1 = fac.generateSecret(dks1); + SecretKey key2 = fac.generateSecret(dks2); + SecretKey key3 = fac.generateSecret(dks3); + cipher.init(Cipher.ENCRYPT_MODE, key1); + byte[] out1 = cipher.doFinal(text, 0, 8); + cipher.init(Cipher.ENCRYPT_MODE, key2); + byte[] out2 = cipher.doFinal(text, 0, 8); + cipher.init(Cipher.ENCRYPT_MODE, key3); + byte[] out3 = cipher.doFinal(text, 0, 8); + byte[] result = new byte[24]; + System.arraycopy(out1, 0, result, 0, 8); + System.arraycopy(out2, 0, result, 8, 8); + System.arraycopy(out3, 0, result, 16, 8); + return result; + } catch (IllegalBlockSizeException ex) { // None will happen + assert false; + } catch (BadPaddingException ex) { + assert false; + } catch (InvalidKeySpecException ex) { + assert false; + } catch (InvalidKeyException ex) { + assert false; + } + return null; + } + + // LMv2/NTLMv2 + + byte[] hmacMD5(byte[] key, byte[] text) { + try { + SecretKeySpec skey = + new SecretKeySpec(Arrays.copyOf(key, 16), "HmacMD5"); + hmac.init(skey); + return hmac.doFinal(text); + } catch (InvalidKeyException ex) { + assert false; + } catch (RuntimeException e) { + assert false; + } + return null; + } + + byte[] calcV2(byte[] nthash, String text, byte[] blob, byte[] challenge) { + try { + byte[] ntlmv2hash = hmacMD5(nthash, + text.getBytes("UnicodeLittleUnmarked")); + byte[] cn = new byte[blob.length+8]; + System.arraycopy(challenge, 0, cn, 0, 8); + System.arraycopy(blob, 0, cn, 8, blob.length); + byte[] result = new byte[16+blob.length]; + System.arraycopy(hmacMD5(ntlmv2hash, cn), 0, result, 0, 16); + System.arraycopy(blob, 0, result, 16, blob.length); + return result; + } catch (UnsupportedEncodingException ex) { + assert false; + } + return null; + } + + // NTLM2 LM/NTLM + + static byte[] ntlm2LM(byte[] nonce) { + return Arrays.copyOf(nonce, 24); + } + + byte[] ntlm2NTLM(byte[] ntlmHash, byte[] nonce, byte[] challenge) { + byte[] b = Arrays.copyOf(challenge, 16); + System.arraycopy(nonce, 0, b, 8, 8); + byte[] sesshash = Arrays.copyOf(md5.digest(b), 8); + return calcResponse(ntlmHash, sesshash); + } + + // Password in ASCII and UNICODE + + static byte[] getP1(char[] password) { + try { + return new String(password).toUpperCase().getBytes("ISO8859_1"); + } catch (UnsupportedEncodingException ex) { + return null; + } + } + + static byte[] getP2(char[] password) { + try { + return new String(password).getBytes("UnicodeLittleUnmarked"); + } catch (UnsupportedEncodingException ex) { + return null; + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/ntlm/NTLMException.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,88 @@ +/* + * 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.security.ntlm; + +import java.security.GeneralSecurityException; + +/** + * An NTLM-related Exception + */ +public final class NTLMException extends GeneralSecurityException { + + /** + * If the incoming packet is invalid. + */ + public final static int PACKET_READ_ERROR = 1; + + /** + * If the client cannot get a domain value from the server and the + * caller has not provided one. + */ + public final static int NO_DOMAIN_INFO = 2; + + /** + * If the domain provided by the client does not match the one received + * from server. + */ + //public final static int DOMAIN_UNMATCH = 3; + + /** + * If the client name is not found on server's user database. + */ + public final static int USER_UNKNOWN = 3; + + /** + * If authentication fails. + */ + public final static int AUTH_FAILED = 4; + + /** + * If an illegal version string is provided. + */ + public final static int BAD_VERSION = 5; + + private int errorCode; + + /** + * Constructs an NTLMException object. + * @param errorCode the error code, which can be retrieved by + * the {@link #errorCode() } method. + * @param msg the string message, which can be retrived by + * the {@link Exception#getMessage() } method. + */ + public NTLMException(int errorCode, String msg) { + super(msg); + this.errorCode = errorCode; + } + + /** + * Returns the error code associated with this NTLMException. + * @return the error code + */ + public int errorCode() { + return errorCode; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/ntlm/Server.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,205 @@ +/* + * 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.security.ntlm; + +import java.util.Arrays; +import java.util.Locale; + +/** + * The NTLM server, not multi-thread enabled.<p> + * Example: + * <pre> + * Server server = new Server(null, "REALM") { + * public char[] getPassword(String ntdomain, String username) { + * switch (username) { + * case "dummy": return "t0pSeCr3t".toCharArray(); + * case "guest": return "".toCharArray(); + * default: return null; + * } + * } + * }; + * // Receive client request as type1 + * byte[] type2 = server.type2(type1, nonce); + * // Send type2 to client and receive type3 + * verify(type3, nonce); + * </pre> + */ +public abstract class Server extends NTLM { + final private String domain; + final private boolean allVersion; + /** + * Creates a Server instance. + * @param version the NTLM version to use, which can be: + * <ul> + * <li>NTLM: Original NTLM v1 + * <li>NTLM2: NTLM v1 with Client Challenge + * <li>NTLMv2: NTLM v2 + * </ul> + * If null, all versions will be supported. Please note that unless NTLM2 + * is selected, authentication succeeds if one of LM (or LMv2) or + * NTLM (or NTLMv2) is verified. + * @param domain the domain, must not be null + * @throws NullPointerException if {@code domain} is null. + */ + public Server(String version, String domain) throws NTLMException { + super(version); + if (domain == null) { + throw new NullPointerException("domain cannot be null"); + } + this.allVersion = (version == null); + this.domain = domain; + debug("NTLM Server: (t,version) = (%s,%s)\n", domain, version); + } + + /** + * Generates the Type 2 message + * @param type1 the Type1 message received, must not be null + * @param nonce the random 8-byte array to be used in message generation, + * must not be null + * @return the message generated + * @throws NullPointerException if type1 or nonce is null + * @throws NTLMException if the incoming message is invalid + */ + public byte[] type2(byte[] type1, byte[] nonce) { + if (nonce == null) { + throw new NullPointerException("nonce cannot be null"); + } + debug("NTLM Server: Type 1 received\n"); + if (type1 != null) debug(type1); + Writer p = new Writer(2, 32); + int flags = 0x80205; + p.writeSecurityBuffer(12, domain, true); + p.writeInt(20, flags); + p.writeBytes(24, nonce); + debug("NTLM Server: Type 2 created\n"); + debug(p.getBytes()); + return p.getBytes(); + } + + /** + * Verifies the Type3 message received from client and returns + * various negotiated information. + * @param type3 the incoming Type3 message from client, must not be null + * @param nonce the same nonce provided in {@link #type2}, must not be null + * @return username and hostname of the client in a byte array + * @throws NullPointerException if {@code type3} or {@code nonce} is null + * @throws NTLMException if the incoming message is invalid + */ + public String[] verify(byte[] type3, byte[] nonce) + throws NTLMException { + if (type3 == null || nonce == null) { + throw new NullPointerException("type1 or nonce cannot be null"); + } + debug("NTLM Server: Type 3 received\n"); + if (type3 != null) debug(type3); + Reader r = new Reader(type3); + String username = r.readSecurityBuffer(36, true); + String hostname = r.readSecurityBuffer(44, true); + String incomingDomain = r.readSecurityBuffer(28, true); + /*if (incomingDomain != null && !incomingDomain.equals(domain)) { + throw new NTLMException(NTLMException.DOMAIN_UNMATCH, + "Wrong domain: " + incomingDomain + + " vs " + domain); // Needed? + }*/ + boolean verified = false; + char[] password = getPassword(domain, username); + if (password == null) { + throw new NTLMException(NTLMException.USER_UNKNOWN, + "Unknown user"); + } + byte[] incomingLM = r.readSecurityBuffer(12); + byte[] incomingNTLM = r.readSecurityBuffer(20); + + if (!verified && (allVersion || v == Version.NTLM)) { + if (incomingLM.length > 0) { + byte[] pw1 = getP1(password); + byte[] lmhash = calcLMHash(pw1); + byte[] lmresponse = calcResponse (lmhash, nonce); + if (Arrays.equals(lmresponse, incomingLM)) { + verified = true; + } + } + if (incomingNTLM.length > 0) { + byte[] pw2 = getP2(password); + byte[] nthash = calcNTHash(pw2); + byte[] ntresponse = calcResponse (nthash, nonce); + if (Arrays.equals(ntresponse, incomingNTLM)) { + verified = true; + } + } + debug("NTLM Server: verify using NTLM: " + verified + "\n"); + } + if (!verified && (allVersion || v == Version.NTLM2)) { + byte[] pw2 = getP2(password); + byte[] nthash = calcNTHash(pw2); + byte[] clientNonce = Arrays.copyOf(incomingLM, 8); + byte[] ntlmresponse = ntlm2NTLM(nthash, clientNonce, nonce); + if (Arrays.equals(incomingNTLM, ntlmresponse)) { + verified = true; + } + debug("NTLM Server: verify using NTLM2: " + verified + "\n"); + } + if (!verified && (allVersion || v == Version.NTLMv2)) { + byte[] pw2 = getP2(password); + byte[] nthash = calcNTHash(pw2); + if (incomingLM.length > 0) { + byte[] clientNonce = Arrays.copyOfRange( + incomingLM, 16, incomingLM.length); + byte[] lmresponse = calcV2(nthash, + username.toUpperCase(Locale.US)+incomingDomain, + clientNonce, nonce); + if (Arrays.equals(lmresponse, incomingLM)) { + verified = true; + } + } + if (incomingNTLM.length > 0) { + byte[] clientBlob = Arrays.copyOfRange( + incomingNTLM, 16, incomingNTLM.length); + byte[] ntlmresponse = calcV2(nthash, + username.toUpperCase(Locale.US)+incomingDomain, + clientBlob, nonce); + if (Arrays.equals(ntlmresponse, incomingNTLM)) { + verified = true; + } + } + debug("NTLM Server: verify using NTLMv2: " + verified + "\n"); + } + if (!verified) { + throw new NTLMException(NTLMException.AUTH_FAILED, + "None of LM and NTLM verified"); + } + return new String[] {username, hostname}; + } + + /** + * Retrieves the password for a given user. This method should be + * overridden in a concrete class. + * @param domain can be null + * @param username must not be null + * @return the password for the user, or null if unknown + */ + public abstract char[] getPassword(String domain, String username); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/ntlm/Version.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,30 @@ +/* + * 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.security.ntlm; + +enum Version { + NTLM, NTLM2, NTLMv2 +}
--- a/jdk/src/share/classes/com/sun/security/sasl/Provider.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/com/sun/security/sasl/Provider.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -35,10 +35,12 @@ * - CRAM-MD5 * - DIGEST-MD5 * - GSSAPI/Kerberos v5 + * - NTLM * And server support for * - CRAM-MD5 * - DIGEST-MD5 * - GSSAPI/Kerberos v5 + * - NTLM */ public final class Provider extends java.security.Provider { @@ -47,8 +49,8 @@ private static final String info = "Sun SASL provider" + "(implements client mechanisms for: " + - "DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5;" + - " server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5)"; + "DIGEST-MD5, GSSAPI, EXTERNAL, PLAIN, CRAM-MD5, NTLM;" + + " server mechanisms for: DIGEST-MD5, GSSAPI, CRAM-MD5, NTLM)"; public Provider() { super("SunSASL", 1.7d, info); @@ -58,6 +60,8 @@ // Client mechanisms put("SaslClientFactory.DIGEST-MD5", "com.sun.security.sasl.digest.FactoryImpl"); + put("SaslClientFactory.NTLM", + "com.sun.security.sasl.ntlm.FactoryImpl"); put("SaslClientFactory.GSSAPI", "com.sun.security.sasl.gsskerb.FactoryImpl"); @@ -75,6 +79,8 @@ "com.sun.security.sasl.gsskerb.FactoryImpl"); put("SaslServerFactory.DIGEST-MD5", "com.sun.security.sasl.digest.FactoryImpl"); + put("SaslServerFactory.NTLM", + "com.sun.security.sasl.ntlm.FactoryImpl"); return null; } });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,119 @@ +/* + * 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.security.sasl.ntlm; + +import java.util.Map; + +import javax.security.sasl.*; +import javax.security.auth.callback.CallbackHandler; + +import com.sun.security.sasl.util.PolicyUtils; + + +/** + * Client and server factory for NTLM SASL client/server mechanisms. + * See NTLMClient and NTLMServer for input requirements. + * + * @since 1.7 + */ + +public final class FactoryImpl implements SaslClientFactory, +SaslServerFactory{ + + private static final String myMechs[] = { "NTLM" }; + private static final int mechPolicies[] = { + PolicyUtils.NOPLAINTEXT|PolicyUtils.NOANONYMOUS + }; + + /** + * Empty constructor. + */ + public FactoryImpl() { + } + + /** + * Returns a new instance of the NTLM SASL client mechanism. + * Argument checks are performed in SaslClient's constructor. + * @returns a new SaslClient ; otherwise null if unsuccessful. + * @throws SaslException If there is an error creating the NTLM + * SASL client. + */ + public SaslClient createSaslClient(String[] mechs, + String authorizationId, String protocol, String serverName, + Map<String,?> props, CallbackHandler cbh) + throws SaslException { + + for (int i=0; i<mechs.length; i++) { + if (mechs[i].equals("NTLM") && + PolicyUtils.checkPolicy(mechPolicies[0], props)) { + + return new NTLMClient(mechs[i], authorizationId, + protocol, serverName, props, cbh); + } + } + return null; + } + + /** + * Returns a new instance of the NTLM SASL server mechanism. + * Argument checks are performed in SaslServer's constructor. + * @returns a new SaslServer ; otherwise null if unsuccessful. + * @throws SaslException If there is an error creating the NTLM + * SASL server. + */ + public SaslServer createSaslServer(String mech, + String protocol, String serverName, Map<String,?> props, CallbackHandler cbh) + throws SaslException { + + if (mech.equals("NTLM") && + PolicyUtils.checkPolicy(mechPolicies[0], props)) { + if (props != null) { + String qop = (String)props.get(Sasl.QOP); + if (qop != null && !qop.equals("auth")) { + throw new SaslException("NTLM only support auth"); + } + } + if (cbh == null) { + throw new SaslException( + "Callback handler with support for AuthorizeCallback, "+ + "RealmCallback, NameCallback, and PasswordCallback " + + "required"); + } + return new NTLMServer(mech, protocol, serverName, props, cbh); + } + return null; + } + + /** + * Returns the authentication mechanisms that this factory can produce. + * + * @returns String[] {"NTLM"} if policies in env match those of this + * factory. + */ + public String[] getMechanismNames(Map<String,?> env) { + return PolicyUtils.filterMechs(myMechs, mechPolicies, env); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,231 @@ +/* + * 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.security.sasl.ntlm; + +import com.sun.security.ntlm.Client; +import com.sun.security.ntlm.NTLMException; +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Map; +import java.util.Random; +import javax.security.auth.callback.Callback; + + +import javax.security.sasl.*; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; + +/** + * Required callbacks: + * - RealmCallback + * handle can provide domain info for authentication, optional + * - NameCallback + * handler must enter username to use for authentication + * - PasswordCallback + * handler must enter password for username to use for authentication + * + * Environment properties that affect behavior of implementation: + * + * javax.security.sasl.qop + * String, quality of protection; only "auth" is accepted, default "auth" + * + * com.sun.security.sasl.ntlm.version + * String, name a specific version to use; can be: + * LM/NTLM: Original NTLM v1 + * LM: Original NTLM v1, LM only + * NTLM: Original NTLM v1, NTLM only + * NTLM2: NTLM v1 with Client Challenge + * LMv2/NTLMv2: NTLM v2 + * LMv2: NTLM v2, LM only + * NTLMv2: NTLM v2, NTLM only + * If not specified, use system property "ntlm.version". If + * still not specified, use default value "LMv2/NTLMv2". + * + * com.sun.security.sasl.ntlm.random + * java.util.Random, the nonce source to be used in NTLM v2 or NTLM v1 with + * Client Challenge. Default null, an internal java.util.Random object + * will be used + * + * Negotiated Properties: + * + * javax.security.sasl.qop + * Always "auth" + * + * com.sun.security.sasl.html.domain + * The domain for the user, provided by the server + * + * @see <a href="http://www.ietf.org/rfc/rfc2222.txt">RFC 2222</a> + * - Simple Authentication and Security Layer (SASL) + * + */ +final class NTLMClient implements SaslClient { + + private static final String NTLM_VERSION = + "com.sun.security.sasl.ntlm.version"; + private static final String NTLM_RANDOM = + "com.sun.security.sasl.ntlm.random"; + private final static String NTLM_DOMAIN = + "com.sun.security.sasl.ntlm.domain"; + private final static String NTLM_HOSTNAME = + "com.sun.security.sasl.ntlm.hostname"; + + private final Client client; + private final String mech; + private final Random random; + + private int step = 0; // 0-start,1-nego,2-auth,3-done + + /** + * @param mech non-null + * @param authorizationId can be null or empty and ignored + * @param protocol non-null for Sasl, useless for NTLM + * @param serverName non-null for Sasl, but can be null for NTLM + * @param props can be null + * @param cbh can be null for Sasl, but will throw NPE for NTLM + * @throws SaslException + */ + NTLMClient(String mech, String authzid, String protocol, String serverName, + Map props, CallbackHandler cbh) throws SaslException { + + this.mech = mech; + String version = null; + Random rtmp = null; + String hostname = null; + + if (props != null) { + String qop = (String)props.get(Sasl.QOP); + if (qop != null && !qop.equals("auth")) { + throw new SaslException("NTLM only support auth"); + } + version = (String)props.get(NTLM_VERSION); + rtmp = (Random)props.get(NTLM_RANDOM); + hostname = (String)props.get(NTLM_HOSTNAME); + } + this.random = rtmp != null ? rtmp : new Random(); + + if (version == null) { + version = System.getProperty("ntlm.version"); + } + + RealmCallback dcb = (serverName != null && !serverName.isEmpty())? + new RealmCallback("Realm: ", serverName) : + new RealmCallback("Realm: "); + NameCallback ncb = (authzid != null && !authzid.isEmpty()) ? + new NameCallback("User name: ", authzid) : + new NameCallback("User name: "); + PasswordCallback pcb = + new PasswordCallback("Password: ", false); + + try { + cbh.handle(new Callback[] {dcb, ncb, pcb}); + } catch (UnsupportedCallbackException e) { + throw new SaslException("NTLM: Cannot perform callback to " + + "acquire realm, username or password", e); + } catch (IOException e) { + throw new SaslException( + "NTLM: Error acquiring realm, username or password", e); + } + + if (hostname == null) { + try { + hostname = InetAddress.getLocalHost().getCanonicalHostName(); + } catch (UnknownHostException e) { + hostname = "localhost"; + } + } + try { + client = new Client(version, hostname, + ncb.getName(), + dcb.getText(), + pcb.getPassword()); + } catch (NTLMException ne) { + throw new SaslException( + "NTLM: Invalid version string: " + version, ne); + } + } + + @Override + public String getMechanismName() { + return mech; + } + + @Override + public boolean isComplete() { + return step >= 2; + } + + @Override + public byte[] unwrap(byte[] incoming, int offset, int len) + throws SaslException { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public byte[] wrap(byte[] outgoing, int offset, int len) + throws SaslException { + throw new UnsupportedOperationException("Not supported."); + } + + @Override + public Object getNegotiatedProperty(String propName) { + if (propName.equals(Sasl.QOP)) { + return "auth"; + } else if (propName.equals(NTLM_DOMAIN)) { + return client.getDomain(); + } else { + return null; + } + } + + @Override + public void dispose() throws SaslException { + client.dispose(); + } + + @Override + public boolean hasInitialResponse() { + return true; + } + + @Override + public byte[] evaluateChallenge(byte[] challenge) throws SaslException { + step++; + if (step == 1) { + return client.type1(); + } else { + try { + byte[] nonce = new byte[8]; + random.nextBytes(nonce); + return client.type3(challenge, nonce); + } catch (NTLMException ex) { + throw new SaslException("Type3 creation failed", ex); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,226 @@ +/* + * 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.security.sasl.ntlm; + +import com.sun.security.ntlm.NTLMException; +import com.sun.security.ntlm.Server; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.Map; +import java.util.Random; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.NameCallback; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; +import javax.security.sasl.*; + +/** + * Required callbacks: + * - RealmCallback + * used as key by handler to fetch password, optional + * - NameCallback + * used as key by handler to fetch password + * - PasswordCallback + * handler must enter password for username/realm supplied + * + * Environment properties that affect the implementation: + * + * javax.security.sasl.qop + * String, quality of protection; only "auth" is accepted, default "auth" + * + * com.sun.security.sasl.ntlm.version + * String, name a specific version to accept: + * LM/NTLM: Original NTLM v1 + * LM: Original NTLM v1, LM only + * NTLM: Original NTLM v1, NTLM only + * NTLM2: NTLM v1 with Client Challenge + * LMv2/NTLMv2: NTLM v2 + * LMv2: NTLM v2, LM only + * NTLMv2: NTLM v2, NTLM only + * If not specified, use system property "ntlm.version". If also + * not specfied, all versions are accepted. + * + * com.sun.security.sasl.ntlm.domain + * String, the domain of the server, default is server name (fqdn parameter) + * + * com.sun.security.sasl.ntlm.random + * java.util.Random, the nonce source. Default null, an internal + * java.util.Random object will be used + * + * Negotiated Properties: + * + * javax.security.sasl.qop + * Always "auth" + * + * com.sun.security.sasl.ntlm.hostname + * The hostname for the user, provided by the client + * + */ + +final class NTLMServer implements SaslServer { + + private final static String NTLM_VERSION = + "com.sun.security.sasl.ntlm.version"; + private final static String NTLM_DOMAIN = + "com.sun.security.sasl.ntlm.domain"; + private final static String NTLM_HOSTNAME = + "com.sun.security.sasl.ntlm.hostname"; + private static final String NTLM_RANDOM = + "com.sun.security.sasl.ntlm.random"; + + private final Random random; + private final Server server; + private byte[] nonce; + private int step = 0; + private String authzId; + private final String mech; + private String hostname; + + /** + * @param mech not null + * @param protocol not null for Sasl, ignored in NTLM + * @param serverName not null for Sasl, can be null in NTLM. If non-null, + * might be used as domain if not provided in props + * @param props can be null + * @param cbh can be null for Sasl, but will throw NPE in auth for NTLM + * @throws SaslException + */ + NTLMServer(String mech, String protocol, String serverName, + Map props, final CallbackHandler cbh) throws SaslException { + + this.mech = mech; + String version = null; + String domain = null; + Random rtmp = null; + + if (props != null) { + domain = (String) props.get(NTLM_DOMAIN); + version = (String)props.get(NTLM_VERSION); + rtmp = (Random)props.get(NTLM_RANDOM); + } + random = rtmp != null ? rtmp : new Random(); + + if (version == null) { + version = System.getProperty("ntlm.version"); + } + if (domain == null) { + domain = serverName; + } + if (domain == null) { + throw new NullPointerException("Domain must be provided as" + + " the serverName argument or in props"); + } + + try { + server = new Server(version, domain) { + public char[] getPassword(String ntdomain, String username) { + try { + RealmCallback rcb = new RealmCallback( + "Domain: ", ntdomain); + NameCallback ncb = new NameCallback( + "Name: ", username); + PasswordCallback pcb = new PasswordCallback( + "Password: ", false); + cbh.handle(new Callback[] { rcb, ncb, pcb }); + char[] passwd = pcb.getPassword(); + pcb.clearPassword(); + return passwd; + } catch (IOException ioe) { + return null; + } catch (UnsupportedCallbackException uce) { + return null; + } + } + }; + } catch (NTLMException ne) { + throw new SaslException( + "NTLM: Invalid version string: " + version, ne); + } + nonce = new byte[8]; + } + + @Override + public String getMechanismName() { + return mech; + } + + @Override + public byte[] evaluateResponse(byte[] response) throws SaslException { + try { + step++; + if (step == 1) { + random.nextBytes(nonce); + return server.type2(response, nonce); + } else { + String[] out = server.verify(response, nonce); + authzId = out[0]; + hostname = out[1]; + return null; + } + } catch (GeneralSecurityException ex) { + throw new SaslException("", ex); + } + } + + @Override + public boolean isComplete() { + return step >= 2; + } + + @Override + public String getAuthorizationID() { + return authzId; + } + + @Override + public byte[] unwrap(byte[] incoming, int offset, int len) + throws SaslException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public byte[] wrap(byte[] outgoing, int offset, int len) + throws SaslException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getNegotiatedProperty(String propName) { + if (propName.equals(Sasl.QOP)) { + return "auth"; + } else if (propName.equals(NTLM_HOSTNAME)) { + return hostname; + } else { + return null; + } + } + + @Override + public void dispose() throws SaslException { + return; + } +}
--- a/jdk/src/share/classes/java/awt/Dialog.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/awt/Dialog.java Fri Sep 24 16:41:32 2010 -0700 @@ -277,10 +277,8 @@ */ String title; - private transient volatile boolean keepBlockingEDT = false; - private transient volatile boolean keepBlockingCT = false; - private transient ModalEventFilter modalFilter; + private transient volatile SecondaryLoop secondaryLoop; /* * Indicates that this dialog is being hidden. This flag is set to true at @@ -1005,12 +1003,6 @@ 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 * are not yet displayable, both are made displayable. The @@ -1037,39 +1029,18 @@ if (!isModal()) { conditionalShow(null, null); } else { - // Set this variable before calling conditionalShow(). That - // 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(); + AppContext showAppContext = AppContext.getAppContext(); AtomicLong time = new AtomicLong(); Component predictedFocusOwner = null; try { predictedFocusOwner = getMostRecentFocusOwner(); 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); - - final Runnable pumpEventsForFilter = new Runnable() { - public void run() { - EventDispatchThread dispatchThread = - (EventDispatchThread)Thread.currentThread(); - dispatchThread.pumpEventsForFilter(new Conditional() { - public boolean evaluate() { - synchronized (getTreeLock()) { - return keepBlockingEDT && windowClosingException == null; - } - } - }, modalFilter); + Conditional cond = new Conditional() { + @Override + public boolean evaluate() { + return windowClosingException == null; } }; @@ -1096,44 +1067,10 @@ modalityPushed(); try { - if (EventQueue.isDispatchThread()) { - /* - * dispose SequencedEvent we are dispatching on current - * AppContext, to prevent us from hang. - * - */ - // 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; - } - } - } + EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue(); + secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000); + if (!secondaryLoop.enter()) { + secondaryLoop = null; } } finally { modalityPopped(); @@ -1194,18 +1131,11 @@ windowClosingException = null; } } - final class WakingRunnable implements Runnable { - public void run() { - synchronized (getTreeLock()) { - keepBlockingCT = false; - getTreeLock().notifyAll(); - } - } - } + private void hideAndDisposePreHandler() { isInHide = true; synchronized (getTreeLock()) { - if (keepBlockingEDT) { + if (secondaryLoop != null) { modalHide(); // dialog can be shown and then disposed before its // modal filter is created @@ -1217,20 +1147,9 @@ } } private void hideAndDisposeHandler() { - synchronized (getTreeLock()) { - if (keepBlockingEDT) { - keepBlockingEDT = false; - 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); - } - } + if (secondaryLoop != null) { + secondaryLoop.exit(); + secondaryLoop = null; } isInHide = false; }
--- a/jdk/src/share/classes/java/awt/EventDispatchThread.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/awt/EventDispatchThread.java Fri Sep 24 16:41:32 2010 -0700 @@ -113,8 +113,7 @@ 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)); } @@ -124,6 +123,7 @@ void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) { addEventFilter(filter); + doDispatch = true; while (doDispatch && cond.evaluate()) { if (isInterrupted() || !pumpOneEventForFilters(id)) { doDispatch = false; @@ -133,6 +133,7 @@ } void addEventFilter(EventFilter filter) { + eventLog.finest("adding the event filter: " + filter); synchronized (eventFilters) { if (!eventFilters.contains(filter)) { if (filter instanceof ModalEventFilter) { @@ -156,6 +157,7 @@ } void removeEventFilter(EventFilter filter) { + eventLog.finest("removing the event filter: " + filter); synchronized (eventFilters) { eventFilters.remove(filter); }
--- a/jdk/src/share/classes/java/awt/EventQueue.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/awt/EventQueue.java Fri Sep 24 16:41:32 2010 -0700 @@ -884,6 +884,41 @@ } /** + * 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 * {@link Toolkit#getSystemEventQueue the current AWT EventQueue}'s * dispatch thread. Use this method to ensure that a particular
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/awt/SecondaryLoop.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,147 @@ +/* + * 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(); + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/awt/WaitDispatchSupport.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,302 @@ +/* + * 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)); + } +}
--- a/jdk/src/share/classes/java/lang/AutoCloseable.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/lang/AutoCloseable.java Fri Sep 24 16:41:32 2010 -0700 @@ -34,8 +34,8 @@ public interface AutoCloseable { /** * Close this resource, relinquishing any underlying resources. - * This method is invoked automatically by the automatic resource - * management block construct. + * This method is invoked automatically by the {@code + * try}-with-resources statement. * * <p>Classes implementing this method are strongly encouraged to * be declared to throw more specific exceptions (or no exception
--- a/jdk/src/share/classes/java/lang/Character.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/lang/Character.java Fri Sep 24 16:41:32 2010 -0700 @@ -595,7 +595,6 @@ /** * Constructs a new <code>Subset</code> instance. * - * @exception NullPointerException if name is <code>null</code> * @param name The name of this subset * @exception NullPointerException if name is <code>null</code> */
--- a/jdk/src/share/classes/java/lang/ClassLoader.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/lang/ClassLoader.java Fri Sep 24 16:41:32 2010 -0700 @@ -823,7 +823,7 @@ * </tt></blockquote> * * @param name - * The expected <a href="#name">binary name</a. of the class, or + * The expected <a href="#name">binary name</a>. of the class, or * <tt>null</tt> if not known * * @param b
--- a/jdk/src/share/classes/java/lang/Object.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/lang/Object.java Fri Sep 24 16:41:32 2010 -0700 @@ -189,7 +189,9 @@ * specific cloning operation. First, if the class of this object does * not implement the interface {@code Cloneable}, then a * {@code CloneNotSupportedException} is thrown. Note that all arrays - * are considered to implement the interface {@code Cloneable}. + * are considered to implement the interface {@code Cloneable} and that + * the return type of the {@code clone} method of an array type {@code T[]} + * is {@code T[]} where T is any reference or primitive type. * Otherwise, this method creates a new instance of the class of this * object and initializes all its fields with exactly the contents of * the corresponding fields of this object, as if by assignment; the
--- a/jdk/src/share/classes/java/lang/Throwable.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/lang/Throwable.java Fri Sep 24 16:41:32 2010 -0700 @@ -498,8 +498,8 @@ * } * </pre> * As of release 7, the platform supports the notion of - * <i>suppressed exceptions</i> (in conjunction with automatic - * resource management blocks). Any exceptions that were + * <i>suppressed exceptions</i> (in conjunction with the {@code + * try}-with-resources statement). Any exceptions that were * suppressed in order to deliver an exception are printed out * beneath the stack trace. The format of this information * depends on the implementation, but the following example may be @@ -805,7 +805,7 @@ /** * Adds the specified exception to the list of exceptions that - * were suppressed, typically by the automatic resource management + * were suppressed, typically by the {@code try}-with-resources * statement, in order to deliver this exception. * * <p>Note that when one exception {@linkplain @@ -839,7 +839,7 @@ /** * Returns an array containing all of the exceptions that were - * suppressed, typically by the automatic resource management + * suppressed, typically by the {@code try}-with-resources * statement, in order to deliver this exception. * * @return an array containing all of the exceptions that were
--- a/jdk/src/share/classes/java/lang/reflect/Constructor.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/lang/reflect/Constructor.java Fri Sep 24 16:41:32 2010 -0700 @@ -166,8 +166,7 @@ /** * Returns the name of this constructor, as a string. This is - * always the same as the simple name of the constructor's declaring - * class. + * the binary name of the constructor's declaring class. */ public String getName() { return getDeclaringClass().getName();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/net/SdpSocketImpl.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,49 @@ +/* + * 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.net; + +import java.io.IOException; +import java.io.FileDescriptor; + +import sun.net.sdp.SdpSupport; + +/** + * SocketImpl that supports the SDP protocol + */ +class SdpSocketImpl extends PlainSocketImpl { + SdpSocketImpl() { } + + @Override + protected void create(boolean stream) throws IOException { + if (!stream) + throw new UnsupportedOperationException("Must be a stream socket"); + fd = SdpSupport.createSocket(); + if (socket != null) + socket.setCreated(); + if (serverSocket != null) + serverSocket.setCreated(); + } +}
--- a/jdk/src/share/classes/java/net/ServerSocket.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/net/ServerSocket.java Fri Sep 24 16:41:32 2010 -0700 @@ -69,6 +69,15 @@ private boolean oldImpl = false; /** + * Package-private constructor to create a ServerSocket associated with + * the given SocketImpl. + */ + ServerSocket(SocketImpl impl) { + this.impl = impl; + impl.setServerSocket(this); + } + + /** * Creates an unbound server socket. * * @exception IOException IO error when opening the socket.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/nio/file/DirectoryIteratorException.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,87 @@ +/* + * 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.nio.file; + +import java.util.ConcurrentModificationException; +import java.util.Objects; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.InvalidObjectException; + +/** + * Runtime exception thrown if an I/O error is encountered when iterating over + * the entries in a directory. The I/O error is retrieved as an {@link + * IOException} using the {@link #getCause() getCause()} method. + * + * @since 1.7 + * @see DirectoryStream + */ + +public final class DirectoryIteratorException + extends ConcurrentModificationException +{ + private static final long serialVersionUID = -6012699886086212874L; + + /** + * Constructs an instance of this class. + * + * @param cause + * the {@code IOException} that caused the directory iteration + * to fail + * + * @throws NullPointerException + * if the cause is {@code null} + */ + public DirectoryIteratorException(IOException cause) { + super(Objects.nonNull(cause)); + } + + /** + * Returns the cause of this exception. + * + * @return the cause + */ + @Override + public IOException getCause() { + return (IOException)super.getCause(); + } + + /** + * Called to read the object from a stream. + * + * @throws InvalidObjectException + * if the object is invalid or has a cause that is not + * an {@code IOException} + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + s.defaultReadObject(); + Throwable cause = super.getCause(); + if (!(cause instanceof IOException)) + throw new InvalidObjectException("Cause must be an IOException"); + } +}
--- a/jdk/src/share/classes/java/nio/file/DirectoryStream.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/DirectoryStream.java Fri Sep 24 16:41:32 2010 -0700 @@ -31,60 +31,84 @@ /** * An object to iterate over the entries in a directory. A directory stream - * allows for convenient use of the for-each construct: + * allows for the convenient use of the for-each construct to iterate over a + * directory. + * + * <p> <b> While {@code DirectoryStream} extends {@code Iterable}, it is not a + * general-purpose {@code Iterable} as it supports only a single {@code + * Iterator}; invoking the {@link #iterator iterator} method to obtain a second + * or subsequent iterator throws {@code IllegalStateException}. </b> + * + * <p> An important property of the directory stream's {@code Iterator} is that + * its {@link Iterator#hasNext() hasNext} method is guaranteed to read-ahead by + * at least one element. If {@code hasNext} method returns {@code true}, and is + * followed by a call to the {@code next} method, it is guaranteed that the + * {@code next} method will not throw an exception due to an I/O error, or + * because the stream has been {@link #close closed}. The {@code Iterator} does + * not support the {@link Iterator#remove remove} operation. + * + * <p> A {@code DirectoryStream} is opened upon creation and is closed by + * invoking the {@code close} method. Closing a directory stream releases any + * resources associated with the stream. Failure to close the stream may result + * in a resource leak. The try-with-resources statement provides a useful + * construct to ensure that the stream is closed: * <pre> * Path dir = ... - * DirectoryStream<Path> stream = dir.newDirectoryStream(); - * try { + * try (DirectoryStream<Path> stream = dir.newDirectoryStream()) { * for (Path entry: stream) { - * .. + * ... * } - * } finally { - * stream.close(); * } * </pre> * - * <p><b> A {@code DirectoryStream} is not a general-purpose {@code Iterable}. - * While this interface extends {@code Iterable}, the {@code iterator} method - * may only be invoked once to obtain the iterator; a second, or subsequent, - * call to the {@code iterator} method throws {@code IllegalStateException}. </b> - * - * <p> A {@code DirectoryStream} is opened upon creation and is closed by - * invoking the {@link #close close} method. Closing the directory stream - * releases any resources associated with the stream. Once a directory stream - * is closed, all further method invocations on the iterator throw {@link - * java.util.ConcurrentModificationException} with cause {@link - * ClosedDirectoryStreamException}. + * <p> Once a directory stream is closed, then further access to the directory, + * using the {@code Iterator}, behaves as if the end of stream has been reached. + * Due to read-ahead, the {@code Iterator} may return one or more elements + * after the directory stream has been closed. Once these buffered elements + * have been read, then subsequent calls to the {@code hasNext} method returns + * {@code false}, and subsequent calls to the {@code next} method will throw + * {@code NoSuchElementException}. * * <p> A directory stream is not required to be <i>asynchronously closeable</i>. * If a thread is blocked on the directory stream's iterator reading from the * directory, and another thread invokes the {@code close} method, then the * second thread may block until the read operation is complete. * - * <p> The {@link Iterator#hasNext() hasNext} and {@link Iterator#next() next} - * methods can encounter an I/O error when iterating over the directory in which - * case {@code ConcurrentModificationException} is thrown with cause - * {@link java.io.IOException}. The {@code hasNext} method is guaranteed to - * read-ahead by at least one element. This means that if the {@code hasNext} - * method returns {@code true} and is followed by a call to the {@code next} - * method then it is guaranteed not to fail with a {@code - * ConcurrentModificationException}. + * <p> If an I/O error is encountered when accessing the directory then it + * causes the {@code Iterator}'s {@code hasNext} or {@code next} methods to + * throw {@link DirectoryIteratorException} with the {@link IOException} as the + * cause. As stated above, the {@code hasNext} method is guaranteed to + * read-ahead by at least one element. This means that if {@code hasNext} method + * returns {@code true}, and is followed by a call to the {@code next} method, + * then it is guaranteed that the {@code next} method will not fail with a + * {@code DirectoryIteratorException}. * * <p> The elements returned by the iterator are in no specific order. Some file * systems maintain special links to the directory itself and the directory's * parent directory. Entries representing these links are not returned by the * iterator. * - * <p> The iterator's {@link Iterator#remove() remove} method removes the - * directory entry for the last element returned by the iterator, as if by - * invoking the {@link Path#delete delete} method. If an I/O error or - * security exception occurs then {@code ConcurrentModificationException} is - * thrown with the cause. - * * <p> The iterator is <i>weakly consistent</i>. It is thread safe but does not * freeze the directory while iterating, so it may (or may not) reflect updates * to the directory that occur after the {@code DirectoryStream} is created. * + * <p> <b>Usage Examples:</b> + * Suppose we want a list of the source files in a directory. This example uses + * both the for-each and try-with-resources constructs. + * <pre> + * List<Path> listSourceFiles(Path dir) throws IOException { + * List<Path> result = new ArrayList<Path>(); + * try (DirectoryStream<Path> stream = dir.newDirectoryStream("*.{c,h,cpp,hpp,java}")) { + * for (Path entry: stream) { + * result.add(entry); + * } + * } catch (DirectoryIteratorException ex) { + * // I/O error encounted during the iteration, the cause is an IOException + * throw ex.getCause(); + * } + * return result; + * } + * </pre> * @param <T> The type of element returned by the iterator * * @since 1.7
--- a/jdk/src/share/classes/java/nio/file/Path.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/Path.java Fri Sep 24 16:41:32 2010 -0700 @@ -984,11 +984,11 @@ * directory. * * <p> Where the filter terminates due to an uncaught error or runtime - * exception then it is propogated to the iterator's {@link Iterator#hasNext() + * exception then it is propagated to the {@link Iterator#hasNext() * hasNext} or {@link Iterator#next() next} method. Where an {@code - * IOException} is thrown, it is propogated as a {@link - * java.util.ConcurrentModificationException} with the {@code - * IOException} as the cause. + * IOException} is thrown, it results in the {@code hasNext} or {@code + * next} method throwing a {@link DirectoryIteratorException} with the + * {@code IOException} as the cause. * * <p> When an implementation supports operations on entries in the * directory that execute in a race-free manner then the returned directory
--- a/jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java Fri Sep 24 16:41:32 2010 -0700 @@ -47,15 +47,6 @@ * newDirectoryStream} method will be a {@code SecureDirectoryStream} and must * be cast to that type in order to invoke the methods defined by this interface. * - * <p> As specified by {@code DirectoryStream}, the iterator's {@link - * java.util.Iterator#remove() remove} method removes the directory entry for - * the last element returned by the iterator. In the case of a {@code - * SecureDirectoryStream} the {@code remove} method behaves as if by invoking - * the {@link #deleteFile deleteFile} or {@link #deleteDirectory deleteDirectory} - * methods defined by this interface. The {@code remove} may require to examine - * the file to determine if the file is a directory, and consequently, it may - * not be atomic with respect to other file system operations. - * * <p> In the case of the default {@link java.nio.file.spi.FileSystemProvider * provider}, and a security manager is set, then the permission checks are * performed using the path obtained by resolving the given relative path
--- a/jdk/src/share/classes/java/sql/CallableStatement.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/CallableStatement.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -2436,4 +2436,64 @@ */ void setNClob(String parameterName, Reader reader) throws SQLException; + + //------------------------- JDBC 4.1 ----------------------------------- + + + /** + *<p>Returns an object representing the value of OUT parameter + * {@code parameterIndex} and will convert from the + * SQL type of the parameter to the requested Java data type, if the + * conversion is supported. If the conversion is not + * supported or null is specified for the type, a + * <code>SQLException</code> is thrown. + *<p> + * At a minimum, an implementation must support the conversions defined in + * Appendix B, Table B-3 and conversion of appropriate user defined SQL + * types to a Java type which implements {@code SQLData}, or {@code Struct}. + * Additional conversions may be supported and are vendor defined. + * + * @param parameterIndex the first parameter is 1, the second is 2, and so on + * @param type Class representing the Java data type to convert the + * designated parameter to. + * @return an instance of {@code type} holding the OUT parameter value + * @throws SQLException if conversion is not supported, type is null or + * another error occurs. The getCause() method of the + * exception may provide a more detailed exception, for example, if + * a conversion error occurs + * @throws SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.7 + */ + public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException; + + + /** + *<p>Returns an object representing the value of OUT parameter + * {@code parameterName} and will convert from the + * SQL type of the parameter to the requested Java data type, if the + * conversion is supported. If the conversion is not + * supported or null is specified for the type, a + * <code>SQLException</code> is thrown. + *<p> + * At a minimum, an implementation must support the conversions defined in + * Appendix B, Table B-3 and conversion of appropriate user defined SQL + * types to a Java type which implements {@code SQLData}, or {@code Struct}. + * Additional conversions may be supported and are vendor defined. + * + * @param parameterName the name of the parameter + * @param type Class representing the Java data type to convert + * the designated parameter to. + * @return an instance of {@code type} holding the OUT parameter + * value + * @throws SQLException if conversion is not supported, type is null or + * another error occurs. The getCause() method of the + * exception may provide a more detailed exception, for example, if + * a conversion error occurs + * @throws SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.7 + */ + public <T> T getObject(String parameterName, Class<T> type) throws SQLException; + }
--- a/jdk/src/share/classes/java/sql/Connection.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/Connection.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ package java.sql; import java.util.Properties; +import java.util.concurrent.Executor; /** * <P>A connection (session) with a specific @@ -38,7 +39,7 @@ * information is obtained with the <code>getMetaData</code> method. * * <P><B>Note:</B> When configuring a <code>Connection</code>, JDBC applications - * should use the appropritate <code>Connection</code> method such as + * should use the appropriate <code>Connection</code> method such as * <code>setAutoCommit</code> or <code>setTransactionIsolation</code>. * Applications should not invoke SQL commands directly to change the connection's * configuration when there is a JDBC method available. By default a <code>Connection</code> object is in @@ -80,7 +81,7 @@ * @see ResultSet * @see DatabaseMetaData */ -public interface Connection extends Wrapper { +public interface Connection extends Wrapper, AutoCloseable { /** * Creates a <code>Statement</code> object for sending @@ -347,6 +348,13 @@ * <P> * If the driver does not support catalogs, it will * silently ignore this request. + * <p> + * Calling {@code setCatalog} has no effect on previously created or prepared + * {@code Statement} objects. It is implementation defined whether a DBMS + * prepare operation takes place immediately when the {@code Connection} + * method {@code prepareStatement} or {@code prepareCall} is invoked. + * For maximum portability, {@code setCatalog} should be called before a + * {@code Statement} is created or prepared. * * @param catalog the name of a catalog (subspace in this * <code>Connection</code> object's database) in which to work @@ -598,7 +606,17 @@ * <code>Connection</code> object. * Unless the application has added an entry, the type map returned * will be empty. - * + * <p> + * You must invoke <code>setTypeMap</code> after making changes to the + * <code>Map</code> object returned from + * <code>getTypeMap</code> as a JDBC driver may create an internal + * copy of the <code>Map</code> object passed to <code>setTypeMap</code>: + * <p> + * <pre> + * Map<String,Class<?>> myMap = con.getTypeMap(); + * myMap.put("mySchemaName.ATHLETES", Athletes.class); + * con.setTypeMap(myMap); + * </pre> * @return the <code>java.util.Map</code> object associated * with this <code>Connection</code> object * @exception SQLException if a database access error occurs @@ -614,7 +632,16 @@ * Installs the given <code>TypeMap</code> object as the type map for * this <code>Connection</code> object. The type map will be used for the * custom mapping of SQL structured types and distinct types. - * + *<p> + * You must set the the values for the <code>TypeMap</code> prior to + * callng <code>setMap</code> as a JDBC driver may create an internal copy + * of the <code>TypeMap</code>: + * <p> + * <pre> + * Map myMap<String,Class<?>> = new HashMap<String,Class<?>>(); + * myMap.put("mySchemaName.ATHLETES", Athletes.class); + * con.setTypeMap(myMap); + * </pre> * @param map the <code>java.util.Map</code> object to install * as the replacement for this <code>Connection</code> * object's default type map @@ -1274,4 +1301,186 @@ */ Struct createStruct(String typeName, Object[] attributes) throws SQLException; + + //--------------------------JDBC 4.1 ----------------------------- + + /** + * Sets the given schema name to access. + * <P> + * If the driver does not support schemas, it will + * silently ignore this request. + * <p> + * Calling {@code setSchema} has no effect on previously created or prepared + * {@code Statement} objects. It is implementation defined whether a DBMS + * prepare operation takes place immediately when the {@code Connection} + * method {@code prepareStatement} or {@code prepareCall} is invoked. + * For maximum portability, {@code setSchema} should be called before a + * {@code Statement} is created or prepared. + * + * @param schema the name of a schema in which to work + * @exception SQLException if a database access error occurs + * or this method is called on a closed connection + * @see #getSchema + * @since 1.7 + */ + void setSchema(String schema) throws SQLException; + + /** + * Retrieves this <code>Connection</code> object's current schema name. + * + * @return the current schema name or <code>null</code> if there is none + * @exception SQLException if a database access error occurs + * or this method is called on a closed connection + * @see #setSchema + * @since 1.7 + */ + String getSchema() throws SQLException; + + /** + * Terminates an open connection. Calling <code>abort</code> results in: + * <ul> + * <li>The connection marked as closed + * <li>Closes any physical connection to the database + * <li>Releases resources used by the connection + * <li>Insures that any thread that is currently accessing the connection + * will either progress to completion or throw an <code>SQLException</code>. + * </ul> + * <p> + * Calling <code>abort</code> marks the connection closed and releases any + * resources. Calling <code>abort</code> on a closed connection is a + * no-op. + * <p> + * It is possible that the aborting and releasing of the resources that are + * held by the connection can take an extended period of time. When the + * <code>abort</code> method returns, the connection will have been marked as + * closed and the <code>Executor</code> that was passed as a parameter to abort + * may still be executing tasks to release resources. + * <p> + * This method checks to see that there is an <code>SQLPermission</code> + * object before allowing the method to proceed. If a + * <code>SecurityManager</code> exists and its + * <code>checkPermission</code> method denies calling <code>abort</code>, + * this method throws a + * <code>java.lang.SecurityException</code>. + * @param executor The <code>Executor</code> implementation which will + * be used by <code>abort</code>. + * @throws java.sql.SQLException if a database access error occurs or + * the {@code executor} is {@code null}, + * @throws java.lang.SecurityException if a security manager exists and its + * <code>checkPermission</code> method denies calling <code>abort</code> + * @see SecurityManager#checkPermission + * @see Executor + * @since 1.7 + */ + void abort(Executor executor) throws SQLException; + + /** + * + * Sets the maximum period a <code>Connection</code> or + * objects created from the <code>Connection</code> + * will wait for the database to reply to any one request. If any + * request remains unanswered, the waiting method will + * return with a <code>SQLException</code>, and the <code>Connection</code> + * or objects created from the <code>Connection</code> will be marked as + * closed. Any subsequent use of + * the objects, with the exception of the <code>close</code>, + * <code>isClosed</code> or <code>Connection.isValid</code> + * methods, will result in a <code>SQLException</code>. + * <p> + * <b>Note</b>: This method is intended to address a rare but serious + * condition where network partitions can cause threads issuing JDBC calls + * to hang uninterruptedly in socket reads, until the OS TCP-TIMEOUT + * (typically 10 minutes). This method is related to the + * {@link #abort abort() } method which provides an administrator + * thread a means to free any such threads in cases where the + * JDBC connection is accessible to the administrator thread. + * The <code>setNetworkTimeout</code> method will cover cases where + * there is no administrator thread, or it has no access to the + * connection. This method is severe in it's effects, and should be + * given a high enough value so it is never triggered before any more + * normal timeouts, such as transaction timeouts. + * <p> + * JDBC driver implementations may also choose to support the + * {@code setNetworkTimeout} method to impose a limit on database + * response time, in environments where no network is present. + * <p> + * Drivers may internally implement some or all of their API calls with + * multiple internal driver-database transmissions, and it is left to the + * driver implementation to determine whether the limit will be + * applied always to the response to the API call, or to any + * single request made during the API call. + * <p> + * + * This method can be invoked more than once, such as to set a limit for an + * area of JDBC code, and to reset to the default on exit from this area. + * Invocation of this method has no impact on already outstanding + * requests. + * <p> + * The {@code Statement.setQueryTimeout()} timeout value is independent of the + * timeout value specified in {@code setNetworkTimeout}. If the query timeout + * expires before the network timeout then the + * statement execution will be canceled. If the network is still + * active the result will be that both the statement and connection + * are still usable. However if the network timeout expires before + * the query timeout or if the statement timeout fails due to network + * problems, the connection will be marked as closed, any resources held by + * the connection will be released and both the connection and + * statement will be unusable. + *<p> + * When the driver determines that the {@code setNetworkTimeout} timeout + * value has expired, the JDBC driver marks the connection + * closed and releases any resources held by the connection. + * <p> + * + * This method checks to see that there is an <code>SQLPermission</code> + * object before allowing the method to proceed. If a + * <code>SecurityManager</code> exists and its + * <code>checkPermission</code> method denies calling + * <code>setNetworkTimeout</code>, this method throws a + * <code>java.lang.SecurityException</code>. + * + * @param executor The <code>Executor</code> implementation which will + * be used by <code>setNetworkTimeout</code>. + * @param milliseconds The time in milliseconds to wait for the database + * operation + * to complete. If the JDBC driver does not support milliseconds, the + * JDBC driver will round the value up to the nearest second. If the + * timeout period expires before the operation + * completes, a SQLException will be thrown. + * A value of 0 indicates that there is not timeout for database operations. + * @throws java.sql.SQLException if a database access error occurs, this + * method is called on a closed connection, + * the {@code executor} is {@code null}, + * or the value specified for <code>seconds</code> is less than 0. + * @throws java.lang.SecurityException if a security manager exists and its + * <code>checkPermission</code> method denies calling + * <code>setNetworkTimeout</code>. + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @see SecurityManager#checkPermission + * @see Statement#setQueryTimeout + * @see #getNetworkTimeout + * @see #abort + * @see Executor + * @since 1.7 + */ + void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException; + + + /** + * Retrieves the number of milliseconds the driver will + * wait for a database request to complete. + * If the limit is exceeded, a + * <code>SQLException</code> is thrown. + * + * @return the current timeout limit in milliseconds; zero means there is + * no limit + * @throws SQLException if a database access error occurs or + * this method is called on a closed <code>Connection</code> + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @see #setNetworkTimeout + * @since 1.7 + */ + int getNetworkTimeout() throws SQLException; }
--- a/jdk/src/share/classes/java/sql/DatabaseMetaData.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/DatabaseMetaData.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -1342,10 +1342,10 @@ * defined. * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine the nullability for a column. * <UL> - * <LI> YES --- if the parameter can include NULLs - * <LI> NO --- if the parameter cannot include NULLs + * <LI> YES --- if the column can include NULLs + * <LI> NO --- if the column cannot include NULLs * <LI> empty string --- if the nullability for the - * parameter is unknown + * column is unknown * </UL> * <LI><B>SPECIFIC_NAME</B> String => the name which uniquely identifies this procedure within its schema. * </OL> @@ -1610,17 +1610,17 @@ * (starting at 1) * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine the nullability for a column. * <UL> - * <LI> YES --- if the parameter can include NULLs - * <LI> NO --- if the parameter cannot include NULLs + * <LI> YES --- if the column can include NULLs + * <LI> NO --- if the column cannot include NULLs * <LI> empty string --- if the nullability for the - * parameter is unknown + * column is unknown * </UL> - * <LI><B>SCOPE_CATLOG</B> String => catalog of table that is the scope + * <LI><B>SCOPE_CATALOG</B> String => catalog of table that is the scope * of a reference attribute (<code>null</code> if DATA_TYPE isn't REF) * <LI><B>SCOPE_SCHEMA</B> String => schema of table that is the scope * of a reference attribute (<code>null</code> if the DATA_TYPE isn't REF) * <LI><B>SCOPE_TABLE</B> String => table name that this the scope - * of a reference attribure (<code>null</code> if the DATA_TYPE isn't REF) + * of a reference attribute (<code>null</code> if the DATA_TYPE isn't REF) * <LI><B>SOURCE_DATA_TYPE</B> short => source type of a distinct type or user-generated * Ref type, SQL type from java.sql.Types (<code>null</code> if DATA_TYPE * isn't DISTINCT or user-generated REF) @@ -1629,11 +1629,16 @@ * <LI> YES --- if the column is auto incremented * <LI> NO --- if the column is not auto incremented * <LI> empty string --- if it cannot be determined whether the column is auto incremented - * parameter is unknown + * </UL> + * <LI><B>IS_GENERATEDCOLUMN</B> String => Indicates whether this is a generated column + * <UL> + * <LI> YES --- if this a generated column + * <LI> NO --- if this not a generated column + * <LI> empty string --- if it cannot be determined whether this is a generated column * </UL> * </OL> * - * <p>The COLUMN_SIZE column the specified column size for the given column. + * <p>The COLUMN_SIZE column specifies the column size for the given column. * For numeric data, this is the maximum precision. For character data, this is the length in characters. * For datetime datatypes, this is the length in characters of the String representation (assuming the * maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype, @@ -3186,7 +3191,7 @@ * Retrieves whether this database supports statement pooling. * * @return <code>true</code> if so; <code>false</code> otherwise - * @throws SQLExcpetion if a database access error occurs + * @throws SQLException if a database access error occurs * @since 1.4 */ boolean supportsStatementPooling() throws SQLException; @@ -3568,4 +3573,83 @@ */ int functionReturnsTable = 2; + //--------------------------JDBC 4.1 ----------------------------- + + /** + * Retrieves a description of the pseudo or hidden columns available + * in a given table within the specified catalog and schema. + * Pseudo or hidden columns may not always be stored within + * a table and are not visible in a ResultSet unless they are + * specified in the query's outermost SELECT list. Pseudo or hidden + * columns may not necessarily be able to be modified. If there are + * no pseudo or hidden columns, an empty ResultSet is returned. + * + * <P>Only column descriptions matching the catalog, schema, table + * and column name criteria are returned. They are ordered by + * <code>TABLE_CAT</code>,<code>TABLE_SCHEM</code>, <code>TABLE_NAME</code> + * and <code>COLUMN_NAME</code>. + * + * <P>Each column description has the following columns: + * <OL> + * <LI><B>TABLE_CAT</B> String => table catalog (may be <code>null</code>) + * <LI><B>TABLE_SCHEM</B> String => table schema (may be <code>null</code>) + * <LI><B>TABLE_NAME</B> String => table name + * <LI><B>COLUMN_NAME</B> String => column name + * <LI><B>DATA_TYPE</B> int => SQL type from java.sql.Types + * <LI><B>COLUMN_SIZE</B> int => column size. + * <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits. Null is returned for data types where + * DECIMAL_DIGITS is not applicable. + * <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2) + * <LI><B>COLUMN_USAGE</B> String => The allowed usage for the column. The + * value returned will correspond to the enum name returned by {@link PseudoColumnUsage#name PseudoColumnUsage.name()} + * <LI><B>REMARKS</B> String => comment describing column (may be <code>null</code>) + * <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the + * maximum number of bytes in the column + * <LI><B>IS_NULLABLE</B> String => ISO rules are used to determine the nullability for a column. + * <UL> + * <LI> YES --- if the column can include NULLs + * <LI> NO --- if the column cannot include NULLs + * <LI> empty string --- if the nullability for the column is unknown + * </UL> + * </OL> + * + * <p>The COLUMN_SIZE column specifies the column size for the given column. + * For numeric data, this is the maximum precision. For character data, this is the length in characters. + * For datetime datatypes, this is the length in characters of the String representation (assuming the + * maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype, + * this is the length in bytes. Null is returned for data types where the + * column size is not applicable. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those without a catalog; + * <code>null</code> means that the catalog name should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema name + * as it is stored in the database; "" retrieves those without a schema; + * <code>null</code> means that the schema name should not be used to narrow + * the search + * @param tableNamePattern a table name pattern; must match the + * table name as it is stored in the database + * @param columnNamePattern a column name pattern; must match the column + * name as it is stored in the database + * @return <code>ResultSet</code> - each row is a column description + * @exception SQLException if a database access error occurs + * @see PseudoColumnUsage + * @since 1.7 + */ + ResultSet getPseudoColumns(String catalog, String schemaPattern, + String tableNamePattern, String columnNamePattern) + throws SQLException; + + /** + * Retrieves whether a generated key will always be returned if the column + * name(s) or indexe(s) specified for the auto generated key column(s) + * are valid and the statement succeeds. The key that is returned may or + * may not be based on the column(s) for the auto generated key. + * Consult your JDBC driver documentation for additional details. + * @return <code>true</code> if so; <code>false</code> otherwise + * @exception SQLException if a database access error occurs + * @since 1.7 + */ + boolean generatedKeyAlwaysReturned() throws SQLException; }
--- a/jdk/src/share/classes/java/sql/Date.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/Date.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -96,11 +96,12 @@ * a <code>Date</code> value. * * @param s a <code>String</code> object representing a date in - * in the format "yyyy-mm-dd" + * in the format "yyyy-[m]m-[d]d". The leading zero for <code>mm</code> + * and <code>dd</code> may also be omitted. * @return a <code>java.sql.Date</code> object representing the * given date * @throws IllegalArgumentException if the date given is not in the - * JDBC date escape format (yyyy-mm-dd) + * JDBC date escape format (yyyy-[m]m-[d]d) */ public static Date valueOf(String s) { final int YEAR_LENGTH = 4; @@ -123,8 +124,9 @@ String yyyy = s.substring(0, firstDash); String mm = s.substring(firstDash + 1, secondDash); String dd = s.substring(secondDash + 1); - if (yyyy.length() == YEAR_LENGTH && mm.length() == MONTH_LENGTH && - dd.length() == DAY_LENGTH) { + if (yyyy.length() == YEAR_LENGTH && + (mm.length() >= 1 && mm.length() <= MONTH_LENGTH) && + (dd.length() >= 1 && dd.length() <= DAY_LENGTH)) { int year = Integer.parseInt(yyyy); int month = Integer.parseInt(mm); int day = Integer.parseInt(dd);
--- a/jdk/src/share/classes/java/sql/Driver.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/Driver.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2005, 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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,8 @@ package java.sql; +import java.util.logging.Logger; + /** * The interface that every driver class must implement. * <P>The Java SQL framework allows for multiple database drivers. @@ -150,4 +152,19 @@ * otherwise */ boolean jdbcCompliant(); + + //------------------------- JDBC 4.1 ----------------------------------- + + /** + * Return the parent Logger of all the Loggers used by this driver. This + * should be the Logger farthest from the root Logger that is + * still an ancestor of all of the Loggers used by this driver. Configuring + * this Logger will affect all of the log messages generated by the driver. + * In the worst case, this may be the root Logger. + * + * @return the parent Logger for this driver + * @throws SQLFeatureNotSupportedException if the driver does not use <code>java.util.logging<code>. + * @since 1.7 + */ + public Logger getParentLogger() throws SQLFeatureNotSupportedException; }
--- a/jdk/src/share/classes/java/sql/PreparedStatement.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/PreparedStatement.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -69,6 +69,10 @@ * @exception SQLException if a database access error occurs; * this method is called on a closed <code>PreparedStatement</code> or the SQL * statement does not return a <code>ResultSet</code> object + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} */ ResultSet executeQuery() throws SQLException; @@ -82,8 +86,11 @@ * or (2) 0 for SQL statements that return nothing * @exception SQLException if a database access error occurs; * this method is called on a closed <code>PreparedStatement</code> - * or the SQL - * statement returns a <code>ResultSet</code> object + * or the SQL statement returns a <code>ResultSet</code> object + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} */ int executeUpdate() throws SQLException; @@ -463,6 +470,10 @@ * @exception SQLException if a database access error occurs; * this method is called on a closed <code>PreparedStatement</code> * or an argument is supplied to this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @see Statement#execute * @see Statement#getResultSet * @see Statement#getUpdateCount @@ -1208,4 +1219,5 @@ void setNClob(int parameterIndex, Reader reader) throws SQLException; + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/sql/PseudoColumnUsage.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,57 @@ +/* + * 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.sql; + + +/** + * Enumeration for pseudo/hidden column usage. + * + * @since 1.7 + * @see DatabaseMetaData#getPseudoColumns + */ +public enum PseudoColumnUsage { + + /** + * The pseudo/hidden column may only be used in a SELECT list. + */ + SELECT_LIST_ONLY, + + /** + * The pseudo/hidden column may only be used in a WHERE clause. + */ + WHERE_CLAUSE_ONLY, + + /** + * There are no restrictions on the usage of the pseudo/hidden columns. + */ + NO_USAGE_RESTRICTIONS, + + /** + * The usage of the pseudo/hidden column cannot be determined. + */ + USAGE_UNKNOWN + +}
--- a/jdk/src/share/classes/java/sql/ResultSet.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/ResultSet.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -145,7 +145,7 @@ * @see ResultSetMetaData */ -public interface ResultSet extends Wrapper { +public interface ResultSet extends Wrapper, AutoCloseable { /** * Moves the cursor froward one row from its current position. @@ -1187,6 +1187,9 @@ * cursor on the last row; calling the method <code>absolute(-2)</code> * moves the cursor to the next-to-last row, and so on. * + * <p>If the row number specified is zero, the cursor is moved to + * before the first row. + * * <p>An attempt to position the cursor beyond the first/last row in * the result set leaves the cursor before the first row or after * the last row. @@ -1196,9 +1199,10 @@ * is the same as calling <code>last()</code>. * * @param row the number of the row to which the cursor should move. - * A positive number indicates the row number counting from the - * beginning of the result set; a negative number indicates the - * row number counting from the end of the result set + * A value of zero indicates that the cursor will be positioned + * before the first row; a positive number indicates the row number + * counting from the beginning of the result set; a negative number + * indicates the row number counting from the end of the result set * @return <code>true</code> if the cursor is moved to a position in this * <code>ResultSet</code> object; * <code>false</code> if the cursor is before the first row or after the @@ -2529,7 +2533,7 @@ * @exception SQLException if the columnLabel is not valid; * if a database access error occurs * or this method is called on a closed result set - * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support * this method * @since 1.2 */ @@ -4072,4 +4076,64 @@ */ void updateNClob(String columnLabel, Reader reader) throws SQLException; + //------------------------- JDBC 4.1 ----------------------------------- + + + /** + *<p>Retrieves the value of the designated column in the current row + * of this <code>ResultSet</code> object and will convert from the + * SQL type of the column to the requested Java data type, if the + * conversion is supported. If the conversion is not + * supported or null is specified for the type, a + * <code>SQLException</code> is thrown. + *<p> + * At a minimum, an implementation must support the conversions defined in + * Appendix B, Table B-3 and conversion of appropriate user defined SQL + * types to a Java type which implements {@code SQLData}, or {@code Struct}. + * Additional conversions may be supported and are vendor defined. + * + * @param columnIndex the first column is 1, the second is 2, ... + * @param type Class representing the Java data type to convert the designated + * column to. + * @return an instance of {@code type} holding the column value + * @throws SQLException if conversion is not supported, type is null or + * another error occurs. The getCause() method of the + * exception may provide a more detailed exception, for example, if + * a conversion error occurs + * @throws SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.7 + */ + public <T> T getObject(int columnIndex, Class<T> type) throws SQLException; + + + /** + *<p>Retrieves the value of the designated column in the current row + * of this <code>ResultSet</code> object and will convert from the + * SQL type of the column to the requested Java data type, if the + * conversion is supported. If the conversion is not + * supported or null is specified for the type, a + * <code>SQLException</code> is thrown. + *<p> + * At a minimum, an implementation must support the conversions defined in + * Appendix B, Table B-3 and conversion of appropriate user defined SQL + * types to a Java type which implements {@code SQLData}, or {@code Struct}. + * Additional conversions may be supported and are vendor defined. + * + * @param columnLabel the label for the column specified with the SQL AS clause. + * If the SQL AS clause was not specified, then the label is the name + * of the column + * @param type Class representing the Java data type to convert the designated + * column to. + * @return an instance of {@code type} holding the column value + * @throws SQLException if conversion is not supported, type is null or + * another error occurs. The getCause() method of the + * exception may provide a more detailed exception, for example, if + * a conversion error occurs + * @throws SQLFeatureNotSupportedException if the JDBC driver does not support + * this method + * @since 1.7 + */ + public <T> T getObject(String columnLabel, Class<T> type) throws SQLException; + }
--- a/jdk/src/share/classes/java/sql/SQLDataException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLDataException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>22</i>'. This indicates - * various data errors, including but not limited to not-allowed conversion, division by 0 - * and invalid arguments to functions. - * + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>22</i>', or under vendor-specified conditions. This indicates + * various data errors, including but not limited to data conversion errors, + * division by 0, and invalid arguments to functions. + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLDataException extends SQLNonTransientException {
--- a/jdk/src/share/classes/java/sql/SQLIntegrityConstraintViolationException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLIntegrityConstraintViolationException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>23</i>'. This indicates that an integrity + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>23</i>', or under vendor-specified conditions. + * This indicates that an integrity * constraint (foreign key, primary key or unique key) has been violated. - * + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLIntegrityConstraintViolationException extends SQLNonTransientException {
--- a/jdk/src/share/classes/java/sql/SQLInvalidAuthorizationSpecException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLInvalidAuthorizationSpecException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>28</i>'. This indicated that the - * authorization credentials presented during connection establishment are not valid. - * + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>28</i>', or under vendor-specified conditions. This indicates that + * the authorization credentials presented during connection establishment + * are not valid. + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLInvalidAuthorizationSpecException extends SQLNonTransientException {
--- a/jdk/src/share/classes/java/sql/SQLNonTransientConnectionException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLNonTransientConnectionException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,13 @@ package java.sql; /** - * <P> The subclass of {@link SQLException} thrown for the SQLState - * class value '<i>08</i>', representing - * that the connection operation that failed will not succeed when + * The subclass of {@link SQLException} thrown for the SQLState + * class value '<i>08</i>', or under vendor-specified conditions. This + * indicates that the connection operation that failed will not succeed if * the operation is retried without the cause of the failure being corrected. * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLNonTransientConnectionException extends java.sql.SQLNonTransientException {
--- a/jdk/src/share/classes/java/sql/SQLPermission.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLPermission.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -30,9 +30,14 @@ /** * The permission for which the <code>SecurityManager</code> will check - * when code that is running in an applet calls the - * <code>DriverManager.setLogWriter</code> method or the - * <code>DriverManager.setLogStream</code> (deprecated) method. + * when code that is running in an applet, or an application with a + * <code>SecurityManager</code> enabled, calls the + * <code>DriverManager.setLogWriter</code> method, + * <code>DriverManager.setLogStream</code> (deprecated) method, + * {@code SyncFactory.setJNDIContext} method, + * {@code SyncFactory.setLogger} method, + * {@code Connection.setNetworktimeout} method, + * or the <code>Connection.abort</code> method. * If there is no <code>SQLPermission</code> object, these methods * throw a <code>java.lang.SecurityException</code> as a runtime exception. * <P> @@ -48,7 +53,6 @@ * but <code>*loadLibrary</code> or <code>a*b</code> is not valid. * <P> * The following table lists all the possible <code>SQLPermission</code> target names. - * Currently, the only name allowed is <code>setLog</code>. * The table gives a description of what the permission allows * and a discussion of the risks of granting code the permission. * <P> @@ -67,9 +71,33 @@ * The contents of the log may contain usernames and passwords, * SQL statements, and SQL data.</td> * </tr> + * <tr> + * <td>callAbort</td> + * <td>Allows the invocation of the {@code Connection} method + * {@code abort}</td> + * <td>Permits an application to terminate a physical connection to a + * database.</td> + * </tr> + * <tr> + * <td>setSyncFactory</td> + * <td>Allows the invocation of the {@code SyncFactory} methods + * {@code setJNDIContext} and {@code setLogger}</td> + * <td>Permits an application to specify the JNDI context from which the + * {@code SyncProvider} implementations can be retrieved from and the logging + * object to be used by the{@codeSyncProvider} implementation.</td> + * </tr> * + * <tr> + * <td>setNetworkTimeout</td> + * <td>Allows the invocation of the {@code Connection} method + * {@code setNetworkTimeout}</td> + * <td>Permits an application to specify the maximum period a + * <code>Connection</code> or + * objects created from the <code>Connection</code> + * will wait for the database to reply to any one request.</td> + * </tr> * </table> - * + *<p> * The person running an applet decides what permissions to allow * and will run the <code>Policy Tool</code> to create an * <code>SQLPermission</code> in a policy file. A programmer does
--- a/jdk/src/share/classes/java/sql/SQLSyntaxErrorException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLSyntaxErrorException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,12 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>42</i>'. This indicates that the + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>42</i>', or under vendor-specified conditions. This indicates that the * in-progress query has violated SQL syntax rules. - * + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLSyntaxErrorException extends SQLNonTransientException {
--- a/jdk/src/share/classes/java/sql/SQLTransactionRollbackException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLTransactionRollbackException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -26,10 +26,13 @@ package java.sql; /** - * The subclass of {@link SQLException} thrown when the SQLState class value is '<i>40</i>'. This indicates that the - * current statement was automatically rolled back by the database becuase of deadlock or other - * transaction serialization failures. - * + * The subclass of {@link SQLException} thrown when the SQLState class value + * is '<i>40</i>', or under vendor-specified conditions. This indicates that the + * current statement was automatically rolled back by the database because + * of deadlock or other transaction serialization failures. + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLTransactionRollbackException extends SQLTransientException {
--- a/jdk/src/share/classes/java/sql/SQLTransientConnectionException.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/SQLTransientConnectionException.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, 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. * * This code is free software; you can redistribute it and/or modify it @@ -27,11 +27,12 @@ /** * The subclass of {@link SQLException} for the SQLState class - * value '<i>08</i>', representing - * that the connection operation that failed might be able to succeed when + * value '<i>08</i>', or under vendor-specified conditions. This indicates + * that the connection operation that failed might be able to succeed if * the operation is retried without any application-level changes. - *<p> - * + * <p> + * Please consult your driver vendor documentation for the vendor-specified + * conditions for which this <code>Exception</code> may be thrown. * @since 1.6 */ public class SQLTransientConnectionException extends java.sql.SQLTransientException {
--- a/jdk/src/share/classes/java/sql/Statement.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/Statement.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -40,20 +40,27 @@ * @see Connection#createStatement * @see ResultSet */ -public interface Statement extends Wrapper { +public interface Statement extends Wrapper, AutoCloseable { /** * Executes the given SQL statement, which returns a single * <code>ResultSet</code> object. - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql an SQL statement to be sent to the database, typically a * static SQL <code>SELECT</code> statement * @return a <code>ResultSet</code> object that contains the data produced * by the given query; never <code>null</code> * @exception SQLException if a database access error occurs, - * this method is called on a closed <code>Statement</code> or the given + * this method is called on a closed <code>Statement</code>, the given * SQL statement produces anything other than a single - * <code>ResultSet</code> object + * <code>ResultSet</code> object, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} */ ResultSet executeQuery(String sql) throws SQLException; @@ -61,7 +68,9 @@ * Executes the given SQL statement, which may be an <code>INSERT</code>, * <code>UPDATE</code>, or <code>DELETE</code> statement or an * SQL statement that returns nothing, such as an SQL DDL statement. - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code>; or an SQL statement that returns nothing, * such as a DDL statement. @@ -70,8 +79,13 @@ * or (2) 0 for SQL statements that return nothing * * @exception SQLException if a database access error occurs, - * this method is called on a closed <code>Statement</code> or the given - * SQL statement produces a <code>ResultSet</code> object + * this method is called on a closed <code>Statement</code>, the given + * SQL statement produces a <code>ResultSet</code> object, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} */ int executeUpdate(String sql) throws SQLException; @@ -198,11 +212,21 @@ /** * Sets the number of seconds the driver will wait for a * <code>Statement</code> object to execute to the given number of seconds. - * If the limit is exceeded, an <code>SQLException</code> is thrown. A JDBC - * driver must apply this limit to the <code>execute</code>, - * <code>executeQuery</code> and <code>executeUpdate</code> methods. JDBC driver - * implementations may also apply this limit to <code>ResultSet</code> methods + *By default there is no limit on the amount of time allowed for a running + * statement to complete. If the limit is exceeded, an + * <code>SQLTimeoutException</code> is thrown. + * A JDBC driver must apply this limit to the <code>execute</code>, + * <code>executeQuery</code> and <code>executeUpdate</code> methods. + * <p> + * <strong>Note:</strong> JDBC driver implementations may also apply this + * limit to {@code ResultSet} methods * (consult your driver vendor documentation for details). + * <p> + * <strong>Note:</strong> In the case of {@code Statement} batching, it is + * implementation defined as to whether the time-out is applied to + * individual SQL commands added via the {@code addBatch} method or to + * the entire batch of SQL commands invoked by the {@code executeBatch} + * method (consult your driver vendor documentation for details). * * @param seconds the new query timeout limit in seconds; zero means * there is no limit @@ -300,13 +324,21 @@ * <code>getResultSet</code> or <code>getUpdateCount</code> * to retrieve the result, and <code>getMoreResults</code> to * move to any subsequent result(s). - * + * <p> + *<strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql any SQL statement * @return <code>true</code> if the first result is a <code>ResultSet</code> * object; <code>false</code> if it is an update count or there are * no results - * @exception SQLException if a database access error occurs or - * this method is called on a closed <code>Statement</code> + * @exception SQLException if a database access error occurs, + * this method is called on a closed <code>Statement</code>, + * the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @see #getResultSet * @see #getUpdateCount * @see #getMoreResults @@ -465,12 +497,14 @@ * <code>Statement</code> object. The commands in this list can be * executed as a batch by calling the method <code>executeBatch</code>. * <P> - * + *<strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql typically this is a SQL <code>INSERT</code> or * <code>UPDATE</code> statement * @exception SQLException if a database access error occurs, - * this method is called on a closed <code>Statement</code> or the - * driver does not support batch updates + * this method is called on a closed <code>Statement</code>, the + * driver does not support batch updates, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @see #executeBatch * @see DatabaseMetaData#supportsBatchUpdates * @since 1.2 @@ -536,7 +570,10 @@ * driver does not support batch statements. Throws {@link BatchUpdateException} * (a subclass of <code>SQLException</code>) if one of the commands sent to the * database fails to execute properly or attempts to return a result set. - * + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * * @see #addBatch * @see DatabaseMetaData#supportsBatchUpdates @@ -678,7 +715,9 @@ * flag if the SQL statement * is not an <code>INSERT</code> statement, or an SQL statement able to return * auto-generated keys (the list of such statements is vendor-specific). - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code>; or an SQL statement that returns nothing, * such as a DDL statement. @@ -693,10 +732,15 @@ * * @exception SQLException if a database access error occurs, * this method is called on a closed <code>Statement</code>, the given - * SQL statement returns a <code>ResultSet</code> object, or - * the given constant is not one of those allowed + * SQL statement returns a <code>ResultSet</code> object, + * the given constant is not one of those allowed, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @exception SQLFeatureNotSupportedException if the JDBC driver does not support * this method with a constant of Statement.RETURN_GENERATED_KEYS + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @since 1.4 */ int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException; @@ -709,7 +753,9 @@ * available. The driver will ignore the array if the SQL statement * is not an <code>INSERT</code> statement, or an SQL statement able to return * auto-generated keys (the list of such statements is vendor-specific). - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code>; or an SQL statement that returns nothing, * such as a DDL statement. @@ -721,10 +767,15 @@ * * @exception SQLException if a database access error occurs, * this method is called on a closed <code>Statement</code>, the SQL - * statement returns a <code>ResultSet</code> object, or the - * second argument supplied to this method is not an <code>int</code> array - * whose elements are valid column indexes + * statement returns a <code>ResultSet</code> object,the second argument + * supplied to this method is not an + * <code>int</code> array whose elements are valid column indexes, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @since 1.4 */ int executeUpdate(String sql, int columnIndexes[]) throws SQLException; @@ -737,7 +788,9 @@ * available. The driver will ignore the array if the SQL statement * is not an <code>INSERT</code> statement, or an SQL statement able to return * auto-generated keys (the list of such statements is vendor-specific). - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql an SQL Data Manipulation Language (DML) statement, such as <code>INSERT</code>, <code>UPDATE</code> or * <code>DELETE</code>; or an SQL statement that returns nothing, * such as a DDL statement. @@ -748,11 +801,15 @@ * that return nothing * @exception SQLException if a database access error occurs, * this method is called on a closed <code>Statement</code>, the SQL - * statement returns a <code>ResultSet</code> object, or the + * statement returns a <code>ResultSet</code> object, the * second argument supplied to this method is not a <code>String</code> array - * whose elements are valid column names - * + * whose elements are valid column names, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @since 1.4 */ int executeUpdate(String sql, String columnNames[]) throws SQLException; @@ -776,7 +833,9 @@ * <code>getResultSet</code> or <code>getUpdateCount</code> * to retrieve the result, and <code>getMoreResults</code> to * move to any subsequent result(s). - * + *<p> + *<strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql any SQL statement * @param autoGeneratedKeys a constant indicating whether auto-generated * keys should be made available for retrieval using the method @@ -787,12 +846,18 @@ * object; <code>false</code> if it is an update count or there are * no results * @exception SQLException if a database access error occurs, - * this method is called on a closed <code>Statement</code> or the second + * this method is called on a closed <code>Statement</code>, the second * parameter supplied to this method is not * <code>Statement.RETURN_GENERATED_KEYS</code> or - * <code>Statement.NO_GENERATED_KEYS</code>. + * <code>Statement.NO_GENERATED_KEYS</code>, + * the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @exception SQLFeatureNotSupportedException if the JDBC driver does not support * this method with a constant of Statement.RETURN_GENERATED_KEYS + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @see #getResultSet * @see #getUpdateCount * @see #getMoreResults @@ -823,7 +888,9 @@ * <code>getResultSet</code> or <code>getUpdateCount</code> * to retrieve the result, and <code>getMoreResults</code> to * move to any subsequent result(s). - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql any SQL statement * @param columnIndexes an array of the indexes of the columns in the * inserted row that should be made available for retrieval by a @@ -832,10 +899,15 @@ * object; <code>false</code> if it is an update count or there * are no results * @exception SQLException if a database access error occurs, - * this method is called on a closed <code>Statement</code> or the + * this method is called on a closed <code>Statement</code>, the * elements in the <code>int</code> array passed to this method - * are not valid column indexes + * are not valid column indexes, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @see #getResultSet * @see #getUpdateCount * @see #getMoreResults @@ -865,7 +937,9 @@ * <code>getResultSet</code> or <code>getUpdateCount</code> * to retrieve the result, and <code>getMoreResults</code> to * move to any subsequent result(s). - * + *<p> + * <strong>Note:</strong>This method cannot be called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code>. * @param sql any SQL statement * @param columnNames an array of the names of the columns in the inserted * row that should be made available for retrieval by a call to the @@ -874,10 +948,15 @@ * object; <code>false</code> if it is an update count or there * are no more results * @exception SQLException if a database access error occurs, - * this method is called on a closed <code>Statement</code> or the + * this method is called on a closed <code>Statement</code>,the * elements of the <code>String</code> array passed to this - * method are not valid column names + * method are not valid column names, the method is called on a + * <code>PreparedStatement</code> or <code>CallableStatement</code> * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} * @see #getResultSet * @see #getUpdateCount * @see #getMoreResults @@ -951,4 +1030,34 @@ boolean isPoolable() throws SQLException; + //--------------------------JDBC 4.1 ----------------------------- + + /** + * Specifies that this {@code Statement} will be closed when all its + * dependent result sets are closed. If execution of the {@code Statement} + * does not produce any result sets, this method has no effect. + * <p> + * <strong>Note:</strong> Multiple calls to {@code closeOnCompletion} do + * not toggle the effect on this {@code Statement}. However, a call to + * {@code closeOnCompletion} does effect both the subsequent execution of + * statements, and statements that currently have open, dependent, + * result sets. + * + * @throws SQLException if this method is called on a closed + * {@code Statement} + * @since 1.7 + */ + public void closeOnCompletion() throws SQLException; + + /** + * Returns a value indicating whether this {@code Statement} will be + * closed when all dependent objects such as resultsets are closed. + * @return {@code true} if the {@code Statement} will be closed when all + * of its dependent objects are closed; {@code false} otherwise + * @throws SQLException if this method is called on a closed + * {@code Statement} + * @since 1.7 + */ + public boolean isCloseOnCompletion() throws SQLException; + }
--- a/jdk/src/share/classes/java/sql/Timestamp.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/sql/Timestamp.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -155,19 +155,26 @@ * Converts a <code>String</code> object in JDBC timestamp escape format to a * <code>Timestamp</code> value. * - * @param s timestamp in format <code>yyyy-mm-dd hh:mm:ss[.f...]</code>. The - * fractional seconds may be omitted. + * @param s timestamp in format <code>yyyy-[m]m-[d]d hh:mm:ss[.f...]</code>. The + * fractional seconds may be omitted. The leading zero for <code>mm</code> + * and <code>dd</code> may also be omitted. + * * @return corresponding <code>Timestamp</code> value * @exception java.lang.IllegalArgumentException if the given argument - * does not have the format <code>yyyy-mm-dd hh:mm:ss[.f...]</code> + * does not have the format <code>yyyy-[m]m-[d]d hh:mm:ss[.f...]</code> */ public static Timestamp valueOf(String s) { + final int YEAR_LENGTH = 4; + final int MONTH_LENGTH = 2; + final int DAY_LENGTH = 2; + final int MAX_MONTH = 12; + final int MAX_DAY = 31; String date_s; String time_s; String nanos_s; - int year; - int month; - int day; + int year = 0; + int month = 0; + int day = 0; int hour; int minute; int second; @@ -182,17 +189,9 @@ String zeros = "000000000"; String delimiterDate = "-"; String delimiterTime = ":"; - StringTokenizer stringTokeninzerDate; - StringTokenizer stringTokeninzerTime; if (s == null) throw new java.lang.IllegalArgumentException("null string"); - int counterD = 0; - int intDate[] = {4,2,2}; - - int counterT = 0; - int intTime[] = {2,2,12}; - // Split the string into date and time components s = s.trim(); dividingSpace = s.indexOf(' '); @@ -203,30 +202,6 @@ throw new java.lang.IllegalArgumentException(formatError); } - stringTokeninzerTime = new StringTokenizer(time_s, delimiterTime); - stringTokeninzerDate = new StringTokenizer(date_s, delimiterDate); - - while(stringTokeninzerDate.hasMoreTokens()) { - String tokenDate = stringTokeninzerDate.nextToken(); - if(tokenDate.length() != intDate[counterD] ) { - throw new java.lang.IllegalArgumentException(formatError); - } - counterD++; - } - - /* - //Commenting this portion out for checking of time - - while(stringTokeninzerTime.hasMoreTokens()) { - String tokenTime = stringTokeninzerTime.nextToken(); - - if (counterT < 2 && tokenTime.length() != intTime[counterT] ) { - throw new java.lang.IllegalArgumentException(formatError); - } - counterT++; - } - */ - // Parse the date firstDash = date_s.indexOf('-'); secondDash = date_s.indexOf('-', firstDash+1); @@ -239,14 +214,24 @@ period = time_s.indexOf('.', secondColon+1); // Convert the date - if ((firstDash > 0) && (secondDash > 0) && - (secondDash < date_s.length()-1)) { - year = Integer.parseInt(date_s.substring(0, firstDash)) - 1900; - month = - Integer.parseInt(date_s.substring - (firstDash+1, secondDash)) - 1; - day = Integer.parseInt(date_s.substring(secondDash+1)); - } else { + boolean parsedDate = false; + if ((firstDash > 0) && (secondDash > 0) && (secondDash < date_s.length() - 1)) { + String yyyy = date_s.substring(0, firstDash); + String mm = date_s.substring(firstDash + 1, secondDash); + String dd = date_s.substring(secondDash + 1); + if (yyyy.length() == YEAR_LENGTH && + (mm.length() >= 1 && mm.length() <= MONTH_LENGTH) && + (dd.length() >= 1 && dd.length() <= DAY_LENGTH)) { + year = Integer.parseInt(yyyy); + month = Integer.parseInt(mm); + day = Integer.parseInt(dd); + + if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) { + parsedDate = true; + } + } + } + if (! parsedDate) { throw new java.lang.IllegalArgumentException(formatError); } @@ -272,10 +257,10 @@ second = Integer.parseInt(time_s.substring(secondColon+1)); } } else { - throw new java.lang.IllegalArgumentException(); + throw new java.lang.IllegalArgumentException(formatError); } - return new Timestamp(year, month, day, hour, minute, second, a_nanos); + return new Timestamp(year - 1900, month - 1, day, hour, minute, second, a_nanos); } /** @@ -502,14 +487,10 @@ /** * Compares this <code>Timestamp</code> object to the given - * <code>Date</code>, which must be a <code>Timestamp</code> - * object. If the argument is not a <code>Timestamp</code> object, - * this method throws a <code>ClassCastException</code> object. - * (<code>Timestamp</code> objects are - * comparable only to other <code>Timestamp</code> objects.) + * <code>Date</code> object. * - * @param o the <code>Date</code> to be compared, which must be a - * <code>Timestamp</code> object + * @param o the <code>Date</code> to be compared to + * this <code>Timestamp</code> object * @return the value <code>0</code> if this <code>Timestamp</code> object * and the given object are equal; a value less than <code>0</code> * if this <code>Timestamp</code> object is before the given argument;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/text/CalendarBuilder.java Fri Sep 24 16:41:32 2010 -0700 @@ -0,0 +1,170 @@ +/* + * 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; + } +}
--- a/jdk/src/share/classes/java/text/DateFormat.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/text/DateFormat.java Fri Sep 24 16:41:32 2010 -0700 @@ -443,7 +443,7 @@ */ 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 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 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 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 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 final static DateFormat getDateTimeInstance(int dateStyle, int timeStyle) { - return get(timeStyle, dateStyle, 3, Locale.getDefault()); + return get(timeStyle, dateStyle, 3, Locale.getDefault(Locale.Category.FORMAT)); } /**
--- a/jdk/src/share/classes/java/text/DateFormatSymbols.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/text/DateFormatSymbols.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -118,7 +118,7 @@ */ public DateFormatSymbols() { - initializeData(Locale.getDefault()); + initializeData(Locale.getDefault(Locale.Category.FORMAT)); } /** @@ -226,7 +226,30 @@ * Unlocalized date-time pattern characters. For example: 'y', 'd', etc. * 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 @@ -282,7 +305,7 @@ * @since 1.6 */ public static final DateFormatSymbols getInstance() { - return getInstance(Locale.getDefault()); + return getInstance(Locale.getDefault(Locale.Category.FORMAT)); } /** @@ -505,7 +528,7 @@ * @return the localized date-time pattern characters. */ public String getLocalPatternChars() { - return new String(localPatternChars); + return localPatternChars; } /** @@ -514,7 +537,8 @@ * pattern characters. */ 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 @@ } else { dst.zoneStrings = null; } - dst.localPatternChars = new String (src.localPatternChars); + dst.localPatternChars = src.localPatternChars; } /**
--- a/jdk/src/share/classes/java/text/DecimalFormat.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/text/DecimalFormat.java Fri Sep 24 16:41:32 2010 -0700 @@ -392,7 +392,7 @@ * @see java.text.NumberFormat#getPercentInstance */ public DecimalFormat() { - Locale def = Locale.getDefault(); + Locale def = Locale.getDefault(Locale.Category.FORMAT); // try to get the pattern from the cache String pattern = (String) cachedLocaleData.get(def); if (pattern == null) { /* cache miss */ @@ -430,7 +430,7 @@ */ public DecimalFormat(String pattern) { // 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); }
--- a/jdk/src/share/classes/java/text/DecimalFormatSymbols.java Thu Sep 23 17:33:40 2010 -0700 +++ b/jdk/src/share/classes/java/text/DecimalFormatSymbols.java Fri Sep 24 16:41:32 2010 -0700 @@ -1,5 +1,5 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it @@ -43,10 +43,10 @@ import java.io.Serializable; import java.text.spi.DecimalFormatSymbolsProvider; import java.util.Currency; -import java.util.Hashtable; import java.util.Locale; import java.util.ResourceBundle; -import java.util.spi.LocaleServiceProvider; +import java.util.concurrent.ConcurrentHashMap; + import sun.util.LocaleServiceProviderPool; import sun.util.resources.LocaleData; @@ -76,7 +76,7 @@ * {@link #getInstance(Locale) getInstance} method. */ public DecimalFormatSymbols() { - initialize( Locale.getDefault() );