From fc8ff44aae9884c08b10e332b47a467e2193ea5b Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 2 Jun 2010 17:53:54 -0700 Subject: 6955840: ThreadLocalRandom bug - overriden setSeed(long) method is not invoked for java.util.Random(long) Summary: Allow setSeed only during construction Reviewed-by: dl, dholmes --- .../classes/java/util/concurrent/ThreadLocalRandom.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java index ba83c80a7..c8a67dd65 100644 --- a/src/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/src/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -73,10 +73,10 @@ public class ThreadLocalRandom extends Random { private long rnd; /** - * Initialization flag to permit the first and only allowed call - * to setSeed (inside Random constructor) to succeed. We can't - * allow others since it would cause setting seed in one part of a - * program to unintentionally impact other usages by the thread. + * Initialization flag to permit calls to setSeed to succeed only + * while executing the Random constructor. We can't allow others + * since it would cause setting seed in one part of a program to + * unintentionally impact other usages by the thread. */ boolean initialized; @@ -98,11 +98,10 @@ public class ThreadLocalRandom extends Random { /** * Constructor called only by localRandom.initialValue. - * We rely on the fact that the superclass no-arg constructor - * invokes setSeed exactly once to initialize. */ ThreadLocalRandom() { super(); + initialized = true; } /** @@ -123,7 +122,6 @@ public class ThreadLocalRandom extends Random { public void setSeed(long seed) { if (initialized) throw new UnsupportedOperationException(); - initialized = true; rnd = (seed ^ multiplier) & mask; } -- cgit v1.2.3 From 2caa32f608a974dcf54eb532a757eb33dbb0f972 Mon Sep 17 00:00:00 2001 From: weijun Date: Fri, 4 Jun 2010 19:28:53 +0800 Subject: 6951366: kerberos login failure on win2008 with AD set to win2000 compat mode Reviewed-by: valeriep, xuelei --- .../classes/sun/security/krb5/Credentials.java | 22 ++++++++--- .../classes/sun/security/krb5/EncryptionKey.java | 20 ++++++++++ src/share/classes/sun/security/krb5/KrbAsReq.java | 44 +++++++++++++--------- 3 files changed, 63 insertions(+), 23 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/sun/security/krb5/Credentials.java b/src/share/classes/sun/security/krb5/Credentials.java index 4114efe2c..3ccf0688a 100644 --- a/src/share/classes/sun/security/krb5/Credentials.java +++ b/src/share/classes/sun/security/krb5/Credentials.java @@ -356,6 +356,7 @@ public class Credentials { * @param princ the client principal. This value cannot be null. * @param secretKey the secret key of the client principal.This value * cannot be null. + * @param password if null, caller is using a keytab * @returns the TGT credentials */ public static Credentials acquireTGT(PrincipalName princ, @@ -372,8 +373,18 @@ public class Credentials { "Cannot have null secretKey to do AS-Exchange"); KrbAsRep asRep = null; + + // The etype field to be placed in AS-REQ. If caller is using keytab, + // it must be limited to etypes in keytab. Otherwise, leave it null, + // and KrbAsReq will populate it with all supported etypes. + + int[] eTypes = null; + if (password == null) { + eTypes = EncryptionKey.getETypes(secretKeys); + } + try { - asRep = sendASRequest(princ, secretKeys, null); + asRep = sendASRequest(princ, secretKeys, eTypes, null); } catch (KrbException ke) { if ((ke.returnCode() == Krb5.KDC_ERR_PREAUTH_FAILED) || (ke.returnCode() == Krb5.KDC_ERR_PREAUTH_REQUIRED)) { @@ -396,7 +407,7 @@ public class Credentials { princ.getSalt(), true, error.getEType(), error.getParams()); } - asRep = sendASRequest(princ, secretKeys, ke.getError()); + asRep = sendASRequest(princ, secretKeys, eTypes, ke.getError()); } else { throw ke; } @@ -406,17 +417,18 @@ public class Credentials { /** * Sends the AS-REQ + * @param eTypes not null if caller using keytab */ private static KrbAsRep sendASRequest(PrincipalName princ, - EncryptionKey[] secretKeys, KRBError error) + EncryptionKey[] secretKeys, int[] eTypes, KRBError error) throws KrbException, IOException { // %%% KrbAsReq asReq = null; if (error == null) { - asReq = new KrbAsReq(princ, secretKeys); + asReq = new KrbAsReq(princ, secretKeys, eTypes); } else { - asReq = new KrbAsReq(princ, secretKeys, true, + asReq = new KrbAsReq(princ, secretKeys, eTypes, true, error.getEType(), error.getSalt(), error.getParams()); } diff --git a/src/share/classes/sun/security/krb5/EncryptionKey.java b/src/share/classes/sun/security/krb5/EncryptionKey.java index ac54b14d5..bd599ed65 100644 --- a/src/share/classes/sun/security/krb5/EncryptionKey.java +++ b/src/share/classes/sun/security/krb5/EncryptionKey.java @@ -76,6 +76,26 @@ public class EncryptionKey private static final boolean DEBUG = Krb5.DEBUG; + public static int[] getETypes(EncryptionKey[] keys) { + int len = keys.length; + int[] result = new int[len]; + int count = 0; // Number of elements in result. Might be less than + // len if there are keys having the same etype + loopi: for (int i=0; i 0) { + key = EncryptionKey.findKey(availableETypes[0], keys); + } + } if (DEBUG) { System.out.println("AS-REQ: Add PA_ENC_TIMESTAMP now"); } @@ -376,7 +384,7 @@ public class KrbAsReq extends KrbKdcReq { } if (eTypes == null) { - eTypes = tktETypes; + eTypes = EType.getDefaults("default_tkt_enctypes"); } // check to use addresses in tickets -- cgit v1.2.3 From d52845b4a437d837c316e29711ccf97956f66e79 Mon Sep 17 00:00:00 2001 From: darcy Date: Tue, 8 Jun 2010 18:52:17 -0700 Subject: 6935997: Please add a nested throwable constructor to AssertionError Reviewed-by: martin, forax, wetmore --- src/share/classes/java/lang/AssertionError.java | 19 ++++++++++++++++++- src/share/classes/java/security/Security.java | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/java/lang/AssertionError.java b/src/share/classes/java/lang/AssertionError.java index 75e8cd8f0..8fb577a6e 100644 --- a/src/share/classes/java/lang/AssertionError.java +++ b/src/share/classes/java/lang/AssertionError.java @@ -66,7 +66,7 @@ public class AssertionError extends Error { * defined in The Java Language Specification, Second * Edition, Section 15.18.1.1. *

- * If the specified object is an instance of Throwable, it + * If the specified object is an instance of {@code Throwable}, it * becomes the cause of the newly constructed assertion error. * * @param detailMessage value to be used in constructing detail message @@ -149,4 +149,21 @@ public class AssertionError extends Error { public AssertionError(double detailMessage) { this("" + detailMessage); } + + /** + * Constructs a new {@code AssertionError} with the specified + * detail message and cause. + * + *

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this error's detail message. + * + * @param message the detail message, may be {@code null} + * @param cause the cause, may be {@code null} + * + * @since 1.7 + */ + public AssertionError(String message, Throwable cause) { + super(message, cause); + } } diff --git a/src/share/classes/java/security/Security.java b/src/share/classes/java/security/Security.java index 4aea17e38..81e029b8e 100644 --- a/src/share/classes/java/security/Security.java +++ b/src/share/classes/java/security/Security.java @@ -678,7 +678,7 @@ public final class Security { spiMap.put(type, clazz); return clazz; } catch (ClassNotFoundException e) { - throw (Error)new AssertionError("Spi class not found").initCause(e); + throw new AssertionError("Spi class not found", e); } } -- cgit v1.2.3 From bef12ca7ad696c03f356c706ddb61214f5caf4d3 Mon Sep 17 00:00:00 2001 From: mchung Date: Thu, 10 Jun 2010 14:14:17 -0700 Subject: 6959965: jstat: Add new -classload option to print class loading statistics Summary: Add a new jstat -classload option Reviewed-by: alanb --- src/share/classes/sun/tools/jstat/Arguments.java | 18 +- .../classes/sun/tools/jstat/OptionFinder.java | 17 +- .../classes/sun/tools/jstat/OptionLister.java | 11 +- .../sun/tools/jstat/resources/jstat_options | 8 +- .../jstat/resources/jstat_unsupported_options | 228 +++++++++++++++++++++ 5 files changed, 259 insertions(+), 23 deletions(-) create mode 100644 src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options (limited to 'src/share') diff --git a/src/share/classes/sun/tools/jstat/Arguments.java b/src/share/classes/sun/tools/jstat/Arguments.java index a6453203a..151917559 100644 --- a/src/share/classes/sun/tools/jstat/Arguments.java +++ b/src/share/classes/sun/tools/jstat/Arguments.java @@ -47,6 +47,7 @@ public class Arguments { private static final String JVMSTAT_USERDIR = ".jvmstat"; private static final String OPTIONS_FILENAME = "jstat_options"; + private static final String UNSUPPORTED_OPTIONS_FILENAME = "jstat_unsupported_options"; private static final String ALL_NAMES = "\\w*"; private Comparator comparator; @@ -411,8 +412,8 @@ public class Arguments { return optionFormat; } - public URL[] optionsSources() { - URL[] sources = new URL[2]; + public List optionsSources() { + List sources = new ArrayList(); int i = 0; String filename = OPTIONS_FILENAME; @@ -421,7 +422,7 @@ public class Arguments { String userHome = System.getProperty("user.home"); String userDir = userHome + "/" + JVMSTAT_USERDIR; File home = new File(userDir + "/" + filename); - sources[i++] = home.toURL(); + sources.add(home.toURI().toURL()); } catch (Exception e) { if (debug) { System.err.println(e.getMessage()); @@ -430,8 +431,15 @@ public class Arguments { throw new IllegalArgumentException("Internal Error: Bad URL: " + e.getMessage()); } - sources[i] = this.getClass().getResource("resources/" + filename); - assert sources[i] != null; + URL u = this.getClass().getResource("resources/" + filename); + assert u != null; + sources.add(u); + + if (showUnsupported) { + u = this.getClass().getResource("resources/" + UNSUPPORTED_OPTIONS_FILENAME); + assert u != null; + sources.add(u); + } return sources; } } diff --git a/src/share/classes/sun/tools/jstat/OptionFinder.java b/src/share/classes/sun/tools/jstat/OptionFinder.java index 628bd6c99..6efa5737a 100644 --- a/src/share/classes/sun/tools/jstat/OptionFinder.java +++ b/src/share/classes/sun/tools/jstat/OptionFinder.java @@ -39,9 +39,9 @@ public class OptionFinder { private static final boolean debug = false; - URL[] optionsSources; + List optionsSources; - public OptionFinder(URL[] optionsSources) { + public OptionFinder(List optionsSources) { this.optionsSources = optionsSources; } @@ -59,24 +59,25 @@ public class OptionFinder { return of; } - protected OptionFormat getOptionFormat(String option, URL[] sources) { + protected OptionFormat getOptionFormat(String option, List sources) { OptionFormat of = null; - for (int i = 0; (i < sources.length) && (of == null); i++) { + for (URL u : sources) { try { - URL u = sources[i]; Reader r = new BufferedReader( new InputStreamReader(u.openStream())); of = new Parser(r).parse(option); + if (of != null) + break; } catch (IOException e) { if (debug) { - System.err.println("Error processing " + sources[i] + System.err.println("Error processing " + u + " : " + e.getMessage()); e.printStackTrace(); } } catch (ParserException e) { // Exception in parsing the options file. - System.err.println(sources[i] + ": " + e.getMessage()); - System.err.println("Parsing of " + sources[i] + " aborted"); + System.err.println(u + ": " + e.getMessage()); + System.err.println("Parsing of " + u + " aborted"); } } return of; diff --git a/src/share/classes/sun/tools/jstat/OptionLister.java b/src/share/classes/sun/tools/jstat/OptionLister.java index d274a4082..5ed55647d 100644 --- a/src/share/classes/sun/tools/jstat/OptionLister.java +++ b/src/share/classes/sun/tools/jstat/OptionLister.java @@ -37,9 +37,9 @@ import java.io.*; */ public class OptionLister { private static final boolean debug = false; - private URL[] sources; + private List sources; - public OptionLister(URL[] sources) { + public OptionLister(List sources) { this.sources = sources; } @@ -54,9 +54,8 @@ public class OptionLister { Set options = new TreeSet(c); - for (int i = 0; i < sources.length; i++) { + for (URL u : sources) { try { - URL u = sources[i]; Reader r = new BufferedReader( new InputStreamReader(u.openStream())); Set s = new Parser(r).parseOptions(); @@ -68,8 +67,8 @@ public class OptionLister { } } catch (ParserException e) { // Exception in parsing the options file. - System.err.println(sources[i] + ": " + e.getMessage()); - System.err.println("Parsing of " + sources[i] + " aborted"); + System.err.println(u + ": " + e.getMessage()); + System.err.println("Parsing of " + u + " aborted"); } } diff --git a/src/share/classes/sun/tools/jstat/resources/jstat_options b/src/share/classes/sun/tools/jstat/resources/jstat_options index a32027d4d..f339965e5 100644 --- a/src/share/classes/sun/tools/jstat/resources/jstat_options +++ b/src/share/classes/sun/tools/jstat/resources/jstat_options @@ -37,7 +37,7 @@ option timestamp { option class { column { header "^Loaded^" /* Number of classes loaded */ - data java.cls.loadedClasses + data (java.cls.loadedClasses + java.cls.sharedLoadedClasses) align right scale raw width 5 @@ -45,7 +45,7 @@ option class { } column { header "^Bytes^" /* Accumulated Size of classes loaded */ - data sun.cls.loadedBytes + data (sun.cls.loadedBytes + sun.cls.sharedLoadedBytes) align right scale K width 7 @@ -53,7 +53,7 @@ option class { } column { header "^Unloaded^" /* Number of classes unloaded */ - data java.cls.unloadedClasses + data (java.cls.unloadedClasses + java.cls.sharedUnloadedClasses) align right width 5 scale raw @@ -61,7 +61,7 @@ option class { } column { header "^Bytes^" /* Accumulated size of classes unloaded */ - data sun.cls.unloadedBytes + data (sun.cls.unloadedBytes + sun.cls.sharedUnloadedBytes) align right scale K width 7 diff --git a/src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options b/src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options new file mode 100644 index 000000000..37008e332 --- /dev/null +++ b/src/share/classes/sun/tools/jstat/resources/jstat_unsupported_options @@ -0,0 +1,228 @@ +/* + * 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. + */ + +option classload { + column { + header "^Loaded^" /* Number of classes loaded */ + data (java.cls.loadedClasses + java.cls.sharedLoadedClasses) + align right + scale raw + width 5 + format "0" + } + column { + header "Time^" /* Accumulated time for class loading */ + data sun.cls.time/sun.os.hrt.frequency + scale sec + align right + width 10 + format "0.000" + } + column { + header "^Inited^" /* Number of initialized classes */ + data sun.cls.initializedClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Time^" /* Accumulated time for class initialization */ + data sun.cls.classInitTime.self/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "Shared^" /* Number of system classes loaded from shared archive */ + data java.cls.sharedLoadedClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Kbytes^" /* Accumulated Size of classes loaded */ + data sun.cls.sharedLoadedBytes + align right + scale K + width 7 + format "0.0" + } + column { + header "LoadTime^" /* Accumulated time for loading classes from shared archive */ + data sun.cls.sharedClassLoadTime/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "^SysClass^" /* Number of system classes loaded */ + data java.cls.loadedClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Kbytes^" /* Bytes read from system class files */ + data sun.cls.sysClassBytes + align right + scale K + width 7 + format "0.0" + } + column { + header "LoadTime^" /* Accumulated time for loading non-shared system classes */ + data sun.cls.sysClassLoadTime/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "Lookup^" /* Time spent in looking up/reading of system classes */ + data sun.cls.lookupSysClassTime/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "Parse^" /* Time spent in parsing system classes */ + data sun.cls.parseClassTime.self/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "^Linked^" /* Number of linked classes */ + data sun.cls.linkedClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Time^" /* Accumulated time for class linking */ + data sun.cls.classInitTime.self/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "^Verified^" /* Number of verified classes */ + data sun.cls.verifiedClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Time^" /* Accumulated time for class verification */ + data sun.cls.classVerifyTime.self/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "AppClass^" /* Number of loaded application classes */ + data sun.cls.appClassLoadCount + align right + scale raw + width 5 + format "0" + } + column { + header "Kbytes^" /* Bytes read from app class files */ + data sun.cls.appClassBytes + align right + scale K + width 7 + format "0.0" + } + column { + header "AppCL^" /* Accumulated time for loading app classes */ + data sun.cls.appClassLoadTime/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "^DefineClass^" /* Number of defineClass calls */ + data sun.cls.defineAppClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Time^" /* Accumulated time for defineClass */ + data sun.cls.defineAppClassTime.self/sun.os.hrt.frequency + scale raw + align right + width 10 + format "0.000" + } + column { + header "^FindClass^" /* Number of findClass calls */ + data sun.classloader.findClasses + align right + scale raw + width 5 + format "0" + } + column { + header "Time^" /* Accumulated time for findClass */ + data sun.classloader.findClassTime/1000000000 + scale raw + align right + width 10 + format "0.000" + } + column { + header "Delegation^" /* Parent class loader delegation time */ + data sun.classloader.parentDelegationTime/1000000000 + scale raw + align right + width 10 + format "0.000" + } + column { + header "URLCL Read^" /* Accumulated time for URLClassLoader reading bytes */ + data sun.urlClassLoader.readClassBytesTime/1000000000 + scale raw + align right + width 10 + format "0.000" + } +} + -- cgit v1.2.3 From d6a7aec593d936d3ca9a1227d2ad7d6d9961391e Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 10 Jun 2010 15:54:25 -0700 Subject: 6960394: Stop linking with -lnsl on Linux Summary: Define LIBNSL (like LIBSOCKET), non-empty only on Solaris Reviewed-by: ohair --- src/share/demo/jvmti/hprof/sample.makefile.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/share') diff --git a/src/share/demo/jvmti/hprof/sample.makefile.txt b/src/share/demo/jvmti/hprof/sample.makefile.txt index 4b7499e40..3766a2877 100644 --- a/src/share/demo/jvmti/hprof/sample.makefile.txt +++ b/src/share/demo/jvmti/hprof/sample.makefile.txt @@ -132,7 +132,7 @@ ifeq ($(OSNAME), linux) LIBRARY=lib$(LIBNAME).so LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text # Libraries we are dependent on - LIBRARIES= -lnsl -ldl -lc + LIBRARIES= -ldl -lc # Building a shared library LINK_SHARED=$(LINK.c) -shared -o $@ endif -- cgit v1.2.3 From a355d0e3608ccc6eb01f85734cbddc8afe6345b3 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 10 Jun 2010 15:55:26 -0700 Subject: 6959259: Minor improvements to static Random field caching Summary: Cache fields in locals; small javadoc clarifications Reviewed-by: emcmanus, dholmes, forax, dl --- src/share/classes/java/lang/Math.java | 21 ++++++++++++--------- src/share/classes/java/lang/StrictMath.java | 21 ++++++++++++--------- src/share/classes/java/util/Collections.java | 8 ++++---- 3 files changed, 28 insertions(+), 22 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/java/lang/Math.java b/src/share/classes/java/lang/Math.java index 7ce31265d..455a21f9a 100644 --- a/src/share/classes/java/lang/Math.java +++ b/src/share/classes/java/lang/Math.java @@ -681,9 +681,9 @@ public final class Math { private static Random randomNumberGenerator; - private static synchronized void initRNG() { - if (randomNumberGenerator == null) - randomNumberGenerator = new Random(); + private static synchronized Random initRNG() { + Random rnd = randomNumberGenerator; + return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd; } /** @@ -694,9 +694,11 @@ public final class Math { * *

When this method is first called, it creates a single new * pseudorandom-number generator, exactly as if by the expression - *

{@code new java.util.Random}
This - * new pseudorandom-number generator is used thereafter for all - * calls to this method and is used nowhere else. + * + *
{@code new java.util.Random()}
+ * + * This new pseudorandom-number generator is used thereafter for + * all calls to this method and is used nowhere else. * *

This method is properly synchronized to allow correct use by * more than one thread. However, if many threads need to generate @@ -705,11 +707,12 @@ public final class Math { * * @return a pseudorandom {@code double} greater than or equal * to {@code 0.0} and less than {@code 1.0}. - * @see java.util.Random#nextDouble() + * @see Random#nextDouble() */ public static double random() { - if (randomNumberGenerator == null) initRNG(); - return randomNumberGenerator.nextDouble(); + Random rnd = randomNumberGenerator; + if (rnd == null) rnd = initRNG(); + return rnd.nextDouble(); } /** diff --git a/src/share/classes/java/lang/StrictMath.java b/src/share/classes/java/lang/StrictMath.java index f2f275b5c..916b82ff9 100644 --- a/src/share/classes/java/lang/StrictMath.java +++ b/src/share/classes/java/lang/StrictMath.java @@ -667,9 +667,9 @@ public final class StrictMath { private static Random randomNumberGenerator; - private static synchronized void initRNG() { - if (randomNumberGenerator == null) - randomNumberGenerator = new Random(); + private static synchronized Random initRNG() { + Random rnd = randomNumberGenerator; + return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd; } /** @@ -680,9 +680,11 @@ public final class StrictMath { * *

When this method is first called, it creates a single new * pseudorandom-number generator, exactly as if by the expression - *

{@code new java.util.Random}
This - * new pseudorandom-number generator is used thereafter for all - * calls to this method and is used nowhere else. + * + *
{@code new java.util.Random()}
+ * + * This new pseudorandom-number generator is used thereafter for + * all calls to this method and is used nowhere else. * *

This method is properly synchronized to allow correct use by * more than one thread. However, if many threads need to generate @@ -691,11 +693,12 @@ public final class StrictMath { * * @return a pseudorandom {@code double} greater than or equal * to {@code 0.0} and less than {@code 1.0}. - * @see java.util.Random#nextDouble() + * @see Random#nextDouble() */ public static double random() { - if (randomNumberGenerator == null) initRNG(); - return randomNumberGenerator.nextDouble(); + Random rnd = randomNumberGenerator; + if (rnd == null) rnd = initRNG(); + return rnd.nextDouble(); } /** diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java index 8b20182f7..e4329dc0e 100644 --- a/src/share/classes/java/util/Collections.java +++ b/src/share/classes/java/util/Collections.java @@ -463,10 +463,10 @@ public class Collections { * its list-iterator does not support the set operation. */ public static void shuffle(List list) { - if (r == null) { - r = new Random(); - } - shuffle(list, r); + Random rnd = r; + if (rnd == null) + r = rnd = new Random(); + shuffle(list, rnd); } private static Random r; -- cgit v1.2.3 From 699492ee3ddbf7df63d55e440d49bb13800b2fd9 Mon Sep 17 00:00:00 2001 From: weijun Date: Fri, 11 Jun 2010 11:38:36 +0800 Subject: 6958869: regression: PKIXValidator fails when multiple trust anchors have same dn Reviewed-by: xuelei, wetmore, mullan --- .../sun/security/validator/PKIXValidator.java | 45 +++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/sun/security/validator/PKIXValidator.java b/src/share/classes/sun/security/validator/PKIXValidator.java index 8068a9db8..59daa9eef 100644 --- a/src/share/classes/sun/security/validator/PKIXValidator.java +++ b/src/share/classes/sun/security/validator/PKIXValidator.java @@ -53,7 +53,7 @@ public final class PKIXValidator extends Validator { private int certPathLength = -1; // needed only for the validator - private Map trustedSubjects; + private Map> trustedSubjects; private CertificateFactory factory; private boolean plugin = false; @@ -95,9 +95,17 @@ public final class PKIXValidator extends Validator { if (TRY_VALIDATOR == false) { return; } - trustedSubjects = new HashMap(); + trustedSubjects = new HashMap>(); for (X509Certificate cert : trustedCerts) { - trustedSubjects.put(cert.getSubjectX500Principal(), cert); + X500Principal dn = cert.getSubjectX500Principal(); + List keys; + if (trustedSubjects.containsKey(dn)) { + keys = trustedSubjects.get(dn); + } else { + keys = new ArrayList(); + trustedSubjects.put(dn, keys); + } + keys.add(cert.getPublicKey()); } try { factory = CertificateFactory.getInstance("X.509"); @@ -161,13 +169,21 @@ public final class PKIXValidator extends Validator { // chain is not ordered correctly, call builder instead return doBuild(chain, otherCerts); } - if (trustedSubjects.containsKey(dn) - && trustedSubjects.get(dn).getPublicKey() - .equals(cert.getPublicKey())) { + + // Check if chain[i] is already trusted. It may be inside + // trustedCerts, or has the same dn and public key as a cert + // inside trustedCerts. The latter happens when a CA has + // updated its cert with a stronger signature algorithm in JRE + // but the weak one is still in circulation. + + if (trustedCerts.contains(cert) || // trusted cert + (trustedSubjects.containsKey(dn) && // replacing ... + trustedSubjects.get(dn).contains( // ... weak cert + cert.getPublicKey()))) { if (i == 0) { return new X509Certificate[] {chain[0]}; } - // Remove and call validator + // Remove and call validator on partial chain [0 .. i-1] X509Certificate[] newChain = new X509Certificate[i]; System.arraycopy(chain, 0, newChain, 0, i); return doValidate(newChain); @@ -217,14 +233,17 @@ public final class PKIXValidator extends Validator { return doBuild(chain, otherCerts); } - private boolean isSignatureValid(X509Certificate iss, X509Certificate sub) { + private boolean isSignatureValid(List keys, X509Certificate sub) { if (plugin) { - try { - sub.verify(iss.getPublicKey()); - } catch (Exception ex) { - return false; + for (PublicKey key: keys) { + try { + sub.verify(key); + return true; + } catch (Exception ex) { + continue; + } } - return true; + return false; } return true; // only check if PLUGIN is set } -- cgit v1.2.3 From eede5cf6fdc8315bc68ae8c6dfa9de59a5719239 Mon Sep 17 00:00:00 2001 From: alanb Date: Fri, 11 Jun 2010 14:47:22 +0100 Subject: 6938230: (so) SocketAdaptor.close() does not translate IOException resulting in Error Reviewed-by: chegar --- src/share/classes/sun/nio/ch/ServerSocketAdaptor.java | 6 +----- src/share/classes/sun/nio/ch/SocketAdaptor.java | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java b/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java index c1b3f3bf3..eff83e2bf 100644 --- a/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java +++ b/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java @@ -144,11 +144,7 @@ public class ServerSocketAdaptor // package-private } public void close() throws IOException { - try { - ssc.close(); - } catch (Exception x) { - Net.translateException(x); - } + ssc.close(); } public ServerSocketChannel getChannel() { diff --git a/src/share/classes/sun/nio/ch/SocketAdaptor.java b/src/share/classes/sun/nio/ch/SocketAdaptor.java index 36c8d9f20..583835727 100644 --- a/src/share/classes/sun/nio/ch/SocketAdaptor.java +++ b/src/share/classes/sun/nio/ch/SocketAdaptor.java @@ -404,11 +404,7 @@ public class SocketAdaptor } public void close() throws IOException { - try { - sc.close(); - } catch (Exception x) { - Net.translateToSocketException(x); - } + sc.close(); } public void shutdownInput() throws IOException { -- cgit v1.2.3 From 75398e43f164f1e747154312ae7bbf64dc9ff706 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 12 Jun 2010 01:32:43 +0100 Subject: 6959197: When building with JAVAC_MAX_WARNINGS=true, the build fails in sun/nio/cs due to the use of -Werror Summary: Remove unneeded casts, add generic types and make better use of static data Reviewed-by: sherman --- src/share/classes/sun/io/ByteToCharISO2022.java | 6 ++-- src/share/classes/sun/io/ByteToCharISO2022JP.java | 2 +- .../classes/sun/io/ByteToCharJISAutoDetect.java | 16 ++++------- src/share/classes/sun/io/CharToBytePCK.java | 2 +- src/share/classes/sun/nio/cs/ext/DoubleByte.java | 4 +-- src/share/classes/sun/nio/cs/ext/EUC_JP.java | 16 +++++------ src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java | 30 +++++++++----------- src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java | 33 ++++++++++------------ src/share/classes/sun/nio/cs/ext/EUC_TW.java | 2 +- src/share/classes/sun/nio/cs/ext/GB18030.java | 2 +- src/share/classes/sun/nio/cs/ext/HKSCS.java | 4 +-- src/share/classes/sun/nio/cs/ext/ISO2022.java | 6 ++-- .../classes/sun/nio/cs/ext/JISAutoDetect.java | 4 +-- src/share/classes/sun/nio/cs/ext/PCK.java | 12 ++++---- src/share/classes/sun/nio/cs/ext/SJIS.java | 8 +++--- 15 files changed, 67 insertions(+), 80 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/sun/io/ByteToCharISO2022.java b/src/share/classes/sun/io/ByteToCharISO2022.java index 4b2e21b56..5fef812fd 100644 --- a/src/share/classes/sun/io/ByteToCharISO2022.java +++ b/src/share/classes/sun/io/ByteToCharISO2022.java @@ -124,15 +124,15 @@ public abstract class ByteToCharISO2022 extends ByteToCharConverter switch(shiftFlag) { case SOFlag: tmpIndex = curSODes; - tmpConverter = (ByteToCharConverter [])SOConverter; + tmpConverter = SOConverter; break; case SS2Flag: tmpIndex = curSS2Des; - tmpConverter = (ByteToCharConverter [])SS2Converter; + tmpConverter = SS2Converter; break; case SS3Flag: tmpIndex = curSS3Des; - tmpConverter = (ByteToCharConverter [])SS3Converter; + tmpConverter = SS3Converter; break; } diff --git a/src/share/classes/sun/io/ByteToCharISO2022JP.java b/src/share/classes/sun/io/ByteToCharISO2022JP.java index 8000870fb..03027c247 100644 --- a/src/share/classes/sun/io/ByteToCharISO2022JP.java +++ b/src/share/classes/sun/io/ByteToCharISO2022JP.java @@ -141,7 +141,7 @@ public class ByteToCharISO2022JP extends ByteToCharJIS0208 { } else { savedSize = 2; savedBytes[0] = (byte)byte1; - savedBytes[1] = (byte)input[readOff + inputSize]; + savedBytes[1] = input[readOff + inputSize]; inputSize++; } break; diff --git a/src/share/classes/sun/io/ByteToCharJISAutoDetect.java b/src/share/classes/sun/io/ByteToCharJISAutoDetect.java index 97a0e8828..8f00ef6c2 100644 --- a/src/share/classes/sun/io/ByteToCharJISAutoDetect.java +++ b/src/share/classes/sun/io/ByteToCharJISAutoDetect.java @@ -34,14 +34,12 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter { private final static int SJIS1B_MASK = 0x04; private final static int EUCJP_KANA1_MASK = 0x08; private final static int EUCJP_KANA2_MASK = 0x10; - private static byte[] maskTable1; - private static byte[] maskTable2; + private final static byte[] maskTable1 = JISAutoDetect.getByteMask1(); + private final static byte[] maskTable2 = JISAutoDetect.getByteMask2(); private final static int SS2 = 0x8e; private final static int SS3 = 0x8f; - private final static JISAutoDetect nioCoder = new JISAutoDetect(); - // SJISName is set to either "SJIS" or "MS932" private String SJISName; private String EUCJPName; @@ -57,8 +55,6 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter { defaultConv = new ByteToCharISO8859_1(); defaultConv.subChars = subChars; defaultConv.subMode = subMode; - maskTable1 = nioCoder.getByteMask1(); - maskTable2 = nioCoder.getByteMask2(); } public int flush(char [] output, int outStart, int outEnd) @@ -133,7 +129,7 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter { break; } if ((mask == SJIS2B_MASK) || (mask == SJIS1B_MASK) - || (nioCoder.canBeSJIS1B(firstmask) && secondmask == 0)) { + || (JISAutoDetect.canBeSJIS1B(firstmask) && secondmask == 0)) { convName = SJISName; break; } @@ -145,15 +141,15 @@ public class ByteToCharJISAutoDetect extends ByteToCharConverter { // character boundary. If we tried both // possibilities here, it might be able to be // determined correctly. - if ((byte1 == SS3) && nioCoder.canBeEUCJP(secondmask)) { + if ((byte1 == SS3) && JISAutoDetect.canBeEUCJP(secondmask)) { if (cnt+1 < inEnd) { int nextbyte = input[cnt+1] & 0xff; - if (! nioCoder.canBeEUCJP(maskTable2[nextbyte])) + if (! JISAutoDetect.canBeEUCJP(maskTable2[nextbyte])) convName = SJISName; } else convName = SJISName; } - if (nioCoder.canBeEUCKana(firstmask, secondmask)) + if (JISAutoDetect.canBeEUCKana(firstmask, secondmask)) euckana++; } else { if ((firstmask & SJIS1B_MASK) != 0) { diff --git a/src/share/classes/sun/io/CharToBytePCK.java b/src/share/classes/sun/io/CharToBytePCK.java index 0c877df0e..9a8d1a76c 100644 --- a/src/share/classes/sun/io/CharToBytePCK.java +++ b/src/share/classes/sun/io/CharToBytePCK.java @@ -66,7 +66,7 @@ public class CharToBytePCK extends CharToByteSJIS { switch (ch) { case '\u2015': - return (int)0x815C; + return 0x815C; case '\u2014': return 0; default: diff --git a/src/share/classes/sun/nio/cs/ext/DoubleByte.java b/src/share/classes/sun/nio/cs/ext/DoubleByte.java index f76c9cc7d..265e03c71 100644 --- a/src/share/classes/sun/nio/cs/ext/DoubleByte.java +++ b/src/share/classes/sun/nio/cs/ext/DoubleByte.java @@ -103,7 +103,7 @@ public class DoubleByte { public final static char[] B2C_UNMAPPABLE; static { B2C_UNMAPPABLE = new char[0x100]; - Arrays.fill(B2C_UNMAPPABLE, (char)UNMAPPABLE_DECODING); + Arrays.fill(B2C_UNMAPPABLE, UNMAPPABLE_DECODING); } public static class Decoder extends CharsetDecoder @@ -374,7 +374,7 @@ public class DoubleByte { static final char[] b2cSB; static { b2cSB = new char[0x100]; - Arrays.fill(b2cSB, (char)UNMAPPABLE_DECODING); + Arrays.fill(b2cSB, UNMAPPABLE_DECODING); } Decoder_EBCDIC_DBCSONLY(Charset cs, char[][] b2c, int b2Min, int b2Max) { super(cs, 0.5f, 1.0f, b2c, b2cSB, b2Min, b2Max); diff --git a/src/share/classes/sun/nio/cs/ext/EUC_JP.java b/src/share/classes/sun/nio/cs/ext/EUC_JP.java index 03de24834..6443de399 100644 --- a/src/share/classes/sun/nio/cs/ext/EUC_JP.java +++ b/src/share/classes/sun/nio/cs/ext/EUC_JP.java @@ -79,8 +79,10 @@ public class EUC_JP JIS_X_0201.Decoder decoderJ0201; JIS_X_0212_Decoder decoderJ0212; - short[] j0208Index1; - String[] j0208Index2; + private static final short[] j0208Index1 = + JIS_X_0208_Decoder.getIndex1(); + private static final String[] j0208Index2 = + JIS_X_0208_Decoder.getIndex2(); protected Decoder(Charset cs) { super(cs); @@ -88,8 +90,6 @@ public class EUC_JP decoderJ0212 = new JIS_X_0212_Decoder(cs); start = 0xa1; end = 0xfe; - j0208Index1 = super.getIndex1(); - j0208Index2 = super.getIndex2(); } protected char decode0212(int byte1, int byte2) { return decoderJ0212.decodeDouble(byte1, byte2); @@ -238,8 +238,10 @@ public class EUC_JP JIS_X_0201.Encoder encoderJ0201; JIS_X_0212_Encoder encoderJ0212; - short[] j0208Index1; - String[] j0208Index2; + private static final short[] j0208Index1 = + JIS_X_0208_Encoder.getIndex1(); + private static final String[] j0208Index2 = + JIS_X_0208_Encoder.getIndex2(); private final Surrogate.Parser sgp = new Surrogate.Parser(); @@ -247,8 +249,6 @@ public class EUC_JP super(cs, 3.0f, 3.0f); encoderJ0201 = new JIS_X_0201.Encoder(cs); encoderJ0212 = new JIS_X_0212_Encoder(cs); - j0208Index1 = super.getIndex1(); - j0208Index2 = super.getIndex2(); } public boolean canEncode(char c) { diff --git a/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java b/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java index fbbd30b13..480a4a740 100644 --- a/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java +++ b/src/share/classes/sun/nio/cs/ext/EUC_JP_LINUX.java @@ -65,20 +65,18 @@ public class EUC_JP_LINUX private static class Decoder extends CharsetDecoder { JIS_X_0201.Decoder decoderJ0201; - JIS_X_0208_Decoder decodeMappingJ0208; protected final char REPLACE_CHAR='\uFFFD'; - short[] jis0208Index1; - String[] jis0208Index2; + private static final int start = 0xa1; + private static final int end = 0xfe; + private static final short[] jis0208Index1 = + JIS_X_0208_Decoder.getIndex1(); + private static final String[] jis0208Index2 = + JIS_X_0208_Decoder.getIndex2(); private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); decoderJ0201 = new JIS_X_0201.Decoder(cs); - decodeMappingJ0208 = new JIS_X_0208_Decoder(cs); - decodeMappingJ0208.start = 0xa1; - decodeMappingJ0208.end = 0xfe; - jis0208Index1 = decodeMappingJ0208.getIndex1(); - jis0208Index2 = decodeMappingJ0208.getIndex2(); } protected char convSingleByte(int b) { @@ -93,11 +91,11 @@ public class EUC_JP_LINUX } if (((byte1 < 0) || (byte1 > jis0208Index1.length)) - || ((byte2 < decodeMappingJ0208.start) || (byte2 > decodeMappingJ0208.end))) + || ((byte2 < start) || (byte2 > end))) return REPLACE_CHAR; - int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (decodeMappingJ0208.end - decodeMappingJ0208.start + 1) - + (byte2 - decodeMappingJ0208.start); + int n = (jis0208Index1[byte1 - 0x80] & 0xf) * (end - start + 1) + + (byte2 - start); return jis0208Index2[jis0208Index1[byte1 - 0x80] >> 4].charAt(n); } @@ -213,18 +211,16 @@ public class EUC_JP_LINUX private static class Encoder extends CharsetEncoder { JIS_X_0201.Encoder encoderJ0201; - JIS_X_0208_Encoder encoderJ0208; private final Surrogate.Parser sgp = new Surrogate.Parser(); - short[] jis0208Index1; - String[] jis0208Index2; + private static final short[] jis0208Index1 = + JIS_X_0208_Encoder.getIndex1(); + private static final String[] jis0208Index2 = + JIS_X_0208_Encoder.getIndex2(); private Encoder(Charset cs) { super(cs, 2.0f, 2.0f); encoderJ0201 = new JIS_X_0201.Encoder(cs); - encoderJ0208 = new JIS_X_0208_Encoder(cs); - jis0208Index1 = encoderJ0208.getIndex1(); - jis0208Index2 = encoderJ0208.getIndex2(); } public boolean canEncode(char c) { diff --git a/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java b/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java index 4043dc1ad..b36b76d3c 100644 --- a/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java +++ b/src/share/classes/sun/nio/cs/ext/EUC_JP_Open.java @@ -75,8 +75,12 @@ public class EUC_JP_Open JIS_X_0212_Solaris_Decoder decodeMappingJ0212; JIS_X_0208_Solaris_Decoder decodeMappingJ0208; - short[] j0208Index1; - String[] j0208Index2; + private static final short[] j0208Index1 = + JIS_X_0208_Solaris_Decoder.getIndex1(); + private static final String[] j0208Index2 = + JIS_X_0208_Solaris_Decoder.getIndex2(); + private static final int start = 0xa1; + private static final int end = 0xfe; protected final char REPLACE_CHAR='\uFFFD'; @@ -84,11 +88,6 @@ public class EUC_JP_Open super(cs); decoderJ0201 = new JIS_X_0201.Decoder(cs); decodeMappingJ0212 = new JIS_X_0212_Solaris_Decoder(cs); - decodeMappingJ0208 = new JIS_X_0208_Solaris_Decoder(cs); - decodeMappingJ0208.start = 0xa1; - decodeMappingJ0208.end = 0xfe; - j0208Index1 = decodeMappingJ0208.getIndex1(); - j0208Index2 = decodeMappingJ0208.getIndex2(); } @@ -103,9 +102,9 @@ public class EUC_JP_Open } if (((byte1 < 0) - || (byte1 > decodeMappingJ0208.getIndex1().length)) - || ((byte2 < decodeMappingJ0208.start) - || (byte2 > decodeMappingJ0208.end))) + || (byte1 > j0208Index1.length)) + || ((byte2 < start) + || (byte2 > end))) return REPLACE_CHAR; char result = super.decodeDouble(byte1, byte2); @@ -113,8 +112,8 @@ public class EUC_JP_Open return result; } else { int n = (j0208Index1[byte1 - 0x80] & 0xf) * - (decodeMappingJ0208.end - decodeMappingJ0208.start + 1) - + (byte2 - decodeMappingJ0208.start); + (end - start + 1) + + (byte2 - start); return j0208Index2[j0208Index1[byte1 - 0x80] >> 4].charAt(n); } } @@ -125,10 +124,11 @@ public class EUC_JP_Open JIS_X_0201.Encoder encoderJ0201; JIS_X_0212_Solaris_Encoder encoderJ0212; - JIS_X_0208_Solaris_Encoder encoderJ0208; - short[] j0208Index1; - String[] j0208Index2; + private static final short[] j0208Index1 = + JIS_X_0208_Solaris_Encoder.getIndex1(); + private static final String[] j0208Index2 = + JIS_X_0208_Solaris_Encoder.getIndex2(); private final Surrogate.Parser sgp = new Surrogate.Parser(); @@ -136,9 +136,6 @@ public class EUC_JP_Open super(cs); encoderJ0201 = new JIS_X_0201.Encoder(cs); encoderJ0212 = new JIS_X_0212_Solaris_Encoder(cs); - encoderJ0208 = new JIS_X_0208_Solaris_Encoder(cs); - j0208Index1 = encoderJ0208.getIndex1(); - j0208Index2 = encoderJ0208.getIndex2(); } protected int encodeSingle(char inputChar, byte[] outputByte) { diff --git a/src/share/classes/sun/nio/cs/ext/EUC_TW.java b/src/share/classes/sun/nio/cs/ext/EUC_TW.java index 368b47190..a4ae8df6e 100644 --- a/src/share/classes/sun/nio/cs/ext/EUC_TW.java +++ b/src/share/classes/sun/nio/cs/ext/EUC_TW.java @@ -423,7 +423,7 @@ public class EUC_TW extends Charset implements HistoricallyNamedCharset if (dst.remaining() < outSize) return CoderResult.OVERFLOW; for (int i = 0; i < outSize; i++) - dst.put((byte)bb[i]); + dst.put(bb[i]); mark += inSize; } return CoderResult.UNDERFLOW; diff --git a/src/share/classes/sun/nio/cs/ext/GB18030.java b/src/share/classes/sun/nio/cs/ext/GB18030.java index 20df56007..acbe23a36 100644 --- a/src/share/classes/sun/nio/cs/ext/GB18030.java +++ b/src/share/classes/sun/nio/cs/ext/GB18030.java @@ -12339,7 +12339,7 @@ public class GB18030 int start = 0x40, end = 0xFE; if (((byte1 < 0) || (byte1 > index1.length)) || ((byte2 < start) || (byte2 > end))) - return (char)'\uFFFD'; + return '\uFFFD'; int n = (index1[byte1] & 0xf) * (end - start + 1) + (byte2 - start); return index2[index1[byte1] >> 4].charAt(n); diff --git a/src/share/classes/sun/nio/cs/ext/HKSCS.java b/src/share/classes/sun/nio/cs/ext/HKSCS.java index d2e118e01..69002ee2b 100644 --- a/src/share/classes/sun/nio/cs/ext/HKSCS.java +++ b/src/share/classes/sun/nio/cs/ext/HKSCS.java @@ -43,7 +43,7 @@ public class HKSCS { private char[][] b2cBmp; private char[][] b2cSupp; - private static DoubleByte.Decoder big5Dec; + private DoubleByte.Decoder big5Dec; protected Decoder(Charset cs, DoubleByte.Decoder big5Dec, @@ -355,7 +355,7 @@ public class HKSCS { c2b[hi] = new char[0x100]; Arrays.fill(c2b[hi], (char)UNMAPPABLE_ENCODING); } - c2b[hi][c & 0xff] = (char)bb; + c2b[hi][c & 0xff] = bb; } c++; } diff --git a/src/share/classes/sun/nio/cs/ext/ISO2022.java b/src/share/classes/sun/nio/cs/ext/ISO2022.java index faf803699..ad4e5978b 100644 --- a/src/share/classes/sun/nio/cs/ext/ISO2022.java +++ b/src/share/classes/sun/nio/cs/ext/ISO2022.java @@ -104,15 +104,15 @@ abstract class ISO2022 switch(shiftFlag) { case SOFlag: tmpIndex = curSODes; - tmpDecoder = (CharsetDecoder [])SODecoder; + tmpDecoder = SODecoder; break; case SS2Flag: tmpIndex = curSS2Des; - tmpDecoder = (CharsetDecoder [])SS2Decoder; + tmpDecoder = SS2Decoder; break; case SS3Flag: tmpIndex = curSS3Des; - tmpDecoder = (CharsetDecoder [])SS3Decoder; + tmpDecoder = SS3Decoder; break; } diff --git a/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java b/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java index 78007a02a..e190bd587 100644 --- a/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java +++ b/src/share/classes/sun/nio/cs/ext/JISAutoDetect.java @@ -82,11 +82,11 @@ public class JISAutoDetect * with the sun.io JISAutoDetect implementation */ - public byte[] getByteMask1() { + public static byte[] getByteMask1() { return Decoder.maskTable1; } - public byte[] getByteMask2() { + public static byte[] getByteMask2() { return Decoder.maskTable2; } diff --git a/src/share/classes/sun/nio/cs/ext/PCK.java b/src/share/classes/sun/nio/cs/ext/PCK.java index a11a9dda5..2c2387e00 100644 --- a/src/share/classes/sun/nio/cs/ext/PCK.java +++ b/src/share/classes/sun/nio/cs/ext/PCK.java @@ -101,17 +101,15 @@ public class PCK private static class Encoder extends SJIS.Encoder { private JIS_X_0201.Encoder jis0201; - private JIS_X_0208_Solaris_Encoder jis0208; - short[] j0208Index1; - String[] j0208Index2; + private static final short[] j0208Index1 = + JIS_X_0208_Solaris_Encoder.getIndex1(); + private static final String[] j0208Index2 = + JIS_X_0208_Solaris_Encoder.getIndex2(); private Encoder(Charset cs) { super(cs); jis0201 = new JIS_X_0201.Encoder(cs); - jis0208 = new JIS_X_0208_Solaris_Encoder(cs); - j0208Index1 = jis0208.getIndex1(); - j0208Index2 = jis0208.getIndex2(); } protected int encodeDouble(char ch) { @@ -121,7 +119,7 @@ public class PCK switch (ch) { case '\u2015': - return (int)0x815C; + return 0x815C; case '\u2014': return 0; default: diff --git a/src/share/classes/sun/nio/cs/ext/SJIS.java b/src/share/classes/sun/nio/cs/ext/SJIS.java index 65a03aea1..1f8a8ea0c 100644 --- a/src/share/classes/sun/nio/cs/ext/SJIS.java +++ b/src/share/classes/sun/nio/cs/ext/SJIS.java @@ -114,14 +114,14 @@ public class SJIS private JIS_X_0201.Encoder jis0201; - short[] j0208Index1; - String[] j0208Index2; + private static final short[] j0208Index1 = + JIS_X_0208_Encoder.getIndex1(); + private static final String[] j0208Index2 = + JIS_X_0208_Encoder.getIndex2(); protected Encoder(Charset cs) { super(cs); jis0201 = new JIS_X_0201.Encoder(cs); - j0208Index1 = super.getIndex1(); - j0208Index2 = super.getIndex2(); } protected int encodeSingle(char inputChar) { -- cgit v1.2.3 From a414d6ac06d1809a654093c9a6013428525d2b28 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 11 Jun 2010 18:55:45 -0700 Subject: 6944584: Improvements to subprocess handling on Unix Summary: use thread pool for reaper thread; move most I/O operations out of reaper thread Reviewed-by: michaelm, hiroshi --- src/share/classes/java/lang/ProcessBuilder.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/share') diff --git a/src/share/classes/java/lang/ProcessBuilder.java b/src/share/classes/java/lang/ProcessBuilder.java index 82fad4a2b..97ce45cdf 100644 --- a/src/share/classes/java/lang/ProcessBuilder.java +++ b/src/share/classes/java/lang/ProcessBuilder.java @@ -418,6 +418,8 @@ public final class ProcessBuilder * Implements a null input stream. */ static class NullInputStream extends InputStream { + static final NullInputStream INSTANCE = new NullInputStream(); + private NullInputStream() {} public int read() { return -1; } public int available() { return 0; } } @@ -426,6 +428,8 @@ public final class ProcessBuilder * Implements a null output stream. */ static class NullOutputStream extends OutputStream { + static final NullOutputStream INSTANCE = new NullOutputStream(); + private NullOutputStream() {} public void write(int b) throws IOException { throw new IOException("Stream closed"); } -- cgit v1.2.3 From 1dfd845bc0e2043e698c3ab17dd7ecfb6ee385c7 Mon Sep 17 00:00:00 2001 From: mchung Date: Tue, 15 Jun 2010 09:49:31 -0700 Subject: 6952161: Rebranding: Registration html for servicetag Summary: Rebrand register.html and jdk_header.png Reviewed-by: ohair, asaha, ogino, mfang --- .../com/sun/servicetag/resources/jdk_header.png | Bin 19005 -> 8705 bytes .../com/sun/servicetag/resources/register.html | 24 ++++++++++----------- .../com/sun/servicetag/resources/register_ja.html | 12 +++++------ .../sun/servicetag/resources/register_zh_CN.html | 12 +++++------ 4 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/com/sun/servicetag/resources/jdk_header.png b/src/share/classes/com/sun/servicetag/resources/jdk_header.png index 011cfd4cd..ccfe6dad8 100644 Binary files a/src/share/classes/com/sun/servicetag/resources/jdk_header.png and b/src/share/classes/com/sun/servicetag/resources/jdk_header.png differ diff --git a/src/share/classes/com/sun/servicetag/resources/register.html b/src/share/classes/com/sun/servicetag/resources/register.html index 263d73e8e..98cb71221 100644 --- a/src/share/classes/com/sun/servicetag/resources/register.html +++ b/src/share/classes/com/sun/servicetag/resources/register.html @@ -53,13 +53,13 @@ a:visited,a:visited code{color:#917E9C}   -

Thank you for installing the +

Thank you for installing the Java Development Kit @@JDK_VERSION@@ - from Sun Microsystems.

+ from Oracle Corporation.

Registering your product will give you the following benefits:

  • Notification of new versions, patches, and updates
  • -
  • Special offers on Sun developer products, services and training
  • +
  • Special offers on Oracle developer products, services and training
  • Access to early releases and documentation

Product registration is FREE, quick and easy!

@@ -68,11 +68,11 @@ a:visited,a:visited code{color:#917E9C} - +
-
+
You need to be connected to the Internet to register this Sun product. You need to be connected to the Internet to register this Oracle product.
@@ -81,16 +81,16 @@ a:visited,a:visited code{color:#917E9C}   -

Sun Microsystems, Inc. respects your privacy. - We will use your personal information for communications - and management of your Sun Online Account, the services - and applications you access using your Sun Online Account, +

Oracle Corporation respects your privacy. + We will use your personal information for communications + and management of your Sun Online Account, the services + and applications you access using your Sun Online Account, and the products and systems you register with your Sun Online Account.

-

For more information on the data that will be collected as +

For more information on the data that will be collected as part of the registration process and how it will be managed
- see http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html.
+ see http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html.

- For more information on Sun's Privacy Policy see http://www.sun.com/privacy/ or contact privacy@sun.com.

+ For more information on Oracle's Privacy Policy see http://www.oracle.com/html/privacy.html or contact privacy_ww@oracle.com.

  diff --git a/src/share/classes/com/sun/servicetag/resources/register_ja.html b/src/share/classes/com/sun/servicetag/resources/register_ja.html index 6f82ec255..3169f89fe 100644 --- a/src/share/classes/com/sun/servicetag/resources/register_ja.html +++ b/src/share/classes/com/sun/servicetag/resources/register_ja.html @@ -50,11 +50,11 @@ a:visited,a:visited code{color:#917E9C}   -

Sun Microsystems の Java Development Kit @@JDK_VERSION@@ をインストールしていただき、ありがとうございます。

+

Oracle Corporation の Java Development Kit @@JDK_VERSION@@ をインストールしていただき、ありがとうございます。

製品登録をすると、次のような特典を受けることができます。

  • 最新のバージョン、パッチ、および更新についての通知
  • -
  • Sun の開発者向け製品、サービス、およびトレーニングの特別販売
  • +
  • Oracle の開発者向け製品、サービス、およびトレーニングの特別販売
  • アーリーリリースおよびドキュメントへのアクセス

製品登録は無料であり、迅速で簡単です。

@@ -62,11 +62,11 @@ a:visited,a:visited code{color:#917E9C}

必要になるのは、Sun 開発者向けネットワークアカウントまたはその他の Sun オンラインアカウントだけです。 まだアカウントがない場合は、アカウントの作成が求められます。

- - +
+
この Sun 製品を登録するには、インターネットに接続している必要があります。 この Oracle 製品を登録するには、インターネットに接続している必要があります。
@@ -75,8 +75,8 @@ a:visited,a:visited code{color:#917E9C}   -

Sun Microsystems, Inc. は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Sun オンラインアカウント、お客様が Sun オンラインアカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Sun オンラインアカウントで登録する製品とシステムの通信と管理に使用します。

-

登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、
http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html を参照してください。

Sun のプライバシーポリシーについての詳細は、http://jp.sun.com/privacy/ を参照するか、お問い合わせフォームからお問い合わせください。

+

Oracle Corporation は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Sun オンラインアカウント、お客様が Sun オンラインアカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Sun オンラインアカウントで登録する製品とシステムの通信と管理に使用します。

+

登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、
http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html を参照してください。

Oracle のプライバシーポリシーについての詳細は、http://www.oracle.com/html/lang/jp/privacy.html を参照するか、お問い合わせフォームからお問い合わせください。

  diff --git a/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html b/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html index 744171ec4..9ae39dc19 100644 --- a/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html +++ b/src/share/classes/com/sun/servicetag/resources/register_zh_CN.html @@ -51,11 +51,11 @@ a:visited,a:visited code{color:#917E9C}   -

感谢您安装 Sun Microsystems 的 Java Development Kit @@JDK_VERSION@@

+

感谢您安装 Oracle Corporation 的 Java Development Kit @@JDK_VERSION@@

注册产品后您将获得如下增值服务:

  • 获得新版本、修补程序和更新的通知服务
  • -
  • 获得有关 Sun 开发者产品、服务和培训的优惠
  • +
  • 获得有关 Oracle 开发者产品、服务和培训的优惠
  • 获得对早期版本和文档的访问权限

产品注册是免费的,即快速又轻松!

@@ -63,11 +63,11 @@ a:visited,a:visited code{color:#917E9C}

您需要具有 Sun 开发者网络或其他 Sun 联机帐户。如果您没有,系统将提示您创建一个。

- - +
+
您需要连接到 Internet 来注册此 Sun 产品。 您需要连接到 Internet 来注册此 Oracle 产品。
@@ -76,8 +76,8 @@ a:visited,a:visited code{color:#917E9C}   -

Sun Microsystems, Inc. 尊重您的隐私。我们会将您的个人信息用于通信和 Sun 联机帐户的管理、Sun 联机帐户访问的服务和应用程序以及用于使用 Sun 联机帐户注册的产品和系统。

-

有关注册过程中收集的数据以及这些数据的管理方式的更多信息,
请访问 http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

有关 Sun 隐私政策的更多信息,请访问 http://www.sun.com/privacy/ 或与 privacy@sun.com 联系。

+

Oracle 尊重您的隐私。我们会将您的个人信息用于通信和 Sun 联机帐户的管理、Sun 联机帐户访问的服务和应用程序以及用于使用 Sun 联机帐户注册的产品和系统。

+

有关注册过程中收集的数据以及这些数据的管理方式的更多信息,
请访问 http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

有关 Oracle 隐私政策的更多信息,请访问 http://www.oracle.com/html/privacy.html 或与 privacy_ww@oracle.com 联系。

  -- cgit v1.2.3 From 06d131b426df4a77ca5b01c6cc9759533e9851b4 Mon Sep 17 00:00:00 2001 From: ksrini Date: Wed, 16 Jun 2010 12:36:49 -0700 Subject: 6575373: Error verifying signatures of pack200 files in some cases Reviewed-by: jrose, forax --- src/share/classes/com/sun/java/util/jar/pack/PropMap.java | 6 +++--- src/share/classes/java/util/jar/Pack200.java | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java index c5eb8d75d..6b92236f8 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 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 @@ -90,8 +90,8 @@ class PropMap extends TreeMap { props.put(Utils.PACK_DEFAULT_TIMEZONE, String.valueOf(Boolean.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))); - // Limit segment size to less than a megabyte. - props.put(Pack200.Packer.SEGMENT_LIMIT, ""+(1*1000*1000)); + // The segment size is unlimited + props.put(Pack200.Packer.SEGMENT_LIMIT, ""); // Preserve file ordering by default. props.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.TRUE); diff --git a/src/share/classes/java/util/jar/Pack200.java b/src/share/classes/java/util/jar/Pack200.java index 83a5d2049..1f126f7ba 100644 --- a/src/share/classes/java/util/jar/Pack200.java +++ b/src/share/classes/java/util/jar/Pack200.java @@ -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 @@ -236,9 +236,10 @@ public abstract class Pack200 { * input file to be transmitted in the segment, along with the size * of its name and other transmitted properties. *

- * The default is 1000000 (a million bytes). This allows input JAR files - * of moderate size to be transmitted in one segment. It also puts - * a limit on memory requirements for packers and unpackers. + * The default is -1, which means the packer will always create a single + * segment output file. In cases where extremely large output files are + * generated, users are strongly encouraged to use segmenting or break + * up the input file into smaller JARs. *

* A 10Mb JAR packed without this limit will * typically pack about 10% smaller, but the packer may require -- cgit v1.2.3 From 709c554666ddf2897f8303df174ab7d95a68c182 Mon Sep 17 00:00:00 2001 From: weijun Date: Thu, 17 Jun 2010 13:46:15 +0800 Subject: 6959292: regression: cannot login if session key and preauth does not use the same etype Reviewed-by: xuelei, valeriep --- .../classes/sun/security/krb5/Credentials.java | 22 +++---------- .../classes/sun/security/krb5/EncryptionKey.java | 37 ++-------------------- src/share/classes/sun/security/krb5/KrbAsReq.java | 32 +++++++------------ .../sun/security/krb5/internal/KRBError.java | 26 +++++++++++++++ 4 files changed, 46 insertions(+), 71 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/sun/security/krb5/Credentials.java b/src/share/classes/sun/security/krb5/Credentials.java index 3ccf0688a..4114efe2c 100644 --- a/src/share/classes/sun/security/krb5/Credentials.java +++ b/src/share/classes/sun/security/krb5/Credentials.java @@ -356,7 +356,6 @@ public class Credentials { * @param princ the client principal. This value cannot be null. * @param secretKey the secret key of the client principal.This value * cannot be null. - * @param password if null, caller is using a keytab * @returns the TGT credentials */ public static Credentials acquireTGT(PrincipalName princ, @@ -373,18 +372,8 @@ public class Credentials { "Cannot have null secretKey to do AS-Exchange"); KrbAsRep asRep = null; - - // The etype field to be placed in AS-REQ. If caller is using keytab, - // it must be limited to etypes in keytab. Otherwise, leave it null, - // and KrbAsReq will populate it with all supported etypes. - - int[] eTypes = null; - if (password == null) { - eTypes = EncryptionKey.getETypes(secretKeys); - } - try { - asRep = sendASRequest(princ, secretKeys, eTypes, null); + asRep = sendASRequest(princ, secretKeys, null); } catch (KrbException ke) { if ((ke.returnCode() == Krb5.KDC_ERR_PREAUTH_FAILED) || (ke.returnCode() == Krb5.KDC_ERR_PREAUTH_REQUIRED)) { @@ -407,7 +396,7 @@ public class Credentials { princ.getSalt(), true, error.getEType(), error.getParams()); } - asRep = sendASRequest(princ, secretKeys, eTypes, ke.getError()); + asRep = sendASRequest(princ, secretKeys, ke.getError()); } else { throw ke; } @@ -417,18 +406,17 @@ public class Credentials { /** * Sends the AS-REQ - * @param eTypes not null if caller using keytab */ private static KrbAsRep sendASRequest(PrincipalName princ, - EncryptionKey[] secretKeys, int[] eTypes, KRBError error) + EncryptionKey[] secretKeys, KRBError error) throws KrbException, IOException { // %%% KrbAsReq asReq = null; if (error == null) { - asReq = new KrbAsReq(princ, secretKeys, eTypes); + asReq = new KrbAsReq(princ, secretKeys); } else { - asReq = new KrbAsReq(princ, secretKeys, eTypes, true, + asReq = new KrbAsReq(princ, secretKeys, true, error.getEType(), error.getSalt(), error.getParams()); } diff --git a/src/share/classes/sun/security/krb5/EncryptionKey.java b/src/share/classes/sun/security/krb5/EncryptionKey.java index bd599ed65..ff920af8e 100644 --- a/src/share/classes/sun/security/krb5/EncryptionKey.java +++ b/src/share/classes/sun/security/krb5/EncryptionKey.java @@ -76,26 +76,6 @@ public class EncryptionKey private static final boolean DEBUG = Krb5.DEBUG; - public static int[] getETypes(EncryptionKey[] keys) { - int len = keys.length; - int[] result = new int[len]; - int count = 0; // Number of elements in result. Might be less than - // len if there are keys having the same etype - loopi: for (int i=0; i 0) { - key = EncryptionKey.findKey(availableETypes[0], keys); + if (tktETypes.length > 0) { + key = EncryptionKey.findKey(tktETypes[0], keys); } } if (DEBUG) { @@ -384,7 +376,7 @@ public class KrbAsReq extends KrbKdcReq { } if (eTypes == null) { - eTypes = EType.getDefaults("default_tkt_enctypes"); + eTypes = tktETypes; } // check to use addresses in tickets diff --git a/src/share/classes/sun/security/krb5/internal/KRBError.java b/src/share/classes/sun/security/krb5/internal/KRBError.java index dca82a439..4bf1de79e 100644 --- a/src/share/classes/sun/security/krb5/internal/KRBError.java +++ b/src/share/classes/sun/security/krb5/internal/KRBError.java @@ -286,6 +286,19 @@ public class KRBError implements java.io.Serializable { salt = info.getSalt(); if (DEBUG) { System.out.println("\t PA-ETYPE-INFO etype = " + etype); + System.out.println("\t PA-ETYPE-INFO salt = " + salt); + } + while (der.data.available() > 0) { + value = der.data.getDerValue(); + info = new ETypeInfo(value); + if (DEBUG) { + etype = info.getEType(); + System.out.println("\t salt for " + etype + + " is " + info.getSalt()); + } + if (salt == null || salt.isEmpty()) { + salt = info.getSalt(); + } } } break; @@ -299,6 +312,19 @@ public class KRBError implements java.io.Serializable { s2kparams = info2.getParams(); if (DEBUG) { System.out.println("\t PA-ETYPE-INFO2 etype = " + etype); + System.out.println("\t PA-ETYPE-INFO salt = " + salt); + } + while (der.data.available() > 0) { + value = der.data.getDerValue(); + info2 = new ETypeInfo2(value); + if (DEBUG) { + etype = info2.getEType(); + System.out.println("\t salt for " + etype + + " is " + info2.getSalt()); + } + if (salt == null || salt.isEmpty()) { + salt = info2.getSalt(); + } } } break; -- cgit v1.2.3 From 8a0ea780bec19d8cd7bcf6496037e8922218327f Mon Sep 17 00:00:00 2001 From: alanb Date: Fri, 18 Jun 2010 16:16:51 +0100 Subject: 4981129: (dc) DatagramSocket created by DatagramChannel does not provide sender info Reviewed-by: chegar --- src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java b/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java index da54a3d64..a59488814 100644 --- a/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java +++ b/src/share/classes/sun/nio/ch/DatagramSocketAdaptor.java @@ -171,10 +171,9 @@ public class DatagramSocketAdaptor // Must hold dc.blockingLock() // - private void receive(ByteBuffer bb) throws IOException { + private SocketAddress receive(ByteBuffer bb) throws IOException { if (timeout == 0) { - dc.receive(bb); - return; + return dc.receive(bb); } // Implement timeout with a selector @@ -183,8 +182,9 @@ public class DatagramSocketAdaptor dc.configureBlocking(false); try { int n; - if (dc.receive(bb) != null) - return; + SocketAddress sender; + if ((sender = dc.receive(bb)) != null) + return sender; sel = Util.getTemporarySelector(dc); sk = dc.register(sel, SelectionKey.OP_READ); long to = timeout; @@ -194,8 +194,8 @@ public class DatagramSocketAdaptor long st = System.currentTimeMillis(); int ns = sel.select(to); if (ns > 0 && sk.isReadable()) { - if (dc.receive(bb) != null) - return; + if ((sender = dc.receive(bb)) != null) + return sender; } sel.selectedKeys().remove(sk); to -= System.currentTimeMillis() - st; @@ -222,7 +222,8 @@ public class DatagramSocketAdaptor ByteBuffer bb = ByteBuffer.wrap(p.getData(), p.getOffset(), p.getLength()); - receive(bb); + SocketAddress sender = receive(bb); + p.setSocketAddress(sender); p.setLength(bb.position() - p.getOffset()); } } catch (IOException x) { -- cgit v1.2.3 From 266338b7e510524ebca8fcd80f638224e7d61224 Mon Sep 17 00:00:00 2001 From: ksrini Date: Sat, 19 Jun 2010 17:42:39 -0700 Subject: 6712743: pack200: should default to 150.7 pack format for classfiles without any classes. Reviewed-by: jrose --- .../classes/com/sun/java/util/jar/pack/Constants.java | 7 +++++-- .../classes/com/sun/java/util/jar/pack/Package.java | 17 ++++++++++------- src/share/classes/java/util/jar/Pack200.java | 16 ++++++++++++---- 3 files changed, 27 insertions(+), 13 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/src/share/classes/com/sun/java/util/jar/pack/Constants.java index a9deb0cd8..19ce04cf5 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -47,10 +47,13 @@ interface Constants { public final static short JAVA5_MAX_CLASS_MAJOR_VERSION = 49; public final static short JAVA5_MAX_CLASS_MINOR_VERSION = 0; - // NOTE: ASSUMED for now + public final static short JAVA6_MAX_CLASS_MAJOR_VERSION = 50; public final static short JAVA6_MAX_CLASS_MINOR_VERSION = 0; + public final static short JAVA7_MAX_CLASS_MAJOR_VERSION = 51; + public final static short JAVA7_MAX_CLASS_MINOR_VERSION = 0; + public final static int JAVA_PACKAGE_MAGIC = 0xCAFED00D; public final static int JAVA5_PACKAGE_MAJOR_VERSION = 150; public final static int JAVA5_PACKAGE_MINOR_VERSION = 7; diff --git a/src/share/classes/com/sun/java/util/jar/pack/Package.java b/src/share/classes/com/sun/java/util/jar/pack/Package.java index ad7fdbaa5..1ea04690e 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Package.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -57,8 +57,8 @@ class Package implements Constants { // These fields can be adjusted by driver properties. short min_class_majver = JAVA_MIN_CLASS_MAJOR_VERSION; short min_class_minver = JAVA_MIN_CLASS_MINOR_VERSION; - short max_class_majver = JAVA6_MAX_CLASS_MAJOR_VERSION; - short max_class_minver = JAVA6_MAX_CLASS_MINOR_VERSION; + short max_class_majver = JAVA7_MAX_CLASS_MAJOR_VERSION; + short max_class_minver = JAVA7_MAX_CLASS_MINOR_VERSION; short observed_max_class_majver = min_class_majver; short observed_max_class_minver = min_class_minver; @@ -122,13 +122,16 @@ class Package implements Constants { void choosePackageVersion() { assert(package_majver <= 0); // do not call this twice int classver = getHighestClassVersion(); - if (classver != 0 && - (classver >>> 16) < JAVA6_MAX_CLASS_MAJOR_VERSION) { - // There are only old classfiles in this segment. + if (classver == 0 || (classver >>> 16) < JAVA6_MAX_CLASS_MAJOR_VERSION) { + // There are only old classfiles in this segment or resources package_majver = JAVA5_PACKAGE_MAJOR_VERSION; package_minver = JAVA5_PACKAGE_MINOR_VERSION; + } else if ((classver >>> 16) == JAVA6_MAX_CLASS_MAJOR_VERSION) { + package_majver = JAVA6_PACKAGE_MAJOR_VERSION; + package_minver = JAVA6_PACKAGE_MINOR_VERSION; } else { - // Normal case. Use the newest archive format. + // Normal case. Use the newest archive format, when available + // TODO: replace the following with JAVA7* when the need arises package_majver = JAVA6_PACKAGE_MAJOR_VERSION; package_minver = JAVA6_PACKAGE_MINOR_VERSION; } diff --git a/src/share/classes/java/util/jar/Pack200.java b/src/share/classes/java/util/jar/Pack200.java index 1f126f7ba..41dec9180 100644 --- a/src/share/classes/java/util/jar/Pack200.java +++ b/src/share/classes/java/util/jar/Pack200.java @@ -212,10 +212,18 @@ public abstract class Pack200 { * to produce a specific bytewise image for any given transmission * ordering of archive elements.) *

- * In order to maintain backward compatibility, if the input JAR-files are - * solely comprised of 1.5 (or lesser) classfiles, a 1.5 compatible - * pack file is produced. Otherwise a 1.6 compatible pack200 file is - * produced. + * In order to maintain backward compatibility, the pack file's version is + * set to accommodate the class files present in the input JAR file. In + * other words, the pack file version will be the latest, if the class files + * are the latest and conversely the pack file version will be the oldest + * if the class file versions are also the oldest. For intermediate class + * file versions the corresponding pack file version will be used. + * For example: + * If the input JAR-files are solely comprised of 1.5 (or lesser) + * class files, a 1.5 compatible pack file is produced. This will also be + * the case for archives that have no class files. + * If the input JAR-files contains a 1.6 class file, then the pack file + * version will be set to 1.6. *

* @since 1.5 */ -- cgit v1.2.3 From a2af7653968d0efee9a602f614a3441ce15acea1 Mon Sep 17 00:00:00 2001 From: mchung Date: Sun, 20 Jun 2010 19:56:42 -0700 Subject: 6962478: Privacy page referenced in register_ja.html is incorrect Summary: Fix the URL for the privacy page Reviewed-by: ogino --- src/share/classes/com/sun/servicetag/resources/register_ja.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/share') diff --git a/src/share/classes/com/sun/servicetag/resources/register_ja.html b/src/share/classes/com/sun/servicetag/resources/register_ja.html index bc97cab9f..3da70723e 100644 --- a/src/share/classes/com/sun/servicetag/resources/register_ja.html +++ b/src/share/classes/com/sun/servicetag/resources/register_ja.html @@ -76,7 +76,7 @@ a:visited,a:visited code{color:#917E9C}  

Oracle Corporation は、お客様のプライバシーを尊重します。 お客様の個人情報は、お客様の Sun オンラインアカウント、お客様が Sun オンラインアカウントを使用してアクセスするサービスとアプリケーション、およびお客様が Sun オンラインアカウントで登録する製品とシステムの通信と管理に使用します。

-

登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、
http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html を参照してください。

Oracle のプライバシーポリシーについての詳細は、http://www.oracle.com/html/lang/jp/privacy.html を参照するか、お問い合わせフォームからお問い合わせください。

+

登録の際に収集されるデータや、それらがどのように管理されるかについての詳細は、
http://java.sun.com/javase/ja/registration/JDKRegistrationPrivacy.html を参照してください。

Oracle のプライバシーポリシーについての詳細は、http://www.oracle.com/html/privacy.html を参照するか、お問い合わせフォームからお問い合わせください。

  -- cgit v1.2.3 From 005b672c17171b2e3d5763bc82eb4d91b752e724 Mon Sep 17 00:00:00 2001 From: mchung Date: Mon, 21 Jun 2010 15:02:47 -0700 Subject: 6962815: support enable and disable of the servicetag's system registry for testing purpose Summary: Allow the system registry to be disabled/enabled at runtime Reviewed-by: ksrini --- src/share/classes/com/sun/servicetag/Registry.java | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/share') diff --git a/src/share/classes/com/sun/servicetag/Registry.java b/src/share/classes/com/sun/servicetag/Registry.java index 68386ce67..14ad2fd62 100644 --- a/src/share/classes/com/sun/servicetag/Registry.java +++ b/src/share/classes/com/sun/servicetag/Registry.java @@ -67,7 +67,6 @@ public class Registry { // The stclient output has to be an exported interface private static final String INSTANCE_URN_DESC = "Product instance URN="; private static boolean initialized = false; - private static boolean supportsHelperClass = true; // default private static File stclient = null; private static String stclientPath = null; private static Registry registry = new Registry(); @@ -81,17 +80,6 @@ public class Registry { private synchronized static String getSTclient() { if (!initialized) { - // the system property always overrides the default setting - if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) { - supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED); - } - - // This is only used for testing - stclientPath = System.getProperty(SVCTAG_STCLIENT_CMD); - if (stclientPath != null) { - return stclientPath; - } - // Initialization to determine the platform's stclient pathname String os = System.getProperty("os.name"); if (os.equals("SunOS")) { @@ -108,10 +96,26 @@ public class Registry { initialized = true; } + boolean supportsHelperClass = true; // default + if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) { + // the system property always overrides the default setting + supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED); + } + + if (!supportsHelperClass) { + // disable system registry + return null; + } + + // This is only used for testing + String path = System.getProperty(SVCTAG_STCLIENT_CMD); + if (path != null) { + return path; + } + // com.sun.servicetag package has to be compiled with JDK 5 as well // JDK 5 doesn't support the File.canExecute() method. // Risk not checking isExecute() for the stclient command is very low. - if (stclientPath == null && stclient != null && stclient.exists()) { stclientPath = stclient.getAbsolutePath(); } @@ -142,8 +146,8 @@ public class Registry { * @return {@code true} if the {@code Registry} class is supported; * otherwise, return {@code false}. */ - public static boolean isSupported() { - return (getSTclient() != null && supportsHelperClass); + public static synchronized boolean isSupported() { + return getSTclient() != null; } private static List getCommandList() { -- cgit v1.2.3