You need to sign in or sign up before continuing.
提交 baea10e4 编写于 作者: L lana

Merge

#
# 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.
#
#
# Variable definitions for SE Embedded builds. This file should
# not contain rules.
#
ifdef JAVASE_EMBEDDED
# Compress jar files
COMPRESS_JARS = true
# Don't mmap zip files
LIBZIP_CAN_USE_MMAP = false
# Disable ALSA version check
REQUIRED_ALSA_VERSION =
# Compilation settings
OTHER_CPPFLAGS += -DJAVASE_EMBEDDED
# Product naming
PRODUCT_SUFFIX = SE Runtime Environment for Embedded
RUNTIME_NAME = $(PRODUCT_NAME) $(PRODUCT_SUFFIX)
# Reduced JRE locations
JRE_REDUCED_HEADLESS_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-reduced-headless-image
JRE_REDUCED_IMAGE_DIR = $(ABS_OUTPUTDIR)/j2re-reduced-image
endif # JAVASE_EMBEDDED
...@@ -115,6 +115,12 @@ endif ...@@ -115,6 +115,12 @@ endif
include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk
#
# SE-Embedded support, if enabled
#
include $(JDK_TOPDIR)/make/common/Defs-embedded.gmk
# #
# Cross-compilation Settings # Cross-compilation Settings
# #
...@@ -144,7 +150,6 @@ ifdef BUILD_CLIENT_ONLY ...@@ -144,7 +150,6 @@ ifdef BUILD_CLIENT_ONLY
VM_NAME = client VM_NAME = client
endif endif
# #
# Freetype logic is applicable to OpenJDK only # Freetype logic is applicable to OpenJDK only
# #
......
# #
# 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
...@@ -78,7 +78,7 @@ LINKER=$(LINK.c) ...@@ -78,7 +78,7 @@ LINKER=$(LINK.c)
endif endif
$(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders $(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
@$(ECHO) Building lib:$(ACTUAL_LIBRARY)
# #
# COMPILE_APPROACH: Different approaches to compile up the native object # COMPILE_APPROACH: Different approaches to compile up the native object
# files as quickly as possible. # files as quickly as possible.
......
#
# 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.
#
#
# SE-Embedded Reduced JRE targets
#
ifdef JAVASE_EMBEDDED
reduced-image-jre reduced-headless-image-jre ::
@$(ECHO) ">>>Making "$@" @ `$(DATE)` ..."
# Add the reduced-jre images as pre-reqs. These will be processed last
images:: reduced-image-jre reduced-headless-image-jre
######################################################
# Create the headless rt.jar
######################################################
NOT_HEADLESS_RT_JAR_LIST = $(ABS_TEMPDIR)/not_hl_rt_jar.list
HEADLESS_RT_JAR_FILELIST=$(JARFILELISTS_TEMPDIR)/hl_rt_jar_list
TOTAL_HEADLESS_JAR_FILELIST=$(REORDER_TEMPDIR)/hl_file_list
HEADLESS_CLASSLIST=$(ABS_TEMPDIR)/headless_classlist
# Add the jar file directories that we don't want in the
# headless JRE. If you want to remove most classes in a
# directory, put the directory in the NOT_HEADLESS_RT_JAR_LIST
# and put the individual classes you want to keep in the
# HEADLESS_CLASSLIST file.
$(NOT_HEADLESS_RT_JAR_LIST): $(NOT_RT_JAR_LIST)
$(RM) $(HEADLESS_CLASSLIST)
$(RM) $(NOT_HEADLESS_RT_JAR_LIST)
$(CP) $(NOT_RT_JAR_LIST) $(NOT_HEADLESS_RT_JAR_LIST)
$(ECHO) "sun/awt/motif/" >> $@
$(ECHO) "sun/awt/X11/" >> $@
$(ECHO) "sun/applet/" >> $@
$(ECHO) "sun/java2d/opengl/" >> $@
$(ECHO) "com/sun/java/swing/plaf/" >> $@
$(ECHO) "sun/awt/motif/MFontConfiguration" >$(HEADLESS_CLASSLIST)
$(ECHO) "sun/applet/AppContextCreator" >>$(HEADLESS_CLASSLIST)
$(ECHO) "sun/applet/AppletAudioClip" >>$(HEADLESS_CLASSLIST)
$(ECHO) "sun/java2d/opengl/GLXSurfaceData" >>$(HEADLESS_CLASSLIST)
$(ECHO) "sun/java2d/opengl/GLXSurfaceData"\$$"GLXOffScreenSurfaceData" >>$(HEADLESS_CLASSLIST)
$(ECHO) "sun/java2d/opengl/GLXVolatileSurfaceManager" >>$(HEADLESS_CLASSLIST)
$(ECHO) "sun/java2d/opengl/OGLSurfaceData" >>$(HEADLESS_CLASSLIST)
$(TOTAL_HEADLESS_JAR_FILELIST): $(JARREORDER_JARFILE) $(NOT_HEADLESS_RT_JAR_LIST)
$(prep-target)
$(RM) $@.temp
$(CD) $(CLASSBINDIR) ; \
$(BOOT_JAVA_CMD) -jar $(JARREORDER_JARFILE) \
-o $@.temp $(HEADLESS_CLASSLIST) $(NOT_HEADLESS_RT_JAR_LIST) .
$(MV) $@.temp $@
@$(CD) $(CLASSBINDIR); $(java-vm-cleanup)
# Create the headless rt.jar file list & non-class files list
MakeHeadlessJarFileList: $(TOTAL_HEADLESS_JAR_FILELIST) $(JARSPLIT_JARFILE)
@$(RM) $(HEADLESS_RT_JAR_FILELIST) $(RES_JAR_FILELIST)
$(BOOT_JAVA_CMD) -jar $(JARSPLIT_JARFILE) $(TOTAL_HEADLESS_JAR_FILELIST) \
-o $(HEADLESS_RT_JAR_FILELIST) $(RES_JAR_FILELIST)
@$(java-vm-cleanup)
# Create headless rt.jar
HL_RT_JAR=$(ABS_TEMPDIR)/rt-hl-orig.jar
$(HL_RT_JAR): MakeHeadlessJarFileList $(JAR_MANIFEST_FILE)
$(prep-target)
$(CD) $(CLASSBINDIR) ; \
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ @$(HEADLESS_RT_JAR_FILELIST) \
$(JAR_JFLAGS)
@$(CD) $(CLASSBINDIR); $(java-vm-cleanup)
#
# Produce a reduced Headful JRE for Embedded Devices
#
# The deployment binaries are added during the deployment build process
#
# Binaries that don't get included in reduced jre image bin directory
NOT_REDUCEDJRE_BIN = \
java_vm \
kinit \
klist \
ktab \
orbd \
policytool \
rmid \
rmiregistry \
servertool \
tnameserv \
pack200 \
unpack200
# jars/resources/libs that don't get included in reduced jre image lib directory
NOT_REDUCEDJRE_LIB = \
charsets.jar \
ext/dnsns.jar \
ext/localedata.jar \
$(LIBARCH)/client/classes.jsa \
$(LIBARCH)/libjavaplugin_jni.so \
$(LIBARCH)/libjavaplugin_nscp_gcc29.so \
$(LIBARCH)/libjavaplugin_nscp.so \
$(LIBARCH)/libjavaplugin_oji.so
ifeq ($(PLATFORM), linux)
STRIP_OPTS = --strip-unneeded
else
STRIP_OPTS = -x
endif
reduced-image-jre::
@$(ECHO) Starting to Produce Reduced JRE
@#
@# First make a copy of the full JRE
@#
$(RM) -r $(JRE_REDUCED_IMAGE_DIR)
$(MKDIR) -p $(JRE_REDUCED_IMAGE_DIR)
$(CD) $(JRE_IMAGE_DIR); \
$(TAR) cf - . | ($(CD) $(JRE_REDUCED_IMAGE_DIR); $(TAR) xf - );
@# strip the main .so files
$(STRIP) $(STRIP_OPTS) $(JRE_REDUCED_IMAGE_DIR)/lib/$(LIBARCH)/client/libjvm.so
ifndef BUILD_CLIENT_ONLY
$(STRIP) $(STRIP_OPTS) $(JRE_REDUCED_IMAGE_DIR)/lib/$(LIBARCH)/server/libjvm.so
endif
@#
@# Remove all of the files that are not needed for the
@# reduced JRE
@#
for l in $(NOT_REDUCEDJRE_BIN) ; do \
$(RM) $(JRE_REDUCED_IMAGE_DIR)/bin/$$l ; \
done
for l in $(NOT_REDUCEDJRE_LIB) ; do \
$(RM) $(JRE_REDUCED_IMAGE_DIR)/lib/$$l ; \
done
@# Remove misc. other files
$(RM) -r $(JRE_REDUCED_IMAGE_DIR)/man
$(RM) -f $(JRE_REDUCED_IMAGE_DIR)/CHANGES
@$(ECHO) Done Creating Reduced JRE
#
# Produce a reduced Headless JRE
#
reduced-headless-image-jre:: $(RT_JAR) $(RESOURCES_JAR) $(BUILD_META_INDEX) $(HL_RT_JAR)
@$(ECHO) Starting to Produce Reduced Headless JRE
@#
@# First make a copy of the reduced JRE we just built
@#
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)
$(MKDIR) -p $(JRE_REDUCED_HEADLESS_IMAGE_DIR)
$(CD) $(JRE_REDUCED_IMAGE_DIR); \
$(TAR) cf - . | ($(CD) $(JRE_REDUCED_HEADLESS_IMAGE_DIR); $(TAR) xf - );
@# Replace the full rt.jar with the headless rt.jar
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
$(CP) $(HL_RT_JAR) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
@#
@# Remove all of the files that are not needed for the
@# reduced Headless JRE
@#
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/gtkhelper
$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libjsoundalsa.so
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/audio
$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/applet
$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/awt_robot
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/xawt
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libsplashscreen.so
@# Remove oblique fonts and reduce font support to LucidaSansRegular only
$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/oblique-fonts
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiBold.ttf
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiItalic.ttf
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightItalic.ttf
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightRegular.ttf
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaSansDemiBold.ttf
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterBold.ttf
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterRegular.ttf
ifeq ($(PLATFORM), linux)
# put out minimal fonts.dir file for the remaining font
$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) 6>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-1">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-2">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-4">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-5">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-7">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-9">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
endif # Linux
@#
@# all done with JRE reduced headless image
@#
@$(ECHO) Done Creating Reduced Headless JRE
images-clobber::
$(RM) -r $(JRE_REDUCED_IMAGE_DIR)
$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)
.PHONY: reduced-image-jre reduced-headless-image-jre
endif # JAVASE_EMBEDDED
...@@ -38,7 +38,7 @@ THIS_JDK_VERSION := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSIO ...@@ -38,7 +38,7 @@ THIS_JDK_VERSION := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSIO
IMAGE_BINDIR = bin IMAGE_BINDIR = bin
# The compiler should not issue a "Sun Propietary" warning when compiling # The compiler should not issue a "Proprietary" warning when compiling
# classes in the com.sun.java.swing.plaf packages, since we've always # classes in the com.sun.java.swing.plaf packages, since we've always
# allowed, and even advocated, extending them (see bug 6476749). # allowed, and even advocated, extending them (see bug 6476749).
# #
...@@ -195,6 +195,16 @@ if [ "$(JA_DIRNAME)" != "" ] ; then \ ...@@ -195,6 +195,16 @@ if [ "$(JA_DIRNAME)" != "" ] ; then \
fi fi
endef endef
# no compression unless requested
ifndef COMPRESS_JARS
CREATE_JAR_OPTS = c0mf
CREATE_JAR_OPTS_NOMANIFEST = c0f
else
CREATE_JAR_OPTS = cmf
CREATE_JAR_OPTS_NOMANIFEST = cf
endif
# #
# Targets. # Targets.
# #
...@@ -613,7 +623,7 @@ RESOURCES_JAR=$(ABS_TEMPDIR)/resources-orig.jar ...@@ -613,7 +623,7 @@ RESOURCES_JAR=$(ABS_TEMPDIR)/resources-orig.jar
$(RESOURCES_JAR): $(RES_JAR_FILELIST) $(JAR_MANIFEST_FILE) $(RESOURCES_JAR): $(RES_JAR_FILELIST) $(JAR_MANIFEST_FILE)
$(prep-target) $(prep-target)
$(CD) $(CLASSBINDIR) && \ $(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ \
@$(RES_JAR_FILELIST) $(BOOT_JAR_JFLAGS) @$(RES_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup) @$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
...@@ -622,7 +632,7 @@ JSSE_JAR=$(ABS_TEMPDIR)/jsse-orig.jar ...@@ -622,7 +632,7 @@ JSSE_JAR=$(ABS_TEMPDIR)/jsse-orig.jar
$(JSSE_JAR): $(JAR_MANIFEST_FILE) $(JSSE_JAR): $(JAR_MANIFEST_FILE)
$(prep-target) $(prep-target)
$(CD) $(CLASSBINDIR) && \ $(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ \
$(JSSE_CLASSES_DIRS) $(BOOT_JAR_JFLAGS) $(JSSE_CLASSES_DIRS) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup) @$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
...@@ -669,7 +679,7 @@ RT_JAR=$(ABS_TEMPDIR)/rt-orig.jar ...@@ -669,7 +679,7 @@ RT_JAR=$(ABS_TEMPDIR)/rt-orig.jar
$(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE) $(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE)
$(prep-target) $(prep-target)
$(CD) $(CLASSBINDIR) && \ $(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ \
@$(RT_JAR_FILELIST) $(BOOT_JAR_JFLAGS) @$(RT_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup) @$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
...@@ -677,6 +687,10 @@ $(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE) ...@@ -677,6 +687,10 @@ $(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE)
BUILDMETAINDEX_JARFILE = $(ABS_BUILDTOOLJARDIR)/buildmetaindex.jar BUILDMETAINDEX_JARFILE = $(ABS_BUILDTOOLJARDIR)/buildmetaindex.jar
# SE-Embedded targets if enabled
include $(JDK_TOPDIR)/make/common/Release-embedded.gmk
###################################################### ######################################################
# JRE Image # JRE Image
###################################################### ######################################################
...@@ -924,7 +938,7 @@ initial-image-jdk:: initial-image-jdk-setup \ ...@@ -924,7 +938,7 @@ initial-image-jdk:: initial-image-jdk-setup \
@# lib/tools.jar @# lib/tools.jar
@# @#
$(CD) $(CLASSBINDIR) && \ $(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0f $(ABS_LIBDIR)/tools.jar \ $(BOOT_JAR_CMD) $(CREATE_JAR_OPTS_NOMANIFEST) $(ABS_LIBDIR)/tools.jar \
$(TOOLS) $(BOOT_JAR_JFLAGS) $(TOOLS) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup) @$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
$(CP) $(LIBDIR)/tools.jar $(JDK_IMAGE_DIR)/lib/tools.jar $(CP) $(LIBDIR)/tools.jar $(JDK_IMAGE_DIR)/lib/tools.jar
...@@ -937,7 +951,7 @@ initial-image-jdk:: initial-image-jdk-setup \ ...@@ -937,7 +951,7 @@ initial-image-jdk:: initial-image-jdk-setup \
-Acom.sun.tools.javac.sym.Jar=$(RT_JAR) \ -Acom.sun.tools.javac.sym.Jar=$(RT_JAR) \
-Acom.sun.tools.javac.sym.Dest=$(OUTPUTDIR)/symbols/META-INF/sym/rt.jar \ -Acom.sun.tools.javac.sym.Dest=$(OUTPUTDIR)/symbols/META-INF/sym/rt.jar \
$(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS) $(EXPORTED_PRIVATE_PKGS) $(CORE_PKGS) $(NON_CORE_PKGS) $(EXCLUDE_PROPWARN_PKGS) $(EXPORTED_PRIVATE_PKGS)
$(BOOT_JAR_CMD) c0f $(LIBDIR)/ct.sym \ $(BOOT_JAR_CMD) $(CREATE_JAR_OPTS_NOMANIFEST) $(LIBDIR)/ct.sym \
-C $(OUTPUTDIR)/symbols META-INF $(BOOT_JAR_JFLAGS) -C $(OUTPUTDIR)/symbols META-INF $(BOOT_JAR_JFLAGS)
@$(java-vm-cleanup) @$(java-vm-cleanup)
$(CP) $(LIBDIR)/ct.sym $(JDK_IMAGE_DIR)/lib/ct.sym $(CP) $(LIBDIR)/ct.sym $(JDK_IMAGE_DIR)/lib/ct.sym
......
...@@ -185,7 +185,9 @@ ifeq ($(PLATFORM),windows) ...@@ -185,7 +185,9 @@ ifeq ($(PLATFORM),windows)
endif endif
endif endif
ifeq ($(PLATFORM),linux) ifeq ($(PLATFORM),linux)
ifdef REQUIRED_ALSA_VERSION
ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION) ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
endif
endif endif
ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION) ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION)
ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_NAME) ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_NAME)
......
...@@ -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)
......
...@@ -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
# #
......
...@@ -37,10 +37,6 @@ include FILES_c.gmk ...@@ -37,10 +37,6 @@ include FILES_c.gmk
AUTO_FILES_JAVA_DIRS = java/net AUTO_FILES_JAVA_DIRS = java/net
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
# Windows 9x module only needed on 32-bit build
ifeq ($(ARCH_DATA_MODEL), 32)
FILES_c += NetworkInterface_win9x.c
endif
FILES_c += NTLMAuthSequence.c FILES_c += NTLMAuthSequence.c
FILES_c += NetworkInterface_winXP.c FILES_c += NetworkInterface_winXP.c
else else
...@@ -96,7 +92,9 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk ...@@ -96,7 +92,9 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
OTHER_LDLIBS = ws2_32.lib $(JVMLIB) OTHER_LDLIBS = ws2_32.lib $(JVMLIB) \
secur32.lib iphlpapi.lib delayimp.lib \
/DELAYLOAD:secur32.dll /DELAYLOAD:iphlpapi.dll
else else
OTHER_LDLIBS = $(LIBSOCKET) $(LIBNSL) -ldl $(JVMLIB) OTHER_LDLIBS = $(LIBSOCKET) $(LIBNSL) -ldl $(JVMLIB)
endif endif
......
# #
# 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
...@@ -50,7 +50,10 @@ FILES_export = \ ...@@ -50,7 +50,10 @@ FILES_export = \
java/util/jar/JarFile.java java/util/jar/JarFile.java
ifneq ($(PLATFORM), windows) ifneq ($(PLATFORM), windows)
OTHER_CFLAGS += -DUSE_MMAP # Use mmap unless explicitly disallowed
ifneq ($(LIBZIP_CAN_USE_MMAP),false)
OTHER_CFLAGS += -DUSE_MMAP
endif
endif endif
# #
......
...@@ -52,8 +52,11 @@ jprt.build.targets= \ ...@@ -52,8 +52,11 @@ jprt.build.targets= \
${jprt.my.windows.i586}-{product|fastdebug}, \ ${jprt.my.windows.i586}-{product|fastdebug}, \
windows_x64_5.2-{product|fastdebug} windows_x64_5.2-{product|fastdebug}
# User can select the test set with jprt submit "-testset name" option
jprt.my.test.set=${jprt.test.set}
# Standard vm test target # Standard vm test target
jprt.test.targets= \ jprt.vm.default.test.targets= \
solaris_sparc_5.10-product-c1-jvm98, \ solaris_sparc_5.10-product-c1-jvm98, \
solaris_sparcv9_5.10-product-c2-jvm98, \ solaris_sparcv9_5.10-product-c2-jvm98, \
solaris_i586_5.10-product-c1-jvm98, \ solaris_i586_5.10-product-c1-jvm98, \
...@@ -63,8 +66,10 @@ jprt.test.targets= \ ...@@ -63,8 +66,10 @@ jprt.test.targets= \
${jprt.my.windows.i586}-product-c1-jvm98, \ ${jprt.my.windows.i586}-product-c1-jvm98, \
windows_x64_5.2-product-c2-jvm98 windows_x64_5.2-product-c2-jvm98
# User can select the test set with jprt submit "-testset name" option # Select vm testlist to use (allow for testset to be empty too)
jprt.my.test.set=${jprt.test.set} jprt.vm.all.test.targets=${jprt.vm.default.test.targets}
jprt.vm..test.targets=${jprt.vm.default.test.targets}
jprt.test.targets=${jprt.vm.${jprt.my.test.set}.test.targets}
# Default jdk test targets in test/Makefile (no fastdebug & limited c2) # Default jdk test targets in test/Makefile (no fastdebug & limited c2)
jprt.make.rule.default.test.targets= \ jprt.make.rule.default.test.targets= \
...@@ -281,6 +286,21 @@ jprt.make.rule.all.test.targets= \ ...@@ -281,6 +286,21 @@ jprt.make.rule.all.test.targets= \
${jprt.my.windows.i586}-product-c1-jdk_tools2, \ ${jprt.my.windows.i586}-product-c1-jdk_tools2, \
windows_x64_5.2-product-c2-jdk_tools2 windows_x64_5.2-product-c2-jdk_tools2
# JCK test targets in test/Makefile (no fastdebug & limited c2, windows broken)
jprt.my.jck.test.target.set= \
solaris_sparc_5.10-product-c1-JCK7TESTRULE, \
solaris_sparcv9_5.10-product-c2-JCK7TESTRULE, \
solaris_i586_5.10-product-c1-JCK7TESTRULE, \
solaris_x64_5.10-product-c2-JCK7TESTRULE, \
linux_i586_2.6-product-c1-JCK7TESTRULE, \
linux_x64_2.6-product-c2-JCK7TESTRULE
# JCK testset targets (e.g. jprt submit -testset jck ... )
jprt.make.rule.jck.test.targets= \
${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7devtools}, \
${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7runtime}, \
${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7compiler}
# Select list to use (allow for testset to be empty too) # Select list to use (allow for testset to be empty too)
jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets} jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets}
jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets} jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets}
......
# #
# 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
...@@ -44,8 +44,17 @@ $(MAKE) -f Makefile.launcher \ ...@@ -44,8 +44,17 @@ $(MAKE) -f Makefile.launcher \
endef endef
# Run MAKE $@ for all generic launchers # Run MAKE $@ for all generic launchers
define make-all-launchers ifndef BUILD_HEADLESS_ONLY
define make-appletviewer
$(call make-launcher, appletviewer, sun.applet.Main, , ) $(call make-launcher, appletviewer, sun.applet.Main, , )
endef
else
define make-appletviewer
endef
endif
define make-all-launchers
$(make-appletviewer)
$(call make-launcher, apt, com.sun.tools.apt.Main, , ) $(call make-launcher, apt, com.sun.tools.apt.Main, , )
$(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , ) $(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
$(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , ) $(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
......
# #
# 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
...@@ -69,10 +69,17 @@ endif ...@@ -69,10 +69,17 @@ endif
# nio need to be compiled before awt to have all charsets ready # nio need to be compiled before awt to have all charsets ready
SUBDIRS = jar security javazic misc net nio text launcher SUBDIRS = jar security javazic misc net nio text launcher
ifdef BUILD_HEADLESS_ONLY
DISPLAY_LIBS = awt $(HEADLESS_SUBDIR)
DISPLAY_TOOLS =
else
DISPLAY_LIBS = awt splashscreen $(XAWT_SUBDIR) $(HEADLESS_SUBDIR)
DISPLAY_TOOLS = applet
endif
SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \ SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \
awt splashscreen $(XAWT_SUBDIR) \ $(DISPLAY_LIBS) $(DGA_SUBDIR) \
$(HEADLESS_SUBDIR) $(DGA_SUBDIR) \ jawt font jpeg cmm $(DISPLAY_TOOLS) beans
jawt font jpeg cmm applet beans
SUBDIRS_management = management SUBDIRS_management = management
SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing
SUBDIRS_tools = native2ascii serialver tools jconsole SUBDIRS_tools = native2ascii serialver tools jconsole
......
# #
# Copyright (c) 2000, 2007, 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
...@@ -149,13 +149,13 @@ ifeq ($(PLATFORM), linux) ...@@ -149,13 +149,13 @@ ifeq ($(PLATFORM), linux)
LIBXT = -lXt LIBXT = -lXt
else else
# Allows for builds on Debian GNU Linux, X11 is in a different place # Allows for builds on Debian GNU Linux, X11 is in a different place
LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \ LIBXT = $(firstword $(wildcard $(OPENWIN_LIB)/libXt.a) \
$(wildcard /usr/lib/libXt.a)) $(wildcard /usr/lib/libXt.a))
LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \ LIBSM = $(firstword $(wildcard $(OPENWIN_LIB)/libSM.a) \
$(wildcard /usr/lib/libSM.a)) $(wildcard /usr/lib/libSM.a))
LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \ LIBICE = $(firstword $(wildcard $(OPENWIN_LIB)/libICE.a) \
$(wildcard /usr/lib/libICE.a)) $(wildcard /usr/lib/libICE.a))
LIBXTST = $(firstword $(wildcard /usr/X11R6/lib/libXtst.a) \ LIBXTST = $(firstword $(wildcard $(OPENWIN_LIB)/libXtst.a) \
$(wildcard /usr/lib/libXtst.a)) $(wildcard /usr/lib/libXtst.a))
endif endif
endif endif
...@@ -224,9 +224,9 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \ ...@@ -224,9 +224,9 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
$(EVENT_MODEL) $(EVENT_MODEL)
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
# Checking for the X11/extensions headers at the additional location # Checking for the X11/extensions headers at the additional location
CPPFLAGS += -I/X11R6/include/X11/extensions \ CPPFLAGS += -I$(firstword $(wildcard $(OPENWIN_HOME)/include/X11/extensions) \
-I/usr/include/X11/extensions $(wildcard /usr/include/X11/extensions))
endif endif
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
......
# #
# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1999, 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
...@@ -112,11 +112,20 @@ CPPFLAGS += -I$(OPENWIN_HOME)/include \ ...@@ -112,11 +112,20 @@ CPPFLAGS += -I$(OPENWIN_HOME)/include \
# Libraries to link in. # Libraries to link in.
# #
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender ifndef BUILD_HEADLESS_ONLY
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
else
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/headless -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
endif
endif # PLATFORM endif # PLATFORM
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt ifndef BUILD_HEADLESS_ONLY
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
else
OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/headless -lmawt
CFLAGS += -DHEADLESS
endif
endif # PLATFORM endif # PLATFORM
endif # PLATFORM endif # PLATFORM
......
...@@ -73,9 +73,10 @@ ifeq ($(PLATFORM), linux) ...@@ -73,9 +73,10 @@ ifeq ($(PLATFORM), linux)
# Recommended way to avoid such warning is to declare the variable as # Recommended way to avoid such warning is to declare the variable as
# volatile to prevent the optimization. However, this approach does not # volatile to prevent the optimization. However, this approach does not
# work because we have to declare all variables as volatile in result. # work because we have to declare all variables as volatile in result.
ifndef CROSS_COMPILE_ARCH
OTHER_CFLAGS += -Wno-clobbered OTHER_CFLAGS += -Wno-clobbered
endif endif
endif
include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk include $(BUILDDIR)/common/Library.gmk
......
# #
# 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
...@@ -120,8 +120,15 @@ $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \ ...@@ -120,8 +120,15 @@ $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
$(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH) $(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH)
$(install-file) $(install-file)
# no compression unless requested
ifndef COMPRESS_JARS
CREATE_JAR_OPTS_NOMANIFEST = cf0
else
CREATE_JAR_OPTS_NOMANIFEST = cf
endif
$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT) $(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT)
$(BOOT_JAR_CMD) cf0 $(CHARSETS_JAR) \ $(BOOT_JAR_CMD) $(CREATE_JAR_OPTS_NOMANIFEST) $(CHARSETS_JAR) \
-C $(CLASSDESTDIR) sun \ -C $(CLASSDESTDIR) sun \
-C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \ -C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \
$(BOOT_JAR_JFLAGS) $(BOOT_JAR_JFLAGS)
......
# #
# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1997, 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
...@@ -46,5 +46,7 @@ include $(BUILDDIR)/common/Classes.gmk ...@@ -46,5 +46,7 @@ include $(BUILDDIR)/common/Classes.gmk
build: build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , ) $(call make-launcher, keytool, sun.security.tools.KeyTool, , )
ifndef BUILD_HEADLESS_ONLY
$(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , ) $(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , )
endif
# #
# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2002, 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
...@@ -129,10 +129,17 @@ CPPFLAGS += -DXAWT -DXAWT_HACK \ ...@@ -129,10 +129,17 @@ CPPFLAGS += -DXAWT -DXAWT_HACK \
-I$(PLATFORM_SRC)/native/sun/awt -I$(PLATFORM_SRC)/native/sun/awt
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
# Allows for builds on Debian GNU Linux, X11 is in a different place ifndef CROSS_COMPILE_ARCH
# Allows for builds on Debian GNU Linux, X11 is in a different place
# This should really be handled at a higher-level so we don't have to
# work-around this when cross-compiling
CPPFLAGS += -I/usr/X11R6/include/X11/extensions \ CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
-I/usr/include/X11/extensions \ -I/usr/include/X11/extensions \
-I$(OPENWIN_HOME)/include -I$(OPENWIN_HOME)/include
else
CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
-I$(OPENWIN_HOME)/include
endif
endif endif
# We have some odd logic here because some Solaris 10 updates # We have some odd logic here because some Solaris 10 updates
...@@ -245,7 +252,11 @@ XLIBTYPES=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/xlibtypes.txt ...@@ -245,7 +252,11 @@ XLIBTYPES=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/xlibtypes.txt
$(SIZERS): $(SIZERS_C) $(SIZERS): $(SIZERS_C)
$(prep-target) $(prep-target)
ifndef CROSS_COMPILE_ARCH
$(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c $(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
else
$(HOST_CC) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
endif
$(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA) $(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA)
$(prep-target) $(prep-target)
......
/* /*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 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
...@@ -30,13 +30,14 @@ import java.lang.RuntimePermission; ...@@ -30,13 +30,14 @@ import java.lang.RuntimePermission;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.SocketPermission; import java.net.SocketPermission;
import java.net.URL; import java.net.URL;
import java.security.GeneralSecurityException;
import java.text.MessageFormat;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Vector; import java.util.Vector;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.security.GeneralSecurityException;
import sun.security.util.PropertyExpander; import sun.security.util.PropertyExpander;
/** /**
...@@ -368,8 +369,8 @@ class PolicyParser { ...@@ -368,8 +369,8 @@ class PolicyParser {
"WILDCARD class but no WILDCARD name"); "WILDCARD class but no WILDCARD name");
throw new ParsingException throw new ParsingException
(st.lineno(), (st.lineno(),
rb.getString("can.not.specify.Principal.with.a.") + rb.getString("can.not.specify.Principal.with.a." +
rb.getString("wildcard.class.without.a.wildcard.name")); "wildcard.class.without.a.wildcard.name"));
} }
try { try {
...@@ -525,9 +526,10 @@ class PolicyParser { ...@@ -525,9 +526,10 @@ class PolicyParser {
rb.getString("number.") + rb.getString("number.") +
String.valueOf(st.nval)); String.valueOf(st.nval));
case StreamTokenizer.TT_EOF: case StreamTokenizer.TT_EOF:
throw new ParsingException MessageFormat form = new MessageFormat(
(rb.getString("expected.") + expect + rb.getString("expected.expect.read.end.of.file."));
rb.getString(".read.end.of.file")); Object[] source = {expect};
throw new ParsingException(form.format(source));
case StreamTokenizer.TT_WORD: case StreamTokenizer.TT_WORD:
if (expect.equalsIgnoreCase(st.sval)) { if (expect.equalsIgnoreCase(st.sval)) {
lookahead = st.nextToken(); lookahead = st.nextToken();
......
/* /*
* 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
...@@ -858,7 +858,7 @@ public abstract class Toolkit { ...@@ -858,7 +858,7 @@ public abstract class Toolkit {
String nm = null; String nm = null;
Class cls = null; Class cls = null;
try { try {
nm = System.getProperty("awt.toolkit", "sun.awt.X11.XToolkit"); nm = System.getProperty("awt.toolkit");
try { try {
cls = Class.forName(nm); cls = Class.forName(nm);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
......
/* /*
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 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
...@@ -30,15 +30,18 @@ package java.lang; ...@@ -30,15 +30,18 @@ package java.lang;
* example, an integer "divide by zero" throws an * example, an integer "divide by zero" throws an
* instance of this class. * instance of this class.
* *
* {@code ArithmeticException} objects may be constructed by the
* virtual machine as if {@linkplain Throwable#Throwable(String,
* Throwable, boolean) suppression were disabled}.
*
* @author unascribed * @author unascribed
* @since JDK1.0 * @since JDK1.0
*/ */
public public class ArithmeticException extends RuntimeException {
class ArithmeticException extends RuntimeException {
private static final long serialVersionUID = 2256477558314496007L; private static final long serialVersionUID = 2256477558314496007L;
/** /**
* Constructs an <code>ArithmeticException</code> with no detail * Constructs an {@code ArithmeticException} with no detail
* message. * message.
*/ */
public ArithmeticException() { public ArithmeticException() {
...@@ -46,7 +49,7 @@ class ArithmeticException extends RuntimeException { ...@@ -46,7 +49,7 @@ class ArithmeticException extends RuntimeException {
} }
/** /**
* Constructs an <code>ArithmeticException</code> with the specified * Constructs an {@code ArithmeticException} with the specified
* detail message. * detail message.
* *
* @param s the detail message. * @param s the detail message.
......
/* /*
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 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,20 +26,24 @@ ...@@ -26,20 +26,24 @@
package java.lang; package java.lang;
/** /**
* Thrown when an application attempts to use <code>null</code> in a * Thrown when an application attempts to use {@code null} in a
* case where an object is required. These include: * case where an object is required. These include:
* <ul> * <ul>
* <li>Calling the instance method of a <code>null</code> object. * <li>Calling the instance method of a {@code null} object.
* <li>Accessing or modifying the field of a <code>null</code> object. * <li>Accessing or modifying the field of a {@code null} object.
* <li>Taking the length of <code>null</code> as if it were an array. * <li>Taking the length of {@code null} as if it were an array.
* <li>Accessing or modifying the slots of <code>null</code> as if it * <li>Accessing or modifying the slots of {@code null} as if it
* were an array. * were an array.
* <li>Throwing <code>null</code> as if it were a <code>Throwable</code> * <li>Throwing {@code null} as if it were a {@code Throwable}
* value. * value.
* </ul> * </ul>
* <p> * <p>
* Applications should throw instances of this class to indicate * Applications should throw instances of this class to indicate
* other illegal uses of the <code>null</code> object. * other illegal uses of the {@code null} object.
*
* {@code NullPointerException} objects may be constructed by the
* virtual machine as if {@linkplain Throwable#Throwable(String,
* Throwable, boolean) suppression were disabled}.
* *
* @author unascribed * @author unascribed
* @since JDK1.0 * @since JDK1.0
...@@ -49,14 +53,14 @@ class NullPointerException extends RuntimeException { ...@@ -49,14 +53,14 @@ class NullPointerException extends RuntimeException {
private static final long serialVersionUID = 5162710183389028792L; private static final long serialVersionUID = 5162710183389028792L;
/** /**
* Constructs a <code>NullPointerException</code> with no detail message. * Constructs a {@code NullPointerException} with no detail message.
*/ */
public NullPointerException() { public NullPointerException() {
super(); super();
} }
/** /**
* Constructs a <code>NullPointerException</code> with the specified * Constructs a {@code NullPointerException} with the specified
* detail message. * detail message.
* *
* @param s the detail message. * @param s the detail message.
......
/* /*
* Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 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
...@@ -30,22 +30,25 @@ package java.lang; ...@@ -30,22 +30,25 @@ package java.lang;
* because it is out of memory, and no more memory could be made * because it is out of memory, and no more memory could be made
* available by the garbage collector. * available by the garbage collector.
* *
* {@code OutOfMemoryError} objects may be constructed by the virtual
* machine as if {@linkplain Throwable#Throwable(String, Throwable,
* boolean) suppression were disabled}.
*
* @author unascribed * @author unascribed
* @since JDK1.0 * @since JDK1.0
*/ */
public public class OutOfMemoryError extends VirtualMachineError {
class OutOfMemoryError extends VirtualMachineError {
private static final long serialVersionUID = 8228564086184010517L; private static final long serialVersionUID = 8228564086184010517L;
/** /**
* Constructs an <code>OutOfMemoryError</code> with no detail message. * Constructs an {@code OutOfMemoryError} with no detail message.
*/ */
public OutOfMemoryError() { public OutOfMemoryError() {
super(); super();
} }
/** /**
* Constructs an <code>OutOfMemoryError</code> with the specified * Constructs an {@code OutOfMemoryError} with the specified
* detail message. * detail message.
* *
* @param s the detail message. * @param s the detail message.
......
...@@ -46,13 +46,16 @@ import java.util.*; ...@@ -46,13 +46,16 @@ import java.util.*;
* are freshly created in the context of the exceptional situation so * are freshly created in the context of the exceptional situation so
* as to include relevant information (such as stack trace data). * as to include relevant information (such as stack trace data).
* *
* <p>A throwable contains a snapshot of the execution stack of its thread at * <p>A throwable contains a snapshot of the execution stack of its
* the time it was created. It can also contain a message string that gives * thread at the time it was created. It can also contain a message
* more information about the error. Finally, it can contain a <i>cause</i>: * string that gives more information about the error. Over time, a
* another throwable that caused this throwable to get thrown. The cause * throwable can {@linkplain Throwable#addSuppressed suppress} other
* facility is new in release 1.4. It is also known as the <i>chained * throwables from being propagated. Finally, the throwable can also
* exception</i> facility, as the cause can, itself, have a cause, and so on, * contain a <i>cause</i>: another throwable that caused this
* leading to a "chain" of exceptions, each caused by another. * throwable to be constructed. The recording of this causal information
* is referred to as the <i>chained exception</i> facility, as the
* cause can, itself, have a cause, and so on, leading to a "chain" of
* exceptions, each caused by another.
* *
* <p>One reason that a throwable may have a cause is that the class that * <p>One reason that a throwable may have a cause is that the class that
* throws it is built atop a lower layered abstraction, and an operation on * throws it is built atop a lower layered abstraction, and an operation on
...@@ -86,47 +89,12 @@ import java.util.*; ...@@ -86,47 +89,12 @@ import java.util.*;
* {@link #initCause(Throwable)} method. New throwable classes that * {@link #initCause(Throwable)} method. New throwable classes that
* wish to allow causes to be associated with them should provide constructors * wish to allow causes to be associated with them should provide constructors
* that take a cause and delegate (perhaps indirectly) to one of the * that take a cause and delegate (perhaps indirectly) to one of the
* {@code Throwable} constructors that takes a cause. For example: * {@code Throwable} constructors that takes a cause.
* <pre> *
* try {
* lowLevelOp();
* } catch (LowLevelException le) {
* throw new HighLevelException(le); // Chaining-aware constructor
* }
* </pre>
* Because the {@code initCause} method is public, it allows a cause to be * Because the {@code initCause} method is public, it allows a cause to be
* associated with any throwable, even a "legacy throwable" whose * associated with any throwable, even a "legacy throwable" whose
* implementation predates the addition of the exception chaining mechanism to * implementation predates the addition of the exception chaining mechanism to
* {@code Throwable}. For example: * {@code Throwable}.
* <pre>
* try {
* lowLevelOp();
* } catch (LowLevelException le) {
* throw (HighLevelException)
* new HighLevelException().initCause(le); // Legacy constructor
* }
* </pre>
*
* <p>Prior to release 1.4, there were many throwables that had their own
* non-standard exception chaining mechanisms (
* {@link ExceptionInInitializerError}, {@link ClassNotFoundException},
* {@link java.lang.reflect.UndeclaredThrowableException},
* {@link java.lang.reflect.InvocationTargetException},
* {@link java.io.WriteAbortedException},
* {@link java.security.PrivilegedActionException},
* {@link java.awt.print.PrinterIOException},
* {@link java.rmi.RemoteException} and
* {@link javax.naming.NamingException}).
* All of these throwables have been retrofitted to
* use the standard exception chaining mechanism, while continuing to
* implement their "legacy" chaining mechanisms for compatibility.
*
* <p>Further, as of release 1.4, many general purpose {@code Throwable}
* classes (for example {@link Exception}, {@link RuntimeException},
* {@link Error}) have been retrofitted with constructors that take
* a cause. This was not strictly necessary, due to the existence of the
* {@code initCause} method, but it is more convenient and expressive to
* delegate to a constructor that takes a cause.
* *
* <p>By convention, class {@code Throwable} and its subclasses have two * <p>By convention, class {@code Throwable} and its subclasses have two
* constructors, one that takes no arguments and one that takes a * constructors, one that takes no arguments and one that takes a
...@@ -137,14 +105,6 @@ import java.util.*; ...@@ -137,14 +105,6 @@ import java.util.*;
* {@code String} (the detail message) and a {@code Throwable} (the * {@code String} (the detail message) and a {@code Throwable} (the
* cause). * cause).
* *
* <p>Also introduced in release 1.4 is the {@link #getStackTrace()} method,
* which allows programmatic access to the stack trace information that was
* previously available only in text form, via the various forms of the
* {@link #printStackTrace()} method. This information has been added to the
* <i>serialized representation</i> of this class so {@code getStackTrace}
* and {@code printStackTrace} will operate properly on a throwable that
* was obtained by deserialization.
*
* @author unascribed * @author unascribed
* @author Josh Bloch (Added exception chaining and programmatic access to * @author Josh Bloch (Added exception chaining and programmatic access to
* stack trace in 1.4.) * stack trace in 1.4.)
...@@ -322,6 +282,41 @@ public class Throwable implements Serializable { ...@@ -322,6 +282,41 @@ public class Throwable implements Serializable {
this.cause = cause; this.cause = cause;
} }
/**
* Constructs a new throwable with the specified detail message,
* cause, and {@linkplain #addSuppressed suppression} enabled or
* disabled. If suppression is disabled, {@link #getSuppressed}
* for this object will return a zero-length array and calls to
* {@link #addSuppressed} that would otherwise append an exception
* to the suppressed list will have no effect.
*
* <p>Note that the other constructors of {@code Throwable} treat
* suppression as being enabled. Subclasses of {@code Throwable}
* should document any conditions under which suppression is
* disabled. Disabling of suppression should only occur in
* exceptional circumstances where special requirements exist,
* such as a virtual machine reusing exception objects under
* low-memory situations.
*
* @param message the detail message.
* @param cause the cause. (A {@code null} value is permitted,
* and indicates that the cause is nonexistent or unknown.)
* @param enableSuppression whether or not suppression is enabled or disabled
*
* @see OutOfMemoryError
* @see NullPointerException
* @see ArithmeticException
* @since 1.7
*/
protected Throwable(String message, Throwable cause,
boolean enableSuppression) {
fillInStackTrace();
detailMessage = message;
this.cause = cause;
if (!enableSuppression)
suppressedExceptions = null;
}
/** /**
* Returns the detail message string of this throwable. * Returns the detail message string of this throwable.
* *
...@@ -870,43 +865,56 @@ public class Throwable implements Serializable { ...@@ -870,43 +865,56 @@ public class Throwable implements Serializable {
* typically called (automatically and implicitly) by the {@code * typically called (automatically and implicitly) by the {@code
* try}-with-resources statement. * try}-with-resources statement.
* *
* If the first exception to be suppressed is {@code null}, that * <p>The suppression behavior is enabled <em>unless</em> disabled
* indicates suppressed exception information will <em>not</em> be * {@linkplain #Throwable(String, Throwable, boolean) via a
* recorded for this exception. Subsequent calls to this method * constructor}. When suppression is disabled, this method does
* will not record any suppressed exceptions. Otherwise, * nothing other than to validate its argument.
* attempting to suppress {@code null} after an exception has
* already been successfully suppressed results in a {@code
* NullPointerException}.
* *
* <p>Note that when one exception {@linkplain * <p>Note that when one exception {@linkplain
* #initCause(Throwable) causes} another exception, the first * #initCause(Throwable) causes} another exception, the first
* exception is usually caught and then the second exception is * exception is usually caught and then the second exception is
* thrown in response. In contrast, when one exception suppresses * thrown in response. In other words, there is a causal
* another, two exceptions are thrown in sibling code blocks, such * connection between the two exceptions.
* as in a {@code try} block and in its {@code finally} block, and *
* control flow can only continue with one exception so the second * In contrast, there are situations where two independent
* is recorded as a suppressed exception of the first. * exceptions can be thrown in sibling code blocks, in particular
* in the {@code try} block of a {@code try}-with-resources
* statement and the compiler-generated {@code finally} block
* which closes the resource.
*
* In these situations, only one of the thrown exceptions can be
* propagated. In the {@code try}-with-resources statement, when
* there are two such exceptions, the exception originating from
* the {@code try} block is propagated and the exception from the
* {@code finally} block is added to the list of exceptions
* suppressed by the exception from the {@code try} block. As an
* exception unwinds the stack, it can accumulate multiple
* suppressed exceptions.
*
* <p>An exception may have suppressed exceptions while also being
* caused by another exception. Whether or not an exception has a
* cause is semantically known at the time of its creation, unlike
* whether or not an exception will suppress other exceptions
* which is typically only determined after an exception is
* thrown.
*
* <p>Note that programmer written code is also able to take
* advantage of calling this method in situations where there are
* multiple sibling exceptions and only one can be propagated.
* *
* @param exception the exception to be added to the list of * @param exception the exception to be added to the list of
* suppressed exceptions * suppressed exceptions
* @throws IllegalArgumentException if {@code exception} is this * @throws IllegalArgumentException if {@code exception} is this
* throwable; a throwable cannot suppress itself. * throwable; a throwable cannot suppress itself.
* @throws NullPointerException if {@code exception} is null and * @throws NullPointerException if {@code exception} is {@code null}
* an exception has already been suppressed by this exception
* @since 1.7 * @since 1.7
*/ */
public final synchronized void addSuppressed(Throwable exception) { public final synchronized void addSuppressed(Throwable exception) {
if (exception == this) if (exception == this)
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE); throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
if (exception == null) { if (exception == null)
if (suppressedExceptions == SUPPRESSED_SENTINEL) {
suppressedExceptions = null; // No suppression information recorded
return;
} else
throw new NullPointerException(NULL_CAUSE_MESSAGE); throw new NullPointerException(NULL_CAUSE_MESSAGE);
} else {
assert exception != null && exception != this;
if (suppressedExceptions == null) // Suppressed exceptions not recorded if (suppressedExceptions == null) // Suppressed exceptions not recorded
return; return;
...@@ -914,11 +922,8 @@ public class Throwable implements Serializable { ...@@ -914,11 +922,8 @@ public class Throwable implements Serializable {
if (suppressedExceptions == SUPPRESSED_SENTINEL) if (suppressedExceptions == SUPPRESSED_SENTINEL)
suppressedExceptions = new ArrayList<>(1); suppressedExceptions = new ArrayList<>(1);
assert suppressedExceptions != SUPPRESSED_SENTINEL;
suppressedExceptions.add(exception); suppressedExceptions.add(exception);
} }
}
private static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0]; private static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0];
...@@ -927,7 +932,9 @@ public class Throwable implements Serializable { ...@@ -927,7 +932,9 @@ public class Throwable implements Serializable {
* suppressed, typically by the {@code try}-with-resources * suppressed, typically by the {@code try}-with-resources
* statement, in order to deliver this exception. * statement, in order to deliver this exception.
* *
* If no exceptions were suppressed, an empty array is returned. * If no exceptions were suppressed or {@linkplain
* Throwable(String, Throwable, boolean) suppression is disabled},
* an empty array is returned.
* *
* @return an array containing all of the exceptions that were * @return an array containing all of the exceptions that were
* suppressed to deliver this exception. * suppressed to deliver this exception.
......
...@@ -23,15 +23,15 @@ ...@@ -23,15 +23,15 @@
* questions. * questions.
*/ */
package java.nio; package java.lang.management;
import java.lang.management.PlatformManagedObject;
/** /**
* The management interface for a buffer pool. * The management interface for a buffer pool, for example a pool of
* {@link java.nio.ByteBuffer#allocateDirect direct} or {@link
* java.nio.MappedByteBuffer mapped} buffers.
* *
* <p> A class implementing this interface is an <a href= * <p> A class implementing this interface is an
* "java.lang.management.ManagementFactory.html#MXBean">MXBean</a>. A Java * {@link javax.management.MXBean}. A Java
* virtual machine has one or more implementations of this interface. The {@link * virtual machine has one or more implementations of this interface. The {@link
* java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans} * java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans}
* method can be used to obtain the list of {@code BufferPoolMXBean} objects * method can be used to obtain the list of {@code BufferPoolMXBean} objects
...@@ -44,14 +44,13 @@ import java.lang.management.PlatformManagedObject; ...@@ -44,14 +44,13 @@ import java.lang.management.PlatformManagedObject;
* javax.management.MBeanServer MBeanServer}. The {@link * javax.management.MBeanServer MBeanServer}. The {@link
* javax.management.ObjectName ObjectName} that uniquely identifies the * javax.management.ObjectName ObjectName} that uniquely identifies the
* management interface within the {@code MBeanServer} takes the form: * management interface within the {@code MBeanServer} takes the form:
* <blockquote> * <pre>
* <tt>java.nio:type=BufferPool</tt><tt>,name=</tt><i>pool name</i> * java.nio:type=BufferPool,name=<i>pool name</i>
* </blockquote> * </pre>
* where <em>pool name</em> is the {@link #getName name} of the buffer pool. * where <em>pool name</em> is the {@link #getName name} of the buffer pool.
* *
* @since 1.7 * @since 1.7
*/ */
public interface BufferPoolMXBean extends PlatformManagedObject { public interface BufferPoolMXBean extends PlatformManagedObject {
/** /**
......
...@@ -29,9 +29,9 @@ import java.util.ArrayList; ...@@ -29,9 +29,9 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.HashSet; import java.util.HashSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.PlatformLoggingMXBean;
import java.nio.BufferPoolMXBean;
import javax.management.MBeanServerConnection; import javax.management.MBeanServerConnection;
import javax.management.ObjectName; import javax.management.ObjectName;
...@@ -66,6 +66,7 @@ enum PlatformComponent { ...@@ -66,6 +66,7 @@ enum PlatformComponent {
CLASS_LOADING( CLASS_LOADING(
"java.lang.management.ClassLoadingMXBean", "java.lang.management.ClassLoadingMXBean",
"java.lang", "ClassLoading", defaultKeyProperties(), "java.lang", "ClassLoading", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<ClassLoadingMXBean>() { new MXBeanFetcher<ClassLoadingMXBean>() {
public List<ClassLoadingMXBean> getMXBeans() { public List<ClassLoadingMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean()); return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean());
...@@ -78,6 +79,7 @@ enum PlatformComponent { ...@@ -78,6 +79,7 @@ enum PlatformComponent {
COMPILATION( COMPILATION(
"java.lang.management.CompilationMXBean", "java.lang.management.CompilationMXBean",
"java.lang", "Compilation", defaultKeyProperties(), "java.lang", "Compilation", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<CompilationMXBean>() { new MXBeanFetcher<CompilationMXBean>() {
public List<CompilationMXBean> getMXBeans() { public List<CompilationMXBean> getMXBeans() {
CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean(); CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean();
...@@ -95,6 +97,7 @@ enum PlatformComponent { ...@@ -95,6 +97,7 @@ enum PlatformComponent {
MEMORY( MEMORY(
"java.lang.management.MemoryMXBean", "java.lang.management.MemoryMXBean",
"java.lang", "Memory", defaultKeyProperties(), "java.lang", "Memory", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<MemoryMXBean>() { new MXBeanFetcher<MemoryMXBean>() {
public List<MemoryMXBean> getMXBeans() { public List<MemoryMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean()); return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean());
...@@ -107,6 +110,7 @@ enum PlatformComponent { ...@@ -107,6 +110,7 @@ enum PlatformComponent {
GARBAGE_COLLECTOR( GARBAGE_COLLECTOR(
"java.lang.management.GarbageCollectorMXBean", "java.lang.management.GarbageCollectorMXBean",
"java.lang", "GarbageCollector", keyProperties("name"), "java.lang", "GarbageCollector", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<GarbageCollectorMXBean>() { new MXBeanFetcher<GarbageCollectorMXBean>() {
public List<GarbageCollectorMXBean> getMXBeans() { public List<GarbageCollectorMXBean> getMXBeans() {
return ManagementFactoryHelper. return ManagementFactoryHelper.
...@@ -120,6 +124,7 @@ enum PlatformComponent { ...@@ -120,6 +124,7 @@ enum PlatformComponent {
MEMORY_MANAGER( MEMORY_MANAGER(
"java.lang.management.MemoryManagerMXBean", "java.lang.management.MemoryManagerMXBean",
"java.lang", "MemoryManager", keyProperties("name"), "java.lang", "MemoryManager", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<MemoryManagerMXBean>() { new MXBeanFetcher<MemoryManagerMXBean>() {
public List<MemoryManagerMXBean> getMXBeans() { public List<MemoryManagerMXBean> getMXBeans() {
return ManagementFactoryHelper.getMemoryManagerMXBeans(); return ManagementFactoryHelper.getMemoryManagerMXBeans();
...@@ -133,6 +138,7 @@ enum PlatformComponent { ...@@ -133,6 +138,7 @@ enum PlatformComponent {
MEMORY_POOL( MEMORY_POOL(
"java.lang.management.MemoryPoolMXBean", "java.lang.management.MemoryPoolMXBean",
"java.lang", "MemoryPool", keyProperties("name"), "java.lang", "MemoryPool", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<MemoryPoolMXBean>() { new MXBeanFetcher<MemoryPoolMXBean>() {
public List<MemoryPoolMXBean> getMXBeans() { public List<MemoryPoolMXBean> getMXBeans() {
return ManagementFactoryHelper.getMemoryPoolMXBeans(); return ManagementFactoryHelper.getMemoryPoolMXBeans();
...@@ -145,6 +151,7 @@ enum PlatformComponent { ...@@ -145,6 +151,7 @@ enum PlatformComponent {
OPERATING_SYSTEM( OPERATING_SYSTEM(
"java.lang.management.OperatingSystemMXBean", "java.lang.management.OperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(), "java.lang", "OperatingSystem", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<OperatingSystemMXBean>() { new MXBeanFetcher<OperatingSystemMXBean>() {
public List<OperatingSystemMXBean> getMXBeans() { public List<OperatingSystemMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean()); return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean());
...@@ -157,6 +164,7 @@ enum PlatformComponent { ...@@ -157,6 +164,7 @@ enum PlatformComponent {
RUNTIME( RUNTIME(
"java.lang.management.RuntimeMXBean", "java.lang.management.RuntimeMXBean",
"java.lang", "Runtime", defaultKeyProperties(), "java.lang", "Runtime", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<RuntimeMXBean>() { new MXBeanFetcher<RuntimeMXBean>() {
public List<RuntimeMXBean> getMXBeans() { public List<RuntimeMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean()); return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean());
...@@ -169,6 +177,7 @@ enum PlatformComponent { ...@@ -169,6 +177,7 @@ enum PlatformComponent {
THREADING( THREADING(
"java.lang.management.ThreadMXBean", "java.lang.management.ThreadMXBean",
"java.lang", "Threading", defaultKeyProperties(), "java.lang", "Threading", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<ThreadMXBean>() { new MXBeanFetcher<ThreadMXBean>() {
public List<ThreadMXBean> getMXBeans() { public List<ThreadMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean()); return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean());
...@@ -180,11 +189,17 @@ enum PlatformComponent { ...@@ -180,11 +189,17 @@ enum PlatformComponent {
* Logging facility. * Logging facility.
*/ */
LOGGING( LOGGING(
"java.util.logging.PlatformLoggingMXBean", "java.lang.management.PlatformLoggingMXBean",
"java.util.logging", "Logging", defaultKeyProperties(), "java.util.logging", "Logging", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<PlatformLoggingMXBean>() { new MXBeanFetcher<PlatformLoggingMXBean>() {
public List<PlatformLoggingMXBean> getMXBeans() { public List<PlatformLoggingMXBean> getMXBeans() {
return ManagementFactoryHelper.getLoggingMXBean(); PlatformLoggingMXBean m = ManagementFactoryHelper.getPlatformLoggingMXBean();
if (m == null) {
return Collections.emptyList();
} else {
return Collections.singletonList(m);
}
} }
}), }),
...@@ -192,8 +207,9 @@ enum PlatformComponent { ...@@ -192,8 +207,9 @@ enum PlatformComponent {
* Buffer pools. * Buffer pools.
*/ */
BUFFER_POOL( BUFFER_POOL(
"java.nio.BufferPoolMXBean", "java.lang.management.BufferPoolMXBean",
"java.nio", "BufferPool", keyProperties("name"), "java.nio", "BufferPool", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<BufferPoolMXBean>() { new MXBeanFetcher<BufferPoolMXBean>() {
public List<BufferPoolMXBean> getMXBeans() { public List<BufferPoolMXBean> getMXBeans() {
return ManagementFactoryHelper.getBufferPoolMXBeans(); return ManagementFactoryHelper.getBufferPoolMXBeans();
...@@ -209,6 +225,7 @@ enum PlatformComponent { ...@@ -209,6 +225,7 @@ enum PlatformComponent {
SUN_GARBAGE_COLLECTOR( SUN_GARBAGE_COLLECTOR(
"com.sun.management.GarbageCollectorMXBean", "com.sun.management.GarbageCollectorMXBean",
"java.lang", "GarbageCollector", keyProperties("name"), "java.lang", "GarbageCollector", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<com.sun.management.GarbageCollectorMXBean>() { new MXBeanFetcher<com.sun.management.GarbageCollectorMXBean>() {
public List<com.sun.management.GarbageCollectorMXBean> getMXBeans() { public List<com.sun.management.GarbageCollectorMXBean> getMXBeans() {
return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class); return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class);
...@@ -222,6 +239,7 @@ enum PlatformComponent { ...@@ -222,6 +239,7 @@ enum PlatformComponent {
SUN_OPERATING_SYSTEM( SUN_OPERATING_SYSTEM(
"com.sun.management.OperatingSystemMXBean", "com.sun.management.OperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(), "java.lang", "OperatingSystem", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<com.sun.management.OperatingSystemMXBean>() { new MXBeanFetcher<com.sun.management.OperatingSystemMXBean>() {
public List<com.sun.management.OperatingSystemMXBean> getMXBeans() { public List<com.sun.management.OperatingSystemMXBean> getMXBeans() {
return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class); return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class);
...@@ -234,6 +252,7 @@ enum PlatformComponent { ...@@ -234,6 +252,7 @@ enum PlatformComponent {
SUN_UNIX_OPERATING_SYSTEM( SUN_UNIX_OPERATING_SYSTEM(
"com.sun.management.UnixOperatingSystemMXBean", "com.sun.management.UnixOperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(), "java.lang", "OperatingSystem", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<UnixOperatingSystemMXBean>() { new MXBeanFetcher<UnixOperatingSystemMXBean>() {
public List<UnixOperatingSystemMXBean> getMXBeans() { public List<UnixOperatingSystemMXBean> getMXBeans() {
return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class); return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class);
...@@ -246,6 +265,7 @@ enum PlatformComponent { ...@@ -246,6 +265,7 @@ enum PlatformComponent {
HOTSPOT_DIAGNOSTIC( HOTSPOT_DIAGNOSTIC(
"com.sun.management.HotSpotDiagnosticMXBean", "com.sun.management.HotSpotDiagnosticMXBean",
"com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(), "com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<HotSpotDiagnosticMXBean>() { new MXBeanFetcher<HotSpotDiagnosticMXBean>() {
public List<HotSpotDiagnosticMXBean> getMXBeans() { public List<HotSpotDiagnosticMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean()); return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean());
...@@ -296,27 +316,19 @@ enum PlatformComponent { ...@@ -296,27 +316,19 @@ enum PlatformComponent {
private final Set<String> keyProperties; private final Set<String> keyProperties;
private final MXBeanFetcher fetcher; private final MXBeanFetcher fetcher;
private final PlatformComponent[] subComponents; private final PlatformComponent[] subComponents;
private final boolean singleton;
private PlatformComponent(String intfName, private PlatformComponent(String intfName,
String domain, String type, String domain, String type,
Set<String> keyProperties, Set<String> keyProperties,
MXBeanFetcher fetcher) { boolean singleton,
this.mxbeanInterfaceName = intfName;
this.domain = domain;
this.type = type;
this.keyProperties = keyProperties;
this.fetcher = fetcher;
this.subComponents = new PlatformComponent[0];
}
private PlatformComponent(String intfName,
String domain, String type,
Set<String> keyProperties,
MXBeanFetcher fetcher, MXBeanFetcher fetcher,
PlatformComponent... subComponents) { PlatformComponent... subComponents) {
this.mxbeanInterfaceName = intfName; this.mxbeanInterfaceName = intfName;
this.domain = domain; this.domain = domain;
this.type = type; this.type = type;
this.keyProperties = keyProperties; this.keyProperties = keyProperties;
this.singleton = singleton;
this.fetcher = fetcher; this.fetcher = fetcher;
this.subComponents = subComponents; this.subComponents = subComponents;
} }
...@@ -338,6 +350,10 @@ enum PlatformComponent { ...@@ -338,6 +350,10 @@ enum PlatformComponent {
return set; return set;
} }
boolean isSingleton() {
return singleton;
}
String getMXBeanInterfaceName() { String getMXBeanInterfaceName() {
return mxbeanInterfaceName; return mxbeanInterfaceName;
} }
...@@ -360,6 +376,33 @@ enum PlatformComponent { ...@@ -360,6 +376,33 @@ enum PlatformComponent {
return fetcher.getMXBeans(); return fetcher.getMXBeans();
} }
<T extends PlatformManagedObject> T getSingletonMXBean(Class<T> mxbeanInterface)
{
if (!singleton)
throw new IllegalArgumentException(mxbeanInterfaceName +
" can have zero or more than one instances");
List<T> list = fetcher.getMXBeans();
assert list.size() == 1;
return list.isEmpty() ? null : list.get(0);
}
<T extends PlatformManagedObject>
T getSingletonMXBean(MBeanServerConnection mbs, Class<T> mxbeanInterface)
throws java.io.IOException
{
if (!singleton)
throw new IllegalArgumentException(mxbeanInterfaceName +
" can have zero or more than one instances");
// ObjectName of a singleton MXBean contains only domain and type
assert keyProperties.size() == 1;
String on = domain + ":type=" + type;
return ManagementFactory.newPlatformMXBeanProxy(mbs,
on,
mxbeanInterface);
}
<T extends PlatformManagedObject> <T extends PlatformManagedObject>
List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface) List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
throws java.io.IOException throws java.io.IOException
...@@ -391,5 +434,34 @@ enum PlatformComponent { ...@@ -391,5 +434,34 @@ enum PlatformComponent {
return set; return set;
} }
// a map from MXBean interface name to PlatformComponent
private static Map<String, PlatformComponent> enumMap;
private static synchronized void ensureInitialized() {
if (enumMap == null) {
enumMap = new HashMap<>();
for (PlatformComponent pc: PlatformComponent.values()) {
// Use String as the key rather than Class<?> to avoid
// causing unnecessary class loading of management interface
enumMap.put(pc.getMXBeanInterfaceName(), pc);
}
}
}
static boolean isPlatformMXBean(String cn) {
ensureInitialized();
return enumMap.containsKey(cn);
}
static <T extends PlatformManagedObject>
PlatformComponent getPlatformComponent(Class<T> mxbeanInterface)
{
ensureInitialized();
String cn = mxbeanInterface.getName();
PlatformComponent pc = enumMap.get(cn);
if (pc != null && pc.getMXBeanInterface() == mxbeanInterface)
return pc;
return null;
}
private static final long serialVersionUID = 6992337162326171013L; private static final long serialVersionUID = 6992337162326171013L;
} }
/*
* Copyright (c) 2009, 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.
*/
package java.lang.management;
/**
* The management interface for the {@linkplain java.util.logging logging} facility.
*
* <p>There is a single global instance of the <tt>PlatformLoggingMXBean</tt>.
* The {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
* ManagementFactory.getPlatformMXBean} method can be used to obtain
* the {@code PlatformLoggingMXBean} object as follows:
* <pre>
* PlatformLoggingMXBean logging = ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class);
* </pre>
* The {@code PlatformLoggingMXBean} object is also registered with the
* platform {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
* MBeanServer}.
* The {@link javax.management.ObjectName ObjectName} for uniquely
* identifying the {@code PlatformLoggingMXBean} within an MBeanServer is:
* <pre>
* {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
* </pre>
*
* <p>The instance registered in the platform <tt>MBeanServer</tt> with
* this {@code ObjectName} implements all attributes defined by
* {@link java.util.logging.LoggingMXBean}.
*
* @since 1.7
*/
public interface PlatformLoggingMXBean extends PlatformManagedObject {
/**
* Returns the list of the currently registered
* {@linkplain java.util.logging.Logger logger} names. This method
* calls {@link java.util.logging.LogManager#getLoggerNames} and
* returns a list of the logger names.
*
* @return A list of {@code String} each of which is a
* currently registered {@code Logger} name.
*/
java.util.List<String> getLoggerNames();
/**
* Gets the name of the log {@linkplain java.util.logging.Logger#getLevel
* level} associated with the specified logger.
* If the specified logger does not exist, {@code null}
* is returned.
* This method first finds the logger of the given name and
* then returns the name of the log level by calling:
* <blockquote>
* {@link java.util.logging.Logger#getLevel
* Logger.getLevel()}.{@link java.util.logging.Level#getName getName()};
* </blockquote>
*
* <p>
* If the {@code Level} of the specified logger is {@code null},
* which means that this logger's effective level is inherited
* from its parent, an empty string will be returned.
*
* @param loggerName The name of the {@code Logger} to be retrieved.
*
* @return The name of the log level of the specified logger; or
* an empty string if the log level of the specified logger
* is {@code null}. If the specified logger does not
* exist, {@code null} is returned.
*
* @see java.util.logging.Logger#getLevel
*/
String getLoggerLevel(String loggerName);
/**
* Sets the specified logger to the specified new
* {@linkplain java.util.logging.Logger#setLevel level}.
* If the {@code levelName} is not {@code null}, the level
* of the specified logger is set to the parsed
* {@link java.util.logging.Level Level}
* matching the {@code levelName}.
* If the {@code levelName} is {@code null}, the level
* of the specified logger is set to {@code null} and
* the effective level of the logger is inherited from
* its nearest ancestor with a specific (non-null) level value.
*
* @param loggerName The name of the {@code Logger} to be set.
* Must be non-null.
* @param levelName The name of the level to set on the specified logger,
* or {@code null} if setting the level to inherit
* from its nearest ancestor.
*
* @throws IllegalArgumentException if the specified logger
* does not exist, or {@code levelName} is not a valid level name.
*
* @throws SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
*
* @see java.util.logging.Logger#setLevel
*/
void setLoggerLevel(String loggerName, String levelName);
/**
* Returns the name of the
* {@linkplain java.util.logging.Logger#getParent parent}
* for the specified logger.
* If the specified logger does not exist, {@code null} is returned.
* If the specified logger is the root {@code Logger} in the namespace,
* the result will be an empty string.
*
* @param loggerName The name of a {@code Logger}.
*
* @return the name of the nearest existing parent logger;
* an empty string if the specified logger is the root logger.
* If the specified logger does not exist, {@code null}
* is returned.
*/
String getParentLoggerName(String loggerName);
}
...@@ -46,7 +46,7 @@ import javax.management.ObjectName; ...@@ -46,7 +46,7 @@ import javax.management.ObjectName;
* intended for the management interfaces for the platform to extend but * intended for the management interfaces for the platform to extend but
* not for applications. * not for applications.
* *
* @see <a href="ManagementFactory.html#MXBean">Platform MXBeans</a> * @see ManagementFactory
* @since 1.7 * @since 1.7
*/ */
public interface PlatformManagedObject { public interface PlatformManagedObject {
......
...@@ -27,108 +27,24 @@ ...@@ -27,108 +27,24 @@
<html> <html>
<body bgcolor="white"> <body bgcolor="white">
Provides the management interface for monitoring and management of the Provides the management interfaces for monitoring and management of the
Java virtual machine as well as the operating system on which the Java virtual machine and other components in the Java runtime.
Java virtual machine is running. It allows both local and remote It allows both local and remote
monitoring and management of the running Java virtual machine. monitoring and management of the running Java virtual machine.
<h4>Platform MXBeans</h4>
This package defines the management interface of the following
components:
<blockquote>
<table cellspacing=1 summary="Description of the MBeans">
<tr>
<th><p align="left">Management Interface</p></th>
<th><p align="left">Description</p></th>
</tr>
<tr>
<td> <tt>{@link java.lang.management.ClassLoadingMXBean}</tt> </td>
<td> Class loading system of the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.CompilationMXBean}</tt> </td>
<td> Compilation system of the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.MemoryMXBean}</tt> </td>
<td> Memory system of the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.ThreadMXBean}</tt> </td>
<td> Threads system of the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.RuntimeMXBean}</tt> </td>
<td> Runtime system of the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.OperatingSystemMXBean}</tt> </td>
<td> Operating system on which the Java virtual machine is running.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.GarbageCollectorMXBean}</tt> </td>
<td> Garbage collector in the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.MemoryManagerMXBean}</tt> </td>
<td> Memory manager in the Java virtual machine.</td>
</tr>
<tr>
<td> <tt>{@link java.lang.management.MemoryPoolMXBean}</tt> </td>
<td> Memory pool in the Java virtual machine.</td>
</tr>
</table>
</blockquote>
<p> <p>
A platform MXBean is a <i>managed bean</i> that defines the management
interface for one component for the platform and is specified in the
<a href="ManagementFactory.html#MXBean">
ManagementFactory</a> class.
<p>An application can monitor the instrumentation of the
Java virtual machine and manage certain characteristics in
the following ways:
<ul>
<li><i>Direct access to an MXBean interface</i>
<ol type="a">
<li>Get the MXBean instance through the static factory method
and access the MXBean interface locally of the running
virtual machine.</li>
<li>Construct an MXBean proxy instance that
forwards the method calls to a given
{@link javax.management.MBeanServer MBeanServer}
by calling
{@link java.lang.management.ManagementFactory#newPlatformMXBeanProxy
ManagementFactory.newPlatformMXBeanProxy}.
A proxy is typically constructed to remotely access
an MXBean of another running virtual machine.</li>
</ol></li>
<li><i>Indirect access via {@link javax.management.MBeanServer MBeanServer}
interface</i>
<ol type="a">
<li>Go through the
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer
platform MBeanServer} to access MXBeans locally or
a specific <tt>MBeanServerConnection</tt> to access
MXBeans remotely.
The attributes and operations of an MXBean use only
<em>JMX open types</em> which include basic data types,
{@link javax.management.openmbean.CompositeData CompositeData},
and {@link javax.management.openmbean.TabularData TabularData}
defined in {@link javax.management.openmbean.OpenType OpenType}.
</li>
</ol></li>
</ul>
Below shows a few <a href="#examples">examples</a> of different
ways to access MXBeans.
<h4><a name="MXBean">Platform MXBean</a></h4>
<p>
A platform MXBean is a <i>managed bean</i> that
conforms to the <a href="../../../javax/management/package-summary.html">JMX</a>
Instrumentation Specification and only uses a set of basic data types.
Each platform MXBean is a {@link java.lang.management.PlatformManagedObject}
with a unique
{@linkplain java.lang.management.PlatformManagedObject#getObjectName name}.
<p>
<h4>ManagementFactory</h4> <h4>ManagementFactory</h4>
The {@link java.lang.management.ManagementFactory} class is the management <p>The {@link java.lang.management.ManagementFactory} class is the management
factory class for the Java platform. This class provides a set of factory class for the Java platform. This class provides a set of
static factory methods to obtain the MXBeans for the Java platform static factory methods to obtain the MXBeans for the Java platform
to allow an application to access the MXBeans directly. to allow an application to access the MXBeans directly.
...@@ -137,50 +53,98 @@ to allow an application to access the MXBeans directly. ...@@ -137,50 +53,98 @@ to allow an application to access the MXBeans directly.
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
getPlatformMBeanServer} method. On the first call to this method, getPlatformMBeanServer} method. On the first call to this method,
it creates the platform MBeanServer and registers all platform MXBeans it creates the platform MBeanServer and registers all platform MXBeans
including platform MXBeans defined in other packages such as including {@linkplain java.lang.management.PlatformManagedObject
{@link java.util.logging.LoggingMXBean}. platform MXBeans}.
Each platform MXBean is registered with a unique name defined in the Each platform MXBean is registered with a unique name defined in
{@link java.lang.management.ManagementFactory ManagementFactory} class the specification of the management interface.
for constructing {@link javax.management.ObjectName ObjectName}.
This is a single MBeanServer that can be shared by different managed This is a single MBeanServer that can be shared by different managed
components running within the same Java virtual machine. components running within the same Java virtual machine.
<h4>Interoperability</h4> <h4>Interoperability</h4>
A management application and a platform MBeanServer of a running <p>A management application and a platform MBeanServer of a running
virtual machine can interoperate virtual machine can interoperate
without requiring classes used by the platform MXBean interfaces. without requiring classes used by the platform MXBean interfaces.
The data types being transmitted between the JMX connector The data types being transmitted between the JMX connector
server and the connector client are JMX server and the connector client are JMX
{@link javax.management.openmbean.OpenType open types} and {@linkplain javax.management.openmbean.OpenType open types} and
this allows interoperation across versions. this allows interoperation across versions.
A data type used by the MXBean interfaces are mapped to an
<p>A data type used by the MXBean interfaces are mapped to open type when being accessed via MBeanServer interface.
an open type when being accessed via MBeanServer interface. See the <a href="../../../javax/management/MXBean.html#MXBean-spec">
The data type mapping is specified in the MXBean</a> specification for details.
{@link java.lang.management.ManagementFactory ManagementFactory} class.
<h4><a name="examples">Ways to Access MXBeans</a></h4> <h4><a name="examples">Ways to Access MXBeans</a></h4>
There are three different ways to access the management interfaces. <p>An application can monitor the instrumentation of the
Java virtual machine and the runtime in the following ways:
<p> <p>
<ol> <b>1. Direct access to an MXBean interface</b>
<li>Call the methods in the MXBean directly within the same <p>
Java virtual machine. <ul>
<blockquote><pre> <li>Get an MXBean instance locally in the running Java virtual machine:<p>
<pre>
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean(); RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
// Get the standard attribute "VmVendor" // Get the standard attribute "VmVendor"
String vendor = mxbean.getVmVendor(); String vendor = mxbean.getVmVendor();
</pre>
<p>Or by calling the
{@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
getPlatformMXBean} or
{@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
getPlatformMXBeans} method:
<pre>
RuntimeMXBean mxbean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class);
// Get the standard attribute "VmVendor"
String vendor = mxbean.getVmVendor();
</pre> </pre>
</blockquote> <p>
</li> </li>
<li>Construct an MXBean proxy instance that forwards the
method calls to a given MBeanServer:<p>
<pre>
MBeanServerConnection mbs;
<li>Go through a <tt>MBeanServerConnection</tt> connecting // Connect to a running JVM (or itself) and get MBeanServerConnection
to the <tt>platform MBeanServer</tt> of a running virtual machine.</li> // that has the JVM MBeans registered in it
<blockquote><pre> ...
// Get a MBean proxy for RuntimeMXBean interface
RuntimeMXBean proxy =
{@link java.lang.management.ManagementFactory#getPlatformMXBean(MBeanServerConnection, Class)
ManagementFactory.getPlatformMXBean}(mbs,
RuntimeMXBean.class);
// Get standard attribute "VmVendor"
String vendor = proxy.getVmVendor();
</pre>
<p>A proxy is typically used to access an MXBean
in a remote Java virtual machine.
An alternative way to create an MXBean proxy is:
<pre>
RuntimeMXBean proxy =
{@link java.lang.management.ManagementFactory#newPlatformMXBeanProxy
ManagementFactory.newPlatformMXBeanProxy}(mbs,
ManagementFactory.RUNTIME_MXBEAN_NAME,
RuntimeMXBean.class);
</pre>
</li>
</ul>
<p>
<b>2. Indirect access to an MXBean interface via MBeanServer</b><p>
<ul>
<li>Go through the
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer
platform MBeanServer} to access MXBeans locally or
a specific {@code MBeanServerConnection} to access
MXBeans remotely.
The attributes and operations of an MXBean use only
<em>JMX open types</em> which include basic data types,
{@link javax.management.openmbean.CompositeData CompositeData},
and {@link javax.management.openmbean.TabularData TabularData}
defined in {@link javax.management.openmbean.OpenType OpenType}.<p>
<pre>
MBeanServerConnection mbs; MBeanServerConnection mbs;
// Connect to a running JVM (or itself) and get MBeanServerConnection // Connect to a running JVM (or itself) and get MBeanServerConnection
...@@ -198,36 +162,19 @@ There are three different ways to access the management interfaces. ...@@ -198,36 +162,19 @@ There are three different ways to access the management interfaces.
// and MBeanServer.getAttribute method // and MBeanServer.getAttribute method
... ...
} }
</pre>
</pre></blockquote> </li>
</ul>
<li>Use MXBean proxy.</li>
<blockquote><pre>
MBeanServerConnection mbs;
// Connect to a running JVM (or itself) and get MBeanServerConnection
// that has the JVM MBeans registered in it
...
// Get a MBean proxy for RuntimeMXBean interface
RuntimeMXBean proxy =
ManagementFactory.newPlatformMXBeanProxy(mbs,
ManagementFactory.RUNTIME_MXBEAN_NAME,
RuntimeMXBean.class);
// Get standard attribute "VmVendor"
String vendor = proxy.getVmVendor();
</pre></blockquote>
</ol>
<h4><a name="extension">Platform Extension</a></h4> <h4><a name="extension">Platform Extension</a></h4>
A Java virtual machine implementation may add its platform extension to <p>A Java virtual machine implementation may add its platform extension to
the management interface by defining platform-dependent the management interface by defining platform-dependent
interfaces that extend the standard management interfaces to include interfaces that extend the standard management interfaces to include
platform-specific metrics and management operations. platform-specific metrics and management operations.
The static factory methods in the <tt>ManagementFactory</tt> class will The static factory methods in the <tt>ManagementFactory</tt> class will
return the MBeans with the platform extension. return the MXBeans with the platform extension.
<p> <p>
It is recommended to name the platform-specific attributes with It is recommended to name the platform-specific attributes with
...@@ -240,26 +187,30 @@ is happened to be same as some vendor-specific attribute's name, ...@@ -240,26 +187,30 @@ is happened to be same as some vendor-specific attribute's name,
the applications accessing that vendor-specific attribute would have the applications accessing that vendor-specific attribute would have
to be modified to cope with versioning and compatibility issues. to be modified to cope with versioning and compatibility issues.
<p>Below is an example showing how to access a platform-specific <p>Below is an example showing how to access an attribute
attribute from Sun's implementation of the <tt>RuntimeMXBean</tt>. from the platform extension:
<p> <p>
1) Direct access to the Sun-specific MXBean interface 1) Direct access to the Oracle-specific MXBean interface
<blockquote><pre> <blockquote>
com.sun.management.RuntimeMXBean mxbean = <pre>
(com.sun.management.RuntimeMXBean) ManagementFactory.getRuntimeMXBean(); List&lt;com.sun.management.GarbageCollectorMXBean&gt; mxbeans =
ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class);
// Get the standard attribute "VmVendor"
String vendor = mxbean.getVmVendor();
// Get the platform-specific attribute "Bar" for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
BarType bar = mxbean.getBar(); // Get the standard attribute "CollectionCount"
String count = mxbean.getCollectionCount();
// Get the platform-specific attribute "LastGcInfo"
GcInfo gcinfo = gc.getLastGcInfo();
...
}
</pre> </pre>
</blockquote> </blockquote>
<p> <p>
2) Access the Sun-specific MXBean interface via <tt>MBeanServer</tt> 2) Access the Oracle-specific MXBean interface via <tt>MBeanServer</tt>
through proxy
<blockquote><pre> <blockquote><pre>
MBeanServerConnection mbs; MBeanServerConnection mbs;
...@@ -268,24 +219,17 @@ attribute from Sun's implementation of the <tt>RuntimeMXBean</tt>. ...@@ -268,24 +219,17 @@ attribute from Sun's implementation of the <tt>RuntimeMXBean</tt>.
// that has the JVM MXBeans registered in it // that has the JVM MXBeans registered in it
... ...
try { List&lt;com.sun.management.GarbageCollectorMXBean&gt; mxbeans =
// Assuming the RuntimeMXBean has been registered in mbs ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class);
ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
// Get standard attribute "VmVendor" for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
String vendor = (String) mbs.getAttribute(oname, "VmVendor"); // Get the standard attribute "CollectionCount"
String count = mxbean.getCollectionCount();
// Check if this MXBean contains Sun's extension // Get the platform-specific attribute "LastGcInfo"
if (mbs.isInstanceOf(oname, "com.sun.management.RuntimeMXBean")) { GcInfo gcinfo = gc.getLastGcInfo();
// Get platform-specific attribute "Bar"
BarType bar = (String) mbs.getAttribute(oname, "Bar");
}
} catch (....) {
// Catch the exceptions thrown by ObjectName constructor
// and MBeanServer methods
... ...
} }
</pre></blockquote> </pre></blockquote>
<p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor <p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor
......
...@@ -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
......
...@@ -3533,20 +3533,20 @@ public class Collections { ...@@ -3533,20 +3533,20 @@ public class Collections {
} }
/** /**
* Returns a comparator that imposes the reverse of the <i>natural * Returns a comparator that imposes the reverse of the <em>natural
* ordering</i> on a collection of objects that implement the * ordering</em> on a collection of objects that implement the
* <tt>Comparable</tt> interface. (The natural ordering is the ordering * {@code Comparable} interface. (The natural ordering is the ordering
* imposed by the objects' own <tt>compareTo</tt> method.) This enables a * imposed by the objects' own {@code compareTo} method.) This enables a
* simple idiom for sorting (or maintaining) collections (or arrays) of * simple idiom for sorting (or maintaining) collections (or arrays) of
* objects that implement the <tt>Comparable</tt> interface in * objects that implement the {@code Comparable} interface in
* reverse-natural-order. For example, suppose a is an array of * reverse-natural-order. For example, suppose {@code a} is an array of
* strings. Then: <pre> * strings. Then: <pre>
* Arrays.sort(a, Collections.reverseOrder()); * Arrays.sort(a, Collections.reverseOrder());
* </pre> sorts the array in reverse-lexicographic (alphabetical) order.<p> * </pre> sorts the array in reverse-lexicographic (alphabetical) order.<p>
* *
* The returned comparator is serializable. * The returned comparator is serializable.
* *
* @return a comparator that imposes the reverse of the <i>natural * @return A comparator that imposes the reverse of the <i>natural
* ordering</i> on a collection of objects that implement * ordering</i> on a collection of objects that implement
* the <tt>Comparable</tt> interface. * the <tt>Comparable</tt> interface.
* @see Comparable * @see Comparable
...@@ -3575,16 +3575,18 @@ public class Collections { ...@@ -3575,16 +3575,18 @@ public class Collections {
/** /**
* Returns a comparator that imposes the reverse ordering of the specified * Returns a comparator that imposes the reverse ordering of the specified
* comparator. If the specified comparator is null, this method is * comparator. If the specified comparator is {@code null}, this method is
* equivalent to {@link #reverseOrder()} (in other words, it returns a * equivalent to {@link #reverseOrder()} (in other words, it returns a
* comparator that imposes the reverse of the <i>natural ordering</i> on a * comparator that imposes the reverse of the <em>natural ordering</em> on
* collection of objects that implement the Comparable interface). * a collection of objects that implement the Comparable interface).
* *
* <p>The returned comparator is serializable (assuming the specified * <p>The returned comparator is serializable (assuming the specified
* comparator is also serializable or null). * comparator is also serializable or {@code null}).
* *
* @return a comparator that imposes the reverse ordering of the * @param cmp a comparator who's ordering is to be reversed by the returned
* specified comparator * comparator or {@code null}
* @return A comparator that imposes the reverse ordering of the
* specified comparator.
* @since 1.5 * @since 1.5
*/ */
public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) { public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {
......
...@@ -241,7 +241,7 @@ class ComparableTimSort { ...@@ -241,7 +241,7 @@ class ComparableTimSort {
* pivot < all in [left, start), so pivot belongs at left. Note * pivot < all in [left, start), so pivot belongs at left. Note
* that if there are elements equal to pivot, left points to the * that if there are elements equal to pivot, left points to the
* first slot after them -- that's why this sort is stable. * first slot after them -- that's why this sort is stable.
* Slide elements over to make room to make room for pivot. * Slide elements over to make room for pivot.
*/ */
int n = start - left; // The number of elements to move int n = start - left; // The number of elements to move
// Switch is just an optimization for arraycopy in default case // Switch is just an optimization for arraycopy in default case
......
...@@ -26,69 +26,70 @@ ...@@ -26,69 +26,70 @@
package java.util; package java.util;
/** /**
* A {@link Map} that further provides a <i>total ordering</i> on its keys. * A {@link Map} that further provides a <em>total ordering</em> on its keys.
* The map is ordered according to the {@linkplain Comparable natural * The map is ordered according to the {@linkplain Comparable natural
* ordering} of its keys, or by a {@link Comparator} typically * ordering} of its keys, or by a {@link Comparator} typically
* provided at sorted map creation time. This order is reflected when * provided at sorted map creation time. This order is reflected when
* iterating over the sorted map's collection views (returned by the * iterating over the sorted map's collection views (returned by the
* <tt>entrySet</tt>, <tt>keySet</tt> and <tt>values</tt> methods). * {@code entrySet}, {@code keySet} and {@code values} methods).
* Several additional operations are provided to take advantage of the * Several additional operations are provided to take advantage of the
* ordering. (This interface is the map analogue of {@link * ordering. (This interface is the map analogue of {@link SortedSet}.)
* SortedSet}.)
* *
* <p>All keys inserted into a sorted map must implement the <tt>Comparable</tt> * <p>All keys inserted into a sorted map must implement the {@code Comparable}
* interface (or be accepted by the specified comparator). Furthermore, all * interface (or be accepted by the specified comparator). Furthermore, all
* such keys must be <i>mutually comparable</i>: <tt>k1.compareTo(k2)</tt> (or * such keys must be <em>mutually comparable</em>: {@code k1.compareTo(k2)} (or
* <tt>comparator.compare(k1, k2)</tt>) must not throw a * {@code comparator.compare(k1, k2)}) must not throw a
* <tt>ClassCastException</tt> for any keys <tt>k1</tt> and <tt>k2</tt> in * {@code ClassCastException} for any keys {@code k1} and {@code k2} in
* the sorted map. Attempts to violate this restriction will cause the * the sorted map. Attempts to violate this restriction will cause the
* offending method or constructor invocation to throw a * offending method or constructor invocation to throw a
* <tt>ClassCastException</tt>. * {@code ClassCastException}.
* *
* <p>Note that the ordering maintained by a sorted map (whether or not an * <p>Note that the ordering maintained by a sorted map (whether or not an
* explicit comparator is provided) must be <i>consistent with equals</i> if * explicit comparator is provided) must be <em>consistent with equals</em> if
* the sorted map is to correctly implement the <tt>Map</tt> interface. (See * the sorted map is to correctly implement the {@code Map} interface. (See
* the <tt>Comparable</tt> interface or <tt>Comparator</tt> interface for a * the {@code Comparable} interface or {@code Comparator} interface for a
* precise definition of <i>consistent with equals</i>.) This is so because * precise definition of <em>consistent with equals</em>.) This is so because
* the <tt>Map</tt> interface is defined in terms of the <tt>equals</tt> * the {@code Map} interface is defined in terms of the {@code equals}
* operation, but a sorted map performs all key comparisons using its * operation, but a sorted map performs all key comparisons using its
* <tt>compareTo</tt> (or <tt>compare</tt>) method, so two keys that are * {@code compareTo} (or {@code compare}) method, so two keys that are
* deemed equal by this method are, from the standpoint of the sorted map, * deemed equal by this method are, from the standpoint of the sorted map,
* equal. The behavior of a tree map <i>is</i> well-defined even if its * equal. The behavior of a tree map <em>is</em> well-defined even if its
* ordering is inconsistent with equals; it just fails to obey the general * ordering is inconsistent with equals; it just fails to obey the general
* contract of the <tt>Map</tt> interface. * contract of the {@code Map} interface.
* *
* <p>All general-purpose sorted map implementation classes should * <p>All general-purpose sorted map implementation classes should provide four
* provide four "standard" constructors: 1) A void (no arguments) * "standard" constructors. It is not possible to enforce this recommendation
* constructor, which creates an empty sorted map sorted according to * though as required constructors cannot be specified by interfaces. The
* the natural ordering of its keys. 2) A constructor with a * expected "standard" constructors for all sorted map implementations are:
* single argument of type <tt>Comparator</tt>, which creates an empty * <ol>
* sorted map sorted according to the specified comparator. 3) A * <li>A void (no arguments) constructor, which creates an empty sorted map
* constructor with a single argument of type <tt>Map</tt>, which * sorted according to the natural ordering of its keys.</li>
* creates a new map with the same key-value mappings as its argument, * <li>A constructor with a single argument of type {@code Comparator}, which
* sorted according to the keys' natural ordering. 4) A constructor * creates an empty sorted map sorted according to the specified comparator.</li>
* with a single argument of type <tt>SortedMap</tt>, * <li>A constructor with a single argument of type {@code Map}, which creates
* which creates a new sorted map with the same key-value mappings and * a new map with the same key-value mappings as its argument, sorted
* the same ordering as the input sorted map. There is no way to * according to the keys' natural ordering.</li>
* enforce this recommendation, as interfaces cannot contain * <li>A constructor with a single argument of type {@code SortedMap}, which
* constructors. * creates a new sorted map with the same key-value mappings and the same
* ordering as the input sorted map.</li>
* </ol>
* *
* <p>Note: several methods return submaps with restricted key ranges. * <p><strong>Note</strong>: several methods return submaps with restricted key
* Such ranges are <i>half-open</i>, that is, they include their low * ranges. Such ranges are <em>half-open</em>, that is, they include their low
* endpoint but not their high endpoint (where applicable). If you need a * endpoint but not their high endpoint (where applicable). If you need a
* <i>closed range</i> (which includes both endpoints), and the key type * <em>closed range</em> (which includes both endpoints), and the key type
* allows for calculation of the successor of a given key, merely request * allows for calculation of the successor of a given key, merely request
* the subrange from <tt>lowEndpoint</tt> to * the subrange from {@code lowEndpoint} to
* <tt>successor(highEndpoint)</tt>. For example, suppose that <tt>m</tt> * {@code successor(highEndpoint)}. For example, suppose that {@code m}
* is a map whose keys are strings. The following idiom obtains a view * is a map whose keys are strings. The following idiom obtains a view
* containing all of the key-value mappings in <tt>m</tt> whose keys are * containing all of the key-value mappings in {@code m} whose keys are
* between <tt>low</tt> and <tt>high</tt>, inclusive:<pre> * between {@code low} and {@code high}, inclusive:<pre>
* SortedMap&lt;String, V&gt; sub = m.subMap(low, high+"\0");</pre> * SortedMap&lt;String, V&gt; sub = m.subMap(low, high+"\0");</pre>
* *
* A similar technique can be used to generate an <i>open range</i> * A similar technique can be used to generate an <em>open range</em>
* (which contains neither endpoint). The following idiom obtains a * (which contains neither endpoint). The following idiom obtains a
* view containing all of the key-value mappings in <tt>m</tt> whose keys * view containing all of the key-value mappings in {@code m} whose keys
* are between <tt>low</tt> and <tt>high</tt>, exclusive:<pre> * are between {@code low} and {@code high}, exclusive:<pre>
* SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre> * SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre>
* *
* <p>This interface is a member of the * <p>This interface is a member of the
...@@ -112,96 +113,96 @@ package java.util; ...@@ -112,96 +113,96 @@ package java.util;
public interface SortedMap<K,V> extends Map<K,V> { public interface SortedMap<K,V> extends Map<K,V> {
/** /**
* Returns the comparator used to order the keys in this map, or * Returns the comparator used to order the keys in this map, or
* <tt>null</tt> if this map uses the {@linkplain Comparable * {@code null} if this map uses the {@linkplain Comparable
* natural ordering} of its keys. * natural ordering} of its keys.
* *
* @return the comparator used to order the keys in this map, * @return the comparator used to order the keys in this map,
* or <tt>null</tt> if this map uses the natural ordering * or {@code null} if this map uses the natural ordering
* of its keys * of its keys
*/ */
Comparator<? super K> comparator(); Comparator<? super K> comparator();
/** /**
* Returns a view of the portion of this map whose keys range from * Returns a view of the portion of this map whose keys range from
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive. (If * {@code fromKey}, inclusive, to {@code toKey}, exclusive. (If
* <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned map * {@code fromKey} and {@code toKey} are equal, the returned map
* is empty.) The returned map is backed by this map, so changes * is empty.) The returned map is backed by this map, so changes
* in the returned map are reflected in this map, and vice-versa. * in the returned map are reflected in this map, and vice-versa.
* The returned map supports all optional map operations that this * The returned map supports all optional map operations that this
* map supports. * map supports.
* *
* <p>The returned map will throw an <tt>IllegalArgumentException</tt> * <p>The returned map will throw an {@code IllegalArgumentException}
* on an attempt to insert a key outside its range. * on an attempt to insert a key outside its range.
* *
* @param fromKey low endpoint (inclusive) of the keys in the returned map * @param fromKey low endpoint (inclusive) of the keys in the returned map
* @param toKey high endpoint (exclusive) of the keys in the returned map * @param toKey high endpoint (exclusive) of the keys in the returned map
* @return a view of the portion of this map whose keys range from * @return a view of the portion of this map whose keys range from
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive * {@code fromKey}, inclusive, to {@code toKey}, exclusive
* @throws ClassCastException if <tt>fromKey</tt> and <tt>toKey</tt> * @throws ClassCastException if {@code fromKey} and {@code toKey}
* cannot be compared to one another using this map's comparator * cannot be compared to one another using this map's comparator
* (or, if the map has no comparator, using natural ordering). * (or, if the map has no comparator, using natural ordering).
* Implementations may, but are not required to, throw this * Implementations may, but are not required to, throw this
* exception if <tt>fromKey</tt> or <tt>toKey</tt> * exception if {@code fromKey} or {@code toKey}
* cannot be compared to keys currently in the map. * cannot be compared to keys currently in the map.
* @throws NullPointerException if <tt>fromKey</tt> or <tt>toKey</tt> * @throws NullPointerException if {@code fromKey} or {@code toKey}
* is null and this map does not permit null keys * is null and this map does not permit null keys
* @throws IllegalArgumentException if <tt>fromKey</tt> is greater than * @throws IllegalArgumentException if {@code fromKey} is greater than
* <tt>toKey</tt>; or if this map itself has a restricted * {@code toKey}; or if this map itself has a restricted
* range, and <tt>fromKey</tt> or <tt>toKey</tt> lies * range, and {@code fromKey} or {@code toKey} lies
* outside the bounds of the range * outside the bounds of the range
*/ */
SortedMap<K,V> subMap(K fromKey, K toKey); SortedMap<K,V> subMap(K fromKey, K toKey);
/** /**
* Returns a view of the portion of this map whose keys are * Returns a view of the portion of this map whose keys are
* strictly less than <tt>toKey</tt>. The returned map is backed * strictly less than {@code toKey}. The returned map is backed
* by this map, so changes in the returned map are reflected in * by this map, so changes in the returned map are reflected in
* this map, and vice-versa. The returned map supports all * this map, and vice-versa. The returned map supports all
* optional map operations that this map supports. * optional map operations that this map supports.
* *
* <p>The returned map will throw an <tt>IllegalArgumentException</tt> * <p>The returned map will throw an {@code IllegalArgumentException}
* on an attempt to insert a key outside its range. * on an attempt to insert a key outside its range.
* *
* @param toKey high endpoint (exclusive) of the keys in the returned map * @param toKey high endpoint (exclusive) of the keys in the returned map
* @return a view of the portion of this map whose keys are strictly * @return a view of the portion of this map whose keys are strictly
* less than <tt>toKey</tt> * less than {@code toKey}
* @throws ClassCastException if <tt>toKey</tt> is not compatible * @throws ClassCastException if {@code toKey} is not compatible
* with this map's comparator (or, if the map has no comparator, * with this map's comparator (or, if the map has no comparator,
* if <tt>toKey</tt> does not implement {@link Comparable}). * if {@code toKey} does not implement {@link Comparable}).
* Implementations may, but are not required to, throw this * Implementations may, but are not required to, throw this
* exception if <tt>toKey</tt> cannot be compared to keys * exception if {@code toKey} cannot be compared to keys
* currently in the map. * currently in the map.
* @throws NullPointerException if <tt>toKey</tt> is null and * @throws NullPointerException if {@code toKey} is null and
* this map does not permit null keys * this map does not permit null keys
* @throws IllegalArgumentException if this map itself has a * @throws IllegalArgumentException if this map itself has a
* restricted range, and <tt>toKey</tt> lies outside the * restricted range, and {@code toKey} lies outside the
* bounds of the range * bounds of the range
*/ */
SortedMap<K,V> headMap(K toKey); SortedMap<K,V> headMap(K toKey);
/** /**
* Returns a view of the portion of this map whose keys are * Returns a view of the portion of this map whose keys are
* greater than or equal to <tt>fromKey</tt>. The returned map is * greater than or equal to {@code fromKey}. The returned map is
* backed by this map, so changes in the returned map are * backed by this map, so changes in the returned map are
* reflected in this map, and vice-versa. The returned map * reflected in this map, and vice-versa. The returned map
* supports all optional map operations that this map supports. * supports all optional map operations that this map supports.
* *
* <p>The returned map will throw an <tt>IllegalArgumentException</tt> * <p>The returned map will throw an {@code IllegalArgumentException}
* on an attempt to insert a key outside its range. * on an attempt to insert a key outside its range.
* *
* @param fromKey low endpoint (inclusive) of the keys in the returned map * @param fromKey low endpoint (inclusive) of the keys in the returned map
* @return a view of the portion of this map whose keys are greater * @return a view of the portion of this map whose keys are greater
* than or equal to <tt>fromKey</tt> * than or equal to {@code fromKey}
* @throws ClassCastException if <tt>fromKey</tt> is not compatible * @throws ClassCastException if {@code fromKey} is not compatible
* with this map's comparator (or, if the map has no comparator, * with this map's comparator (or, if the map has no comparator,
* if <tt>fromKey</tt> does not implement {@link Comparable}). * if {@code fromKey} does not implement {@link Comparable}).
* Implementations may, but are not required to, throw this * Implementations may, but are not required to, throw this
* exception if <tt>fromKey</tt> cannot be compared to keys * exception if {@code fromKey} cannot be compared to keys
* currently in the map. * currently in the map.
* @throws NullPointerException if <tt>fromKey</tt> is null and * @throws NullPointerException if {@code fromKey} is null and
* this map does not permit null keys * this map does not permit null keys
* @throws IllegalArgumentException if this map itself has a * @throws IllegalArgumentException if this map itself has a
* restricted range, and <tt>fromKey</tt> lies outside the * restricted range, and {@code fromKey} lies outside the
* bounds of the range * bounds of the range
*/ */
SortedMap<K,V> tailMap(K fromKey); SortedMap<K,V> tailMap(K fromKey);
...@@ -228,12 +229,12 @@ public interface SortedMap<K,V> extends Map<K,V> { ...@@ -228,12 +229,12 @@ public interface SortedMap<K,V> extends Map<K,V> {
* The set is backed by the map, so changes to the map are * The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified * reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through * while an iteration over the set is in progress (except through
* the iterator's own <tt>remove</tt> operation), the results of * the iterator's own {@code remove} operation), the results of
* the iteration are undefined. The set supports element removal, * the iteration are undefined. The set supports element removal,
* which removes the corresponding mapping from the map, via the * which removes the corresponding mapping from the map, via the
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, * {@code Iterator.remove}, {@code Set.remove},
* <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> * {@code removeAll}, {@code retainAll}, and {@code clear}
* operations. It does not support the <tt>add</tt> or <tt>addAll</tt> * operations. It does not support the {@code add} or {@code addAll}
* operations. * operations.
* *
* @return a set view of the keys contained in this map, sorted in * @return a set view of the keys contained in this map, sorted in
...@@ -248,13 +249,13 @@ public interface SortedMap<K,V> extends Map<K,V> { ...@@ -248,13 +249,13 @@ public interface SortedMap<K,V> extends Map<K,V> {
* The collection is backed by the map, so changes to the map are * The collection is backed by the map, so changes to the map are
* reflected in the collection, and vice-versa. If the map is * reflected in the collection, and vice-versa. If the map is
* modified while an iteration over the collection is in progress * modified while an iteration over the collection is in progress
* (except through the iterator's own <tt>remove</tt> operation), * (except through the iterator's own {@code remove} operation),
* the results of the iteration are undefined. The collection * the results of the iteration are undefined. The collection
* supports element removal, which removes the corresponding * supports element removal, which removes the corresponding
* mapping from the map, via the <tt>Iterator.remove</tt>, * mapping from the map, via the {@code Iterator.remove},
* <tt>Collection.remove</tt>, <tt>removeAll</tt>, * {@code Collection.remove}, {@code removeAll},
* <tt>retainAll</tt> and <tt>clear</tt> operations. It does not * {@code retainAll} and {@code clear} operations. It does not
* support the <tt>add</tt> or <tt>addAll</tt> operations. * support the {@code add} or {@code addAll} operations.
* *
* @return a collection view of the values contained in this map, * @return a collection view of the values contained in this map,
* sorted in ascending key order * sorted in ascending key order
...@@ -267,14 +268,14 @@ public interface SortedMap<K,V> extends Map<K,V> { ...@@ -267,14 +268,14 @@ public interface SortedMap<K,V> extends Map<K,V> {
* The set is backed by the map, so changes to the map are * The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified * reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through * while an iteration over the set is in progress (except through
* the iterator's own <tt>remove</tt> operation, or through the * the iterator's own {@code remove} operation, or through the
* <tt>setValue</tt> operation on a map entry returned by the * {@code setValue} operation on a map entry returned by the
* iterator) the results of the iteration are undefined. The set * iterator) the results of the iteration are undefined. The set
* supports element removal, which removes the corresponding * supports element removal, which removes the corresponding
* mapping from the map, via the <tt>Iterator.remove</tt>, * mapping from the map, via the {@code Iterator.remove},
* <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt> and * {@code Set.remove}, {@code removeAll}, {@code retainAll} and
* <tt>clear</tt> operations. It does not support the * {@code clear} operations. It does not support the
* <tt>add</tt> or <tt>addAll</tt> operations. * {@code add} or {@code addAll} operations.
* *
* @return a set view of the mappings contained in this map, * @return a set view of the mappings contained in this map,
* sorted in ascending key order * sorted in ascending key order
......
...@@ -274,7 +274,7 @@ class TimSort<T> { ...@@ -274,7 +274,7 @@ class TimSort<T> {
* pivot < all in [left, start), so pivot belongs at left. Note * pivot < all in [left, start), so pivot belongs at left. Note
* that if there are elements equal to pivot, left points to the * that if there are elements equal to pivot, left points to the
* first slot after them -- that's why this sort is stable. * first slot after them -- that's why this sort is stable.
* Slide elements over to make room to make room for pivot. * Slide elements over to make room for pivot.
*/ */
int n = start - left; // The number of elements to move int n = start - left; // The number of elements to move
// Switch is just an optimization for arraycopy in default case // Switch is just an optimization for arraycopy in default case
......
...@@ -415,6 +415,12 @@ class JarVerifier { ...@@ -415,6 +415,12 @@ class JarVerifier {
pendingBlocks = null; pendingBlocks = null;
signerCache = null; signerCache = null;
manDig = null; manDig = null;
// MANIFEST.MF is always treated as signed and verified,
// move its signers from sigFileSigners to verifiedSigners.
if (sigFileSigners.containsKey(JarFile.MANIFEST_NAME)) {
verifiedSigners.put(JarFile.MANIFEST_NAME,
sigFileSigners.remove(JarFile.MANIFEST_NAME));
}
} }
static class VerifierStream extends java.io.InputStream { static class VerifierStream extends java.io.InputStream {
......
...@@ -1166,7 +1166,12 @@ public class LogManager { ...@@ -1166,7 +1166,12 @@ public class LogManager {
private static LoggingMXBean loggingMXBean = null; private static LoggingMXBean loggingMXBean = null;
/** /**
* String representation of the * String representation of the
* {@link javax.management.ObjectName} for {@link LoggingMXBean}. * {@link javax.management.ObjectName} for the management interface
* for the logging facility.
*
* @see java.lang.management.PlatformLoggingMXBean
* @see java.util.logging.LoggingMXBean
*
* @since 1.5 * @since 1.5
*/ */
public final static String LOGGING_MXBEAN_NAME public final static String LOGGING_MXBEAN_NAME
...@@ -1174,17 +1179,17 @@ public class LogManager { ...@@ -1174,17 +1179,17 @@ public class LogManager {
/** /**
* Returns <tt>LoggingMXBean</tt> for managing loggers. * Returns <tt>LoggingMXBean</tt> for managing loggers.
* An alternative way to manage loggers is using * An alternative way to manage loggers is through the
* the {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class) * {@link java.lang.management.PlatformLoggingMXBean} interface
* ManagementFactory.getPlatformMXBeans} method as follows: * that can be obtained by calling:
* <pre> * <pre>
* List&lt{@link PlatformLoggingMXBean}&gt result = ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class); * PlatformLoggingMXBean logging = {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
* ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class);
* </pre> * </pre>
* *
* @return a {@link LoggingMXBean} object. * @return a {@link LoggingMXBean} object.
* *
* @see PlatformLoggingMXBean * @see java.lang.management.PlatformLoggingMXBean
* @see java.lang.management.ManagementFactory
* @since 1.5 * @since 1.5
*/ */
public static synchronized LoggingMXBean getLoggingMXBean() { public static synchronized LoggingMXBean getLoggingMXBean() {
......
...@@ -27,36 +27,41 @@ package java.util.logging; ...@@ -27,36 +27,41 @@ package java.util.logging;
/** /**
* The management interface for the logging facility. * The management interface for the logging facility. It is recommended
* to use the {@link java.lang.management.PlatformLoggingMXBean} management
* interface that implements all attributes defined in this
* {@code LoggingMXBean}. The
* {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
* ManagementFactory.getPlatformMXBean} method can be used to obtain
* the {@code PlatformLoggingMXBean} object representing the management
* interface for logging.
* *
* <p>There is a single global instance of the <tt>LoggingMXBean</tt>. * <p>There is a single global instance of the <tt>LoggingMXBean</tt>.
* This instance is an * This instance is an {@link javax.management.MXBean MXBean} that
* <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a> * can be obtained by calling the {@link LogManager#getLoggingMXBean}
* can be obtained by calling * method or from the
* the {@link LogManager#getLoggingMXBean} method or from the
* {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
* platform <tt>MBeanServer</tt>}. * platform <tt>MBeanServer</tt>}.
* * <p>
* The {@link javax.management.ObjectName ObjectName} for uniquely * The {@link javax.management.ObjectName ObjectName} that uniquely identifies
* identifying the <tt>LoggingMXBean</tt> within an MBeanServer is: * the management interface for logging within the {@code MBeanServer} is:
* <blockquote> * <pre>
* {@link LogManager#LOGGING_MXBEAN_NAME * {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
* <tt>java.util.logging:type=Logging</tt>} * </pre>
* </blockquote> * <p>
* * The instance registered in the platform {@code MBeanServer}
* The instance registered in the platform <tt>MBeanServer</tt> with * is also a {@link java.lang.management.PlatformLoggingMXBean}.
* this {@code ObjectName} is also a {@link PlatformLoggingMXBean}.
* *
* @author Ron Mann * @author Ron Mann
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
* *
* @see PlatformLoggingMXBean * @see java.lang.management.PlatformLoggingMXBean
*/ */
public interface LoggingMXBean { public interface LoggingMXBean {
/** /**
* Returns the list of currently registered loggers. This method * Returns the list of currently registered logger names. This method
* calls {@link LogManager#getLoggerNames} and returns a list * calls {@link LogManager#getLoggerNames} and returns a list
* of the logger names. * of the logger names.
* *
...@@ -89,7 +94,7 @@ public interface LoggingMXBean { ...@@ -89,7 +94,7 @@ public interface LoggingMXBean {
* *
* @see Logger#getLevel * @see Logger#getLevel
*/ */
public String getLoggerLevel( String loggerName ); public String getLoggerLevel(String loggerName);
/** /**
* Sets the specified logger to the specified new level. * Sets the specified logger to the specified new level.
...@@ -115,7 +120,7 @@ public interface LoggingMXBean { ...@@ -115,7 +120,7 @@ public interface LoggingMXBean {
* *
* @see Logger#setLevel * @see Logger#setLevel
*/ */
public void setLoggerLevel( String loggerName, String levelName ); public void setLoggerLevel(String loggerName, String levelName);
/** /**
* Returns the name of the parent for the specified logger. * Returns the name of the parent for the specified logger.
......
...@@ -99,4 +99,9 @@ class LoggingProxyImpl implements LoggingProxy { ...@@ -99,4 +99,9 @@ class LoggingProxyImpl implements LoggingProxy {
public String getLevelName(Object level) { public String getLevelName(Object level) {
return ((Level) level).getName(); return ((Level) level).getName();
} }
@Override
public String getProperty(String key) {
return LogManager.getLogManager().getProperty(key);
}
} }
...@@ -29,31 +29,108 @@ package java.util.logging; ...@@ -29,31 +29,108 @@ package java.util.logging;
import java.io.*; import java.io.*;
import java.text.*; import java.text.*;
import java.util.Date; import java.util.Date;
import sun.util.logging.LoggingSupport;
/** /**
* Print a brief summary of the LogRecord in a human readable * Print a brief summary of the {@code LogRecord} in a human readable
* format. The summary will typically be 1 or 2 lines. * format. The summary will typically be 1 or 2 lines.
* *
* <p>
* <a name="formatting">
* <b>Configuration:</b></a>
* The {@code SimpleFormatter} is initialized with the
* <a href="../Formatter.html#syntax">format string</a>
* specified in the {@code java.util.logging.SimpleFormatter.format}
* property to {@linkplain #format format} the log messages.
* This property can be defined
* in the {@linkplain LogManager#getProperty logging properties}
* configuration file
* or as a system property. If this property is set in both
* the logging properties and system properties,
* the format string specified in the system property will be used.
* If this property is not defined or the given format string
* is {@linkplain java.util.IllegalFormatException illegal},
* the default format is implementation-specific.
*
* @since 1.4 * @since 1.4
* @see java.util.Formatter
*/ */
public class SimpleFormatter extends Formatter { public class SimpleFormatter extends Formatter {
Date dat = new Date(); // format string for printing the log record
private final static String format = "{0,date} {0,time}"; private static final String format = LoggingSupport.getSimpleFormat();
private MessageFormat formatter; private final Date dat = new Date();
private Object args[] = new Object[1];
// Line separator string. This is the value of the line.separator
// property at the moment that the SimpleFormatter was created.
private String lineSeparator = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("line.separator"));
/** /**
* Format the given LogRecord. * Format the given LogRecord.
* <p> * <p>
* This method can be overridden in a subclass. * The formatting can be customized by specifying the
* <a href="../Formatter.html#syntax">format string</a>
* in the <a href="#formatting">
* {@code java.util.logging.SimpleFormatter.format}</a> property.
* The given {@code LogRecord} will be formatted as if by calling:
* <pre>
* {@link String#format String.format}(format, date, source, logger, level, message, thrown);
* </pre>
* where the arguments are:<br>
* <ol>
* <li>{@code format} - the {@link java.util.Formatter
* java.util.Formatter} format string specified in the
* {@code java.util.logging.SimpleFormatter.format} property
* or the default format.</li>
* <li>{@code date} - a {@link Date} object representing
* {@linkplain LogRecord#getMillis event time} of the log record.</li>
* <li>{@code source} - a string representing the caller, if available;
* otherwise, the logger's name.</li>
* <li>{@code logger} - the logger's name.</li>
* <li>{@code level} - the {@linkplain Level#getLocalizedName
* log level}.</li>
* <li>{@code message} - the formatted log message
* returned from the {@link Formatter#formatMessage(LogRecord)}
* method. It uses {@link java.text.MessageFormat java.text}
* formatting and does not use the {@code java.util.Formatter
* format} argument.</li>
* <li>{@code thrown} - a string representing
* the {@linkplain LogRecord#getThrown throwable}
* associated with the log record and its backtrace
* beginning with a newline character, if any;
* otherwise, an empty string.</li>
* </ol>
*
* <p>Some example formats:<br>
* <ul>
* <li> {@code java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"}
* <p>This prints 1 line with the log level ({@code 4$}),
* the log message ({@code 5$}) and the timestamp ({@code 1$}) in
* a square bracket.
* <pre>
* WARNING: warning message [Tue Mar 22 13:11:31 PDT 2011]
* </pre></li>
* <li> {@code java.util.logging.SimpleFormatter.format="%1$tc %2$s%n%4$s: %5$s%6$s%n"}
* <p>This prints 2 lines where the first line includes
* the timestamp ({@code 1$}) and the source ({@code 2$});
* the second line includes the log level ({@code 4$}) and
* the log message ({@code 5$}) followed with the throwable
* and its backtrace ({@code 6$}), if any:
* <pre>
* Tue Mar 22 13:11:31 PDT 2011 MyClass fatal
* SEVERE: several message with an exception
* java.lang.IllegalArgumentException: invalid argument
* at MyClass.mash(MyClass.java:9)
* at MyClass.crunch(MyClass.java:6)
* at MyClass.main(MyClass.java:3)
* </pre></li>
* <li> {@code java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n"}
* <p>This prints 2 lines similar to the example above
* with a different date/time formatting and does not print
* the throwable and its backtrace:
* <pre>
* Mar 22, 2011 1:11:31 PM MyClass fatal
* SEVERE: several message with an exception
* </pre></li>
* </ul>
* <p>This method can also be overridden in a subclass.
* It is recommended to use the {@link Formatter#formatMessage} * It is recommended to use the {@link Formatter#formatMessage}
* convenience method to localize and format the message field. * convenience method to localize and format the message field.
* *
...@@ -61,42 +138,32 @@ public class SimpleFormatter extends Formatter { ...@@ -61,42 +138,32 @@ public class SimpleFormatter extends Formatter {
* @return a formatted log record * @return a formatted log record
*/ */
public synchronized String format(LogRecord record) { public synchronized String format(LogRecord record) {
StringBuffer sb = new StringBuffer();
// Minimize memory allocations here.
dat.setTime(record.getMillis()); dat.setTime(record.getMillis());
args[0] = dat; String source;
StringBuffer text = new StringBuffer();
if (formatter == null) {
formatter = new MessageFormat(format);
}
formatter.format(args, text, null);
sb.append(text);
sb.append(" ");
if (record.getSourceClassName() != null) { if (record.getSourceClassName() != null) {
sb.append(record.getSourceClassName()); source = record.getSourceClassName();
} else {
sb.append(record.getLoggerName());
}
if (record.getSourceMethodName() != null) { if (record.getSourceMethodName() != null) {
sb.append(" "); source += " " + record.getSourceMethodName();
sb.append(record.getSourceMethodName()); }
} else {
source = record.getLoggerName();
} }
sb.append(lineSeparator);
String message = formatMessage(record); String message = formatMessage(record);
sb.append(record.getLevel().getLocalizedName()); String throwable = "";
sb.append(": ");
sb.append(message);
sb.append(lineSeparator);
if (record.getThrown() != null) { if (record.getThrown() != null) {
try {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw); PrintWriter pw = new PrintWriter(sw);
pw.println();
record.getThrown().printStackTrace(pw); record.getThrown().printStackTrace(pw);
pw.close(); pw.close();
sb.append(sw.toString()); throwable = sw.toString();
} catch (Exception ex) {
}
} }
return sb.toString(); return String.format(format,
dat,
source,
record.getLoggerName(),
record.getLevel().getLocalizedName(),
message,
throwable);
} }
} }
...@@ -206,17 +206,12 @@ class DeflaterOutputStream extends FilterOutputStream { ...@@ -206,17 +206,12 @@ class DeflaterOutputStream extends FilterOutputStream {
return; return;
} }
if (!def.finished()) { if (!def.finished()) {
// Deflate no more than stride bytes at a time. This avoids def.setInput(b, off, len);
// excess copying in deflateBytes (see Deflater.c)
int stride = buf.length;
for (int i = 0; i < len; i+= stride) {
def.setInput(b, off + i, Math.min(stride, len - i));
while (!def.needsInput()) { while (!def.needsInput()) {
deflate(); deflate();
} }
} }
} }
}
/** /**
* Finishes writing compressed data to the output stream without closing * Finishes writing compressed data to the output stream without closing
......
/* /*
* Copyright (c) 2003, 2005, 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
...@@ -51,7 +51,7 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters { ...@@ -51,7 +51,7 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters {
* @exception NullPointerException if builder is null * @exception NullPointerException if builder is null
*/ */
public KeyStoreBuilderParameters(Builder builder) { public KeyStoreBuilderParameters(Builder builder) {
parameters = Collections.singletonList(builder); parameters = Collections.singletonList(Objects.requireNonNull(builder));
} }
/** /**
...@@ -64,11 +64,12 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters { ...@@ -64,11 +64,12 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters {
* @exception IllegalArgumentException if parameters is an empty list * @exception IllegalArgumentException if parameters is an empty list
*/ */
public KeyStoreBuilderParameters(List<Builder> parameters) { public KeyStoreBuilderParameters(List<Builder> parameters) {
this.parameters = Collections.unmodifiableList( if (parameters.isEmpty()) {
new ArrayList<Builder>(parameters));
if (this.parameters.isEmpty()) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.parameters = Collections.unmodifiableList(
new ArrayList<Builder>(parameters));
} }
/** /**
......
/*
* 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.
*/
package sun.awt;
import java.awt.*;
import java.awt.dnd.*;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.im.InputMethodHighlight;
import java.awt.im.spi.InputMethodDescriptor;
import java.awt.image.*;
import java.awt.datatransfer.Clipboard;
import java.awt.peer.*;
import java.util.Map;
import java.util.Properties;
/*
* HToolkit is a platform independent Toolkit used
* with the HeadlessToolkit. It is primarily used
* in embedded JRE's that do not have sun/awt/X11 classes.
*/
public class HToolkit extends SunToolkit
implements ComponentFactory {
public HToolkit() {
}
/*
* Component peer objects - unsupported.
*/
public WindowPeer createWindow(Window target)
throws HeadlessException {
throw new HeadlessException();
}
public FramePeer createFrame(Frame target)
throws HeadlessException {
throw new HeadlessException();
}
public DialogPeer createDialog(Dialog target)
throws HeadlessException {
throw new HeadlessException();
}
public ButtonPeer createButton(Button target)
throws HeadlessException {
throw new HeadlessException();
}
public TextFieldPeer createTextField(TextField target)
throws HeadlessException {
throw new HeadlessException();
}
public ChoicePeer createChoice(Choice target)
throws HeadlessException {
throw new HeadlessException();
}
public LabelPeer createLabel(Label target)
throws HeadlessException {
throw new HeadlessException();
}
public ListPeer createList(List target)
throws HeadlessException {
throw new HeadlessException();
}
public CheckboxPeer createCheckbox(Checkbox target)
throws HeadlessException {
throw new HeadlessException();
}
public ScrollbarPeer createScrollbar(Scrollbar target)
throws HeadlessException {
throw new HeadlessException();
}
public ScrollPanePeer createScrollPane(ScrollPane target)
throws HeadlessException {
throw new HeadlessException();
}
public TextAreaPeer createTextArea(TextArea target)
throws HeadlessException {
throw new HeadlessException();
}
public FileDialogPeer createFileDialog(FileDialog target)
throws HeadlessException {
throw new HeadlessException();
}
public MenuBarPeer createMenuBar(MenuBar target)
throws HeadlessException {
throw new HeadlessException();
}
public MenuPeer createMenu(Menu target)
throws HeadlessException {
throw new HeadlessException();
}
public PopupMenuPeer createPopupMenu(PopupMenu target)
throws HeadlessException {
throw new HeadlessException();
}
public MenuItemPeer createMenuItem(MenuItem target)
throws HeadlessException {
throw new HeadlessException();
}
public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
throws HeadlessException {
throw new HeadlessException();
}
public DragSourceContextPeer createDragSourceContextPeer(
DragGestureEvent dge)
throws InvalidDnDOperationException {
throw new InvalidDnDOperationException("Headless environment");
}
public RobotPeer createRobot(Robot target, GraphicsDevice screen)
throws AWTException, HeadlessException {
throw new HeadlessException();
}
public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
// See 6833019.
return
new KeyboardFocusManagerPeer() {
public Window getCurrentFocusedWindow() { return null; }
public void setCurrentFocusOwner(Component comp) {}
public Component getCurrentFocusOwner() { return null; }
public void clearGlobalFocusOwner(Window activeWindow) {}
};
}
public TrayIconPeer createTrayIcon(TrayIcon target)
throws HeadlessException {
throw new HeadlessException();
}
public SystemTrayPeer createSystemTray(SystemTray target)
throws HeadlessException {
throw new HeadlessException();
}
public boolean isTraySupported() {
return false;
}
public GlobalCursorManager getGlobalCursorManager()
throws HeadlessException {
throw new HeadlessException();
}
/*
* Headless toolkit - unsupported.
*/
protected void loadSystemColors(int[] systemColors)
throws HeadlessException {
throw new HeadlessException();
}
public ColorModel getColorModel()
throws HeadlessException {
throw new HeadlessException();
}
public int getScreenResolution()
throws HeadlessException {
throw new HeadlessException();
}
public Map mapInputMethodHighlight(InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}
public int getMenuShortcutKeyMask()
throws HeadlessException {
throw new HeadlessException();
}
public boolean getLockingKeyState(int keyCode)
throws UnsupportedOperationException {
throw new HeadlessException();
}
public void setLockingKeyState(int keyCode, boolean on)
throws UnsupportedOperationException {
throw new HeadlessException();
}
public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
throws IndexOutOfBoundsException, HeadlessException {
throw new HeadlessException();
}
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
throws HeadlessException {
throw new HeadlessException();
}
public int getMaximumCursorColors()
throws HeadlessException {
throw new HeadlessException();
}
public <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> abstractRecognizerClass,
DragSource ds, Component c,
int srcActions, DragGestureListener dgl)
{
return null;
}
public int getScreenHeight()
throws HeadlessException {
throw new HeadlessException();
}
public int getScreenWidth()
throws HeadlessException {
throw new HeadlessException();
}
public Dimension getScreenSize()
throws HeadlessException {
throw new HeadlessException();
}
public Insets getScreenInsets(GraphicsConfiguration gc)
throws HeadlessException {
throw new HeadlessException();
}
public void setDynamicLayout(boolean dynamic)
throws HeadlessException {
throw new HeadlessException();
}
protected boolean isDynamicLayoutSet()
throws HeadlessException {
throw new HeadlessException();
}
public boolean isDynamicLayoutActive()
throws HeadlessException {
throw new HeadlessException();
}
public Clipboard getSystemClipboard()
throws HeadlessException {
throw new HeadlessException();
}
/*
* Printing
*/
public PrintJob getPrintJob(Frame frame, String jobtitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) {
if (frame != null) {
// Should never happen
throw new HeadlessException();
}
throw new IllegalArgumentException(
"PrintJob not supported in a headless environment");
}
public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
{
if (frame != null) {
// Should never happen
throw new HeadlessException();
}
throw new IllegalArgumentException(
"PrintJob not supported in a headless environment");
}
/*
* Headless toolkit - supported.
*/
public void sync() {
// Do nothing
}
protected boolean syncNativeQueue(final long timeout) {
return false;
}
public void beep() {
// Send alert character
System.out.write(0x07);
}
/*
* Fonts
*/
public FontPeer getFontPeer(String name, int style) {
return (FontPeer)null;
}
/*
* Modality
*/
public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
return false;
}
public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
return false;
}
public boolean isDesktopSupported() {
return false;
}
public DesktopPeer createDesktopPeer(Desktop target)
throws HeadlessException{
throw new HeadlessException();
}
public boolean isWindowOpacityControlSupported() {
return false;
}
public boolean isWindowShapingSupported() {
return false;
}
public boolean isWindowTranslucencySupported() {
return false;
}
public void grab(Window w) { }
public void ungrab(Window w) { }
protected boolean syncNativeQueue() { return false; }
public InputMethodDescriptor getInputMethodAdapterDescriptor()
throws AWTException
{
return (InputMethodDescriptor)null;
}
}
...@@ -27,20 +27,18 @@ package sun.management; ...@@ -27,20 +27,18 @@ package sun.management;
import java.lang.management.*; import java.lang.management.*;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException; import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.MBeanRegistrationException; import javax.management.MBeanRegistrationException;
import javax.management.NotCompliantMBeanException; import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.RuntimeOperationsException; import javax.management.RuntimeOperationsException;
import java.nio.BufferPoolMXBean;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedActionException; import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import sun.security.action.LoadLibraryAction; import sun.security.action.LoadLibraryAction;
import java.util.logging.PlatformLoggingMXBean;
import sun.util.logging.LoggingSupport; import sun.util.logging.LoggingSupport;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -139,17 +137,34 @@ public class ManagementFactoryHelper { ...@@ -139,17 +137,34 @@ public class ManagementFactoryHelper {
return result; return result;
} }
public static List<PlatformLoggingMXBean> getLoggingMXBean() { public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
if (LoggingSupport.isAvailable()) { if (LoggingSupport.isAvailable()) {
return Collections.singletonList(createPlatformLoggingMXBean()); return PlatformLoggingImpl.instance;
} else { } else {
return Collections.emptyList(); return null;
} }
} }
private final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging"; // The logging MXBean object is an instance of
private static PlatformLoggingMXBean createPlatformLoggingMXBean() { // PlatformLoggingMXBean and java.util.logging.LoggingMXBean
return new PlatformLoggingMXBean() { // but it can't directly implement two MXBean interfaces
// as a compliant MXBean implements exactly one MXBean interface,
// or if it implements one interface that is a subinterface of
// all the others; otherwise, it is a non-compliant MXBean
// and MBeanServer will throw NotCompliantMBeanException.
// See the Definition of an MXBean section in javax.management.MXBean spec.
//
// To create a compliant logging MXBean, define a LoggingMXBean interface
// that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
interface LoggingMXBean
extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean {
}
static class PlatformLoggingImpl implements LoggingMXBean
{
final static PlatformLoggingMXBean instance = new PlatformLoggingImpl();
final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
private volatile ObjectName objname; // created lazily private volatile ObjectName objname; // created lazily
@Override @Override
public ObjectName getObjectName() { public ObjectName getObjectName() {
...@@ -184,16 +199,18 @@ public class ManagementFactoryHelper { ...@@ -184,16 +199,18 @@ public class ManagementFactoryHelper {
public String getParentLoggerName(String loggerName) { public String getParentLoggerName(String loggerName) {
return LoggingSupport.getParentLoggerName(loggerName); return LoggingSupport.getParentLoggerName(loggerName);
} }
};
} }
public static List<BufferPoolMXBean> getBufferPoolMXBeans() { private static List<BufferPoolMXBean> bufferPools = null;
List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2); public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() {
pools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess() if (bufferPools == null) {
bufferPools = new ArrayList<>(2);
bufferPools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
.getDirectBufferPool())); .getDirectBufferPool()));
pools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
.getMappedBufferPool())); .getMappedBufferPool()));
return pools; }
return bufferPools;
} }
private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool"; private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool";
......
/* /*
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 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
...@@ -87,12 +87,26 @@ public class Version { ...@@ -87,12 +87,26 @@ public class Version {
* Give a stream, it will print version info on it. * Give a stream, it will print version info on it.
*/ */
public static void print(PrintStream ps) { public static void print(PrintStream ps) {
boolean isHeadless = false;
/* Report that we're running headless if the property is true */
String headless = System.getProperty("java.awt.headless");
if ( (headless != null) && (headless.equalsIgnoreCase("true")) ) {
isHeadless = true;
}
/* First line: platform version. */ /* First line: platform version. */
ps.println(launcher_name + " version \"" + java_version + "\""); ps.println(launcher_name + " version \"" + java_version + "\"");
/* Second line: runtime version (ie, libraries). */ /* Second line: runtime version (ie, libraries). */
ps.println(java_runtime_name + " (build " +
java_runtime_version + ")"); ps.print(java_runtime_name + " (build " + java_runtime_version);
if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) {
// embedded builds report headless state
ps.print(", headless");
}
ps.println(')');
/* Third line: JVM information. */ /* Third line: JVM information. */
String java_vm_name = System.getProperty("java.vm.name"); String java_vm_name = System.getProperty("java.vm.name");
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package sun.nio.fs; package sun.nio.fs;
import java.util.*; import java.util.*;
import java.nio.file.*;
/** /**
* Utility methods * Utility methods
...@@ -80,4 +81,21 @@ class Util { ...@@ -80,4 +81,21 @@ class Util {
} }
return set; return set;
} }
/**
* Returns {@code true} if symbolic links should be followed
*/
static boolean followLinks(LinkOption... options) {
boolean followLinks = true;
for (LinkOption option: options) {
if (option == LinkOption.NOFOLLOW_LINKS) {
followLinks = false;
} else if (option == null) {
throw new NullPointerException();
} else {
throw new AssertionError("Should not get here");
}
}
return followLinks;
}
} }
/* /*
* Copyright (c) 2000, 2009, 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
...@@ -362,19 +362,15 @@ public class Realm implements Cloneable { ...@@ -362,19 +362,15 @@ public class Realm implements Cloneable {
Stack<String> iStack = new Stack<>(); Stack<String> iStack = new Stack<>();
/* /*
* I don't expect any more than a handful of intermediaries. * The half-established reversed-path, starting from the final target
* (sRealm), each item can be connected to by the next one.
* Might contains wrong item, if found, a bad track is performed
*/ */
Vector<String> tempList = new Vector<>(8, 8); Vector<String> tempList = new Vector<>(8, 8);
tempList.add(sRealm);
/*
* The initiator at first location.
*/
tempList.add(cRealm);
int count = 0; // For debug only int count = 0; // For debug only
if (DEBUG) {
tempTarget = sRealm; tempTarget = sRealm;
}
out: do { out: do {
if (DEBUG) { if (DEBUG) {
...@@ -384,8 +380,8 @@ public class Realm implements Cloneable { ...@@ -384,8 +380,8 @@ public class Realm implements Cloneable {
} }
if (intermediaries != null && if (intermediaries != null &&
!intermediaries.equals(PrincipalName.REALM_COMPONENT_SEPARATOR_STR)) !intermediaries.equals(".") &&
{ !intermediaries.equals(cRealm)) {
if (DEBUG) { if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " + System.out.println(">>> Realm parseCapaths: loop " +
count + ": intermediaries=[" + count + ": intermediaries=[" +
...@@ -466,11 +462,15 @@ public class Realm implements Cloneable { ...@@ -466,11 +462,15 @@ public class Realm implements Cloneable {
} while (true); } while (true);
if (tempList.isEmpty()) {
return null;
}
// From (SREALM, T1, T2) to (CREALM, T2, T1)
retList = new String[tempList.size()]; retList = new String[tempList.size()];
try { retList[0] = cRealm;
retList = tempList.toArray(retList); for (int i=1; i<tempList.size(); i++) {
} catch (ArrayStoreException exc) { retList[i] = tempList.elementAt(tempList.size()-i);
retList = null;
} }
if (DEBUG && retList != null) { if (DEBUG && retList != null) {
......
/* /*
* 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
...@@ -694,47 +694,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange ...@@ -694,47 +694,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange
// the preferable signature algorithm used by this ServerKeyExchange message // the preferable signature algorithm used by this ServerKeyExchange message
private SignatureAndHashAlgorithm preferableSignatureAlgorithm; private SignatureAndHashAlgorithm preferableSignatureAlgorithm;
/* Return the Diffie-Hellman modulus */
BigInteger getModulus() {
return new BigInteger(1, dh_p);
}
/* Return the Diffie-Hellman base/generator */
BigInteger getBase() {
return new BigInteger(1, dh_g);
}
/* Return the server's Diffie-Hellman public key */
BigInteger getServerPublicKey() {
return new BigInteger(1, dh_Ys);
}
/*
* Update sig with nonces and Diffie-Hellman public key.
*/
private void updateSignature(Signature sig, byte clntNonce[],
byte svrNonce[]) throws SignatureException {
int tmp;
sig.update(clntNonce);
sig.update(svrNonce);
tmp = dh_p.length;
sig.update((byte)(tmp >> 8));
sig.update((byte)(tmp & 0x0ff));
sig.update(dh_p);
tmp = dh_g.length;
sig.update((byte)(tmp >> 8));
sig.update((byte)(tmp & 0x0ff));
sig.update(dh_g);
tmp = dh_Ys.length;
sig.update((byte)(tmp >> 8));
sig.update((byte)(tmp & 0x0ff));
sig.update(dh_Ys);
}
/* /*
* Construct from initialized DH key object, for DH_anon * Construct from initialized DH key object, for DH_anon
* key exchange. * key exchange.
...@@ -779,12 +738,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange ...@@ -779,12 +738,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange
signature = sig.sign(); signature = sig.sign();
} }
private void setValues(DHCrypt obj) {
dh_p = toByteArray(obj.getModulus());
dh_g = toByteArray(obj.getBase());
dh_Ys = toByteArray(obj.getPublicKey());
}
/* /*
* Construct a DH_ServerKeyExchange message from an input * Construct a DH_ServerKeyExchange message from an input
* stream, as if sent from server to client for use with * stream, as if sent from server to client for use with
...@@ -875,6 +828,53 @@ class DH_ServerKeyExchange extends ServerKeyExchange ...@@ -875,6 +828,53 @@ class DH_ServerKeyExchange extends ServerKeyExchange
} }
} }
/* Return the Diffie-Hellman modulus */
BigInteger getModulus() {
return new BigInteger(1, dh_p);
}
/* Return the Diffie-Hellman base/generator */
BigInteger getBase() {
return new BigInteger(1, dh_g);
}
/* Return the server's Diffie-Hellman public key */
BigInteger getServerPublicKey() {
return new BigInteger(1, dh_Ys);
}
/*
* Update sig with nonces and Diffie-Hellman public key.
*/
private void updateSignature(Signature sig, byte clntNonce[],
byte svrNonce[]) throws SignatureException {
int tmp;
sig.update(clntNonce);
sig.update(svrNonce);
tmp = dh_p.length;
sig.update((byte)(tmp >> 8));
sig.update((byte)(tmp & 0x0ff));
sig.update(dh_p);
tmp = dh_g.length;
sig.update((byte)(tmp >> 8));
sig.update((byte)(tmp & 0x0ff));
sig.update(dh_g);
tmp = dh_Ys.length;
sig.update((byte)(tmp >> 8));
sig.update((byte)(tmp & 0x0ff));
sig.update(dh_Ys);
}
private void setValues(DHCrypt obj) {
dh_p = toByteArray(obj.getModulus());
dh_g = toByteArray(obj.getBase());
dh_Ys = toByteArray(obj.getPublicKey());
}
int messageLength() { int messageLength() {
int temp = 6; // overhead for p, g, y(s) values. int temp = 6; // overhead for p, g, y(s) values.
...@@ -945,8 +945,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange ...@@ -945,8 +945,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
* We support named curves only, no explicitly encoded curves. * We support named curves only, no explicitly encoded curves.
*/ */
static final static final
class ECDH_ServerKeyExchange extends ServerKeyExchange class ECDH_ServerKeyExchange extends ServerKeyExchange {
{
// constants for ECCurveType // constants for ECCurveType
private final static int CURVE_EXPLICIT_PRIME = 1; private final static int CURVE_EXPLICIT_PRIME = 1;
...@@ -1120,11 +1119,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange ...@@ -1120,11 +1119,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
} }
int messageLength() { int messageLength() {
int sigLen = (signatureBytes == null) ? 0 : 2 + signatureBytes.length; int sigLen = 0;
if (signatureBytes != null) {
sigLen = 2 + signatureBytes.length;
if (protocolVersion.v >= ProtocolVersion.TLS12.v) { if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
sigLen += SignatureAndHashAlgorithm.sizeInRecord(); sigLen += SignatureAndHashAlgorithm.sizeInRecord();
} }
}
return 4 + pointBytes.length + sigLen; return 4 + pointBytes.length + sigLen;
} }
...@@ -1133,12 +1134,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange ...@@ -1133,12 +1134,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
s.putInt8(CURVE_NAMED_CURVE); s.putInt8(CURVE_NAMED_CURVE);
s.putInt16(curveId); s.putInt16(curveId);
s.putBytes8(pointBytes); s.putBytes8(pointBytes);
if (signatureBytes != null) {
if (protocolVersion.v >= ProtocolVersion.TLS12.v) { if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
s.putInt8(preferableSignatureAlgorithm.getHashValue()); s.putInt8(preferableSignatureAlgorithm.getHashValue());
s.putInt8(preferableSignatureAlgorithm.getSignatureValue()); s.putInt8(preferableSignatureAlgorithm.getSignatureValue());
} }
if (signatureBytes != null) {
s.putBytes16(signatureBytes); s.putBytes16(signatureBytes);
} }
} }
...@@ -1147,10 +1149,14 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange ...@@ -1147,10 +1149,14 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
s.println("*** ECDH ServerKeyExchange"); s.println("*** ECDH ServerKeyExchange");
if (debug != null && Debug.isOn("verbose")) { if (debug != null && Debug.isOn("verbose")) {
if (signatureBytes == null) {
s.println("Anonymous");
} else {
if (protocolVersion.v >= ProtocolVersion.TLS12.v) { if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
s.println("Signature Algorithm " + s.println("Signature Algorithm " +
preferableSignatureAlgorithm.getAlgorithmName()); preferableSignatureAlgorithm.getAlgorithmName());
} }
}
s.println("Server key: " + publicKey); s.println("Server key: " + publicKey);
} }
......
...@@ -1238,10 +1238,11 @@ public class JarSigner { ...@@ -1238,10 +1238,11 @@ public class JarSigner {
// Provide a helpful message when TSA is beyond a firewall // Provide a helpful message when TSA is beyond a firewall
error(rb.getString("unable.to.sign.jar.") + error(rb.getString("unable.to.sign.jar.") +
rb.getString("no.response.from.the.Timestamping.Authority.") + rb.getString("no.response.from.the.Timestamping.Authority.") +
rb.getString("When.connecting.from.behind.a.firewall.then.an.HTTP.proxy.may.need.to.be.specified.") + "\n -J-Dhttp.proxyHost=<hostname>" +
rb.getString("Supply.the.following.options.to.jarsigner.") + "\n -J-Dhttp.proxyPort=<portnumber>\n" +
"\n -J-Dhttp.proxyHost=<hostname> " + rb.getString("or") +
"\n -J-Dhttp.proxyPort=<portnumber> ", e); "\n -J-Dhttps.proxyHost=<hostname> " +
"\n -J-Dhttps.proxyPort=<portnumber> ", e);
} }
sfFilename = sf.getMetaName(); sfFilename = sf.getMetaName();
......
...@@ -181,11 +181,10 @@ public class JarSignerResources extends java.util.ListResourceBundle { ...@@ -181,11 +181,10 @@ public class JarSignerResources extends java.util.ListResourceBundle {
{"TSA.location.", "TSA location: "}, {"TSA.location.", "TSA location: "},
{"TSA.certificate.", "TSA certificate: "}, {"TSA.certificate.", "TSA certificate: "},
{"no.response.from.the.Timestamping.Authority.", {"no.response.from.the.Timestamping.Authority.",
"no response from the Timestamping Authority. "}, "no response from the Timestamping Authority. When connecting"
{"When.connecting.from.behind.a.firewall.then.an.HTTP.proxy.may.need.to.be.specified.", + " from behind a firewall an HTTP or HTTPS proxy may need to"
"When connecting from behind a firewall then an HTTP proxy may need to be specified. "}, + " be specified. Supply the following options to jarsigner:"},
{"Supply.the.following.options.to.jarsigner.", {"or", "or"},
"Supply the following options to jarsigner: "},
{"Certificate.not.found.for.alias.alias.must.reference.a.valid.KeyStore.entry.containing.an.X.509.public.key.certificate.for.the", {"Certificate.not.found.for.alias.alias.must.reference.a.valid.KeyStore.entry.containing.an.X.509.public.key.certificate.for.the",
"Certificate not found for: {0}. {1} must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority."}, "Certificate not found for: {0}. {1} must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority."},
{"using.an.alternative.signing.mechanism", {"using.an.alternative.signing.mechanism",
......
...@@ -1740,16 +1740,19 @@ public final class KeyTool { ...@@ -1740,16 +1740,19 @@ public final class KeyTool {
KeyStore.TrustedCertificateEntry.class)) { KeyStore.TrustedCertificateEntry.class)) {
// We have a trusted certificate entry // We have a trusted certificate entry
Certificate cert = keyStore.getCertificate(alias); Certificate cert = keyStore.getCertificate(alias);
Object[] source = {"trustedCertEntry"};
String mf = new MessageFormat(
rb.getString("Entry.type.type.")).format(source) + "\n";
if (verbose && (cert instanceof X509Certificate)) { if (verbose && (cert instanceof X509Certificate)) {
out.println(rb.getString("Entry.type.trustedCertEntry.")); out.println(mf);
printX509Cert((X509Certificate)cert, out); printX509Cert((X509Certificate)cert, out);
} else if (rfc) { } else if (rfc) {
out.println(rb.getString("Entry.type.trustedCertEntry.")); out.println(mf);
dumpCert(cert, out); dumpCert(cert, out);
} else if (debug) { } else if (debug) {
out.println(cert.toString()); out.println(cert.toString());
} else { } else {
out.println(rb.getString("trustedCertEntry.")); out.println("trustedCertEntry, ");
out.println(rb.getString("Certificate.fingerprint.SHA1.") out.println(rb.getString("Certificate.fingerprint.SHA1.")
+ getCertFingerPrint("SHA1", cert)); + getCertFingerPrint("SHA1", cert));
} }
...@@ -1836,10 +1839,6 @@ public final class KeyTool { ...@@ -1836,10 +1839,6 @@ public final class KeyTool {
(".WARNING.WARNING.WARNING.")); (".WARNING.WARNING.WARNING."));
System.err.println(rb.getString System.err.println(rb.getString
(".The.integrity.of.the.information.stored.in.the.srckeystore.")); (".The.integrity.of.the.information.stored.in.the.srckeystore."));
System.err.println(rb.getString
(".has.NOT.been.verified.In.order.to.verify.its.integrity."));
System.err.println(rb.getString
(".you.must.provide.the.srckeystore.password."));
System.err.println(rb.getString System.err.println(rb.getString
(".WARNING.WARNING.WARNING.")); (".WARNING.WARNING.WARNING."));
System.err.println(); System.err.println();
...@@ -3186,10 +3185,6 @@ public final class KeyTool { ...@@ -3186,10 +3185,6 @@ public final class KeyTool {
(".WARNING.WARNING.WARNING.")); (".WARNING.WARNING.WARNING."));
System.err.println(rb.getString System.err.println(rb.getString
(".The.integrity.of.the.information.stored.in.your.keystore.")); (".The.integrity.of.the.information.stored.in.your.keystore."));
System.err.println(rb.getString
(".has.NOT.been.verified.In.order.to.verify.its.integrity."));
System.err.println(rb.getString
(".you.must.provide.your.keystore.password."));
System.err.println(rb.getString System.err.println(rb.getString
(".WARNING.WARNING.WARNING.")); (".WARNING.WARNING.WARNING."));
System.err.println(); System.err.println();
......
...@@ -250,10 +250,10 @@ public final class TimestampedSigner extends ContentSigner { ...@@ -250,10 +250,10 @@ public final class TimestampedSigner extends ContentSigner {
* (<a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280</a>). * (<a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280</a>).
* The extension's <tt>accessMethod</tt> field should contain the object * The extension's <tt>accessMethod</tt> field should contain the object
* identifier defined for timestamping: 1.3.6.1.5.5.7.48.3 and its * identifier defined for timestamping: 1.3.6.1.5.5.7.48.3 and its
* <tt>accessLocation</tt> field should contain an HTTP URL. * <tt>accessLocation</tt> field should contain an HTTP or HTTPS URL.
* *
* @param tsaCertificate An X.509 certificate for the TSA. * @param tsaCertificate An X.509 certificate for the TSA.
* @return An HTTP URL or null if none was found. * @return An HTTP or HTTPS URL or null if none was found.
*/ */
public static String getTimestampingUrl(X509Certificate tsaCertificate) { public static String getTimestampingUrl(X509Certificate tsaCertificate) {
...@@ -279,7 +279,8 @@ public final class TimestampedSigner extends ContentSigner { ...@@ -279,7 +279,8 @@ public final class TimestampedSigner extends ContentSigner {
location = description.getAccessLocation(); location = description.getAccessLocation();
if (location.getType() == GeneralNameInterface.NAME_URI) { if (location.getType() == GeneralNameInterface.NAME_URI) {
uri = (URIName) location.getName(); uri = (URIName) location.getName();
if (uri.getScheme().equalsIgnoreCase("http")) { if (uri.getScheme().equalsIgnoreCase("http") ||
uri.getScheme().equalsIgnoreCase("https")) {
return uri.getName(); return uri.getName();
} }
} }
......
/* /*
* Copyright (c) 2000, 2010, 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
...@@ -111,17 +111,15 @@ public class AuthResources extends java.util.ListResourceBundle { ...@@ -111,17 +111,15 @@ public class AuthResources extends java.util.ListResourceBundle {
// com.sun.security.auth.PolicyParser // com.sun.security.auth.PolicyParser
{"expected.keystore.type", "expected keystore type"}, {"expected.keystore.type", "expected keystore type"},
{"can.not.specify.Principal.with.a.", {"can.not.specify.Principal.with.a.wildcard.class.without.a.wildcard.name",
"can not specify Principal with a "}, "can not specify Principal with a wildcard class without a wildcard name"},
{"wildcard.class.without.a.wildcard.name",
"wildcard class without a wildcard name"},
{"expected.codeBase.or.SignedBy", "expected codeBase or SignedBy"}, {"expected.codeBase.or.SignedBy", "expected codeBase or SignedBy"},
{"only.Principal.based.grant.entries.permitted", {"only.Principal.based.grant.entries.permitted",
"only Principal-based grant entries permitted"}, "only Principal-based grant entries permitted"},
{"expected.permission.entry", "expected permission entry"}, {"expected.permission.entry", "expected permission entry"},
{"number.", "number "}, {"number.", "number "},
{"expected.", "expected "}, {"expected.expect.read.end.of.file.",
{".read.end.of.file", ", read end of file"}, "expected {0}, read end of file"},
{"expected.read.end.of.file", "expected ';', read end of file"}, {"expected.read.end.of.file", "expected ';', read end of file"},
{"line.", "line "}, {"line.", "line "},
{".expected.", ": expected '"}, {".expected.", ": expected '"},
...@@ -136,6 +134,9 @@ public class AuthResources extends java.util.ListResourceBundle { ...@@ -136,6 +134,9 @@ public class AuthResources extends java.util.ListResourceBundle {
{"SolarisNumericUserPrincipal.", {"SolarisNumericUserPrincipal.",
"SolarisNumericUserPrincipal: "}, "SolarisNumericUserPrincipal: "},
{"SolarisPrincipal.", "SolarisPrincipal: "}, {"SolarisPrincipal.", "SolarisPrincipal: "},
// provided.null.name is the NullPointerException message when a
// developer incorrectly passes a null name to the constructor of
// subclasses of java.security.Principal
{"provided.null.name", "provided null name"} {"provided.null.name", "provided null name"}
}; };
......
...@@ -195,8 +195,7 @@ public class ManifestEntryVerifier { ...@@ -195,8 +195,7 @@ public class ManifestEntryVerifier {
Hashtable<String, CodeSigner[]> sigFileSigners) Hashtable<String, CodeSigner[]> sigFileSigners)
throws JarException throws JarException
{ {
// MANIFEST.MF should not be skipped. It has signers. if (skip) {
if (skip && !entry.getName().equals(JarFile.MANIFEST_NAME)) {
return null; return null;
} }
......
/* /*
* Copyright (c) 2000, 2010, 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
...@@ -304,8 +304,6 @@ public class Resources extends java.util.ListResourceBundle { ...@@ -304,8 +304,6 @@ public class Resources extends java.util.ListResourceBundle {
{"Certificate.chain.length.", "Certificate chain length: "}, {"Certificate.chain.length.", "Certificate chain length: "},
{"Certificate.i.1.", "Certificate[{0,number,integer}]:"}, {"Certificate.i.1.", "Certificate[{0,number,integer}]:"},
{"Certificate.fingerprint.SHA1.", "Certificate fingerprint (SHA1): "}, {"Certificate.fingerprint.SHA1.", "Certificate fingerprint (SHA1): "},
{"Entry.type.trustedCertEntry.", "Entry type: trustedCertEntry\n"},
{"trustedCertEntry.", "trustedCertEntry,"},
{"Keystore.type.", "Keystore type: "}, {"Keystore.type.", "Keystore type: "},
{"Keystore.provider.", "Keystore provider: "}, {"Keystore.provider.", "Keystore provider: "},
{"Your.keystore.contains.keyStore.size.entry", {"Your.keystore.contains.keyStore.size.entry",
...@@ -378,21 +376,15 @@ public class Resources extends java.util.ListResourceBundle { ...@@ -378,21 +376,15 @@ public class Resources extends java.util.ListResourceBundle {
{"No.certificate.from.the.SSL.server", {"No.certificate.from.the.SSL.server",
"No certificate from the SSL server"}, "No certificate from the SSL server"},
// Translators of the following 5 pairs, ATTENTION:
// the next 5 string pairs are meant to be combined into 2 paragraphs,
// 1+3+4 and 2+3+5. make sure your translation also does.
{".The.integrity.of.the.information.stored.in.your.keystore.", {".The.integrity.of.the.information.stored.in.your.keystore.",
"* The integrity of the information stored in your keystore *"}, "* The integrity of the information stored in your keystore *\n" +
{".The.integrity.of.the.information.stored.in.the.srckeystore.", "* has NOT been verified! In order to verify its integrity, *\n" +
"* The integrity of the information stored in the srckeystore*"},
{".has.NOT.been.verified.In.order.to.verify.its.integrity.",
"* has NOT been verified! In order to verify its integrity, *"},
{".you.must.provide.your.keystore.password.",
"* you must provide your keystore password. *"}, "* you must provide your keystore password. *"},
{".you.must.provide.the.srckeystore.password.", {".The.integrity.of.the.information.stored.in.the.srckeystore.",
"* The integrity of the information stored in the srckeystore*\n" +
"* has NOT been verified! In order to verify its integrity, *\n" +
"* you must provide the srckeystore password. *"}, "* you must provide the srckeystore password. *"},
{"Certificate.reply.does.not.contain.public.key.for.alias.", {"Certificate.reply.does.not.contain.public.key.for.alias.",
"Certificate reply does not contain public key for <{0}>"}, "Certificate reply does not contain public key for <{0}>"},
{"Incomplete.certificate.chain.in.reply", {"Incomplete.certificate.chain.in.reply",
......
...@@ -3457,13 +3457,18 @@ public class BidiBase { ...@@ -3457,13 +3457,18 @@ public class BidiBase {
*/ */
static final AttributedCharacterIterator.Attribute RUN_DIRECTION = static final AttributedCharacterIterator.Attribute RUN_DIRECTION =
getTextAttribute("RUN_DIRECTION"); getTextAttribute("RUN_DIRECTION");
static final Boolean RUN_DIRECTION_LTR =
(Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING = static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING =
getTextAttribute("NUMERIC_SHAPING"); getTextAttribute("NUMERIC_SHAPING");
static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING = static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING =
getTextAttribute("BIDI_EMBEDDING"); getTextAttribute("BIDI_EMBEDDING");
/**
* TextAttribute.RUN_DIRECTION_LTR
*/
static final Boolean RUN_DIRECTION_LTR = (clazz == null) ?
Boolean.FALSE : (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
private static Class<?> getClass(String name) { private static Class<?> getClass(String name) {
try { try {
return Class.forName(name, true, null); return Class.forName(name, true, null);
...@@ -3473,27 +3478,25 @@ public class BidiBase { ...@@ -3473,27 +3478,25 @@ public class BidiBase {
} }
private static Object getStaticField(Class<?> clazz, String name) { private static Object getStaticField(Class<?> clazz, String name) {
if (clazz == null) {
// fake attribute
return new AttributedCharacterIterator.Attribute(name) { };
} else {
try { try {
Field f = clazz.getField(name); Field f = clazz.getField(name);
return f.get(null); return f.get(null);
} catch (NoSuchFieldException x) { } catch (NoSuchFieldException | IllegalAccessException x) {
throw new AssertionError(x); throw new AssertionError(x);
} catch (IllegalAccessException x) {
throw new AssertionError(x);
}
} }
} }
private static AttributedCharacterIterator.Attribute private static AttributedCharacterIterator.Attribute
getTextAttribute(String name) getTextAttribute(String name)
{ {
if (clazz == null) {
// fake attribute
return new AttributedCharacterIterator.Attribute(name) { };
} else {
return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name); return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
} }
} }
}
/** /**
* A class that provides access to java.awt.font.NumericShaping without * A class that provides access to java.awt.font.NumericShaping without
......
...@@ -479,7 +479,7 @@ public class ZoneInfoFile { ...@@ -479,7 +479,7 @@ public class ZoneInfoFile {
String zi = System.getProperty("java.home") + String zi = System.getProperty("java.home") +
File.separator + "lib" + File.separator + "zi"; File.separator + "lib" + File.separator + "zi";
try { try {
zi = FileSystems.getDefault().getPath(zi).toRealPath(true).toString(); zi = FileSystems.getDefault().getPath(zi).toRealPath().toString();
} catch(Exception e) { } catch(Exception e) {
} }
return zi; return zi;
......
...@@ -60,4 +60,7 @@ public interface LoggingProxy { ...@@ -60,4 +60,7 @@ public interface LoggingProxy {
public Object parseLevel(String levelName); public Object parseLevel(String levelName);
public String getLevelName(Object level); public String getLevelName(Object level);
// return the logging property
public String getProperty(String key);
} }
...@@ -29,6 +29,7 @@ package sun.util.logging; ...@@ -29,6 +29,7 @@ package sun.util.logging;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.Date;
/** /**
* Internal API to support JRE implementation to detect if the java.util.logging * Internal API to support JRE implementation to detect if the java.util.logging
...@@ -138,4 +139,42 @@ public class LoggingSupport { ...@@ -138,4 +139,42 @@ public class LoggingSupport {
ensureAvailable(); ensureAvailable();
return proxy.getLevelName(level); return proxy.getLevelName(level);
} }
private static final String DEFAULT_FORMAT =
"%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n";
private static final String FORMAT_PROP_KEY = "java.util.logging.SimpleFormatter.format";
public static String getSimpleFormat() {
return getSimpleFormat(true);
}
// useProxy if true will cause initialization of
// java.util.logging and read its configuration
static String getSimpleFormat(boolean useProxy) {
String format =
AccessController.doPrivileged(
new PrivilegedAction<String>() {
public String run() {
return System.getProperty(FORMAT_PROP_KEY);
}
});
if (useProxy && proxy != null && format == null) {
format = proxy.getProperty(FORMAT_PROP_KEY);
}
if (format != null) {
try {
// validate the user-defined format string
String.format(format, new Date(), "", "", "", "", "");
} catch (IllegalArgumentException e) {
// illegal syntax; fall back to the default format
format = DEFAULT_FORMAT;
}
} else {
format = DEFAULT_FORMAT;
}
return format;
}
} }
...@@ -316,12 +316,6 @@ public class PlatformLogger { ...@@ -316,12 +316,6 @@ public class PlatformLogger {
*/ */
static class LoggerProxy { static class LoggerProxy {
private static final PrintStream defaultStream = System.err; private static final PrintStream defaultStream = System.err;
private static final String lineSeparator = AccessController.doPrivileged(
new PrivilegedAction<String>() {
public String run() {
return System.getProperty("line.separator");
}
});
final String name; final String name;
volatile int levelValue; volatile int levelValue;
...@@ -353,14 +347,14 @@ public class PlatformLogger { ...@@ -353,14 +347,14 @@ public class PlatformLogger {
if (level < levelValue || levelValue == OFF) { if (level < levelValue || levelValue == OFF) {
return; return;
} }
defaultStream.println(format(level, msg, null)); defaultStream.print(format(level, msg, null));
} }
void doLog(int level, String msg, Throwable thrown) { void doLog(int level, String msg, Throwable thrown) {
if (level < levelValue || levelValue == OFF) { if (level < levelValue || levelValue == OFF) {
return; return;
} }
defaultStream.println(format(level, msg, thrown)); defaultStream.print(format(level, msg, thrown));
} }
void doLog(int level, String msg, Object... params) { void doLog(int level, String msg, Object... params) {
...@@ -368,7 +362,7 @@ public class PlatformLogger { ...@@ -368,7 +362,7 @@ public class PlatformLogger {
return; return;
} }
String newMsg = formatMessage(msg, params); String newMsg = formatMessage(msg, params);
defaultStream.println(format(level, newMsg, null)); defaultStream.print(format(level, newMsg, null));
} }
public boolean isLoggable(int level) { public boolean isLoggable(int level) {
...@@ -378,12 +372,6 @@ public class PlatformLogger { ...@@ -378,12 +372,6 @@ public class PlatformLogger {
return true; return true;
} }
private static final String format = "{0,date} {0,time}";
private Object args[] = new Object[1];
private MessageFormat formatter;
private Date dat;
// Copied from java.util.logging.Formatter.formatMessage // Copied from java.util.logging.Formatter.formatMessage
private String formatMessage(String format, Object... parameters) { private String formatMessage(String format, Object... parameters) {
// Do the formatting. // Do the formatting.
...@@ -408,37 +396,30 @@ public class PlatformLogger { ...@@ -408,37 +396,30 @@ public class PlatformLogger {
} }
} }
private static final String formatString =
LoggingSupport.getSimpleFormat(false); // don't check logging.properties
// minimize memory allocation
private Date date = new Date();
private synchronized String format(int level, String msg, Throwable thrown) { private synchronized String format(int level, String msg, Throwable thrown) {
StringBuffer sb = new StringBuffer(); date.setTime(System.currentTimeMillis());
// Minimize memory allocations here. String throwable = "";
if (dat == null) {
dat = new Date();
formatter = new MessageFormat(format);
}
dat.setTime(System.currentTimeMillis());
args[0] = dat;
StringBuffer text = new StringBuffer();
formatter.format(args, text, null);
sb.append(text);
sb.append(" ");
sb.append(getCallerInfo());
sb.append(lineSeparator);
sb.append(PlatformLogger.getLevelName(level));
sb.append(": ");
sb.append(msg);
if (thrown != null) { if (thrown != null) {
try {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw); PrintWriter pw = new PrintWriter(sw);
pw.println();
thrown.printStackTrace(pw); thrown.printStackTrace(pw);
pw.close(); pw.close();
sb.append(sw.toString()); throwable = sw.toString();
} catch (Exception ex) {
throw new AssertionError(ex);
}
} }
return sb.toString(); return String.format(formatString,
date,
getCallerInfo(),
name,
PlatformLogger.getLevelName(level),
msg,
throwable);
} }
// Returns the caller's class and method's name; best effort // Returns the caller's class and method's name; best effort
......
...@@ -150,7 +150,7 @@ public class ZipPath implements Path { ...@@ -150,7 +150,7 @@ public class ZipPath implements Path {
} }
@Override @Override
public ZipPath toRealPath(boolean resolveLinks) throws IOException { public ZipPath toRealPath(LinkOption... options) throws IOException {
ZipPath realPath = new ZipPath(zfs, getResolvedPath()).toAbsolutePath(); ZipPath realPath = new ZipPath(zfs, getResolvedPath()).toAbsolutePath();
realPath.checkAccess(); realPath.checkAccess();
return realPath; return realPath;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册