提交 7d9c5d37 编写于 作者: A asaha

Merge

# #
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2003, 2011, Oracle and/or its affiliates. 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
...@@ -56,10 +56,6 @@ build: unpacker ...@@ -56,10 +56,6 @@ build: unpacker
vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR) vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)
ifeq ($(STANDALONE),true) ifeq ($(STANDALONE),true)
ZIPOBJDIR = $(OUTPUTDIR)/tmp/sun/java.util.zip/zip/$(OBJDIRNAME) ZIPOBJDIR = $(OUTPUTDIR)/tmp/sun/java.util.zip/zip/$(OBJDIRNAME)
...@@ -131,8 +127,9 @@ prop: ...@@ -131,8 +127,9 @@ prop:
pack200-tool: pack200-tool:
$(call make-launcher, pack200, com.sun.java.util.jar.pack.Driver, , --pack) $(call make-launcher, pack200, com.sun.java.util.jar.pack.Driver, , --pack)
# ignore mapfile for non-product binary
unpacker: unpacker:
$(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_OPT= LDMAPFLAGS_DBG= $(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_DBG=
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
IMVERSIONVALUE=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER) IMVERSIONVALUE=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
...@@ -147,8 +144,14 @@ winres:: ...@@ -147,8 +144,14 @@ winres::
$(ECHO) "Resource files not required for Unix" $(ECHO) "Resource files not required for Unix"
endif endif
# Mapfile-vers.gmk, does not copy over the mapfile-vers-unpack200, when
# the make utiliy is re-invoked, as in this case. In order to workaround
# this special case, the mapfile required for the unpack200 command, is
# explicitly copied over to the expected location.
$(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres $(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
$(prep-target) $(prep-target)
$(RM) $(TEMPDIR)/mapfile-vers
$(CP) mapfile-vers-unpack200 $(TEMPDIR)/mapfile-vers
$(LINKER) $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX) $(LINKER) $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
ifdef MT ifdef MT
$(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1 $(MT) /manifest $(OBJDIR)/unpack200$(EXE_SUFFIX).manifest /outputresource:$(TEMPDIR)/unpack200$(EXE_SUFFIX);#1
......
#
# Copyright (c) 2011, 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.
#
# Define library interface.
SUNWprivate_1.1 {
local:
*;
};
...@@ -76,7 +76,6 @@ endif ...@@ -76,7 +76,6 @@ endif
endif # PLATFORM endif # PLATFORM
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
ifeq ($(VARIANT), OPT) ifeq ($(VARIANT), OPT)
......
# #
# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1995, 2011, Oracle and/or its affiliates. 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
...@@ -55,6 +55,11 @@ program_default_rule: all ...@@ -55,6 +55,11 @@ program_default_rule: all
program: $(ACTUAL_PROGRAM) program: $(ACTUAL_PROGRAM)
# reuse the mapfiles in the launcher's directory, the same should
# be applicable to the tool launchers as well.
FILES_m = $(BUILDDIR)/java/main/java/mapfile-$(ARCH)
include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(JDK_TOPDIR)/make/common/Rules.gmk include $(JDK_TOPDIR)/make/common/Rules.gmk
ifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE ifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE
......
...@@ -198,10 +198,12 @@ INSTALL_DOT_LIB = true ...@@ -198,10 +198,12 @@ INSTALL_DOT_LIB = true
# #
# What to link? # What to link?
# On Windows, shell32 is not normally required and so it is delay loaded.
# #
ifeq ($(PLATFORM),windows) ifeq ($(PLATFORM),windows)
OTHER_LDLIBS += $(JVMLIB) -libpath:$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) fdlibm.lib \ OTHER_LDLIBS += $(JVMLIB) -libpath:$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) fdlibm.lib \
-libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib -libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \
shell32.lib delayimp.lib /DELAYLOAD:shell32.dll
else else
OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \ OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH) -L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
......
# #
# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1996, 2011, Oracle and/or its affiliates. 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
...@@ -61,5 +61,4 @@ OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' ...@@ -61,5 +61,4 @@ OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
LDFLAGS += -R$(OPENWIN_LIB) LDFLAGS += -R$(OPENWIN_LIB)
LDFLAGS += -M mapfile-$(ARCH)
endif endif
# #
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# interested in declaring a version, simply scoping the file is sufficient. # interested in declaring a version, simply scoping the file is sufficient.
# #
{ SUNWprivate_1.1 {
global: global:
main; # Provides basic adb symbol offsets main; # Provides basic adb symbol offsets
environ; # Public symbols and required by Java run time environ; # Public symbols and required by Java run time
......
# #
# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
# interested in declaring a version, simply scoping the file is sufficient. # interested in declaring a version, simply scoping the file is sufficient.
# #
{ SUNWprivate_1.1 {
global: global:
main; # Provides basic adb symbol offsets main; # Provides basic adb symbol offsets
environ; # Public symbols and required by Java run time environ; # Public symbols and required by Java run time
......
# #
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# interested in declaring a version, simply scoping the file is sufficient. # interested in declaring a version, simply scoping the file is sufficient.
# #
{ SUNWprivate_1.1 {
global: global:
main; # Provides basic adb symbol offsets main; # Provides basic adb symbol offsets
environ; # Public symbols and required by Java run time environ; # Public symbols and required by Java run time
......
# #
# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
# interested in declaring a version, simply scoping the file is sufficient. # interested in declaring a version, simply scoping the file is sufficient.
# #
{ SUNWprivate_1.1 {
global: global:
main; # Provides basic adb symbol offsets main; # Provides basic adb symbol offsets
environ; # Public symbols and required by Java run time environ; # Public symbols and required by Java run time
......
...@@ -86,7 +86,8 @@ OTHER_INCLUDES += \ ...@@ -86,7 +86,8 @@ OTHER_INCLUDES += \
-I$(SHARE_SRC)/native/sun/management -I$(SHARE_SRC)/native/sun/management
ifeq ($(PLATFORM),windows) ifeq ($(PLATFORM),windows)
OTHER_LDLIBS += $(JVMLIB) # Need process status helper API (psapi) on Windows
OTHER_LDLIBS += $(JVMLIB) psapi.lib
endif endif
# #
......
# #
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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
...@@ -38,7 +38,7 @@ else ...@@ -38,7 +38,7 @@ else
endif endif
SUBDIRS = SUBDIRS =
SUBDIRS_misc = nio scripting nbproject SUBDIRS_misc = nio scripting nbproject forkjoin
SUBDIRS_enterprise = $(WEBSERVICES_SUBDIR) SUBDIRS_enterprise = $(WEBSERVICES_SUBDIR)
SUBDIRS_management = jmx SUBDIRS_management = jmx
......
#
# Copyright (c) 2011, 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.
#
#
# Makefile for building all the samples under the forkjoin subdirectory.
#
BUILDDIR = ../..
PRODUCT = java
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = mergesort
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
$(SUBDIRS-loop)
clobber clean ::
$(RM) -r $(SAMPLEDIR)/forkjoin
#
# Copyright (c) 2011, 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.
#
#
# Makefile for the forkjoin/mergesort sample code
#
BUILDDIR = ../../..
PRODUCT = java
include $(BUILDDIR)/common/Defs.gmk
SAMPLE_SRC_DIR = $(SHARE_SRC)/sample/forkjoin/mergesort
SAMPLE_DST_DIR = $(SAMPLEDIR)/forkjoin/mergesort
SAMPLE_FILES = \
$(SAMPLE_DST_DIR)/MergeDemo.java \
$(SAMPLE_DST_DIR)/MergeSort.java
all build: $(SAMPLE_FILES)
$(SAMPLE_DST_DIR)/%: $(SAMPLE_SRC_DIR)/%
$(install-file)
clean clobber:
$(RM) -r $(SAMPLE_DST_DIR)
.PHONY: all build clean clobber
# #
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2004, 2011, Oracle and/or its affiliates. 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
...@@ -31,7 +31,7 @@ BUILDDIR = ../.. ...@@ -31,7 +31,7 @@ BUILDDIR = ../..
PRODUCT = java PRODUCT = java
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = file multicast server SUBDIRS = chatserver file multicast server
include $(BUILDDIR)/common/Subdirs.gmk include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber:: all build clean clobber::
......
#
# Copyright (c) 2011, 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.
#
#
# Makefile for the nio/chatserver sample code
#
BUILDDIR = ../../..
PRODUCT = java
include $(BUILDDIR)/common/Defs.gmk
SAMPLE_SRC_DIR = $(SHARE_SRC)/sample/nio/chatserver
SAMPLE_DST_DIR = $(SAMPLEDIR)/nio/chatserver
SAMPLE_FILES = \
$(SAMPLE_DST_DIR)/ChatServer.java \
$(SAMPLE_DST_DIR)/Client.java \
$(SAMPLE_DST_DIR)/ClientReader.java \
$(SAMPLE_DST_DIR)/DataReader.java \
$(SAMPLE_DST_DIR)/MessageReader.java \
$(SAMPLE_DST_DIR)/NameReader.java \
$(SAMPLE_DST_DIR)/README.txt
all build: $(SAMPLE_FILES)
$(SAMPLE_DST_DIR)/%: $(SAMPLE_SRC_DIR)/%
$(install-file)
clean clobber:
$(RM) -r $(SAMPLE_DST_DIR)
.PHONY: all build clean clobber
/* /*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2011, Oracle and/or its affiliates. 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
...@@ -35,7 +35,6 @@ char *JLI_StringDup(const char *s1); ...@@ -35,7 +35,6 @@ char *JLI_StringDup(const char *s1);
void JLI_MemFree(void *ptr); void JLI_MemFree(void *ptr);
int JLI_StrCCmp(const char *s1, const char* s2); int JLI_StrCCmp(const char *s1, const char* s2);
#define JLI_StrLen(p1) strlen((p1)) #define JLI_StrLen(p1) strlen((p1))
#define JLI_StrChr(p1, p2) strchr((p1), (p2)) #define JLI_StrChr(p1, p2) strchr((p1), (p2))
#define JLI_StrRChr(p1, p2) strrchr((p1), (p2)) #define JLI_StrRChr(p1, p2) strrchr((p1), (p2))
...@@ -48,6 +47,7 @@ int JLI_StrCCmp(const char *s1, const char* s2); ...@@ -48,6 +47,7 @@ int JLI_StrCCmp(const char *s1, const char* s2);
#define JLI_StrSpn(p1, p2) strspn((p1), (p2)) #define JLI_StrSpn(p1, p2) strspn((p1), (p2))
#define JLI_StrCSpn(p1, p2) strcspn((p1), (p2)) #define JLI_StrCSpn(p1, p2) strcspn((p1), (p2))
#define JLI_StrPBrk(p1, p2) strpbrk((p1), (p2)) #define JLI_StrPBrk(p1, p2) strpbrk((p1), (p2))
#define JLI_StrTok(p1, p2) strtok((p1), (p2))
/* On Windows lseek() is in io.h rather than the location dictated by POSIX. */ /* On Windows lseek() is in io.h rather than the location dictated by POSIX. */
#ifdef _WIN32 #ifdef _WIN32
......
...@@ -4184,9 +4184,11 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -4184,9 +4184,11 @@ class Character implements java.io.Serializable, Comparable<Character> {
aliases.put("AVST", AVESTAN); aliases.put("AVST", AVESTAN);
aliases.put("BALI", BALINESE); aliases.put("BALI", BALINESE);
aliases.put("BAMU", BAMUM); aliases.put("BAMU", BAMUM);
aliases.put("BATK", BATAK);
aliases.put("BENG", BENGALI); aliases.put("BENG", BENGALI);
aliases.put("BOPO", BOPOMOFO); aliases.put("BOPO", BOPOMOFO);
aliases.put("BRAI", BRAILLE); aliases.put("BRAI", BRAILLE);
aliases.put("BRAH", BRAHMI);
aliases.put("BUGI", BUGINESE); aliases.put("BUGI", BUGINESE);
aliases.put("BUHD", BUHID); aliases.put("BUHD", BUHID);
aliases.put("CANS", CANADIAN_ABORIGINAL); aliases.put("CANS", CANADIAN_ABORIGINAL);
...@@ -4230,6 +4232,7 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -4230,6 +4232,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
aliases.put("LISU", LISU); aliases.put("LISU", LISU);
aliases.put("LYCI", LYCIAN); aliases.put("LYCI", LYCIAN);
aliases.put("LYDI", LYDIAN); aliases.put("LYDI", LYDIAN);
aliases.put("MAND", MANDAIC);
aliases.put("MLYM", MALAYALAM); aliases.put("MLYM", MALAYALAM);
aliases.put("MONG", MONGOLIAN); aliases.put("MONG", MONGOLIAN);
aliases.put("MTEI", MEETEI_MAYEK); aliases.put("MTEI", MEETEI_MAYEK);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package java.lang.reflect; package java.lang.reflect;
import java.security.AccessController; import java.security.AccessController;
import sun.reflect.Reflection;
import sun.reflect.ReflectionFactory; import sun.reflect.ReflectionFactory;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
...@@ -201,4 +202,73 @@ public class AccessibleObject implements AnnotatedElement { ...@@ -201,4 +202,73 @@ public class AccessibleObject implements AnnotatedElement {
public Annotation[] getDeclaredAnnotations() { public Annotation[] getDeclaredAnnotations() {
throw new AssertionError("All subclasses should override this method"); throw new AssertionError("All subclasses should override this method");
} }
// Shared access checking logic.
// For non-public members or members in package-private classes,
// it is necessary to perform somewhat expensive security checks.
// If the security check succeeds for a given class, it will
// always succeed (it is not affected by the granting or revoking
// of permissions); we speed up the check in the common case by
// remembering the last Class for which the check succeeded.
//
// The simple security check for Constructor is to see if
// the caller has already been seen, verified, and cached.
// (See also Class.newInstance(), which uses a similar method.)
//
// A more complicated security check cache is needed for Method and Field
// The cache can be either null (empty cache), a 2-array of {caller,target},
// or a caller (with target implicitly equal to this.clazz).
// In the 2-array case, the target is always different from the clazz.
volatile Object securityCheckCache;
void checkAccess(Class<?> caller, Class<?> clazz, Object obj, int modifiers)
throws IllegalAccessException
{
if (caller == clazz) { // quick check
return; // ACCESS IS OK
}
Object cache = securityCheckCache; // read volatile
Class<?> targetClass = clazz;
if (obj != null
&& Modifier.isProtected(modifiers)
&& ((targetClass = obj.getClass()) != clazz)) {
// Must match a 2-list of { caller, targetClass }.
if (cache instanceof Class[]) {
Class<?>[] cache2 = (Class<?>[]) cache;
if (cache2[1] == targetClass &&
cache2[0] == caller) {
return; // ACCESS IS OK
}
// (Test cache[1] first since range check for [1]
// subsumes range check for [0].)
}
} else if (cache == caller) {
// Non-protected case (or obj.class == this.clazz).
return; // ACCESS IS OK
}
// If no return, fall through to the slow path.
slowCheckMemberAccess(caller, clazz, obj, modifiers, targetClass);
}
// Keep all this slow stuff out of line:
void slowCheckMemberAccess(Class<?> caller, Class<?> clazz, Object obj, int modifiers,
Class<?> targetClass)
throws IllegalAccessException
{
Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
// Success: Update the cache.
Object cache = ((targetClass == clazz)
? caller
: new Class<?>[] { caller, targetClass });
// Note: The two cache elements are not volatile,
// but they are effectively final. The Java memory model
// guarantees that the initializing stores for the cache
// elements will occur before the volatile write.
securityCheckCache = cache; // write volatile
}
} }
...@@ -74,14 +74,6 @@ public final ...@@ -74,14 +74,6 @@ public final
private byte[] annotations; private byte[] annotations;
private byte[] parameterAnnotations; private byte[] parameterAnnotations;
// For non-public members or members in package-private classes,
// it is necessary to perform somewhat expensive security checks.
// If the security check succeeds for a given class, it will
// always succeed (it is not affected by the granting or revoking
// of permissions); we speed up the check in the common case by
// remembering the last Class for which the check succeeded.
private volatile Class<?> securityCheckCache;
// Generics infrastructure // Generics infrastructure
// Accessor for factory // Accessor for factory
private GenericsFactory getFactory() { private GenericsFactory getFactory() {
...@@ -495,7 +487,7 @@ public final ...@@ -495,7 +487,7 @@ public final
* this object represents * this object represents
* *
* @exception IllegalAccessException if this {@code Constructor} object * @exception IllegalAccessException if this {@code Constructor} object
* enforces Java language access control and the underlying * is enforcing Java language access control and the underlying
* constructor is inaccessible. * constructor is inaccessible.
* @exception IllegalArgumentException if the number of actual * @exception IllegalArgumentException if the number of actual
* and formal parameters differ; if an unwrapping * and formal parameters differ; if an unwrapping
...@@ -518,16 +510,17 @@ public final ...@@ -518,16 +510,17 @@ public final
if (!override) { if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) { if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class<?> caller = Reflection.getCallerClass(2); Class<?> caller = Reflection.getCallerClass(2);
if (securityCheckCache != caller) {
Reflection.ensureMemberAccess(caller, clazz, null, modifiers); checkAccess(caller, clazz, null, modifiers);
securityCheckCache = caller;
}
} }
} }
if ((clazz.getModifiers() & Modifier.ENUM) != 0) if ((clazz.getModifiers() & Modifier.ENUM) != 0)
throw new IllegalArgumentException("Cannot reflectively create enum objects"); throw new IllegalArgumentException("Cannot reflectively create enum objects");
if (constructorAccessor == null) acquireConstructorAccessor(); ConstructorAccessor ca = constructorAccessor; // read volatile
return (T) constructorAccessor.newInstance(initargs); if (ca == null) {
ca = acquireConstructorAccessor();
}
return (T) ca.newInstance(initargs);
} }
/** /**
...@@ -560,20 +553,22 @@ public final ...@@ -560,20 +553,22 @@ public final
// ConstructorAccessor for a given Constructor. However, avoiding // ConstructorAccessor for a given Constructor. However, avoiding
// synchronization will probably make the implementation more // synchronization will probably make the implementation more
// scalable. // scalable.
private void acquireConstructorAccessor() { private ConstructorAccessor acquireConstructorAccessor() {
// First check to see if one has been created yet, and take it // First check to see if one has been created yet, and take it
// if so. // if so.
ConstructorAccessor tmp = null; ConstructorAccessor tmp = null;
if (root != null) tmp = root.getConstructorAccessor(); if (root != null) tmp = root.getConstructorAccessor();
if (tmp != null) { if (tmp != null) {
constructorAccessor = tmp; constructorAccessor = tmp;
return; } else {
}
// Otherwise fabricate one and propagate it up to the root // Otherwise fabricate one and propagate it up to the root
tmp = reflectionFactory.newConstructorAccessor(this); tmp = reflectionFactory.newConstructorAccessor(this);
setConstructorAccessor(tmp); setConstructorAccessor(tmp);
} }
return tmp;
}
// Returns ConstructorAccessor for this Constructor object, not // Returns ConstructorAccessor for this Constructor object, not
// looking up the chain to the root // looking up the chain to the root
ConstructorAccessor getConstructorAccessor() { ConstructorAccessor getConstructorAccessor() {
......
...@@ -79,11 +79,6 @@ class Field extends AccessibleObject implements Member { ...@@ -79,11 +79,6 @@ class Field extends AccessibleObject implements Member {
// potentially many Field objects pointing to it.) // potentially many Field objects pointing to it.)
private Field root; private Field root;
// More complicated security check cache needed here than for
// Class.newInstance() and Constructor.newInstance()
private Class<?> securityCheckCache;
private Class<?> securityCheckTargetClassCache;
// Generics infrastructure // Generics infrastructure
private String getGenericSignature() {return signature;} private String getGenericSignature() {return signature;}
...@@ -340,7 +335,7 @@ class Field extends AccessibleObject implements Member { ...@@ -340,7 +335,7 @@ class Field extends AccessibleObject implements Member {
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field, the method throws an {@code IllegalArgumentException}. * field, the method throws an {@code IllegalArgumentException}.
* *
* <p>If this {@code Field} object enforces Java language access control, and * <p>If this {@code Field} object is enforcing Java language access control, and
* the underlying field is inaccessible, the method throws an * the underlying field is inaccessible, the method throws an
* {@code IllegalAccessException}. * {@code IllegalAccessException}.
* If the underlying field is static, the class that declared the * If the underlying field is static, the class that declared the
...@@ -360,8 +355,9 @@ class Field extends AccessibleObject implements Member { ...@@ -360,8 +355,9 @@ class Field extends AccessibleObject implements Member {
* {@code obj}; primitive values are wrapped in an appropriate * {@code obj}; primitive values are wrapped in an appropriate
* object before being returned * object before being returned
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof). * field (or a subclass or implementor thereof).
...@@ -383,8 +379,9 @@ class Field extends AccessibleObject implements Member { ...@@ -383,8 +379,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the {@code boolean} field * @return the value of the {@code boolean} field
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -410,8 +407,9 @@ class Field extends AccessibleObject implements Member { ...@@ -410,8 +407,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the {@code byte} field * @return the value of the {@code byte} field
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -439,8 +437,9 @@ class Field extends AccessibleObject implements Member { ...@@ -439,8 +437,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the field converted to type {@code char} * @return the value of the field converted to type {@code char}
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -468,8 +467,9 @@ class Field extends AccessibleObject implements Member { ...@@ -468,8 +467,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the field converted to type {@code short} * @return the value of the field converted to type {@code short}
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -497,8 +497,9 @@ class Field extends AccessibleObject implements Member { ...@@ -497,8 +497,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the field converted to type {@code int} * @return the value of the field converted to type {@code int}
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -526,8 +527,9 @@ class Field extends AccessibleObject implements Member { ...@@ -526,8 +527,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the field converted to type {@code long} * @return the value of the field converted to type {@code long}
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -555,8 +557,9 @@ class Field extends AccessibleObject implements Member { ...@@ -555,8 +557,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the field converted to type {@code float} * @return the value of the field converted to type {@code float}
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -584,8 +587,9 @@ class Field extends AccessibleObject implements Member { ...@@ -584,8 +587,9 @@ class Field extends AccessibleObject implements Member {
* from * from
* @return the value of the field converted to type {@code double} * @return the value of the field converted to type {@code double}
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not * @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the * an instance of the class or interface declaring the
* underlying field (or a subclass or implementor * underlying field (or a subclass or implementor
...@@ -621,14 +625,14 @@ class Field extends AccessibleObject implements Member { ...@@ -621,14 +625,14 @@ class Field extends AccessibleObject implements Member {
* an instance of the class or interface declaring the underlying * an instance of the class or interface declaring the underlying
* field, the method throws an {@code IllegalArgumentException}. * field, the method throws an {@code IllegalArgumentException}.
* *
* <p>If this {@code Field} object enforces Java language access control, and * <p>If this {@code Field} object is enforcing Java language access control, and
* the underlying field is inaccessible, the method throws an * the underlying field is inaccessible, the method throws an
* {@code IllegalAccessException}. * {@code IllegalAccessException}.
* *
* <p>If the underlying field is final, the method throws an * <p>If the underlying field is final, the method throws an
* {@code IllegalAccessException} unless * {@code IllegalAccessException} unless {@code setAccessible(true)}
* {@code setAccessible(true)} has succeeded for this field * has succeeded for this {@code Field} object
* and this field is non-static. Setting a final field in this way * and the field is non-static. Setting a final field in this way
* is meaningful only during deserialization or reconstruction of * is meaningful only during deserialization or reconstruction of
* instances of classes with blank final fields, before they are * instances of classes with blank final fields, before they are
* made available for access by other parts of a program. Use in * made available for access by other parts of a program. Use in
...@@ -658,8 +662,9 @@ class Field extends AccessibleObject implements Member { ...@@ -658,8 +662,9 @@ class Field extends AccessibleObject implements Member {
* @param value the new value for the field of {@code obj} * @param value the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -686,8 +691,9 @@ class Field extends AccessibleObject implements Member { ...@@ -686,8 +691,9 @@ class Field extends AccessibleObject implements Member {
* @param z the new value for the field of {@code obj} * @param z the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -715,8 +721,9 @@ class Field extends AccessibleObject implements Member { ...@@ -715,8 +721,9 @@ class Field extends AccessibleObject implements Member {
* @param b the new value for the field of {@code obj} * @param b the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -744,8 +751,9 @@ class Field extends AccessibleObject implements Member { ...@@ -744,8 +751,9 @@ class Field extends AccessibleObject implements Member {
* @param c the new value for the field of {@code obj} * @param c the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -773,8 +781,9 @@ class Field extends AccessibleObject implements Member { ...@@ -773,8 +781,9 @@ class Field extends AccessibleObject implements Member {
* @param s the new value for the field of {@code obj} * @param s the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -802,8 +811,9 @@ class Field extends AccessibleObject implements Member { ...@@ -802,8 +811,9 @@ class Field extends AccessibleObject implements Member {
* @param i the new value for the field of {@code obj} * @param i the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -831,8 +841,9 @@ class Field extends AccessibleObject implements Member { ...@@ -831,8 +841,9 @@ class Field extends AccessibleObject implements Member {
* @param l the new value for the field of {@code obj} * @param l the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -860,8 +871,9 @@ class Field extends AccessibleObject implements Member { ...@@ -860,8 +871,9 @@ class Field extends AccessibleObject implements Member {
* @param f the new value for the field of {@code obj} * @param f the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -889,8 +901,9 @@ class Field extends AccessibleObject implements Member { ...@@ -889,8 +901,9 @@ class Field extends AccessibleObject implements Member {
* @param d the new value for the field of {@code obj} * @param d the new value for the field of {@code obj}
* being modified * being modified
* *
* @exception IllegalAccessException if the underlying field * @exception IllegalAccessException if this {@code Field} object
* is inaccessible. * is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an * @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying * instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof), * field (or a subclass or implementor thereof),
...@@ -936,6 +949,7 @@ class Field extends AccessibleObject implements Member { ...@@ -936,6 +949,7 @@ class Field extends AccessibleObject implements Member {
tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck); tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
setFieldAccessor(tmp, overrideFinalCheck); setFieldAccessor(tmp, overrideFinalCheck);
} }
return tmp; return tmp;
} }
...@@ -965,21 +979,8 @@ class Field extends AccessibleObject implements Member { ...@@ -965,21 +979,8 @@ class Field extends AccessibleObject implements Member {
if (!override) { if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) { if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class<?> caller = Reflection.getCallerClass(4); Class<?> caller = Reflection.getCallerClass(4);
Class<?> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
? clazz
: obj.getClass());
synchronized (this) { checkAccess(caller, clazz, obj, modifiers);
if ((securityCheckCache == caller)
&& (securityCheckTargetClassCache == targetClass)) {
return;
}
}
Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
synchronized (this) {
securityCheckCache = caller;
securityCheckTargetClassCache = targetClass;
}
} }
} }
} }
......
...@@ -83,11 +83,6 @@ public final ...@@ -83,11 +83,6 @@ public final
// potentially many Method objects pointing to it.) // potentially many Method objects pointing to it.)
private Method root; private Method root;
// More complicated security check cache needed here than for
// Class.newInstance() and Constructor.newInstance()
private Class<?> securityCheckCache;
private Class<?> securityCheckTargetClassCache;
// Generics infrastructure // Generics infrastructure
private String getGenericSignature() {return signature;} private String getGenericSignature() {return signature;}
...@@ -402,28 +397,28 @@ public final ...@@ -402,28 +397,28 @@ public final
*/ */
public String toString() { public String toString() {
try { try {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
int mod = getModifiers() & Modifier.methodModifiers(); int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) { if (mod != 0) {
sb.append(Modifier.toString(mod) + " "); sb.append(Modifier.toString(mod)).append(' ');
} }
sb.append(Field.getTypeName(getReturnType()) + " "); sb.append(Field.getTypeName(getReturnType())).append(' ');
sb.append(Field.getTypeName(getDeclaringClass()) + "."); sb.append(Field.getTypeName(getDeclaringClass())).append('.');
sb.append(getName() + "("); sb.append(getName()).append('(');
Class<?>[] params = parameterTypes; // avoid clone Class<?>[] params = parameterTypes; // avoid clone
for (int j = 0; j < params.length; j++) { for (int j = 0; j < params.length; j++) {
sb.append(Field.getTypeName(params[j])); sb.append(Field.getTypeName(params[j]));
if (j < (params.length - 1)) if (j < (params.length - 1))
sb.append(","); sb.append(',');
} }
sb.append(")"); sb.append(')');
Class<?>[] exceptions = exceptionTypes; // avoid clone Class<?>[] exceptions = exceptionTypes; // avoid clone
if (exceptions.length > 0) { if (exceptions.length > 0) {
sb.append(" throws "); sb.append(" throws ");
for (int k = 0; k < exceptions.length; k++) { for (int k = 0; k < exceptions.length; k++) {
sb.append(exceptions[k].getName()); sb.append(exceptions[k].getName());
if (k < (exceptions.length - 1)) if (k < (exceptions.length - 1))
sb.append(","); sb.append(',');
} }
} }
return sb.toString(); return sb.toString();
...@@ -475,15 +470,15 @@ public final ...@@ -475,15 +470,15 @@ public final
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int mod = getModifiers() & Modifier.methodModifiers(); int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) { if (mod != 0) {
sb.append(Modifier.toString(mod) + " "); sb.append(Modifier.toString(mod)).append(' ');
} }
TypeVariable<?>[] typeparms = getTypeParameters(); TypeVariable<?>[] typeparms = getTypeParameters();
if (typeparms.length > 0) { if (typeparms.length > 0) {
boolean first = true; boolean first = true;
sb.append("<"); sb.append('<');
for(TypeVariable<?> typeparm: typeparms) { for(TypeVariable<?> typeparm: typeparms) {
if (!first) if (!first)
sb.append(","); sb.append(',');
// Class objects can't occur here; no need to test // Class objects can't occur here; no need to test
// and call Class.getName(). // and call Class.getName().
sb.append(typeparm.toString()); sb.append(typeparm.toString());
...@@ -494,10 +489,11 @@ public final ...@@ -494,10 +489,11 @@ public final
Type genRetType = getGenericReturnType(); Type genRetType = getGenericReturnType();
sb.append( ((genRetType instanceof Class<?>)? sb.append( ((genRetType instanceof Class<?>)?
Field.getTypeName((Class<?>)genRetType):genRetType.toString()) + " "); Field.getTypeName((Class<?>)genRetType):genRetType.toString()))
.append(' ');
sb.append(Field.getTypeName(getDeclaringClass()) + "."); sb.append(Field.getTypeName(getDeclaringClass())).append('.');
sb.append(getName() + "("); sb.append(getName()).append('(');
Type[] params = getGenericParameterTypes(); Type[] params = getGenericParameterTypes();
for (int j = 0; j < params.length; j++) { for (int j = 0; j < params.length; j++) {
String param = (params[j] instanceof Class)? String param = (params[j] instanceof Class)?
...@@ -507,9 +503,9 @@ public final ...@@ -507,9 +503,9 @@ public final
param = param.replaceFirst("\\[\\]$", "..."); param = param.replaceFirst("\\[\\]$", "...");
sb.append(param); sb.append(param);
if (j < (params.length - 1)) if (j < (params.length - 1))
sb.append(","); sb.append(',');
} }
sb.append(")"); sb.append(')');
Type[] exceptions = getGenericExceptionTypes(); Type[] exceptions = getGenericExceptionTypes();
if (exceptions.length > 0) { if (exceptions.length > 0) {
sb.append(" throws "); sb.append(" throws ");
...@@ -518,7 +514,7 @@ public final ...@@ -518,7 +514,7 @@ public final
((Class)exceptions[k]).getName(): ((Class)exceptions[k]).getName():
exceptions[k].toString()); exceptions[k].toString());
if (k < (exceptions.length - 1)) if (k < (exceptions.length - 1))
sb.append(","); sb.append(',');
} }
} }
return sb.toString(); return sb.toString();
...@@ -565,7 +561,7 @@ public final ...@@ -565,7 +561,7 @@ public final
* {@code args} * {@code args}
* *
* @exception IllegalAccessException if this {@code Method} object * @exception IllegalAccessException if this {@code Method} object
* enforces Java language access control and the underlying * is enforcing Java language access control and the underlying
* method is inaccessible. * method is inaccessible.
* @exception IllegalArgumentException if the method is an * @exception IllegalArgumentException if the method is an
* instance method and the specified object argument * instance method and the specified object argument
...@@ -591,26 +587,15 @@ public final ...@@ -591,26 +587,15 @@ public final
if (!override) { if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) { if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class<?> caller = Reflection.getCallerClass(1); Class<?> caller = Reflection.getCallerClass(1);
Class<?> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
? clazz
: obj.getClass());
boolean cached; checkAccess(caller, clazz, obj, modifiers);
synchronized (this) {
cached = (securityCheckCache == caller)
&& (securityCheckTargetClassCache == targetClass);
}
if (!cached) {
Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
synchronized (this) {
securityCheckCache = caller;
securityCheckTargetClassCache = targetClass;
}
} }
} }
MethodAccessor ma = methodAccessor; // read volatile
if (ma == null) {
ma = acquireMethodAccessor();
} }
if (methodAccessor == null) acquireMethodAccessor(); return ma.invoke(obj, args);
return methodAccessor.invoke(obj, args);
} }
/** /**
...@@ -654,20 +639,22 @@ public final ...@@ -654,20 +639,22 @@ public final
// (though not efficient) to generate more than one MethodAccessor // (though not efficient) to generate more than one MethodAccessor
// for a given Method. However, avoiding synchronization will // for a given Method. However, avoiding synchronization will
// probably make the implementation more scalable. // probably make the implementation more scalable.
private void acquireMethodAccessor() { private MethodAccessor acquireMethodAccessor() {
// First check to see if one has been created yet, and take it // First check to see if one has been created yet, and take it
// if so // if so
MethodAccessor tmp = null; MethodAccessor tmp = null;
if (root != null) tmp = root.getMethodAccessor(); if (root != null) tmp = root.getMethodAccessor();
if (tmp != null) { if (tmp != null) {
methodAccessor = tmp; methodAccessor = tmp;
return; } else {
}
// Otherwise fabricate one and propagate it up to the root // Otherwise fabricate one and propagate it up to the root
tmp = reflectionFactory.newMethodAccessor(this); tmp = reflectionFactory.newMethodAccessor(this);
setMethodAccessor(tmp); setMethodAccessor(tmp);
} }
return tmp;
}
// Returns MethodAccessor for this Method object, not looking up // Returns MethodAccessor for this Method object, not looking up
// the chain to the root // the chain to the root
MethodAccessor getMethodAccessor() { MethodAccessor getMethodAccessor() {
......
...@@ -2067,7 +2067,7 @@ public final class Files { ...@@ -2067,7 +2067,7 @@ public final class Files {
* *
* @return {@code true} if the file is a symbolic link; {@code false} if * @return {@code true} if the file is a symbolic link; {@code false} if
* the file does not exist, is not a symbolic link, or it cannot * the file does not exist, is not a symbolic link, or it cannot
* be determined if the file is symbolic link or not. * be determined if the file is a symbolic link or not.
* *
* @throws SecurityException * @throws SecurityException
* In the case of the default provider, and a security manager is * In the case of the default provider, and a security manager is
...@@ -2106,7 +2106,7 @@ public final class Files { ...@@ -2106,7 +2106,7 @@ public final class Files {
* *
* @return {@code true} if the file is a directory; {@code false} if * @return {@code true} if the file is a directory; {@code false} if
* the file does not exist, is not a directory, or it cannot * the file does not exist, is not a directory, or it cannot
* be determined if the file is directory or not. * be determined if the file is a directory or not.
* *
* @throws SecurityException * @throws SecurityException
* In the case of the default provider, and a security manager is * In the case of the default provider, and a security manager is
...@@ -2142,8 +2142,8 @@ public final class Files { ...@@ -2142,8 +2142,8 @@ public final class Files {
* options indicating how symbolic links are handled * options indicating how symbolic links are handled
* *
* @return {@code true} if the file is a regular file; {@code false} if * @return {@code true} if the file is a regular file; {@code false} if
* the file does not exist, is not a direcregular filetory, or it * the file does not exist, is not a regular file, or it
* cannot be determined if the file is regular file or not. * cannot be determined if the file is a regular file or not.
* *
* @throws SecurityException * @throws SecurityException
* In the case of the default provider, and a security manager is * In the case of the default provider, and a security manager is
......
...@@ -550,18 +550,21 @@ public interface Path ...@@ -550,18 +550,21 @@ public interface Path
* <p> If this path is relative then its absolute path is first obtained, * <p> If this path is relative then its absolute path is first obtained,
* as if by invoking the {@link #toAbsolutePath toAbsolutePath} method. * as if by invoking the {@link #toAbsolutePath toAbsolutePath} method.
* *
* <p> The {@code resolveLinks} parameter specifies if symbolic links * <p> The {@code options} array may be used to indicate how symbolic links
* should be resolved. This parameter is ignored when symbolic links are * are handled. By default, symbolic links are resolved to their final
* not supported. Where supported, and the parameter has the value {@code * target. If the option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is
* true} then symbolic links are resolved to their final target. Where the * present then this method does not resolve symbolic links.
* parameter has the value {@code false} then this method does not resolve *
* symbolic links. Some implementations allow special names such as * Some implementations allow special names such as "{@code ..}" to refer to
* "{@code ..}" to refer to the parent directory. When deriving the <em>real * the parent directory. When deriving the <em>real path</em>, and a
* path</em>, and a "{@code ..}" (or equivalent) is preceded by a * "{@code ..}" (or equivalent) is preceded by a non-"{@code ..}" name then
* non-"{@code ..}" name then an implementation will typically causes both * an implementation will typically cause both names to be removed. When
* names to be removed. When not resolving symbolic links and the preceding * not resolving symbolic links and the preceding name is a symbolic link
* name is a symbolic link then the names are only removed if it guaranteed * then the names are only removed if it guaranteed that the resulting path
* that the resulting path will locate the same file as this path. * will locate the same file as this path.
*
* @param options
* options indicating how symbolic links are handled
* *
* @return an absolute path represent the <em>real</em> path of the file * @return an absolute path represent the <em>real</em> path of the file
* located by this object * located by this object
...@@ -576,7 +579,7 @@ public interface Path ...@@ -576,7 +579,7 @@ public interface Path
* checkPropertyAccess} method is invoked to check access to the * checkPropertyAccess} method is invoked to check access to the
* system property {@code user.dir} * system property {@code user.dir}
*/ */
Path toRealPath(boolean resolveLinks) throws IOException; Path toRealPath(LinkOption... options) throws IOException;
/** /**
* Returns a {@link File} object representing this path. Where this {@code * Returns a {@link File} object representing this path. Where this {@code
......
...@@ -80,7 +80,7 @@ public class DriverManager { ...@@ -80,7 +80,7 @@ public class DriverManager {
// List of registered JDBC drivers // List of registered JDBC drivers
private final static CopyOnWriteArrayList<Driver> registeredDrivers = new CopyOnWriteArrayList<Driver>(); private final static CopyOnWriteArrayList<DriverInfo> registeredDrivers = new CopyOnWriteArrayList<DriverInfo>();
private static volatile int loginTimeout = 0; private static volatile int loginTimeout = 0;
private static volatile java.io.PrintWriter logWriter = null; private static volatile java.io.PrintWriter logWriter = null;
private static volatile java.io.PrintStream logStream = null; private static volatile java.io.PrintStream logStream = null;
...@@ -265,22 +265,22 @@ public class DriverManager { ...@@ -265,22 +265,22 @@ public class DriverManager {
// Walk through the loaded registeredDrivers attempting to locate someone // Walk through the loaded registeredDrivers attempting to locate someone
// who understands the given URL. // who understands the given URL.
for (Driver aDriver : registeredDrivers) { for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then // If the caller does not have permission to load the driver then
// skip it. // skip it.
if(isDriverAllowed(aDriver, callerCL)) { if(isDriverAllowed(aDriver.driver, callerCL)) {
try { try {
if(aDriver.acceptsURL(url)) { if(aDriver.driver.acceptsURL(url)) {
// Success! // Success!
println("getDriver returning " + aDriver.getClass().getName()); println("getDriver returning " + aDriver.driver.getClass().getName());
return (aDriver); return (aDriver.driver);
} }
} catch(SQLException sqe) { } catch(SQLException sqe) {
// Drop through and try the next driver. // Drop through and try the next driver.
} }
} else { } else {
println(" skipping: " + aDriver.getClass().getName()); println(" skipping: " + aDriver.driver.getClass().getName());
} }
} }
...@@ -305,7 +305,7 @@ public class DriverManager { ...@@ -305,7 +305,7 @@ public class DriverManager {
/* Register the driver if it has not already been added to our list */ /* Register the driver if it has not already been added to our list */
if(driver != null) { if(driver != null) {
registeredDrivers.addIfAbsent(driver); registeredDrivers.addIfAbsent(new DriverInfo(driver));
} else { } else {
// This is for compatibility with the original DriverManager // This is for compatibility with the original DriverManager
throw new NullPointerException(); throw new NullPointerException();
...@@ -333,9 +333,10 @@ public class DriverManager { ...@@ -333,9 +333,10 @@ public class DriverManager {
ClassLoader callerCL = DriverManager.getCallerClassLoader(); ClassLoader callerCL = DriverManager.getCallerClassLoader();
println("DriverManager.deregisterDriver: " + driver); println("DriverManager.deregisterDriver: " + driver);
if(registeredDrivers.contains(driver)) { DriverInfo aDriver = new DriverInfo(driver);
if(registeredDrivers.contains(aDriver)) {
if (isDriverAllowed(driver, callerCL)) { if (isDriverAllowed(driver, callerCL)) {
registeredDrivers.remove(driver); registeredDrivers.remove(aDriver);
} else { } else {
// If the caller does not have permission to load the driver then // If the caller does not have permission to load the driver then
// throw a SecurityException. // throw a SecurityException.
...@@ -363,11 +364,11 @@ public class DriverManager { ...@@ -363,11 +364,11 @@ public class DriverManager {
ClassLoader callerCL = DriverManager.getCallerClassLoader(); ClassLoader callerCL = DriverManager.getCallerClassLoader();
// Walk through the loaded registeredDrivers. // Walk through the loaded registeredDrivers.
for(Driver aDriver : registeredDrivers) { for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then // If the caller does not have permission to load the driver then
// skip it. // skip it.
if(isDriverAllowed(aDriver, callerCL)) { if(isDriverAllowed(aDriver.driver, callerCL)) {
result.addElement(aDriver); result.addElement(aDriver.driver);
} else { } else {
println(" skipping: " + aDriver.getClass().getName()); println(" skipping: " + aDriver.getClass().getName());
} }
...@@ -482,8 +483,8 @@ public class DriverManager { ...@@ -482,8 +483,8 @@ public class DriverManager {
private static void loadInitialDrivers() { private static void loadInitialDrivers() {
String drivers; String drivers;
try { try {
drivers = (String) AccessController.doPrivileged(new PrivilegedAction() { drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
public Object run() { public String run() {
return System.getProperty("jdbc.drivers"); return System.getProperty("jdbc.drivers");
} }
}); });
...@@ -495,8 +496,8 @@ public class DriverManager { ...@@ -495,8 +496,8 @@ public class DriverManager {
// exposed as a java.sql.Driver.class service. // exposed as a java.sql.Driver.class service.
// ServiceLoader.load() replaces the sun.misc.Providers() // ServiceLoader.load() replaces the sun.misc.Providers()
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class); ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
Iterator driversIterator = loadedDrivers.iterator(); Iterator driversIterator = loadedDrivers.iterator();
...@@ -569,16 +570,16 @@ public class DriverManager { ...@@ -569,16 +570,16 @@ public class DriverManager {
// Remember the first exception that gets raised so we can reraise it. // Remember the first exception that gets raised so we can reraise it.
SQLException reason = null; SQLException reason = null;
for(Driver aDriver : registeredDrivers) { for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then // If the caller does not have permission to load the driver then
// skip it. // skip it.
if(isDriverAllowed(aDriver, callerCL)) { if(isDriverAllowed(aDriver.driver, callerCL)) {
try { try {
println(" trying " + aDriver.getClass().getName()); println(" trying " + aDriver.driver.getClass().getName());
Connection con = aDriver.connect(url, info); Connection con = aDriver.driver.connect(url, info);
if (con != null) { if (con != null) {
// Success! // Success!
println("getConnection returning " + aDriver.getClass().getName()); println("getConnection returning " + aDriver.driver.getClass().getName());
return (con); return (con);
} }
} catch (SQLException ex) { } catch (SQLException ex) {
...@@ -607,3 +608,29 @@ public class DriverManager { ...@@ -607,3 +608,29 @@ public class DriverManager {
private static native ClassLoader getCallerClassLoader(); private static native ClassLoader getCallerClassLoader();
} }
/*
* Wrapper class for registered Drivers in order to not expose Driver.equals()
* to avoid the capture of the Driver it being compared to as it might not
* normally have access.
*/
class DriverInfo {
final Driver driver;
DriverInfo(Driver driver) {
this.driver = driver;
}
public boolean equals(Object other) {
return (other instanceof DriverInfo)
&& this.driver == ((DriverInfo) other).driver;
}
public int hashCode() {
return driver.hashCode();
}
public String toString() {
return ("driver[className=" + driver + "]");
}
}
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util; package java.util;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* file: * file:
* *
* Written by Josh Bloch of Google Inc. and released to the public domain, * Written by Josh Bloch of Google Inc. and released to the public domain,
* as explained at http://creativecommons.org/licenses/publicdomain. * as explained at http://creativecommons.org/publicdomain/zero/1.0/.
*/ */
package java.util; package java.util;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea and Josh Bloch with assistance from members of * Written by Doug Lea and Josh Bloch with assistance from members of
* JCP JSR-166 Expert Group and released to the public domain, as explained * JCP JSR-166 Expert Group and released to the public domain, as explained
* at http://creativecommons.org/licenses/publicdomain * at http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util; package java.util;
......
...@@ -106,7 +106,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -106,7 +106,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
/** /**
* Distinguished non-null value for representing null values. * Distinguished non-null value for representing null values.
*/ */
private static final Object NULL = new Object(); private static final Object NULL = new Integer(0);
private Object maskNull(Object value) { private Object maskNull(Object value) {
return (value == null ? NULL : value); return (value == null ? NULL : value);
...@@ -116,7 +116,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -116,7 +116,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
return (V) (value == NULL ? null : value); return (V) (value == NULL ? null : value);
} }
private static Enum[] ZERO_LENGTH_ENUM_ARRAY = new Enum[0]; private static final Enum[] ZERO_LENGTH_ENUM_ARRAY = new Enum[0];
/** /**
* Creates an empty enum map with the specified key type. * Creates an empty enum map with the specified key type.
...@@ -464,6 +464,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -464,6 +464,7 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
public Iterator<Map.Entry<K,V>> iterator() { public Iterator<Map.Entry<K,V>> iterator() {
return new EntryIterator(); return new EntryIterator();
} }
public boolean contains(Object o) { public boolean contains(Object o) {
if (!(o instanceof Map.Entry)) if (!(o instanceof Map.Entry))
return false; return false;
...@@ -552,72 +553,84 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -552,72 +553,84 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
} }
} }
/** private class EntryIterator extends EnumMapIterator<Map.Entry<K,V>> {
* Since we don't use Entry objects, we use the Iterator itself as entry. private Entry lastReturnedEntry = null;
*/
private class EntryIterator extends EnumMapIterator<Map.Entry<K,V>>
implements Map.Entry<K,V>
{
public Map.Entry<K,V> next() { public Map.Entry<K,V> next() {
if (!hasNext()) if (!hasNext())
throw new NoSuchElementException(); throw new NoSuchElementException();
lastReturnedIndex = index++; lastReturnedEntry = new Entry(index++);
return this; return lastReturnedEntry;
}
public void remove() {
lastReturnedIndex =
((null == lastReturnedEntry) ? -1 : lastReturnedEntry.index);
super.remove();
lastReturnedEntry.index = lastReturnedIndex;
lastReturnedEntry = null;
}
private class Entry implements Map.Entry<K,V> {
private int index;
private Entry(int index) {
this.index = index;
} }
public K getKey() { public K getKey() {
checkLastReturnedIndexForEntryUse(); checkIndexForEntryUse();
return keyUniverse[lastReturnedIndex]; return keyUniverse[index];
} }
public V getValue() { public V getValue() {
checkLastReturnedIndexForEntryUse(); checkIndexForEntryUse();
return unmaskNull(vals[lastReturnedIndex]); return unmaskNull(vals[index]);
} }
public V setValue(V value) { public V setValue(V value) {
checkLastReturnedIndexForEntryUse(); checkIndexForEntryUse();
V oldValue = unmaskNull(vals[lastReturnedIndex]); V oldValue = unmaskNull(vals[index]);
vals[lastReturnedIndex] = maskNull(value); vals[index] = maskNull(value);
return oldValue; return oldValue;
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if (lastReturnedIndex < 0) if (index < 0)
return o == this; return o == this;
if (!(o instanceof Map.Entry)) if (!(o instanceof Map.Entry))
return false; return false;
Map.Entry e = (Map.Entry)o; Map.Entry e = (Map.Entry)o;
V ourValue = unmaskNull(vals[lastReturnedIndex]); V ourValue = unmaskNull(vals[index]);
Object hisValue = e.getValue(); Object hisValue = e.getValue();
return e.getKey() == keyUniverse[lastReturnedIndex] && return (e.getKey() == keyUniverse[index] &&
(ourValue == hisValue || (ourValue == hisValue ||
(ourValue != null && ourValue.equals(hisValue))); (ourValue != null && ourValue.equals(hisValue))));
} }
public int hashCode() { public int hashCode() {
if (lastReturnedIndex < 0) if (index < 0)
return super.hashCode(); return super.hashCode();
Object value = vals[lastReturnedIndex]; return entryHashCode(index);
return keyUniverse[lastReturnedIndex].hashCode()
^ (value == NULL ? 0 : value.hashCode());
} }
public String toString() { public String toString() {
if (lastReturnedIndex < 0) if (index < 0)
return super.toString(); return super.toString();
return keyUniverse[lastReturnedIndex] + "=" return keyUniverse[index] + "="
+ unmaskNull(vals[lastReturnedIndex]); + unmaskNull(vals[index]);
} }
private void checkLastReturnedIndexForEntryUse() { private void checkIndexForEntryUse() {
if (lastReturnedIndex < 0) if (index < 0)
throw new IllegalStateException("Entry was removed"); throw new IllegalStateException("Entry was removed");
} }
} }
}
// Comparison and hashing // Comparison and hashing
...@@ -631,10 +644,35 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -631,10 +644,35 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
* @return <tt>true</tt> if the specified object is equal to this map * @return <tt>true</tt> if the specified object is equal to this map
*/ */
public boolean equals(Object o) { public boolean equals(Object o) {
if (!(o instanceof EnumMap)) if (this == o)
return super.equals(o); return true;
if (o instanceof EnumMap)
return equals((EnumMap)o);
if (!(o instanceof Map))
return false;
Map<K,V> m = (Map<K,V>)o;
if (size != m.size())
return false;
EnumMap em = (EnumMap)o; for (int i = 0; i < keyUniverse.length; i++) {
if (null != vals[i]) {
K key = keyUniverse[i];
V value = unmaskNull(vals[i]);
if (null == value) {
if (!((null == m.get(key)) && m.containsKey(key)))
return false;
} else {
if (!value.equals(m.get(key)))
return false;
}
}
}
return true;
}
private boolean equals(EnumMap em) {
if (em.keyType != keyType) if (em.keyType != keyType)
return size == 0 && em.size == 0; return size == 0 && em.size == 0;
...@@ -649,6 +687,26 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -649,6 +687,26 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
return true; return true;
} }
/**
* Returns the hash code value for this map. The hash code of a map is
* defined to be the sum of the hash codes of each entry in the map.
*/
public int hashCode() {
int h = 0;
for (int i = 0; i < keyUniverse.length; i++) {
if (null != vals[i]) {
h += entryHashCode(i);
}
}
return h;
}
private int entryHashCode(int index) {
return (keyUniverse[index].hashCode() ^ vals[index].hashCode());
}
/** /**
* Returns a shallow copy of this enum map. (The values themselves * Returns a shallow copy of this enum map. (The values themselves
* are not cloned. * are not cloned.
...@@ -705,9 +763,13 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V> ...@@ -705,9 +763,13 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
s.writeInt(size); s.writeInt(size);
// Write out keys and values (alternating) // Write out keys and values (alternating)
for (Map.Entry<K,V> e : entrySet()) { int entriesToBeWritten = size;
s.writeObject(e.getKey()); for (int i = 0; entriesToBeWritten > 0; i++) {
s.writeObject(e.getValue()); if (null != vals[i]) {
s.writeObject(keyUniverse[i]);
s.writeObject(unmaskNull(vals[i]));
entriesToBeWritten--;
}
} }
} }
......
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2011, Oracle and/or its affiliates. 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
...@@ -829,71 +829,82 @@ public class IdentityHashMap<K,V> ...@@ -829,71 +829,82 @@ public class IdentityHashMap<K,V>
} }
} }
/**
* Since we don't use Entry objects, we use the Iterator
* itself as an entry.
*/
private class EntryIterator private class EntryIterator
extends IdentityHashMapIterator<Map.Entry<K,V>> extends IdentityHashMapIterator<Map.Entry<K,V>>
implements Map.Entry<K,V>
{ {
private Entry lastReturnedEntry = null;
public Map.Entry<K,V> next() { public Map.Entry<K,V> next() {
nextIndex(); lastReturnedEntry = new Entry(nextIndex());
return this; return lastReturnedEntry;
} }
public K getKey() { public void remove() {
// Provide a better exception than out of bounds index lastReturnedIndex =
if (lastReturnedIndex < 0) ((null == lastReturnedEntry) ? -1 : lastReturnedEntry.index);
throw new IllegalStateException("Entry was removed"); super.remove();
lastReturnedEntry.index = lastReturnedIndex;
lastReturnedEntry = null;
}
private class Entry implements Map.Entry<K,V> {
private int index;
return (K) unmaskNull(traversalTable[lastReturnedIndex]); private Entry(int index) {
this.index = index;
} }
public V getValue() { public K getKey() {
// Provide a better exception than out of bounds index checkIndexForEntryUse();
if (lastReturnedIndex < 0) return (K) unmaskNull(traversalTable[index]);
throw new IllegalStateException("Entry was removed"); }
return (V) traversalTable[lastReturnedIndex+1]; public V getValue() {
checkIndexForEntryUse();
return (V) traversalTable[index+1];
} }
public V setValue(V value) { public V setValue(V value) {
// It would be mean-spirited to proceed here if remove() called checkIndexForEntryUse();
if (lastReturnedIndex < 0) V oldValue = (V) traversalTable[index+1];
throw new IllegalStateException("Entry was removed"); traversalTable[index+1] = value;
V oldValue = (V) traversalTable[lastReturnedIndex+1];
traversalTable[lastReturnedIndex+1] = value;
// if shadowing, force into main table // if shadowing, force into main table
if (traversalTable != IdentityHashMap.this.table) if (traversalTable != IdentityHashMap.this.table)
put((K) traversalTable[lastReturnedIndex], value); put((K) traversalTable[index], value);
return oldValue; return oldValue;
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if (lastReturnedIndex < 0) if (index < 0)
return super.equals(o); return super.equals(o);
if (!(o instanceof Map.Entry)) if (!(o instanceof Map.Entry))
return false; return false;
Map.Entry e = (Map.Entry)o; Map.Entry e = (Map.Entry)o;
return e.getKey() == getKey() && return (e.getKey() == unmaskNull(traversalTable[index]) &&
e.getValue() == getValue(); e.getValue() == traversalTable[index+1]);
} }
public int hashCode() { public int hashCode() {
if (lastReturnedIndex < 0) if (lastReturnedIndex < 0)
return super.hashCode(); return super.hashCode();
return System.identityHashCode(getKey()) ^ return (System.identityHashCode(unmaskNull(traversalTable[index])) ^
System.identityHashCode(getValue()); System.identityHashCode(traversalTable[index+1]));
} }
public String toString() { public String toString() {
if (lastReturnedIndex < 0) if (index < 0)
return super.toString(); return super.toString();
return getKey() + "=" + getValue(); return (unmaskNull(traversalTable[index]) + "="
+ traversalTable[index+1]);
}
private void checkIndexForEntryUse() {
if (index < 0)
throw new IllegalStateException("Entry was removed");
}
} }
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea and Josh Bloch with assistance from members of JCP * Written by Doug Lea and Josh Bloch with assistance from members of JCP
* JSR-166 Expert Group and released to the public domain, as explained at * JSR-166 Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util; package java.util;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea and Josh Bloch with assistance from members of JCP * Written by Doug Lea and Josh Bloch with assistance from members of JCP
* JSR-166 Expert Group and released to the public domain, as explained at * JSR-166 Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util; package java.util;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util; package java.util;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea and Martin Buchholz with assistance from members of * Written by Doug Lea and Martin Buchholz with assistance from members of
* JCP JSR-166 Expert Group and released to the public domain, as explained * JCP JSR-166 Expert Group and released to the public domain, as explained
* at http://creativecommons.org/licenses/publicdomain * at http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea and Martin Buchholz with assistance from members of * Written by Doug Lea and Martin Buchholz with assistance from members of
* JCP JSR-166 Expert Group and released to the public domain, as explained * JCP JSR-166 Expert Group and released to the public domain, as explained
* at http://creativecommons.org/licenses/publicdomain * at http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* Written by Doug Lea, Bill Scherer, and Michael Scott with * Written by Doug Lea, Bill Scherer, and Michael Scott with
* assistance from members of JCP JSR-166 Expert Group and released to * assistance from members of JCP JSR-166 Expert Group and released to
* the public domain, as explained at * the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
...@@ -791,18 +791,19 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -791,18 +791,19 @@ public class ForkJoinPool extends AbstractExecutorService {
/** /**
* Tries to enqueue worker w in wait queue and await change in * Tries to enqueue worker w in wait queue and await change in
* worker's eventCount. If the pool is quiescent, possibly * worker's eventCount. If the pool is quiescent and there is
* terminates worker upon exit. Otherwise, before blocking, * more than one worker, possibly terminates worker upon exit.
* rescans queues to avoid missed signals. Upon finding work, * Otherwise, before blocking, rescans queues to avoid missed
* releases at least one worker (which may be the current * signals. Upon finding work, releases at least one worker
* worker). Rescans restart upon detected staleness or failure to * (which may be the current worker). Rescans restart upon
* release due to contention. Note the unusual conventions about * detected staleness or failure to release due to
* Thread.interrupt here and elsewhere: Because interrupts are * contention. Note the unusual conventions about Thread.interrupt
* used solely to alert threads to check termination, which is * here and elsewhere: Because interrupts are used solely to alert
* checked here anyway, we clear status (using Thread.interrupted) * threads to check termination, which is checked here anyway, we
* before any call to park, so that park does not immediately * clear status (using Thread.interrupted) before any call to
* return due to status being set via some other unrelated call to * park, so that park does not immediately return due to status
* interrupt in user code. * being set via some other unrelated call to interrupt in user
* code.
* *
* @param w the calling worker * @param w the calling worker
* @param c the ctl value on entry * @param c the ctl value on entry
...@@ -823,7 +824,7 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -823,7 +824,7 @@ public class ForkJoinPool extends AbstractExecutorService {
else if (w.eventCount != v) else if (w.eventCount != v)
return true; // update next time return true; // update next time
} }
if (parallelism + (int)(nc >> AC_SHIFT) == 0 && if ((int)c != 0 && parallelism + (int)(nc >> AC_SHIFT) == 0 &&
blockedCount == 0 && quiescerCount == 0) blockedCount == 0 && quiescerCount == 0)
idleAwaitWork(w, nc, c, v); // quiescent idleAwaitWork(w, nc, c, v); // quiescent
for (boolean rescanned = false;;) { for (boolean rescanned = false;;) {
...@@ -893,7 +894,8 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -893,7 +894,8 @@ public class ForkJoinPool extends AbstractExecutorService {
w.parked = false; w.parked = false;
if (w.eventCount != v) if (w.eventCount != v)
break; break;
else if (System.nanoTime() - startTime < SHRINK_RATE) else if (System.nanoTime() - startTime <
SHRINK_RATE - (SHRINK_RATE / 10)) // timing slop
Thread.interrupted(); // spurious wakeup Thread.interrupted(); // spurious wakeup
else if (UNSAFE.compareAndSwapLong(this, ctlOffset, else if (UNSAFE.compareAndSwapLong(this, ctlOffset,
currentCtl, prevCtl)) { currentCtl, prevCtl)) {
...@@ -1175,7 +1177,7 @@ public class ForkJoinPool extends AbstractExecutorService { ...@@ -1175,7 +1177,7 @@ public class ForkJoinPool extends AbstractExecutorService {
ws[k] = w; ws[k] = w;
nextWorkerIndex = k + 1; nextWorkerIndex = k + 1;
int m = g & SMASK; int m = g & SMASK;
g = k >= m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1); g = k > m? ((m << 1) + 1) & SMASK : g + (SG_UNIT<<1);
} }
} finally { } finally {
scanGuard = g; scanGuard = g;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* Written by Doug Lea, Bill Scherer, and Michael Scott with * Written by Doug Lea, Bill Scherer, and Michael Scott with
* assistance from members of JCP JSR-166 Expert Group and released to * assistance from members of JCP JSR-166 Expert Group and released to
* the public domain, as explained at * the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent; package java.util.concurrent;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.atomic; package java.util.concurrent.atomic;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
/** /**
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* *
* Written by Doug Lea with assistance from members of JCP JSR-166 * Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at * Expert Group and released to the public domain, as explained at
* http://creativecommons.org/licenses/publicdomain * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
package java.util.concurrent.locks; package java.util.concurrent.locks;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册