diff --git a/make/com/oracle/security/ucrypto/Makefile b/make/com/oracle/security/ucrypto/Makefile index 8ea7a749a7bb6b4d97fb961fc60dffe32ecfe277..f6545e89828c2bc0c715476614373877a02c83f7 100644 --- a/make/com/oracle/security/ucrypto/Makefile +++ b/make/com/oracle/security/ucrypto/Makefile @@ -139,7 +139,7 @@ ifndef OPENJDK # CLASSDESTDIR = $(TEMPDIR)/classes JAVAHFLAGS = -bootclasspath \ - "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Library.gmk diff --git a/make/common/shared/Defs-java.gmk b/make/common/shared/Defs-java.gmk index 5002c28198ae855ccf7cac773f09fbcf4036f8c1..eb50e475e4816503c3cd42924316962f7aa029b7 100644 --- a/make/common/shared/Defs-java.gmk +++ b/make/common/shared/Defs-java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, 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 @@ -139,7 +139,7 @@ JAVACFLAGS += $(JAVAC_LINT_OPTIONS) # built implicitly/explicitly. # ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),) - JCEFLAGS = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar + JCE_PATH = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar endif # Add the source level @@ -152,11 +152,11 @@ TARGET_CLASS_VERSION = 7 CLASS_VERSION = -target $(TARGET_CLASS_VERSION) JAVACFLAGS += $(CLASS_VERSION) JAVACFLAGS += -encoding ascii -JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCEFLAGS)" +JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCE_PATH)" JAVACFLAGS += $(OTHER_JAVACFLAGS) # Needed for javah -JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCEFLAGS)" +JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCE_PATH)" # Needed for javadoc to ensure it builds documentation # against the newly built classes diff --git a/make/sun/security/ec/Makefile b/make/sun/security/ec/Makefile index 841fc3716d2af1b7acae0c66a5d2ca12bd3783a6..0e92dd59cfff5934f4d81bbe625f8fc86634f292 100644 --- a/make/sun/security/ec/Makefile +++ b/make/sun/security/ec/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2012, 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 @@ -160,7 +160,7 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true) $(PKGDIR)/ECKeyPairGenerator.java JAVAHFLAGS = -bootclasspath \ - "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" # diff --git a/make/sun/security/mscapi/Makefile b/make/sun/security/mscapi/Makefile index 65eef7826547446663b3cc376e0d4566cd730874..1cd6024a9c4cbe7387ec4c4e7424761fe1e04cae 100644 --- a/make/sun/security/mscapi/Makefile +++ b/make/sun/security/mscapi/Makefile @@ -150,7 +150,7 @@ OTHER_INCLUDES += \ # CLASSDESTDIR = $(TEMPDIR)/classes JAVAHFLAGS = -bootclasspath \ - "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" include $(BUILDDIR)/common/Mapfile-vers.gmk diff --git a/make/sun/security/pkcs11/Makefile b/make/sun/security/pkcs11/Makefile index d7e049d9e1fd1543620b20cf14e46d14ec7e6538..ecdba0997daab04ab4586ccdeb33cf087c802a5b 100644 --- a/make/sun/security/pkcs11/Makefile +++ b/make/sun/security/pkcs11/Makefile @@ -151,7 +151,7 @@ OTHER_INCLUDES += \ # CLASSDESTDIR = $(TEMPDIR)/classes JAVAHFLAGS = -bootclasspath \ - "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" include $(BUILDDIR)/common/Mapfile-vers.gmk diff --git a/makefiles/com/oracle/security/ucrypto/Makefile b/makefiles/com/oracle/security/ucrypto/Makefile index 8ea7a749a7bb6b4d97fb961fc60dffe32ecfe277..f6545e89828c2bc0c715476614373877a02c83f7 100644 --- a/makefiles/com/oracle/security/ucrypto/Makefile +++ b/makefiles/com/oracle/security/ucrypto/Makefile @@ -139,7 +139,7 @@ ifndef OPENJDK # CLASSDESTDIR = $(TEMPDIR)/classes JAVAHFLAGS = -bootclasspath \ - "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Library.gmk diff --git a/makefiles/common/shared/Defs-java.gmk b/makefiles/common/shared/Defs-java.gmk index 4422ca312b0c9ddb293c1d1dc0d69668b89f9ccb..897b24d77a343efa9bf6dc527ebadd1517ba8bf3 100644 --- a/makefiles/common/shared/Defs-java.gmk +++ b/makefiles/common/shared/Defs-java.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, 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 @@ -141,7 +141,7 @@ JAVACFLAGS += $(JAVAC_LINT_OPTIONS) # built implicitly/explicitly. # ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),) - JCEFLAGS = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar + JCE_PATH = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar endif # Add the source level @@ -154,11 +154,11 @@ TARGET_CLASS_VERSION = 7 CLASS_VERSION = -target $(TARGET_CLASS_VERSION) JAVACFLAGS += $(CLASS_VERSION) JAVACFLAGS += -encoding ascii -JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCEFLAGS)" +JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCE_PATH)" JAVACFLAGS += $(OTHER_JAVACFLAGS) # Needed for javah -JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCEFLAGS)" +JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCE_PATH)" # Needed for javadoc to ensure it builds documentation # against the newly built classes diff --git a/makefiles/sun/security/ec/Makefile b/makefiles/sun/security/ec/Makefile index 146a24e7a9b1e5306a267145aef3c9ef813a2970..d09dbecf629505bdd9e16ed803bd694c1ef404d4 100644 --- a/makefiles/sun/security/ec/Makefile +++ b/makefiles/sun/security/ec/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2012, 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 @@ -159,7 +159,8 @@ ifeq ($(NATIVE_ECC_AVAILABLE), true) $(PKGDIR)/ECDSASignature.java \ $(PKGDIR)/ECKeyPairGenerator.java - JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR) + JAVAHFLAGS = -bootclasspath \ + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" # # C and C++ files diff --git a/makefiles/sun/security/mscapi/Makefile b/makefiles/sun/security/mscapi/Makefile index 389d5a1a01644bcfbcdf125e3afb5c1b1accca00..1cd6024a9c4cbe7387ec4c4e7424761fe1e04cae 100644 --- a/makefiles/sun/security/mscapi/Makefile +++ b/makefiles/sun/security/mscapi/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2012, 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 @@ -149,7 +149,8 @@ OTHER_INCLUDES += \ # Rules # CLASSDESTDIR = $(TEMPDIR)/classes -JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR) +JAVAHFLAGS = -bootclasspath \ + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" include $(BUILDDIR)/common/Mapfile-vers.gmk diff --git a/makefiles/sun/security/pkcs11/Makefile b/makefiles/sun/security/pkcs11/Makefile index 7f9c1c755742fd535abf6c9a28c0212b1545bc80..b94a6dbc109b3173aa320b66baec4d878a0f2ec0 100644 --- a/makefiles/sun/security/pkcs11/Makefile +++ b/makefiles/sun/security/pkcs11/Makefile @@ -150,7 +150,8 @@ OTHER_INCLUDES += \ # Rules # CLASSDESTDIR = $(TEMPDIR)/classes -JAVAHFLAGS = -bootclasspath "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)" +JAVAHFLAGS = -bootclasspath \ + "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)" include $(BUILDDIR)/common/Mapfile-vers.gmk diff --git a/src/share/classes/java/util/prefs/AbstractPreferences.java b/src/share/classes/java/util/prefs/AbstractPreferences.java index f4a7e5e0a398eca6704d716669f7b6a15b889d72..5ba264e5354521fb9302b0582f9aed94f02411be 100644 --- a/src/share/classes/java/util/prefs/AbstractPreferences.java +++ b/src/share/classes/java/util/prefs/AbstractPreferences.java @@ -305,8 +305,10 @@ public abstract class AbstractPreferences extends Preferences { * @param key key whose mapping is to be removed from the preference node. * @throws IllegalStateException if this node (or an ancestor) has been * removed with the {@link #removeNode()} method. + * @throws NullPointerException {@inheritDoc}. */ public void remove(String key) { + Objects.requireNonNull(key, "Specified key cannot be null"); synchronized(lock) { if (removed) throw new IllegalStateException("Node has been removed."); diff --git a/src/share/classes/sun/nio/ch/SocketChannelImpl.java b/src/share/classes/sun/nio/ch/SocketChannelImpl.java index fe2c5fe33ac02a815c21aa0b3ab9194adc5eefd0..f0f7255161411d7c10b48a667cc0ee6058724806 100644 --- a/src/share/classes/sun/nio/ch/SocketChannelImpl.java +++ b/src/share/classes/sun/nio/ch/SocketChannelImpl.java @@ -629,17 +629,6 @@ class SocketChannelImpl break; } - synchronized (stateLock) { - if (isOpen() && (localAddress == null) || - ((InetSocketAddress)localAddress) - .getAddress().isAnyLocalAddress()) - { - // Socket was not bound before connecting or - // Socket was bound with an "anyLocalAddress" - localAddress = Net.localAddress(fd); - } - } - } finally { readerCleanup(); end((n > 0) || (n == IOStatus.UNAVAILABLE)); @@ -659,6 +648,8 @@ class SocketChannelImpl // Connection succeeded; disallow further // invocation state = ST_CONNECTED; + if (isOpen()) + localAddress = Net.localAddress(fd); return true; } // If nonblocking and no exception then connection @@ -747,6 +738,8 @@ class SocketChannelImpl if (n > 0) { synchronized (stateLock) { state = ST_CONNECTED; + if (isOpen()) + localAddress = Net.localAddress(fd); } return true; } diff --git a/src/share/classes/sun/security/provider/SecureRandom.java b/src/share/classes/sun/security/provider/SecureRandom.java index aee8846ed144613e3442359c59dc395e5b9b3878..e79e9d7f49aac666ede4ed887ff703cfc1d548da 100644 --- a/src/share/classes/sun/security/provider/SecureRandom.java +++ b/src/share/classes/sun/security/provider/SecureRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2012, 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 @@ -102,7 +102,7 @@ implements java.io.Serializable { try { digest = MessageDigest.getInstance ("SHA"); } catch (NoSuchAlgorithmException e) { - throw new InternalError("internal error: SHA-1 not available."); + throw new InternalError("internal error: SHA-1 not available.", e); } if (seed != null) { diff --git a/src/share/demo/management/MemoryMonitor/README.txt b/src/share/demo/management/MemoryMonitor/README.txt index 9b264c7f18c0c8b0bfff0f118ae183459f794ae3..2009e1339e2cac5b32601a9a6cfd0da9724ce265 100644 --- a/src/share/demo/management/MemoryMonitor/README.txt +++ b/src/share/demo/management/MemoryMonitor/README.txt @@ -38,7 +38,7 @@ and plots the memory usage history graph. To run the MemoryMonitor demo - java -jar /demo/management/MemoryMonitor.jar + java -jar /demo/management/MemoryMonitor/MemoryMonitor.jar These instructions assume that this installation's version of the java command is in your path. If it isn't, then you should either diff --git a/src/share/native/com/sun/java/util/jar/pack/jni.cpp b/src/share/native/com/sun/java/util/jar/pack/jni.cpp index e77e99f33c50ad3a1164e7ff075943b5094e0060..bedecda53913702f1078708f29944eb8720e0f21 100644 --- a/src/share/native/com/sun/java/util/jar/pack/jni.cpp +++ b/src/share/native/com/sun/java/util/jar/pack/jni.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, 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 @@ -82,7 +82,11 @@ static unpacker* get_unpacker(JNIEnv *env, jobject pObj, bool noCreate=false) { static unpacker* get_unpacker() { //fprintf(stderr, "get_unpacker()\n"); JavaVM* vm = null; - JNI_GetCreatedJavaVMs(&vm, 1, null); + jsize nVM = 0; + jint retval = JNI_GetCreatedJavaVMs(&vm, 1, &nVM); + // other VM implements may differ, thus for correctness, we need these checks + if (retval != JNI_OK || nVM != 1) + return null; void* envRaw = null; vm->GetEnv(&envRaw, JNI_VERSION_1_1); JNIEnv* env = (JNIEnv*) envRaw; diff --git a/test/java/util/prefs/RemoveNullKeyCheck.java b/test/java/util/prefs/RemoveNullKeyCheck.java index e45459b44950533f55062372e9be99bd72a52b72..c74f0d82d37ea129a40f474be5609e444d1978b1 100644 --- a/test/java/util/prefs/RemoveNullKeyCheck.java +++ b/test/java/util/prefs/RemoveNullKeyCheck.java @@ -22,23 +22,77 @@ */ /* @test - * @bug 7160242 + * @bug 7160242 7165118 * @summary Check if NullPointerException is thrown if the key passed * to remove() is null. */ import java.util.prefs.Preferences; +import java.util.prefs.AbstractPreferences; +import java.util.prefs.BackingStoreException; public class RemoveNullKeyCheck { + private static boolean failed = false; + public static void main(String[] args) throws Exception { - try { - Preferences node = Preferences.userRoot().node("N1"); - node.remove(null); - throw new RuntimeException("Expected NullPointerException " + - "not thrown"); - } catch (NullPointerException npe) { - System.out.println("NullPointerException thrown"); - } + checkPreferencesRemove(); + checkAbstractPreferencesRemove(); + if (failed) { + throw new RuntimeException("Expected NullPointerException " + + "not thrown"); + } + } + + public static void checkPreferencesRemove() { + try { + Preferences node = Preferences.userRoot().node("N1"); + node.remove(null); + failed = true; + } catch (NullPointerException npe) { + } + } + + public static void checkAbstractPreferencesRemove() { + + Preferences abstrPrefs = new AbstractPreferences(null, "") { + @Override + protected void putSpi(String key, String value) { + } + @Override + protected String getSpi(String key) { + return null; + } + @Override + protected void removeSpi(String key) { + } + @Override + protected void removeNodeSpi() throws BackingStoreException { + } + @Override + protected String[] keysSpi() throws BackingStoreException { + return new String[0]; + } + @Override + protected String[] childrenNamesSpi() throws BackingStoreException { + return new String[0]; + } + @Override + protected AbstractPreferences childSpi(String name) { + return null; + } + @Override + protected void syncSpi() throws BackingStoreException { + } + @Override + protected void flushSpi() throws BackingStoreException { + } + }; + + try { + abstrPrefs.remove(null); + failed = true; + } catch(NullPointerException npe) { + } } }