提交 bb15e51e 编写于 作者: T tbell

Merge

...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = com/sun/org/apache/xml ...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = com/sun/org/apache/xml
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jre LOCALE_SET_DEFINITION = jre
NEW_RESOURCE_BUNDLES_PROPERTIES = \ NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = \
$(PKGDIR)/internal/security/resource/config.dtd \ $(PKGDIR)/internal/security/resource/config.dtd \
$(PKGDIR)/internal/security/resource/config.xml \ $(PKGDIR)/internal/security/resource/config.xml \
$(PKGDIR)/internal/security/resource/xmlsecurity_de.properties \ $(PKGDIR)/internal/security/resource/xmlsecurity_de.properties \
......
...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = com/sun/rowset ...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = com/sun/rowset
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jre LOCALE_SET_DEFINITION = jre
RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/RowSetResourceBundle.properties RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/RowSetResourceBundle.properties
# #
# Rules # Rules
......
...@@ -44,12 +44,8 @@ ...@@ -44,12 +44,8 @@
# #
# NEW_RESOURCE_BUNDLES_JAVA - new resource bundles implemented in # NEW_RESOURCE_BUNDLES_JAVA - new resource bundles implemented in
# Java, not localized # Java, not localized
# NEW_RESOURCE_BUNDLES_PROPERTIES - new resource bundles implemented as
# properties files, not localized
# RESOURCE_BUNDLES_JAVA - resource bundles implemented in # RESOURCE_BUNDLES_JAVA - resource bundles implemented in
# Java, localized # 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. # The following variable is now used for most .properties files in the JDK.
# These properties files are converted into java and compiled with javac. # These properties files are converted into java and compiled with javac.
...@@ -61,6 +57,13 @@ ...@@ -61,6 +57,13 @@
# properties files, localized # properties files, localized
# NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES - same as above, not 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 files to be installed are identified using the variable:
# #
# OTHER_PROPERTIES # OTHER_PROPERTIES
...@@ -109,11 +112,12 @@ COMPILED_PROPERTIES += $(RESOURCE_BUNDLES_COMPILED_PROPERTIES) \ ...@@ -109,11 +112,12 @@ COMPILED_PROPERTIES += $(RESOURCE_BUNDLES_COMPILED_PROPERTIES) \
FILES_java += $(COMPILED_PROPERTIES:%.properties=%.java) FILES_java += $(COMPILED_PROPERTIES:%.properties=%.java)
# Non-compiled files # Non-compiled files
PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_PROPERTIES) PROPERTIES_FILES += $(NEW_RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES)
PROPERTIES_FILES += $(RESOURCE_BUNDLES_PROPERTIES) \ PROPERTIES_FILES += $(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES) \
$(foreach file,$(RESOURCE_BUNDLES_PROPERTIES), \ $(foreach file,$(RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES), \
$(foreach locale,$(LOCALE_SUFFIXES), \ $(foreach locale,$(LOCALE_SUFFIXES), \
$(basename $(file))_$(locale)$(suffix $(file)))) $(basename $(file))_$(locale)$(suffix $(file))))
# other properties
PROPERTIES_FILES += $(OTHER_PROPERTIES) PROPERTIES_FILES += $(OTHER_PROPERTIES)
# #
......
...@@ -37,7 +37,7 @@ AUTO_FILES_JAVA_DIRS = sun/launcher ...@@ -37,7 +37,7 @@ AUTO_FILES_JAVA_DIRS = sun/launcher
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jre LOCALE_SET_DEFINITION = jre
NEW_RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/launcher.properties NEW_RESOURCE_BUNDLES_COMPILED_PROPERTIES = $(PKGDIR)/resources/launcher.properties
# #
# Rules # Rules
......
...@@ -41,7 +41,7 @@ include FILES_java.gmk ...@@ -41,7 +41,7 @@ include FILES_java.gmk
# Resources # Resources
# #
LOCALE_SET_DEFINITION = j2sdk LOCALE_SET_DEFINITION = j2sdk
RESOURCE_BUNDLES_PROPERTIES = sun/tools/javac/resources/javac.properties RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = sun/tools/javac/resources/javac.properties
# #
# Rules # Rules
......
...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = sun/rmi/registry ...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = sun/rmi/registry
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jre LOCALE_SET_DEFINITION = jre
RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/rmiregistry.properties RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/resources/rmiregistry.properties
# #
# Rules # Rules
......
...@@ -43,7 +43,7 @@ FILES_java = $(RMIC_java) ...@@ -43,7 +43,7 @@ FILES_java = $(RMIC_java)
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jdk LOCALE_SET_DEFINITION = jdk
RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/rmic.properties RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/resources/rmic.properties
# #
# Rules # Rules
......
...@@ -39,7 +39,7 @@ build: stubs ...@@ -39,7 +39,7 @@ build: stubs
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jre 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. # Extra dependencies.
......
...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = sun/tools/serialver ...@@ -41,7 +41,7 @@ AUTO_FILES_JAVA_DIRS = sun/tools/serialver
# Resources # Resources
# #
LOCALE_SET_DEFINITION = jdk LOCALE_SET_DEFINITION = jdk
RESOURCE_BUNDLES_PROPERTIES = $(PKGDIR)/resources/serialver.properties RESOURCE_BUNDLES_UNCOMPILED_PROPERTIES = $(PKGDIR)/resources/serialver.properties
# #
# Rules # Rules
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -404,8 +404,19 @@ public final class Double extends Number implements Comparable<Double> { ...@@ -404,8 +404,19 @@ public final class Double extends Number implements Comparable<Double> {
* binary value that is then rounded to type {@code double} * binary value that is then rounded to type {@code double}
* by the usual round-to-nearest rule of IEEE 754 floating-point * by the usual round-to-nearest rule of IEEE 754 floating-point
* arithmetic, which includes preserving the sign of a zero * arithmetic, which includes preserving the sign of a zero
* value. Finally, a {@code Double} object representing this * value.
* {@code double} value is returned. *
* 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.
* *
* <p> To interpret localized string representations of a * <p> To interpret localized string representations of a
* floating-point value, use subclasses of {@link * floating-point value, use subclasses of {@link
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -365,8 +365,19 @@ public final class Float extends Number implements Comparable<Float> { ...@@ -365,8 +365,19 @@ public final class Float extends Number implements Comparable<Float> {
* binary value that is then rounded to type {@code float} * binary value that is then rounded to type {@code float}
* by the usual round-to-nearest rule of IEEE 754 floating-point * by the usual round-to-nearest rule of IEEE 754 floating-point
* arithmetic, which includes preserving the sign of a zero * arithmetic, which includes preserving the sign of a zero
* value. Finally, a {@code Float} object representing this * value.
* {@code float} value is returned. *
* 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.
* *
* <p>To interpret localized string representations of a * <p>To interpret localized string representations of a
* floating-point value, use subclasses of {@link * floating-point value, use subclasses of {@link
......
...@@ -41,10 +41,11 @@ import java.security.PrivilegedExceptionAction; ...@@ -41,10 +41,11 @@ import java.security.PrivilegedExceptionAction;
* one machine to another may be routed differently, and may arrive in * one machine to another may be routed differently, and may arrive in
* any order. * any order.
* *
* <p>UDP broadcasts sends are always enabled on a DatagramSocket. * <p> Where possible, a newly constructed {@code DatagramSocket} has the
* In order to receive broadcast packets a DatagramSocket * {@link SocketOptions#SO_BROADCAST SO_BROADCAST} socket option enabled so as
* should be bound to the wildcard address. In some * to allow the transmission of broadcast datagrams. In order to receive
* implementations, broadcast packets may also be received when * 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. * a DatagramSocket is bound to a more specific address.
* <p> * <p>
* Example: * Example:
...@@ -1017,9 +1018,18 @@ class DatagramSocket implements java.io.Closeable { ...@@ -1017,9 +1018,18 @@ class DatagramSocket implements java.io.Closeable {
/** /**
* Enable/disable SO_BROADCAST. * Enable/disable SO_BROADCAST.
* @param on whether or not to have broadcast turned on. *
* @exception SocketException if there is an error * <p> Some operating systems may require that the Java virtual machine be
* in the underlying protocol, such as an UDP error. * 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 * @since 1.4
* @see #getBroadcast() * @see #getBroadcast()
*/ */
......
...@@ -427,7 +427,7 @@ public interface Collection<E> extends Iterable<E> { ...@@ -427,7 +427,7 @@ public interface Collection<E> extends Iterable<E> {
* contract for the <tt>Object.hashCode</tt> method, programmers should * contract for the <tt>Object.hashCode</tt> method, programmers should
* take note that any class that overrides the <tt>Object.equals</tt> * take note that any class that overrides the <tt>Object.equals</tt>
* method must also override the <tt>Object.hashCode</tt> method in order * method must also override the <tt>Object.hashCode</tt> method in order
* to satisfy the general contract for the <tt>Object.hashCode</tt>method. * to satisfy the general contract for the <tt>Object.hashCode</tt> method.
* In particular, <tt>c1.equals(c2)</tt> implies that * In particular, <tt>c1.equals(c2)</tt> implies that
* <tt>c1.hashCode()==c2.hashCode()</tt>. * <tt>c1.hashCode()==c2.hashCode()</tt>.
* *
......
...@@ -39,6 +39,7 @@ import java.io.UnsupportedEncodingException; ...@@ -39,6 +39,7 @@ import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.math.MathContext; import java.math.MathContext;
import java.math.RoundingMode;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.DateFormatSymbols; import java.text.DateFormatSymbols;
import java.text.DecimalFormat; import java.text.DecimalFormat;
...@@ -1252,7 +1253,7 @@ import sun.misc.FormattedFloatingDecimal; ...@@ -1252,7 +1253,7 @@ import sun.misc.FormattedFloatingDecimal;
* Double#toString(double)} respectively, then the value will be rounded * Double#toString(double)} respectively, then the value will be rounded
* using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up * using the {@linkplain java.math.BigDecimal#ROUND_HALF_UP round half up
* algorithm}. Otherwise, zeros may be appended to reach the precision. * 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 * Float#toString(float)} or {@link Double#toString(double)} as
* appropriate. * appropriate.
* *
...@@ -3569,15 +3570,23 @@ public final class Formatter implements Closeable, Flushable { ...@@ -3569,15 +3570,23 @@ public final class Formatter implements Closeable, Flushable {
// Create a new BigDecimal with the desired precision. // Create a new BigDecimal with the desired precision.
int prec = (precision == -1 ? 6 : precision); int prec = (precision == -1 ? 6 : precision);
int scale = value.scale(); int scale = value.scale();
if (scale > prec) {
// more "scale" digits than the requested "precision
int compPrec = value.precision(); int compPrec = value.precision();
if (scale > prec) if (compPrec <= scale) {
// case of 0.xxxxxx
value = value.setScale(prec, RoundingMode.HALF_UP);
} else {
compPrec -= (scale - prec); compPrec -= (scale - prec);
MathContext mc = new MathContext(compPrec); value = new BigDecimal(value.unscaledValue(),
BigDecimal v scale,
= new BigDecimal(value.unscaledValue(), scale, mc); new MathContext(compPrec));
}
BigDecimalLayout bdl }
= new BigDecimalLayout(v.unscaledValue(), v.scale(), BigDecimalLayout bdl = new BigDecimalLayout(
value.unscaledValue(),
value.scale(),
BigDecimalLayoutForm.DECIMAL_FLOAT); BigDecimalLayoutForm.DECIMAL_FLOAT);
char mant[] = bdl.mantissa(); char mant[] = bdl.mantissa();
......
...@@ -32,7 +32,7 @@ import sun.misc.Unsafe; ...@@ -32,7 +32,7 @@ import sun.misc.Unsafe;
* An instance of this class is used to generate a stream of * An instance of this class is used to generate a stream of
* pseudorandom numbers. The class uses a 48-bit seed, which is * pseudorandom numbers. The class uses a 48-bit seed, which is
* modified using a linear congruential formula. (See Donald Knuth, * modified using a linear congruential formula. (See Donald Knuth,
* <i>The Art of Computer Programming, Volume 3</i>, Section 3.2.1.) * <i>The Art of Computer Programming, Volume 2</i>, Section 3.2.1.)
* <p> * <p>
* If two instances of {@code Random} are created with the same * If two instances of {@code Random} are created with the same
* seed, and the same sequence of method calls is made for each, they * seed, and the same sequence of method calls is made for each, they
......
...@@ -60,9 +60,6 @@ public class FileChannelImpl ...@@ -60,9 +60,6 @@ public class FileChannelImpl
// Memory allocation size for mapping buffers // Memory allocation size for mapping buffers
private static final long allocationGranularity; private static final long allocationGranularity;
// Cached field for MappedByteBuffer.isAMappedBuffer
private static final Field isAMappedBufferField;
// File descriptor // File descriptor
private final FileDescriptor fd; private final FileDescriptor fd;
...@@ -1315,8 +1312,6 @@ public class FileChannelImpl ...@@ -1315,8 +1312,6 @@ public class FileChannelImpl
Util.load(); Util.load();
allocationGranularity = initIDs(); allocationGranularity = initIDs();
nd = new FileDispatcher(); nd = new FileDispatcher();
isAMappedBufferField = Reflect.lookupField("java.nio.MappedByteBuffer",
"isAMappedBuffer");
} }
} }
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -74,7 +74,7 @@ public class Config { ...@@ -74,7 +74,7 @@ public class Config {
private String defaultRealm; // default kdc realm. private String defaultRealm; // default kdc realm.
// used for native interface // used for native interface
private static native String getWindowsDirectory(); private static native String getWindowsDirectory(boolean isSystem);
/** /**
...@@ -661,38 +661,37 @@ public class Config { ...@@ -661,38 +661,37 @@ public class Config {
} }
/** /**
* Gets the default configuration file name. The file will be searched * Gets the default configuration file name. This method will never
* in a list of possible loations in the following order: * return null.
* 1. the location and file name defined by system property *
* "java.security.krb5.conf", * If the system property "java.security.krb5.conf" is defined, we'll
* 2. at Java home lib\security directory with "krb5.conf" name, * use its value, no matter if the file exists or not. Otherwise,
* 3. "krb5.ini" at Java home, * the file will be searched in a list of possible loations in the
* 4. at windows directory with the name of "krb5.ini" for Windows, * following order:
* /etc/krb5/krb5.conf for Solaris, /etc/krb5.conf for Linux. *
* 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() { private String getFileName() {
String name = String name =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action. new sun.security.action.
GetPropertyAction("java.security.krb5.conf")); GetPropertyAction("java.security.krb5.conf"));
if (name != null) { if (name == null) {
boolean temp =
java.security.AccessController.doPrivileged(
new FileExistsAction(name));
if (temp)
return name;
} else {
name = java.security.AccessController.doPrivileged( name = java.security.AccessController.doPrivileged(
new sun.security.action. new sun.security.action.
GetPropertyAction("java.home")) + File.separator + GetPropertyAction("java.home")) + File.separator +
"lib" + File.separator + "security" + "lib" + File.separator + "security" +
File.separator + "krb5.conf"; File.separator + "krb5.conf";
boolean temp = if (!fileExists(name)) {
java.security.AccessController.doPrivileged( name = null;
new FileExistsAction(name));
if (temp) {
return name;
} else {
String osname = String osname =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("os.name")); new sun.security.action.GetPropertyAction("os.name"));
...@@ -703,19 +702,35 @@ public class Config { ...@@ -703,19 +702,35 @@ public class Config {
// ignore exceptions // ignore exceptions
} }
if (Credentials.alreadyLoaded) { if (Credentials.alreadyLoaded) {
if ((name = getWindowsDirectory()) == null) { String path = getWindowsDirectory(false);
name = "c:\\winnt\\krb5.ini"; if (path != null) {
} else if (name.endsWith("\\")) { if (path.endsWith("\\")) {
name += "krb5.ini"; path = path + "krb5.ini";
} else { } else {
name += "\\krb5.ini"; path = path + "\\krb5.ini";
}
if (fileExists(path)) {
name = path;
}
} }
if (name == null) {
path = getWindowsDirectory(true);
if (path != null) {
if (path.endsWith("\\")) {
path = path + "krb5.ini";
} else { } else {
path = path + "\\krb5.ini";
}
name = path;
}
}
}
if (name == null) {
name = "c:\\winnt\\krb5.ini"; name = "c:\\winnt\\krb5.ini";
} }
} else if (osname.startsWith("SunOS")) { } else if (osname.startsWith("SunOS")) {
name = "/etc/krb5/krb5.conf"; name = "/etc/krb5/krb5.conf";
} else if (osname.startsWith("Linux")) { } else {
name = "/etc/krb5.conf"; name = "/etc/krb5.conf";
} }
} }
...@@ -1171,6 +1186,11 @@ public class Config { ...@@ -1171,6 +1186,11 @@ public class Config {
return kdcs; return kdcs;
} }
private boolean fileExists(String name) {
return java.security.AccessController.doPrivileged(
new FileExistsAction(name));
}
static class FileExistsAction static class FileExistsAction
implements java.security.PrivilegedAction<Boolean> { implements java.security.PrivilegedAction<Boolean> {
......
...@@ -74,7 +74,6 @@ class Main { ...@@ -74,7 +74,6 @@ class Main {
static final String MANIFEST = JarFile.MANIFEST_NAME; static final String MANIFEST = JarFile.MANIFEST_NAME;
static final String MANIFEST_DIR = "META-INF/"; static final String MANIFEST_DIR = "META-INF/";
static final String VERSION = "1.0"; static final String VERSION = "1.0";
static final char SEPARATOR = File.separatorChar;
static final String INDEX = JarIndex.INDEX_NAME; static final String INDEX = JarIndex.INDEX_NAME;
private static ResourceBundle rsrc; private static ResourceBundle rsrc;
...@@ -227,19 +226,32 @@ class Main { ...@@ -227,19 +226,32 @@ class Main {
} }
tmpFile.delete(); tmpFile.delete();
} }
} else if (xflag || tflag) { } else if (tflag) {
InputStream in; replaceFSC(files);
if (fname != null) { if (fname != null) {
in = new FileInputStream(fname); list(fname, files);
} else {
in = new FileInputStream(FileDescriptor.in);
}
if (xflag) {
extract(new BufferedInputStream(in), files);
} else { } else {
InputStream in = new FileInputStream(FileDescriptor.in);
try{
list(new BufferedInputStream(in), files); list(new BufferedInputStream(in), files);
} finally {
in.close();
} }
}
} else if (xflag) {
replaceFSC(files);
if (fname != null && files != null) {
extract(fname, files);
} else {
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) { } else if (iflag) {
genIndex(rootjar, files); genIndex(rootjar, files);
} }
...@@ -760,6 +772,31 @@ class Main { ...@@ -760,6 +772,31 @@ class Main {
e.setCrc(crc32.getValue()); e.setCrc(crc32.getValue());
} }
void replaceFSC(String files[]) {
if (files != null) {
for (String file : files) {
file = file.replace(File.separatorChar, '/');
}
}
}
Set<ZipEntry> newDirSet() {
return new HashSet<ZipEntry>() {
public boolean add(ZipEntry e) {
return ((e == null || useExtractionTime) ? false : super.add(e));
}};
}
void updateLastModifiedTime(Set<ZipEntry> 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. * Extracts specified entries from JAR file.
*/ */
...@@ -768,19 +805,13 @@ class Main { ...@@ -768,19 +805,13 @@ class Main {
ZipEntry e; ZipEntry e;
// Set of all directory entries specified in archive. Disallows // Set of all directory entries specified in archive. Disallows
// null entries. Disallows all entries if using pre-6.0 behavior. // null entries. Disallows all entries if using pre-6.0 behavior.
Set<ZipEntry> dirs = new HashSet<ZipEntry>() { Set<ZipEntry> dirs = newDirSet();
public boolean add(ZipEntry e) {
return ((e == null || useExtractionTime) ? false : super.add(e));
}};
while ((e = zis.getNextEntry()) != null) { while ((e = zis.getNextEntry()) != null) {
if (files == null) { if (files == null) {
dirs.add(extractFile(zis, e)); dirs.add(extractFile(zis, e));
} else { } else {
String name = e.getName(); String name = e.getName();
for (int i = 0; i < files.length; i++) { for (String file : files) {
String file = files[i].replace(File.separatorChar, '/');
if (name.startsWith(file)) { if (name.startsWith(file)) {
dirs.add(extractFile(zis, e)); dirs.add(extractFile(zis, e));
break; break;
...@@ -793,21 +824,41 @@ class Main { ...@@ -793,21 +824,41 @@ class Main {
// timestamps as given in the archive. We do this after extraction, // timestamps as given in the archive. We do this after extraction,
// instead of during, because creating a file in a directory changes // instead of during, because creating a file in a directory changes
// that directory's timestamp. // that directory's timestamp.
for (ZipEntry dirEntry : dirs) { updateLastModifiedTime(dirs);
long lastModified = dirEntry.getTime(); }
if (lastModified != -1) {
File dir = new File(dirEntry.getName().replace('/', File.separatorChar)); /*
dir.setLastModified(lastModified); * Extracts specified entries from JAR file, via ZipFile.
*/
void extract(String fname, String files[]) throws IOException {
ZipFile zf = new ZipFile(fname);
Set<ZipEntry> dirs = newDirSet();
Enumeration<? extends ZipEntry> 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);
}
/* /*
* Extracts next entry from JAR file, creating directories as needed. If * Extracts next entry from JAR file, creating directories as needed. If
* the entry is for a directory which doesn't exist prior to this * the entry is for a directory which doesn't exist prior to this
* invocation, returns that entry, otherwise returns null. * 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; ZipEntry rc = null;
String name = e.getName(); String name = e.getName();
File f = new File(e.getName().replace('/', File.separatorChar)); File f = new File(e.getName().replace('/', File.separatorChar));
...@@ -838,13 +889,19 @@ class Main { ...@@ -838,13 +889,19 @@ class Main {
} }
} }
OutputStream os = new FileOutputStream(f); OutputStream os = new FileOutputStream(f);
byte[] b = new byte[512]; byte[] b = new byte[8192];
int len; int len;
while ((len = zis.read(b, 0, b.length)) != -1) { try {
while ((len = is.read(b, 0, b.length)) != -1) {
os.write(b, 0, len); os.write(b, 0, len);
} }
zis.closeEntry(); } finally {
if (is instanceof ZipInputStream)
((ZipInputStream)is).closeEntry();
else
is.close();
os.close(); os.close();
}
if (vflag) { if (vflag) {
if (e.getMethod() == ZipEntry.DEFLATED) { if (e.getMethod() == ZipEntry.DEFLATED) {
output(formatMsg("out.inflated", name)); output(formatMsg("out.inflated", name));
...@@ -869,7 +926,6 @@ class Main { ...@@ -869,7 +926,6 @@ class Main {
ZipInputStream zis = new ZipInputStream(in); ZipInputStream zis = new ZipInputStream(in);
ZipEntry e; ZipEntry e;
while ((e = zis.getNextEntry()) != null) { while ((e = zis.getNextEntry()) != null) {
String name = e.getName();
/* /*
* In the case of a compressed (deflated) entry, the entry size * In the case of a compressed (deflated) entry, the entry size
* is stored immediately following the entry data and cannot be * is stored immediately following the entry data and cannot be
...@@ -877,18 +933,20 @@ class Main { ...@@ -877,18 +933,20 @@ class Main {
* the entry first before printing out its attributes. * the entry first before printing out its attributes.
*/ */
zis.closeEntry(); zis.closeEntry();
if (files == null) { printEntry(e, files);
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;
}
} }
} }
/*
* Lists contents of JAR file, via ZipFile.
*/
void list(String fname, String files[]) throws IOException {
ZipFile zf = new ZipFile(fname);
Enumeration<? extends ZipEntry> zes = zf.entries();
while (zes.hasMoreElements()) {
printEntry(zes.nextElement(), files);
} }
zf.close();
} }
/** /**
...@@ -974,13 +1032,29 @@ class Main { ...@@ -974,13 +1032,29 @@ class Main {
dumpIndex(rootjar, index); 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. * Prints entry information.
*/ */
void printEntry(ZipEntry e) throws IOException { void printEntry(ZipEntry e) throws IOException {
if (vflag) { if (vflag) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
String s = Long.toString(e.getSize()); String s = Long.toString(e.getSize());
for (int i = 6 - s.length(); i > 0; --i) { for (int i = 6 - s.length(); i > 0; --i) {
sb.append(' '); sb.append(' ');
......
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* have any questions. * have any questions.
*/ */
#define UNICODE
#include <jni.h> #include <jni.h>
#include <windows.h> #include <windows.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -30,22 +31,20 @@ ...@@ -30,22 +31,20 @@
/* /*
* Class: sun_security_krb5_Config * Class: sun_security_krb5_Config
* Method: getWindowsDirectory * Method: getWindowsDirectory
* Signature: ()Ljava/lang/String; * Signature: (Z)Ljava/lang/String;
*/ */
JNIEXPORT jstring JNICALL Java_sun_security_krb5_Config_getWindowsDirectory( JNIEXPORT jstring JNICALL Java_sun_security_krb5_Config_getWindowsDirectory(
JNIEnv* env, jclass configClass) { JNIEnv* env, jclass configClass, jboolean isSystem) {
LPTSTR lpPath = NULL; TCHAR lpPath[MAX_PATH+1];
UINT uLength ; UINT len;
jstring path = NULL; if (isSystem) {
len = GetSystemWindowsDirectory(lpPath, MAX_PATH);
if (uLength = GetWindowsDirectory(lpPath, 0)) { } else {
lpPath = (LPTSTR)malloc(sizeof(TCHAR) * uLength); len = GetWindowsDirectory(lpPath, MAX_PATH);
if (lpPath != NULL) {
if (GetWindowsDirectory(lpPath, uLength)) {
path = (*env)->NewStringUTF(env, lpPath);
}
free(lpPath);
} }
if (len) {
return (*env)->NewString(env, lpPath, len);
} else {
return NULL;
} }
return path;
} }
...@@ -1054,6 +1054,52 @@ public class Basic$Type$ extends Basic { ...@@ -1054,6 +1054,52 @@ public class Basic$Type$ extends Basic {
test("%4.1f", " 1.0", val); test("%4.1f", " 1.0", val);
test("%4.2f", "0.99", val); test("%4.2f", "0.99", val);
test("%4.3f", "0.990", 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] #end[BigDecimal]
#if[float] #if[float]
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* @summary Unit test for formatter * @summary Unit test for formatter
* @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937 * @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937
* 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122 * 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 * @run shell/timeout=240 Basic.sh
*/ */
......
...@@ -1055,6 +1055,52 @@ public class BasicBigDecimal extends Basic { ...@@ -1055,6 +1055,52 @@ public class BasicBigDecimal extends Basic {
test("%4.2f", "0.99", val); test("%4.2f", "0.99", val);
test("%4.3f", "0.990", 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);
......
...@@ -1503,6 +1503,52 @@ public class BasicBigInteger extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicBigInteger extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicBoolean extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicBoolean extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicBooleanObject extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicBooleanObject extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicByte extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicByte extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicByteObject extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicByteObject extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicChar extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicChar extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicCharObject extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicCharObject extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicDateTime extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicDateTime extends Basic {
......
...@@ -1053,6 +1053,52 @@ public class BasicDouble extends Basic { ...@@ -1053,6 +1053,52 @@ public class BasicDouble extends Basic {
......
...@@ -1053,6 +1053,52 @@ public class BasicDoubleObject extends Basic { ...@@ -1053,6 +1053,52 @@ public class BasicDoubleObject extends Basic {
......
...@@ -1056,6 +1056,52 @@ public class BasicFloat extends Basic { ...@@ -1056,6 +1056,52 @@ public class BasicFloat extends Basic {
//--------------------------------------------------------------------- //---------------------------------------------------------------------
// %f - float // %f - float
......
...@@ -1069,6 +1069,52 @@ public class BasicFloatObject extends Basic { ...@@ -1069,6 +1069,52 @@ public class BasicFloatObject extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicInt extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicInt extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicIntObject extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicIntObject extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicLong extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicLong extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicLongObject extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicLongObject extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicShort extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicShort extends Basic {
......
...@@ -1503,6 +1503,52 @@ public class BasicShortObject extends Basic { ...@@ -1503,6 +1503,52 @@ public class BasicShortObject extends Basic {
......
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
# have any questions. # have any questions.
# #
SPP='sh ../../../../make/java/nio/spp.sh' javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java
gen() { gen() {
# if [ $3 = "true" ] # if [ $3 = "true" ]
# then $SPP -K$1 -Dtype=$1 -DType=$2 -Kprim<Basic-X.java >Basic$2.java # then $SPP -K$1 -Dtype=$1 -DType=$2 -Kprim<Basic-X.java >Basic$2.java
# else $SPP -K$1 -Dtype=$1 -DType=$2 -K$3 <Basic-X.java >Basic$2.java # else $SPP -K$1 -Dtype=$1 -DType=$2 -K$3 <Basic-X.java >Basic$2.java
# fi # fi
$SPP -K$1 -Dtype=$1 -DType=$2 -K$3 -K$4 -K$5 -K$6 <Basic-X.java >Basic$2.java java build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -K$3 -K$4 -K$5 -K$6 <Basic-X.java >Basic$2.java
} }
gen boolean Boolean prim "" "" "" gen boolean Boolean prim "" "" ""
...@@ -54,3 +54,5 @@ gen Double DoubleObject "" fp "" "" ...@@ -54,3 +54,5 @@ gen Double DoubleObject "" fp "" ""
gen BigDecimal BigDecimal "" fp "" "" gen BigDecimal BigDecimal "" fp "" ""
gen Calendar DateTime "" "" "" datetime gen Calendar DateTime "" "" "" datetime
rm -rf build
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册