From 4a82a1723e93972a99effd3f3c514f09c0817e20 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Tue, 13 Jan 2009 09:21:54 -0800 Subject: [PATCH 1/8] 6332094: "jar t" and "jar x" should use ZipFile, not ZipInputStream To use ZipFile for jar "t" and "x" to boost performance Reviewed-by: martin, alanb --- jdk/src/share/classes/sun/tools/jar/Main.java | 156 +++++++++++++----- 1 file changed, 115 insertions(+), 41 deletions(-) diff --git a/jdk/src/share/classes/sun/tools/jar/Main.java b/jdk/src/share/classes/sun/tools/jar/Main.java index 693866e1866..6d2a67810fe 100644 --- a/jdk/src/share/classes/sun/tools/jar/Main.java +++ b/jdk/src/share/classes/sun/tools/jar/Main.java @@ -74,7 +74,6 @@ class Main { static final String MANIFEST = JarFile.MANIFEST_NAME; static final String MANIFEST_DIR = "META-INF/"; static final String VERSION = "1.0"; - static final char SEPARATOR = File.separatorChar; static final String INDEX = JarIndex.INDEX_NAME; private static ResourceBundle rsrc; @@ -227,19 +226,32 @@ class Main { } tmpFile.delete(); } - } else if (xflag || tflag) { - InputStream in; + } else if (tflag) { + replaceFSC(files); if (fname != null) { - in = new FileInputStream(fname); + list(fname, files); } else { - in = new FileInputStream(FileDescriptor.in); + InputStream in = new FileInputStream(FileDescriptor.in); + try{ + list(new BufferedInputStream(in), files); + } finally { + in.close(); + } } - if (xflag) { - extract(new BufferedInputStream(in), files); + } else if (xflag) { + replaceFSC(files); + if (fname != null && files != null) { + extract(fname, files); } else { - list(new BufferedInputStream(in), files); + InputStream in = (fname == null) + ? new FileInputStream(FileDescriptor.in) + : new FileInputStream(fname); + try { + extract(new BufferedInputStream(in), files); + } finally { + in.close(); + } } - in.close(); } else if (iflag) { genIndex(rootjar, files); } @@ -760,6 +772,31 @@ class Main { e.setCrc(crc32.getValue()); } + void replaceFSC(String files[]) { + if (files != null) { + for (String file : files) { + file = file.replace(File.separatorChar, '/'); + } + } + } + + Set newDirSet() { + return new HashSet() { + public boolean add(ZipEntry e) { + return ((e == null || useExtractionTime) ? false : super.add(e)); + }}; + } + + void updateLastModifiedTime(Set zes) throws IOException { + for (ZipEntry ze : zes) { + long lastModified = ze.getTime(); + if (lastModified != -1) { + File f = new File(ze.getName().replace('/', File.separatorChar)); + f.setLastModified(lastModified); + } + } + } + /* * Extracts specified entries from JAR file. */ @@ -768,19 +805,13 @@ class Main { ZipEntry e; // Set of all directory entries specified in archive. Disallows // null entries. Disallows all entries if using pre-6.0 behavior. - Set dirs = new HashSet() { - public boolean add(ZipEntry e) { - return ((e == null || useExtractionTime) ? false : super.add(e)); - }}; - + Set dirs = newDirSet(); while ((e = zis.getNextEntry()) != null) { if (files == null) { dirs.add(extractFile(zis, e)); - } else { String name = e.getName(); - for (int i = 0; i < files.length; i++) { - String file = files[i].replace(File.separatorChar, '/'); + for (String file : files) { if (name.startsWith(file)) { dirs.add(extractFile(zis, e)); break; @@ -793,13 +824,33 @@ class Main { // timestamps as given in the archive. We do this after extraction, // instead of during, because creating a file in a directory changes // that directory's timestamp. - for (ZipEntry dirEntry : dirs) { - long lastModified = dirEntry.getTime(); - if (lastModified != -1) { - File dir = new File(dirEntry.getName().replace('/', File.separatorChar)); - dir.setLastModified(lastModified); + updateLastModifiedTime(dirs); + } + + /* + * Extracts specified entries from JAR file, via ZipFile. + */ + void extract(String fname, String files[]) throws IOException { + ZipFile zf = new ZipFile(fname); + Set dirs = newDirSet(); + Enumeration zes = zf.entries(); + while (zes.hasMoreElements()) { + ZipEntry e = zes.nextElement(); + InputStream is; + if (files == null) { + dirs.add(extractFile(zf.getInputStream(e), e)); + } else { + String name = e.getName(); + for (String file : files) { + if (name.startsWith(file)) { + dirs.add(extractFile(zf.getInputStream(e), e)); + break; + } + } } } + zf.close(); + updateLastModifiedTime(dirs); } /* @@ -807,7 +858,7 @@ class Main { * the entry is for a directory which doesn't exist prior to this * invocation, returns that entry, otherwise returns null. */ - ZipEntry extractFile(ZipInputStream zis, ZipEntry e) throws IOException { + ZipEntry extractFile(InputStream is, ZipEntry e) throws IOException { ZipEntry rc = null; String name = e.getName(); File f = new File(e.getName().replace('/', File.separatorChar)); @@ -838,13 +889,19 @@ class Main { } } OutputStream os = new FileOutputStream(f); - byte[] b = new byte[512]; + byte[] b = new byte[8192]; int len; - while ((len = zis.read(b, 0, b.length)) != -1) { - os.write(b, 0, len); + try { + while ((len = is.read(b, 0, b.length)) != -1) { + os.write(b, 0, len); + } + } finally { + if (is instanceof ZipInputStream) + ((ZipInputStream)is).closeEntry(); + else + is.close(); + os.close(); } - zis.closeEntry(); - os.close(); if (vflag) { if (e.getMethod() == ZipEntry.DEFLATED) { output(formatMsg("out.inflated", name)); @@ -869,7 +926,6 @@ class Main { ZipInputStream zis = new ZipInputStream(in); ZipEntry e; while ((e = zis.getNextEntry()) != null) { - String name = e.getName(); /* * In the case of a compressed (deflated) entry, the entry size * is stored immediately following the entry data and cannot be @@ -877,20 +933,22 @@ class Main { * the entry first before printing out its attributes. */ zis.closeEntry(); - if (files == null) { - printEntry(e); - } else { - for (int i = 0; i < files.length; i++) { - String file = files[i].replace(File.separatorChar, '/'); - if (name.startsWith(file)) { - printEntry(e); - break; - } - } - } + printEntry(e, files); } } + /* + * Lists contents of JAR file, via ZipFile. + */ + void list(String fname, String files[]) throws IOException { + ZipFile zf = new ZipFile(fname); + Enumeration zes = zf.entries(); + while (zes.hasMoreElements()) { + printEntry(zes.nextElement(), files); + } + zf.close(); + } + /** * Output the class index table to the INDEX.LIST file of the * root jar file. @@ -974,13 +1032,29 @@ class Main { dumpIndex(rootjar, index); } + /* + * Prints entry information, if requested. + */ + void printEntry(ZipEntry e, String[] files) throws IOException { + if (files == null) { + printEntry(e); + } else { + String name = e.getName(); + for (String file : files) { + if (name.startsWith(file)) { + printEntry(e); + return; + } + } + } + } /* * Prints entry information. */ void printEntry(ZipEntry e) throws IOException { if (vflag) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); String s = Long.toString(e.getSize()); for (int i = 6 - s.length(); i > 0; --i) { sb.append(' '); From 1606eaa0b99fa575a6af46a7332e8ee6c6f0d817 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 14 Jan 2009 17:17:34 +0000 Subject: [PATCH 2/8] 6755782: It is not clear how DatagramSocket deals with broadcast enabling/disabling Reviewed-by: jccollet --- .../classes/java/net/DatagramSocket.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/java/net/DatagramSocket.java b/jdk/src/share/classes/java/net/DatagramSocket.java index 4558632c214..40c95ef5aee 100644 --- a/jdk/src/share/classes/java/net/DatagramSocket.java +++ b/jdk/src/share/classes/java/net/DatagramSocket.java @@ -41,10 +41,11 @@ import java.security.PrivilegedExceptionAction; * one machine to another may be routed differently, and may arrive in * any order. * - *

UDP broadcasts sends are always enabled on a DatagramSocket. - * In order to receive broadcast packets a DatagramSocket - * should be bound to the wildcard address. In some - * implementations, broadcast packets may also be received when + *

Where possible, a newly constructed {@code DatagramSocket} has the + * {@link SocketOptions#SO_BROADCAST SO_BROADCAST} socket option enabled so as + * to allow the transmission of broadcast datagrams. In order to receive + * broadcast packets a DatagramSocket should be bound to the wildcard address. + * In some implementations, broadcast packets may also be received when * a DatagramSocket is bound to a more specific address. *

* Example: @@ -1017,9 +1018,18 @@ class DatagramSocket implements java.io.Closeable { /** * Enable/disable SO_BROADCAST. - * @param on whether or not to have broadcast turned on. - * @exception SocketException if there is an error - * in the underlying protocol, such as an UDP error. + * + *

Some operating systems may require that the Java virtual machine be + * started with implementation specific privileges to enable this option or + * send broadcast datagrams. + * + * @param on + * whether or not to have broadcast turned on. + * + * @throws SocketException + * if there is an error in the underlying protocol, such as an UDP + * error. + * * @since 1.4 * @see #getBroadcast() */ From 640ed7d08b6b13f841498a139e81f90e609c8be0 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 14 Jan 2009 16:23:29 -0800 Subject: [PATCH 3/8] 6792545: Typo in java.util.Collection JavaDoc 6655123: Incorrect ref to The Art of Computer Programming in doc for java.util.Random Fix a pair of typos. Reviewed-by: jjg --- jdk/src/share/classes/java/util/Collection.java | 2 +- jdk/src/share/classes/java/util/Random.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/util/Collection.java b/jdk/src/share/classes/java/util/Collection.java index 28c923ff2a0..e7cb3c91e0c 100644 --- a/jdk/src/share/classes/java/util/Collection.java +++ b/jdk/src/share/classes/java/util/Collection.java @@ -427,7 +427,7 @@ public interface Collection extends Iterable { * contract for the Object.hashCode method, programmers should * take note that any class that overrides the Object.equals * method must also override the Object.hashCode method in order - * to satisfy the general contract for the Object.hashCodemethod. + * to satisfy the general contract for the Object.hashCode method. * In particular, c1.equals(c2) implies that * c1.hashCode()==c2.hashCode(). * diff --git a/jdk/src/share/classes/java/util/Random.java b/jdk/src/share/classes/java/util/Random.java index 26cc4e234e0..cfa48248166 100644 --- a/jdk/src/share/classes/java/util/Random.java +++ b/jdk/src/share/classes/java/util/Random.java @@ -32,7 +32,7 @@ import sun.misc.Unsafe; * An instance of this class is used to generate a stream of * pseudorandom numbers. The class uses a 48-bit seed, which is * modified using a linear congruential formula. (See Donald Knuth, - * The Art of Computer Programming, Volume 3, Section 3.2.1.) + * The Art of Computer Programming, Volume 2, Section 3.2.1.) *

* If two instances of {@code Random} are created with the same * seed, and the same sequence of method calls is made for each, they From 220ed00264776702ddadd96e0db106917afc2f02 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Mon, 19 Jan 2009 18:49:10 +0800 Subject: [PATCH 4/8] 6793475: krb5.ini not found on some Windows Reviewed-by: xuelei --- .../classes/sun/security/krb5/Config.java | 82 ++++++++++++------- .../sun/security/krb5/WindowsDirectory.c | 31 ++++--- 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/jdk/src/share/classes/sun/security/krb5/Config.java b/jdk/src/share/classes/sun/security/krb5/Config.java index 2a16b983f33..ec3eb81767d 100644 --- a/jdk/src/share/classes/sun/security/krb5/Config.java +++ b/jdk/src/share/classes/sun/security/krb5/Config.java @@ -1,5 +1,5 @@ /* - * Portions Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. + * Portions Copyright 2000-2009 Sun Microsystems, Inc. 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 @@ -74,7 +74,7 @@ public class Config { private String defaultRealm; // default kdc realm. // used for native interface - private static native String getWindowsDirectory(); + private static native String getWindowsDirectory(boolean isSystem); /** @@ -661,38 +661,37 @@ public class Config { } /** - * Gets the default configuration file name. The file will be searched - * in a list of possible loations in the following order: - * 1. the location and file name defined by system property - * "java.security.krb5.conf", - * 2. at Java home lib\security directory with "krb5.conf" name, - * 3. "krb5.ini" at Java home, - * 4. at windows directory with the name of "krb5.ini" for Windows, - * /etc/krb5/krb5.conf for Solaris, /etc/krb5.conf for Linux. + * Gets the default configuration file name. This method will never + * return null. + * + * If the system property "java.security.krb5.conf" is defined, we'll + * use its value, no matter if the file exists or not. Otherwise, + * the file will be searched in a list of possible loations in the + * following order: + * + * 1. at Java home lib\security directory with "krb5.conf" name, + * 2. at windows directory with the name of "krb5.ini" for Windows, + * /etc/krb5/krb5.conf for Solaris, /etc/krb5.conf otherwise. + * + * Note: When the Terminal Service is started in Windows (from 2003), + * there are two kinds of Windows directories: A system one (say, + * C:\Windows), and a user-private one (say, C:\Users\Me\Windows). + * We will first look for krb5.ini in the user-private one. If not + * found, try the system one instead. */ private String getFileName() { String name = java.security.AccessController.doPrivileged( new sun.security.action. GetPropertyAction("java.security.krb5.conf")); - if (name != null) { - boolean temp = - java.security.AccessController.doPrivileged( - new FileExistsAction(name)); - if (temp) - return name; - } else { + if (name == null) { name = java.security.AccessController.doPrivileged( new sun.security.action. GetPropertyAction("java.home")) + File.separator + "lib" + File.separator + "security" + File.separator + "krb5.conf"; - boolean temp = - java.security.AccessController.doPrivileged( - new FileExistsAction(name)); - if (temp) { - return name; - } else { + if (!fileExists(name)) { + name = null; String osname = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.name")); @@ -703,19 +702,35 @@ public class Config { // ignore exceptions } if (Credentials.alreadyLoaded) { - if ((name = getWindowsDirectory()) == null) { - name = "c:\\winnt\\krb5.ini"; - } else if (name.endsWith("\\")) { - name += "krb5.ini"; - } else { - name += "\\krb5.ini"; + String path = getWindowsDirectory(false); + if (path != null) { + if (path.endsWith("\\")) { + path = path + "krb5.ini"; + } else { + path = path + "\\krb5.ini"; + } + if (fileExists(path)) { + name = path; + } } - } else { + if (name == null) { + path = getWindowsDirectory(true); + if (path != null) { + if (path.endsWith("\\")) { + path = path + "krb5.ini"; + } else { + path = path + "\\krb5.ini"; + } + name = path; + } + } + } + if (name == null) { name = "c:\\winnt\\krb5.ini"; } } else if (osname.startsWith("SunOS")) { name = "/etc/krb5/krb5.conf"; - } else if (osname.startsWith("Linux")) { + } else { name = "/etc/krb5.conf"; } } @@ -1171,6 +1186,11 @@ public class Config { return kdcs; } + private boolean fileExists(String name) { + return java.security.AccessController.doPrivileged( + new FileExistsAction(name)); + } + static class FileExistsAction implements java.security.PrivilegedAction { diff --git a/jdk/src/windows/native/sun/security/krb5/WindowsDirectory.c b/jdk/src/windows/native/sun/security/krb5/WindowsDirectory.c index dc96bad91ab..7b11163863d 100644 --- a/jdk/src/windows/native/sun/security/krb5/WindowsDirectory.c +++ b/jdk/src/windows/native/sun/security/krb5/WindowsDirectory.c @@ -1,5 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 2005-2009 Sun Microsystems, Inc. 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 @@ -23,6 +23,7 @@ * have any questions. */ +#define UNICODE #include #include #include @@ -30,22 +31,20 @@ /* * Class: sun_security_krb5_Config * Method: getWindowsDirectory - * Signature: ()Ljava/lang/String; + * Signature: (Z)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_sun_security_krb5_Config_getWindowsDirectory( - JNIEnv* env, jclass configClass) { - LPTSTR lpPath = NULL; - UINT uLength ; - jstring path = NULL; - - if (uLength = GetWindowsDirectory(lpPath, 0)) { - lpPath = (LPTSTR)malloc(sizeof(TCHAR) * uLength); - if (lpPath != NULL) { - if (GetWindowsDirectory(lpPath, uLength)) { - path = (*env)->NewStringUTF(env, lpPath); - } - free(lpPath); - } + JNIEnv* env, jclass configClass, jboolean isSystem) { + TCHAR lpPath[MAX_PATH+1]; + UINT len; + if (isSystem) { + len = GetSystemWindowsDirectory(lpPath, MAX_PATH); + } else { + len = GetWindowsDirectory(lpPath, MAX_PATH); + } + if (len) { + return (*env)->NewString(env, lpPath, len); + } else { + return NULL; } - return path; } From 11431a6329413dc851453a1aaa4c384f968f7162 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 20 Jan 2009 13:02:58 -0800 Subject: [PATCH 5/8] 6793429: Use compiled properties instead of plain properties for resource file Rename the variables in Resources.gmk to make compiled properties more explicit Reviewed-by: naoto, yhuang --- jdk/make/com/sun/org/apache/xml/Makefile | 2 +- jdk/make/com/sun/rowset/Makefile | 2 +- jdk/make/common/internal/Resources.gmk | 18 +++++++++++------- jdk/make/sun/launcher/Makefile | 2 +- jdk/make/sun/rmi/oldtools/Makefile | 2 +- jdk/make/sun/rmi/registry/Makefile | 2 +- jdk/make/sun/rmi/rmic/Makefile | 2 +- jdk/make/sun/rmi/rmid/Makefile | 2 +- jdk/make/sun/serialver/Makefile | 2 +- 9 files changed, 19 insertions(+), 15 deletions(-) diff --git a/jdk/make/com/sun/org/apache/xml/Makefile b/jdk/make/com/sun/org/apache/xml/Makefile index 140a381c45e..36a15bac490 100644 --- a/jdk/make/com/sun/org/apache/xml/Makefile +++ b/jdk/make/com/sun/org/apache/xml/Makefile @@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = com/sun/org/apache/xml # Resources # LOCALE_SET_DEFINITION = jre -NEW_RESOURCE_BUNDLES_PROPERTIES = \ +NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = \ $(PKGDIR)/internal/security/resource/config.dtd \ $(PKGDIR)/internal/security/resource/config.xml \ $(PKGDIR)/internal/security/resource/xmlsecurity_de.properties \ diff --git a/jdk/make/com/sun/rowset/Makefile b/jdk/make/com/sun/rowset/Makefile index 919ef46fd99..ff7641a128e 100644 --- a/jdk/make/com/sun/rowset/Makefile +++ b/jdk/make/com/sun/rowset/Makefile @@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = com/sun/rowset # Resources # LOCALE_SET_DEFINITION = jre -RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/RowSetResourceBundle.properties +RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/RowSetResourceBundle.properties # # Rules diff --git a/jdk/make/common/internal/Resources.gmk b/jdk/make/common/internal/Resources.gmk index dbc11ef832f..a772194b471 100644 --- a/jdk/make/common/internal/Resources.gmk +++ b/jdk/make/common/internal/Resources.gmk @@ -44,12 +44,8 @@ # # NEW_RESOURCE_BUNDLES_JAVA - new resource bundles implemented in # Java, not localized -# NEW_RESOURCE_BUNDLES_PROPERTIES - new resource bundles implemented as -# properties files, not localized # RESOURCE_BUNDLES_JAVA - resource bundles implemented in # Java, localized -# RESOURCE_BUNDLES_PROPERTIES - new resource bundles implemented as -# properties files, localized # # The following variable is now used for most .properties files in the JDK. # These properties files are converted into java and compiled with javac. @@ -61,6 +57,13 @@ # properties files, localized # NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES - same as above, not localized # +# For non-compiled properties files, use the following variables: +# +# NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES - new resource bundles implemented as +# properties files, not localized +# RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES - resource bundles implemented as +# properties files, localized +# # Other properties files to be installed are identified using the variable: # # OTHER_PROPERTIES @@ -109,11 +112,12 @@ COMPILED_PROPERTIES += $(RESOURCE_BUNDLES_COMPILED_PROPERTIES) \ FILES_java += $(COMPILED_PROPERTIES:%.properties=%.java) # Non-compiled files -PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_PROPERTIES) -PROPERTIES_FILES += $(RESOURCE_BUNDLES_PROPERTIES) \ - $(foreach file,$(RESOURCE_BUNDLES_PROPERTIES), \ +PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES) +PROPERTIES_FILES += $(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES) \ + $(foreach file,$(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES), \ $(foreach locale,$(LOCALE_SUFFIXES), \ $(basename $(file))_$(locale)$(suffix $(file)))) +# other properties PROPERTIES_FILES += $(OTHER_PROPERTIES) # diff --git a/jdk/make/sun/launcher/Makefile b/jdk/make/sun/launcher/Makefile index d9fba17bbbe..1346bc4e200 100644 --- a/jdk/make/sun/launcher/Makefile +++ b/jdk/make/sun/launcher/Makefile @@ -37,7 +37,7 @@ AUTO_FILES_JAVA_DIRS = sun/launcher # Resources # LOCALE_SET_DEFINITION = jre -NEW_RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/launcher.properties +NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES = $(PKGDIR)/resources/launcher.properties # # Rules diff --git a/jdk/make/sun/rmi/oldtools/Makefile b/jdk/make/sun/rmi/oldtools/Makefile index 1b5dfaaa8de..ad610ffca41 100644 --- a/jdk/make/sun/rmi/oldtools/Makefile +++ b/jdk/make/sun/rmi/oldtools/Makefile @@ -41,7 +41,7 @@ include FILES_java.gmk # Resources # LOCALE_SET_DEFINITION = j2sdk -RESOURCE_BUNDLES_PROPERTIES = sun/tools/javac/resources/javac.properties +RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = sun/tools/javac/resources/javac.properties # # Rules diff --git a/jdk/make/sun/rmi/registry/Makefile b/jdk/make/sun/rmi/registry/Makefile index 552131848d7..c5254a7f3c9 100644 --- a/jdk/make/sun/rmi/registry/Makefile +++ b/jdk/make/sun/rmi/registry/Makefile @@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = sun/rmi/registry # Resources # LOCALE_SET_DEFINITION = jre -RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/rmiregistry.properties +RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/resources/rmiregistry.properties # # Rules diff --git a/jdk/make/sun/rmi/rmic/Makefile b/jdk/make/sun/rmi/rmic/Makefile index c6c7c53e23c..8d9f435e6ec 100644 --- a/jdk/make/sun/rmi/rmic/Makefile +++ b/jdk/make/sun/rmi/rmic/Makefile @@ -43,7 +43,7 @@ FILES_java = $(RMIC_java) # Resources # LOCALE_SET_DEFINITION = jdk -RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/rmic.properties +RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/resources/rmic.properties # # Rules diff --git a/jdk/make/sun/rmi/rmid/Makefile b/jdk/make/sun/rmi/rmid/Makefile index 48c62d1a942..845b103220d 100644 --- a/jdk/make/sun/rmi/rmid/Makefile +++ b/jdk/make/sun/rmi/rmid/Makefile @@ -39,7 +39,7 @@ build: stubs # Resources # LOCALE_SET_DEFINITION = jre -RESOURCE_BUNDLES_PROPERTIES = sun/rmi/server/resources/rmid.properties +RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = sun/rmi/server/resources/rmid.properties # # Extra dependencies. diff --git a/jdk/make/sun/serialver/Makefile b/jdk/make/sun/serialver/Makefile index 3dfae491160..e848154af6a 100644 --- a/jdk/make/sun/serialver/Makefile +++ b/jdk/make/sun/serialver/Makefile @@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = sun/tools/serialver # Resources # LOCALE_SET_DEFINITION = jdk -RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/serialver.properties +RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/resources/serialver.properties # # Rules From 4f3a9a439240940b9f2fcbd4734c53d63c40a02a Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 20 Jan 2009 13:04:19 -0800 Subject: [PATCH 6/8] 6769976: (fc) FileChannelImpl.isAMappedBufferField not used Remove the FileChannelImpl.isAMappedBufferField field Reviewed-by: alanb --- jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java index 894c489cd85..4d0543e4b1c 100644 --- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java +++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java @@ -60,9 +60,6 @@ public class FileChannelImpl // Memory allocation size for mapping buffers private static final long allocationGranularity; - // Cached field for MappedByteBuffer.isAMappedBuffer - private static final Field isAMappedBufferField; - // File descriptor private final FileDescriptor fd; @@ -1315,8 +1312,6 @@ public class FileChannelImpl Util.load(); allocationGranularity = initIDs(); nd = new FileDispatcher(); - isAMappedBufferField = Reflect.lookupField("java.nio.MappedByteBuffer", - "isAMappedBuffer"); } } From a9c275ed18bd85b40030d0145b16e3799eece521 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Thu, 22 Jan 2009 20:29:54 -0800 Subject: [PATCH 7/8] 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima Correct the wrong calculation of "precision" in certain circumstances. Reviewed-by: darcy, alanb --- .../share/classes/java/util/Formatter.java | 27 +++++++---- jdk/test/java/util/Formatter/Basic-X.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/Basic.java | 2 +- .../java/util/Formatter/BasicBigDecimal.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicBigInteger.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicBoolean.java | 46 +++++++++++++++++++ .../util/Formatter/BasicBooleanObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicByte.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicByteObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicChar.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicCharObject.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicDateTime.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicDouble.java | 46 +++++++++++++++++++ .../util/Formatter/BasicDoubleObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicFloat.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicFloatObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicInt.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicIntObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicLong.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicLongObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/BasicShort.java | 46 +++++++++++++++++++ .../java/util/Formatter/BasicShortObject.java | 46 +++++++++++++++++++ jdk/test/java/util/Formatter/genBasic.sh | 6 ++- 23 files changed, 943 insertions(+), 12 deletions(-) diff --git a/jdk/src/share/classes/java/util/Formatter.java b/jdk/src/share/classes/java/util/Formatter.java index ad4dca1d3e6..5100adbd27c 100644 --- a/jdk/src/share/classes/java/util/Formatter.java +++ b/jdk/src/share/classes/java/util/Formatter.java @@ -39,6 +39,7 @@ import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; +import java.math.RoundingMode; import java.nio.charset.Charset; import java.text.DateFormatSymbols; import java.text.DecimalFormat; @@ -1252,7 +1253,7 @@ import sun.misc.FormattedFloatingDecimal; * Double#toString(double)} respectively, then the value will be rounded * using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up * algorithm}. Otherwise, zeros may be appended to reach the precision. - * For a canonical representation of the value,use {@link + * For a canonical representation of the value, use {@link * Float#toString(float)} or {@link Double#toString(double)} as * appropriate. * @@ -3569,15 +3570,23 @@ public final class Formatter implements Closeable, Flushable { // Create a new BigDecimal with the desired precision. int prec = (precision == -1 ? 6 : precision); int scale = value.scale(); - int compPrec = value.precision(); - if (scale > prec) - compPrec -= (scale - prec); - MathContext mc = new MathContext(compPrec); - BigDecimal v - = new BigDecimal(value.unscaledValue(), scale, mc); - BigDecimalLayout bdl - = new BigDecimalLayout(v.unscaledValue(), v.scale(), + if (scale > prec) { + // more "scale" digits than the requested "precision + int compPrec = value.precision(); + if (compPrec <= scale) { + // case of 0.xxxxxx + value = value.setScale(prec, RoundingMode.HALF_UP); + } else { + compPrec -= (scale - prec); + value = new BigDecimal(value.unscaledValue(), + scale, + new MathContext(compPrec)); + } + } + BigDecimalLayout bdl = new BigDecimalLayout( + value.unscaledValue(), + value.scale(), BigDecimalLayoutForm.DECIMAL_FLOAT); char mant[] = bdl.mantissa(); diff --git a/jdk/test/java/util/Formatter/Basic-X.java b/jdk/test/java/util/Formatter/Basic-X.java index b4a603f7bcd..4677062cc14 100644 --- a/jdk/test/java/util/Formatter/Basic-X.java +++ b/jdk/test/java/util/Formatter/Basic-X.java @@ -1054,6 +1054,52 @@ public class Basic$Type$ extends Basic { test("%4.1f", " 1.0", val); test("%4.2f", "0.99", val); test("%4.3f", "0.990", val); + + // #6476425 + val = new BigDecimal("0.00001"); + test("%.0f", "0", val); + test("%.1f", "0.0", val); + test("%.2f", "0.00", val); + test("%.3f", "0.000", val); + test("%.4f", "0.0000", val); + test("%.5f", "0.00001", val); + + val = new BigDecimal("1.00001"); + test("%.0f", "1", val); + test("%.1f", "1.0", val); + test("%.2f", "1.00", val); + test("%.3f", "1.000", val); + test("%.4f", "1.0000", val); + test("%.5f", "1.00001", val); + + val = new BigDecimal("1.23456"); + test("%.0f", "1", val); + test("%.1f", "1.2", val); + test("%.2f", "1.23", val); + test("%.3f", "1.235", val); + test("%.4f", "1.2346", val); + test("%.5f", "1.23456", val); + test("%.6f", "1.234560", val); + + val = new BigDecimal("9.99999"); + test("%.0f", "10", val); + test("%.1f", "10.0", val); + test("%.2f", "10.00", val); + test("%.3f", "10.000", val); + test("%.4f", "10.0000", val); + test("%.5f", "9.99999", val); + test("%.6f", "9.999990", val); + + + val = new BigDecimal("1.99999"); + test("%.0f", "2", val); + test("%.1f", "2.0", val); + test("%.2f", "2.00", val); + test("%.3f", "2.000", val); + test("%.4f", "2.0000", val); + test("%.5f", "1.99999", val); + test("%.6f", "1.999990", val); + #end[BigDecimal] #if[float] diff --git a/jdk/test/java/util/Formatter/Basic.java b/jdk/test/java/util/Formatter/Basic.java index 22d92495d49..3a957b2f4fa 100644 --- a/jdk/test/java/util/Formatter/Basic.java +++ b/jdk/test/java/util/Formatter/Basic.java @@ -25,7 +25,7 @@ * @summary Unit test for formatter * @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937 * 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122 - * 6344623 6369500 6534606 6282094 6286592 + * 6344623 6369500 6534606 6282094 6286592 6476425 * * @run shell/timeout=240 Basic.sh */ diff --git a/jdk/test/java/util/Formatter/BasicBigDecimal.java b/jdk/test/java/util/Formatter/BasicBigDecimal.java index d35da256576..da96391384c 100644 --- a/jdk/test/java/util/Formatter/BasicBigDecimal.java +++ b/jdk/test/java/util/Formatter/BasicBigDecimal.java @@ -1055,6 +1055,52 @@ public class BasicBigDecimal extends Basic { test("%4.2f", "0.99", val); test("%4.3f", "0.990", val); + // #6476425 + val = new BigDecimal("0.00001"); + test("%.0f", "0", val); + test("%.1f", "0.0", val); + test("%.2f", "0.00", val); + test("%.3f", "0.000", val); + test("%.4f", "0.0000", val); + test("%.5f", "0.00001", val); + + val = new BigDecimal("1.00001"); + test("%.0f", "1", val); + test("%.1f", "1.0", val); + test("%.2f", "1.00", val); + test("%.3f", "1.000", val); + test("%.4f", "1.0000", val); + test("%.5f", "1.00001", val); + + val = new BigDecimal("1.23456"); + test("%.0f", "1", val); + test("%.1f", "1.2", val); + test("%.2f", "1.23", val); + test("%.3f", "1.235", val); + test("%.4f", "1.2346", val); + test("%.5f", "1.23456", val); + test("%.6f", "1.234560", val); + + val = new BigDecimal("9.99999"); + test("%.0f", "10", val); + test("%.1f", "10.0", val); + test("%.2f", "10.00", val); + test("%.3f", "10.000", val); + test("%.4f", "10.0000", val); + test("%.5f", "9.99999", val); + test("%.6f", "9.999990", val); + + + val = new BigDecimal("1.99999"); + test("%.0f", "2", val); + test("%.1f", "2.0", val); + test("%.2f", "2.00", val); + test("%.3f", "2.000", val); + test("%.4f", "2.0000", val); + test("%.5f", "1.99999", val); + test("%.6f", "1.999990", val); + + diff --git a/jdk/test/java/util/Formatter/BasicBigInteger.java b/jdk/test/java/util/Formatter/BasicBigInteger.java index e93f60d398d..4bba5a0fbe4 100644 --- a/jdk/test/java/util/Formatter/BasicBigInteger.java +++ b/jdk/test/java/util/Formatter/BasicBigInteger.java @@ -1503,6 +1503,52 @@ public class BasicBigInteger extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicBoolean.java b/jdk/test/java/util/Formatter/BasicBoolean.java index c7af21083aa..ea60e388652 100644 --- a/jdk/test/java/util/Formatter/BasicBoolean.java +++ b/jdk/test/java/util/Formatter/BasicBoolean.java @@ -1503,6 +1503,52 @@ public class BasicBoolean extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicBooleanObject.java b/jdk/test/java/util/Formatter/BasicBooleanObject.java index 81c1f3e1ada..b4fbabb76b8 100644 --- a/jdk/test/java/util/Formatter/BasicBooleanObject.java +++ b/jdk/test/java/util/Formatter/BasicBooleanObject.java @@ -1503,6 +1503,52 @@ public class BasicBooleanObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicByte.java b/jdk/test/java/util/Formatter/BasicByte.java index ff44286fdc3..deaf37957e5 100644 --- a/jdk/test/java/util/Formatter/BasicByte.java +++ b/jdk/test/java/util/Formatter/BasicByte.java @@ -1503,6 +1503,52 @@ public class BasicByte extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicByteObject.java b/jdk/test/java/util/Formatter/BasicByteObject.java index e2b158c3e85..06eb68ebd27 100644 --- a/jdk/test/java/util/Formatter/BasicByteObject.java +++ b/jdk/test/java/util/Formatter/BasicByteObject.java @@ -1503,6 +1503,52 @@ public class BasicByteObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicChar.java b/jdk/test/java/util/Formatter/BasicChar.java index bb1b5037e88..5ada7b166e7 100644 --- a/jdk/test/java/util/Formatter/BasicChar.java +++ b/jdk/test/java/util/Formatter/BasicChar.java @@ -1503,6 +1503,52 @@ public class BasicChar extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicCharObject.java b/jdk/test/java/util/Formatter/BasicCharObject.java index 2d15fa1c528..1e7d05d543f 100644 --- a/jdk/test/java/util/Formatter/BasicCharObject.java +++ b/jdk/test/java/util/Formatter/BasicCharObject.java @@ -1503,6 +1503,52 @@ public class BasicCharObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicDateTime.java b/jdk/test/java/util/Formatter/BasicDateTime.java index 97ae65026bb..fd42da06f70 100644 --- a/jdk/test/java/util/Formatter/BasicDateTime.java +++ b/jdk/test/java/util/Formatter/BasicDateTime.java @@ -1503,6 +1503,52 @@ public class BasicDateTime extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicDouble.java b/jdk/test/java/util/Formatter/BasicDouble.java index abbd093fc0a..d985b46b1a5 100644 --- a/jdk/test/java/util/Formatter/BasicDouble.java +++ b/jdk/test/java/util/Formatter/BasicDouble.java @@ -1053,6 +1053,52 @@ public class BasicDouble extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicDoubleObject.java b/jdk/test/java/util/Formatter/BasicDoubleObject.java index d49f9e60910..70dfd2929e5 100644 --- a/jdk/test/java/util/Formatter/BasicDoubleObject.java +++ b/jdk/test/java/util/Formatter/BasicDoubleObject.java @@ -1053,6 +1053,52 @@ public class BasicDoubleObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicFloat.java b/jdk/test/java/util/Formatter/BasicFloat.java index 61493b59b98..122b44f1e75 100644 --- a/jdk/test/java/util/Formatter/BasicFloat.java +++ b/jdk/test/java/util/Formatter/BasicFloat.java @@ -1056,6 +1056,52 @@ public class BasicFloat extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + //--------------------------------------------------------------------- // %f - float diff --git a/jdk/test/java/util/Formatter/BasicFloatObject.java b/jdk/test/java/util/Formatter/BasicFloatObject.java index fb7bffa150f..64c874cf2d5 100644 --- a/jdk/test/java/util/Formatter/BasicFloatObject.java +++ b/jdk/test/java/util/Formatter/BasicFloatObject.java @@ -1069,6 +1069,52 @@ public class BasicFloatObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicInt.java b/jdk/test/java/util/Formatter/BasicInt.java index 1945d5b612a..4010d2250e0 100644 --- a/jdk/test/java/util/Formatter/BasicInt.java +++ b/jdk/test/java/util/Formatter/BasicInt.java @@ -1503,6 +1503,52 @@ public class BasicInt extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicIntObject.java b/jdk/test/java/util/Formatter/BasicIntObject.java index 267ffd2eb95..fe41ea2964b 100644 --- a/jdk/test/java/util/Formatter/BasicIntObject.java +++ b/jdk/test/java/util/Formatter/BasicIntObject.java @@ -1503,6 +1503,52 @@ public class BasicIntObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicLong.java b/jdk/test/java/util/Formatter/BasicLong.java index 151dcb78975..fe232f1978e 100644 --- a/jdk/test/java/util/Formatter/BasicLong.java +++ b/jdk/test/java/util/Formatter/BasicLong.java @@ -1503,6 +1503,52 @@ public class BasicLong extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicLongObject.java b/jdk/test/java/util/Formatter/BasicLongObject.java index 3944418b3a6..c99e0ba3c2a 100644 --- a/jdk/test/java/util/Formatter/BasicLongObject.java +++ b/jdk/test/java/util/Formatter/BasicLongObject.java @@ -1503,6 +1503,52 @@ public class BasicLongObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicShort.java b/jdk/test/java/util/Formatter/BasicShort.java index 5554c15382d..39079e4ad1e 100644 --- a/jdk/test/java/util/Formatter/BasicShort.java +++ b/jdk/test/java/util/Formatter/BasicShort.java @@ -1503,6 +1503,52 @@ public class BasicShort extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/BasicShortObject.java b/jdk/test/java/util/Formatter/BasicShortObject.java index 629fb573674..e2dcc230174 100644 --- a/jdk/test/java/util/Formatter/BasicShortObject.java +++ b/jdk/test/java/util/Formatter/BasicShortObject.java @@ -1503,6 +1503,52 @@ public class BasicShortObject extends Basic { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdk/test/java/util/Formatter/genBasic.sh b/jdk/test/java/util/Formatter/genBasic.sh index 493e0360444..2c352ad39cf 100644 --- a/jdk/test/java/util/Formatter/genBasic.sh +++ b/jdk/test/java/util/Formatter/genBasic.sh @@ -23,14 +23,14 @@ # have any questions. # -SPP='sh ../../../../make/java/nio/spp.sh' +javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java gen() { # if [ $3 = "true" ] # then $SPP -K$1 -Dtype=$1 -DType=$2 -KprimBasic$2.java # else $SPP -K$1 -Dtype=$1 -DType=$2 -K$3 Basic$2.java # fi - $SPP -K$1 -Dtype=$1 -DType=$2 -K$3 -K$4 -K$5 -K$6 Basic$2.java + java build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -K$3 -K$4 -K$5 -K$6 Basic$2.java } gen boolean Boolean prim "" "" "" @@ -54,3 +54,5 @@ gen Double DoubleObject "" fp "" "" gen BigDecimal BigDecimal "" fp "" "" gen Calendar DateTime "" "" "" datetime + +rm -rf build From e08feb9741b8ef23e2fb41ad7459f2181f918182 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 23 Jan 2009 10:37:41 -0800 Subject: [PATCH 8/8] 6604864: Double.valueOf(String) does not specify behaviour for overflow and underflow Reviewed-by: emcmanus --- jdk/src/share/classes/java/lang/Double.java | 17 ++++++++++++++--- jdk/src/share/classes/java/lang/Float.java | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Double.java b/jdk/src/share/classes/java/lang/Double.java index 852d27dccc8..9866d5d4aee 100644 --- a/jdk/src/share/classes/java/lang/Double.java +++ b/jdk/src/share/classes/java/lang/Double.java @@ -1,5 +1,5 @@ /* - * Copyright 1994-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1994-2009 Sun Microsystems, Inc. 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 @@ -404,8 +404,19 @@ public final class Double extends Number implements Comparable { * binary value that is then rounded to type {@code double} * by the usual round-to-nearest rule of IEEE 754 floating-point * arithmetic, which includes preserving the sign of a zero - * value. Finally, a {@code Double} object representing this - * {@code double} value is returned. + * value. + * + * Note that the round-to-nearest rule also implies overflow and + * underflow behaviour; if the exact value of {@code s} is large + * enough in magnitude (greater than or equal to ({@link + * #MAX_VALUE} + {@link Math#ulp(double) ulp(MAX_VALUE)}/2), + * rounding to {@code double} will result in an infinity and if the + * exact value of {@code s} is small enough in magnitude (less + * than or equal to {@link #MIN_VALUE}/2), rounding to float will + * result in a zero. + * + * Finally, after rounding a {@code Double} object representing + * this {@code double} value is returned. * *

To interpret localized string representations of a * floating-point value, use subclasses of {@link diff --git a/jdk/src/share/classes/java/lang/Float.java b/jdk/src/share/classes/java/lang/Float.java index b8b6a1afcef..1c89a458fa7 100644 --- a/jdk/src/share/classes/java/lang/Float.java +++ b/jdk/src/share/classes/java/lang/Float.java @@ -1,5 +1,5 @@ /* - * Copyright 1994-2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1994-2009 Sun Microsystems, Inc. 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 @@ -365,8 +365,19 @@ public final class Float extends Number implements Comparable { * binary value that is then rounded to type {@code float} * by the usual round-to-nearest rule of IEEE 754 floating-point * arithmetic, which includes preserving the sign of a zero - * value. Finally, a {@code Float} object representing this - * {@code float} value is returned. + * value. + * + * Note that the round-to-nearest rule also implies overflow and + * underflow behaviour; if the exact value of {@code s} is large + * enough in magnitude (greater than or equal to ({@link + * #MAX_VALUE} + {@link Math#ulp(float) ulp(MAX_VALUE)}/2), + * rounding to {@code float} will result in an infinity and if the + * exact value of {@code s} is small enough in magnitude (less + * than or equal to {@link #MIN_VALUE}/2), rounding to float will + * result in a zero. + * + * Finally, after rounding a {@code Float} object representing + * this {@code float} value is returned. * *

To interpret localized string representations of a * floating-point value, use subclasses of {@link