This commit is contained in:
Lana Steuck 2011-04-04 17:28:28 -07:00
commit 1c712d2e72
143 changed files with 4521 additions and 4491 deletions

View File

@ -0,0 +1,53 @@
#
# 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

View File

@ -115,6 +115,12 @@ endif
include $(JDK_TOPDIR)/make/common/Defs-$(PLATFORM).gmk
#
# SE-Embedded support, if enabled
#
include $(JDK_TOPDIR)/make/common/Defs-embedded.gmk
#
# Cross-compilation Settings
#
@ -144,7 +150,6 @@ ifdef BUILD_CLIENT_ONLY
VM_NAME = client
endif
#
# Freetype logic is applicable to OpenJDK only
#

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -78,7 +78,7 @@ LINKER=$(LINK.c)
endif
$(ACTUAL_LIBRARY):: $(INIT) $(TEMPDIR) $(LIBDIR) $(BINDIR) $(EXTDIR) classheaders
@$(ECHO) Building lib:$(ACTUAL_LIBRARY)
#
# COMPILE_APPROACH: Different approaches to compile up the native object
# files as quickly as possible.

View File

@ -0,0 +1,232 @@
#
# 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

View File

@ -38,7 +38,7 @@ THIS_JDK_VERSION := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSIO
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
# allowed, and even advocated, extending them (see bug 6476749).
#
@ -195,6 +195,16 @@ if [ "$(JA_DIRNAME)" != "" ] ; then \
fi
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.
#
@ -222,7 +232,7 @@ images:: sanity-images post-sanity-images \
$(INITIAL_IMAGE_JRE) $(INITIAL_IMAGE_JDK) \
trim-image-jre trim-image-jdk \
identify-image-jre identify-image-jdk \
process-image-jre process-image-jdk sec-files sec-files-win jgss-files
process-image-jre process-image-jdk sec-files sec-files-win jgss-files
# Don't use these
image-jre:: initial-image-jre trim-image-jre identify-image-jre process-image-jre
@ -613,7 +623,7 @@ RESOURCES_JAR=$(ABS_TEMPDIR)/resources-orig.jar
$(RESOURCES_JAR): $(RES_JAR_FILELIST) $(JAR_MANIFEST_FILE)
$(prep-target)
$(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ \
@$(RES_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
@ -622,7 +632,7 @@ JSSE_JAR=$(ABS_TEMPDIR)/jsse-orig.jar
$(JSSE_JAR): $(JAR_MANIFEST_FILE)
$(prep-target)
$(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ \
$(JSSE_CLASSES_DIRS) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
@ -669,7 +679,7 @@ RT_JAR=$(ABS_TEMPDIR)/rt-orig.jar
$(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE)
$(prep-target)
$(CD) $(CLASSBINDIR) && \
$(BOOT_JAR_CMD) c0mf $(JAR_MANIFEST_FILE) $@ \
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS) $(JAR_MANIFEST_FILE) $@ \
@$(RT_JAR_FILELIST) $(BOOT_JAR_JFLAGS)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
@ -677,6 +687,10 @@ $(RT_JAR): $(RT_JAR_FILELIST) $(JAR_MANIFEST_FILE)
BUILDMETAINDEX_JARFILE = $(ABS_BUILDTOOLJARDIR)/buildmetaindex.jar
# SE-Embedded targets if enabled
include $(JDK_TOPDIR)/make/common/Release-embedded.gmk
######################################################
# JRE Image
######################################################
@ -924,7 +938,7 @@ initial-image-jdk:: initial-image-jdk-setup \
@# lib/tools.jar
@#
$(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)
@$(CD) $(CLASSBINDIR) && $(java-vm-cleanup)
$(CP) $(LIBDIR)/tools.jar $(JDK_IMAGE_DIR)/lib/tools.jar
@ -937,7 +951,7 @@ initial-image-jdk:: initial-image-jdk-setup \
-Acom.sun.tools.javac.sym.Jar=$(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)
$(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)
@$(java-vm-cleanup)
$(CP) $(LIBDIR)/ct.sym $(JDK_IMAGE_DIR)/lib/ct.sym

View File

@ -185,7 +185,9 @@ ifeq ($(PLATFORM),windows)
endif
endif
ifeq ($(PLATFORM),linux)
ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
ifdef REQUIRED_ALSA_VERSION
ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
endif
endif
ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION)
ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_NAME)

View File

@ -198,10 +198,12 @@ INSTALL_DOT_LIB = true
#
# What to link?
# On Windows, shell32 is not normally required and so it is delay loaded.
#
ifeq ($(PLATFORM),windows)
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
OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)

View File

@ -86,7 +86,8 @@ OTHER_INCLUDES += \
-I$(SHARE_SRC)/native/sun/management
ifeq ($(PLATFORM),windows)
OTHER_LDLIBS += $(JVMLIB)
# Need process status helper API (psapi) on Windows
OTHER_LDLIBS += $(JVMLIB) psapi.lib
endif
#

View File

@ -37,10 +37,6 @@ include FILES_c.gmk
AUTO_FILES_JAVA_DIRS = java/net
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 += NetworkInterface_winXP.c
else
@ -96,7 +92,9 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk
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
OTHER_LDLIBS = $(LIBSOCKET) $(LIBNSL) -ldl $(JVMLIB)
endif

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,10 @@ FILES_export = \
java/util/jar/JarFile.java
ifneq ($(PLATFORM), windows)
OTHER_CFLAGS += -DUSE_MMAP
# Use mmap unless explicitly disallowed
ifneq ($(LIBZIP_CAN_USE_MMAP),false)
OTHER_CFLAGS += -DUSE_MMAP
endif
endif
#

View File

@ -52,8 +52,11 @@ jprt.build.targets= \
${jprt.my.windows.i586}-{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
jprt.test.targets= \
jprt.vm.default.test.targets= \
solaris_sparc_5.10-product-c1-jvm98, \
solaris_sparcv9_5.10-product-c2-jvm98, \
solaris_i586_5.10-product-c1-jvm98, \
@ -63,8 +66,10 @@ jprt.test.targets= \
${jprt.my.windows.i586}-product-c1-jvm98, \
windows_x64_5.2-product-c2-jvm98
# User can select the test set with jprt submit "-testset name" option
jprt.my.test.set=${jprt.test.set}
# Select vm testlist to use (allow for testset to be empty too)
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)
jprt.make.rule.default.test.targets= \
@ -281,6 +286,21 @@ jprt.make.rule.all.test.targets= \
${jprt.my.windows.i586}-product-c1-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)
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}

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -44,8 +44,17 @@ $(MAKE) -f Makefile.launcher \
endef
# Run MAKE $@ for all generic launchers
define make-all-launchers
ifndef BUILD_HEADLESS_ONLY
define make-appletviewer
$(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, extcheck, com.sun.tools.extcheck.Main, , )
$(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -69,10 +69,17 @@ endif
# nio need to be compiled before awt to have all charsets ready
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 \
awt splashscreen $(XAWT_SUBDIR) \
$(HEADLESS_SUBDIR) $(DGA_SUBDIR) \
jawt font jpeg cmm applet beans
$(DISPLAY_LIBS) $(DGA_SUBDIR) \
jawt font jpeg cmm $(DISPLAY_TOOLS) beans
SUBDIRS_management = management
SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing
SUBDIRS_tools = native2ascii serialver tools jconsole

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -149,13 +149,13 @@ ifeq ($(PLATFORM), linux)
LIBXT = -lXt
else
# 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))
LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
LIBSM = $(firstword $(wildcard $(OPENWIN_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))
LIBXTST = $(firstword $(wildcard /usr/X11R6/lib/libXtst.a) \
LIBXTST = $(firstword $(wildcard $(OPENWIN_LIB)/libXtst.a) \
$(wildcard /usr/lib/libXtst.a))
endif
endif
@ -224,9 +224,9 @@ CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR)/debug \
$(EVENT_MODEL)
ifeq ($(PLATFORM), linux)
# Checking for the X11/extensions headers at the additional location
CPPFLAGS += -I/X11R6/include/X11/extensions \
-I/usr/include/X11/extensions
# Checking for the X11/extensions headers at the additional location
CPPFLAGS += -I$(firstword $(wildcard $(OPENWIN_HOME)/include/X11/extensions) \
$(wildcard /usr/include/X11/extensions))
endif
ifeq ($(PLATFORM), solaris)

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -112,11 +112,20 @@ CPPFLAGS += -I$(OPENWIN_HOME)/include \
# Libraries to link in.
#
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
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

View File

@ -73,9 +73,10 @@ ifeq ($(PLATFORM), linux)
# Recommended way to avoid such warning is to declare the variable as
# volatile to prevent the optimization. However, this approach does not
# work because we have to declare all variables as volatile in result.
ifndef CROSS_COMPILE_ARCH
OTHER_CFLAGS += -Wno-clobbered
endif
endif
include $(BUILDDIR)/common/Mapfile-vers.gmk
include $(BUILDDIR)/common/Library.gmk

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -120,8 +120,15 @@ $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
$(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH)
$(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)
$(BOOT_JAR_CMD) cf0 $(CHARSETS_JAR) \
$(BOOT_JAR_CMD) $(CREATE_JAR_OPTS_NOMANIFEST) $(CHARSETS_JAR) \
-C $(CLASSDESTDIR) sun \
-C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \
$(BOOT_JAR_JFLAGS)

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -46,5 +46,7 @@ include $(BUILDDIR)/common/Classes.gmk
build:
$(call make-launcher, keytool, sun.security.tools.KeyTool, , )
ifndef BUILD_HEADLESS_ONLY
$(call make-launcher, policytool, sun.security.tools.policytool.PolicyTool, , )
endif

View File

@ -1,5 +1,5 @@
#
# 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.
#
# This code is free software; you can redistribute it and/or modify it
@ -129,10 +129,17 @@ CPPFLAGS += -DXAWT -DXAWT_HACK \
-I$(PLATFORM_SRC)/native/sun/awt
ifeq ($(PLATFORM), linux)
# Allows for builds on Debian GNU Linux, X11 is in a different place
CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
-I/usr/include/X11/extensions \
-I$(OPENWIN_HOME)/include
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 \
-I/usr/include/X11/extensions \
-I$(OPENWIN_HOME)/include
else
CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
-I$(OPENWIN_HOME)/include
endif
endif
# 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
$(SIZERS): $(SIZERS_C)
$(prep-target)
ifndef CROSS_COMPILE_ARCH
$(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
else
$(HOST_CC) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
endif
$(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA)
$(prep-target)

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,13 +30,14 @@ import java.lang.RuntimePermission;
import java.net.MalformedURLException;
import java.net.SocketPermission;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Vector;
import java.util.StringTokenizer;
import java.security.GeneralSecurityException;
import sun.security.util.PropertyExpander;
/**
@ -368,8 +369,8 @@ class PolicyParser {
"WILDCARD class but no WILDCARD name");
throw new ParsingException
(st.lineno(),
rb.getString("can.not.specify.Principal.with.a.") +
rb.getString("wildcard.class.without.a.wildcard.name"));
rb.getString("can.not.specify.Principal.with.a." +
"wildcard.class.without.a.wildcard.name"));
}
try {
@ -525,9 +526,10 @@ class PolicyParser {
rb.getString("number.") +
String.valueOf(st.nval));
case StreamTokenizer.TT_EOF:
throw new ParsingException
(rb.getString("expected.") + expect +
rb.getString(".read.end.of.file"));
MessageFormat form = new MessageFormat(
rb.getString("expected.expect.read.end.of.file."));
Object[] source = {expect};
throw new ParsingException(form.format(source));
case StreamTokenizer.TT_WORD:
if (expect.equalsIgnoreCase(st.sval)) {
lookahead = st.nextToken();

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -858,7 +858,7 @@ public abstract class Toolkit {
String nm = null;
Class cls = null;
try {
nm = System.getProperty("awt.toolkit", "sun.awt.X11.XToolkit");
nm = System.getProperty("awt.toolkit");
try {
cls = Class.forName(nm);
} catch (ClassNotFoundException e) {

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,15 +30,18 @@ package java.lang;
* example, an integer "divide by zero" throws an
* 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
* @since JDK1.0
*/
public
class ArithmeticException extends RuntimeException {
public class ArithmeticException extends RuntimeException {
private static final long serialVersionUID = 2256477558314496007L;
/**
* Constructs an <code>ArithmeticException</code> with no detail
* Constructs an {@code ArithmeticException} with no detail
* message.
*/
public ArithmeticException() {
@ -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.
*
* @param s the detail message.

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,20 +26,24 @@
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:
* <ul>
* <li>Calling the instance method of a <code>null</code> object.
* <li>Accessing or modifying the field of a <code>null</code> object.
* <li>Taking the length of <code>null</code> as if it were an array.
* <li>Accessing or modifying the slots of <code>null</code> as if it
* <li>Calling the instance method of a {@code null} object.
* <li>Accessing or modifying the field of a {@code null} object.
* <li>Taking the length of {@code null} as if it were an array.
* <li>Accessing or modifying the slots of {@code null} as if it
* 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.
* </ul>
* <p>
* 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
* @since JDK1.0
@ -49,14 +53,14 @@ class NullPointerException extends RuntimeException {
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() {
super();
}
/**
* Constructs a <code>NullPointerException</code> with the specified
* Constructs a {@code NullPointerException} with the specified
* detail message.
*
* @param s the detail message.

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,22 +30,25 @@ package java.lang;
* because it is out of memory, and no more memory could be made
* 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
* @since JDK1.0
*/
public
class OutOfMemoryError extends VirtualMachineError {
public class OutOfMemoryError extends VirtualMachineError {
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() {
super();
}
/**
* Constructs an <code>OutOfMemoryError</code> with the specified
* Constructs an {@code OutOfMemoryError} with the specified
* detail message.
*
* @param s the detail message.

View File

@ -46,13 +46,16 @@ import java.util.*;
* are freshly created in the context of the exceptional situation so
* as to include relevant information (such as stack trace data).
*
* <p>A throwable contains a snapshot of the execution stack of its thread at
* the time it was created. It can also contain a message string that gives
* more information about the error. Finally, it can contain a <i>cause</i>:
* another throwable that caused this throwable to get thrown. The cause
* facility is new in release 1.4. It is also known 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>A throwable contains a snapshot of the execution stack of its
* thread at the time it was created. It can also contain a message
* string that gives more information about the error. Over time, a
* throwable can {@linkplain Throwable#addSuppressed suppress} other
* throwables from being propagated. Finally, the throwable can also
* contain a <i>cause</i>: another throwable that caused this
* 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
* throws it is built atop a lower layered abstraction, and an operation on
@ -86,47 +89,12 @@ import java.util.*;
* {@link #initCause(Throwable)} method. New throwable classes that
* wish to allow causes to be associated with them should provide constructors
* that take a cause and delegate (perhaps indirectly) to one of the
* {@code Throwable} constructors that takes a cause. For example:
* <pre>
* try {
* lowLevelOp();
* } catch (LowLevelException le) {
* throw new HighLevelException(le); // Chaining-aware constructor
* }
* </pre>
* {@code Throwable} constructors that takes a cause.
*
* Because the {@code initCause} method is public, it allows a cause to be
* associated with any throwable, even a "legacy throwable" whose
* implementation predates the addition of the exception chaining mechanism to
* {@code Throwable}. For example:
* <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.
* {@code Throwable}.
*
* <p>By convention, class {@code Throwable} and its subclasses have two
* constructors, one that takes no arguments and one that takes a
@ -137,14 +105,6 @@ import java.util.*;
* {@code String} (the detail message) and a {@code Throwable} (the
* 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 Josh Bloch (Added exception chaining and programmatic access to
* stack trace in 1.4.)
@ -322,6 +282,41 @@ public class Throwable implements Serializable {
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.
*
@ -870,54 +865,64 @@ public class Throwable implements Serializable {
* typically called (automatically and implicitly) by the {@code
* try}-with-resources statement.
*
* If the first exception to be suppressed is {@code null}, that
* indicates suppressed exception information will <em>not</em> be
* recorded for this exception. Subsequent calls to this method
* will not record any suppressed exceptions. Otherwise,
* attempting to suppress {@code null} after an exception has
* already been successfully suppressed results in a {@code
* NullPointerException}.
* <p>The suppression behavior is enabled <em>unless</em> disabled
* {@linkplain #Throwable(String, Throwable, boolean) via a
* constructor}. When suppression is disabled, this method does
* nothing other than to validate its argument.
*
* <p>Note that when one exception {@linkplain
* #initCause(Throwable) causes} another exception, the first
* exception is usually caught and then the second exception is
* thrown in response. In contrast, when one exception suppresses
* another, two exceptions are thrown in sibling code blocks, such
* as in a {@code try} block and in its {@code finally} block, and
* control flow can only continue with one exception so the second
* is recorded as a suppressed exception of the first.
* thrown in response. In other words, there is a causal
* connection between the two exceptions.
*
* In contrast, there are situations where two independent
* 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
* suppressed exceptions
* @throws IllegalArgumentException if {@code exception} is this
* throwable; a throwable cannot suppress itself.
* @throws NullPointerException if {@code exception} is null and
* an exception has already been suppressed by this exception
* @throws NullPointerException if {@code exception} is {@code null}
* @since 1.7
*/
public final synchronized void addSuppressed(Throwable exception) {
if (exception == this)
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
if (exception == null) {
if (suppressedExceptions == SUPPRESSED_SENTINEL) {
suppressedExceptions = null; // No suppression information recorded
return;
} else
throw new NullPointerException(NULL_CAUSE_MESSAGE);
} else {
assert exception != null && exception != this;
if (exception == null)
throw new NullPointerException(NULL_CAUSE_MESSAGE);
if (suppressedExceptions == null) // Suppressed exceptions not recorded
return;
if (suppressedExceptions == null) // Suppressed exceptions not recorded
return;
if (suppressedExceptions == SUPPRESSED_SENTINEL)
suppressedExceptions = new ArrayList<>(1);
if (suppressedExceptions == SUPPRESSED_SENTINEL)
suppressedExceptions = new ArrayList<>(1);
assert suppressedExceptions != SUPPRESSED_SENTINEL;
suppressedExceptions.add(exception);
}
suppressedExceptions.add(exception);
}
private static final Throwable[] EMPTY_THROWABLE_ARRAY = new Throwable[0];
@ -927,7 +932,9 @@ public class Throwable implements Serializable {
* suppressed, typically by the {@code try}-with-resources
* 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
* suppressed to deliver this exception.

View File

@ -23,15 +23,15 @@
* questions.
*/
package java.nio;
import java.lang.management.PlatformManagedObject;
package java.lang.management;
/**
* 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=
* "java.lang.management.ManagementFactory.html#MXBean">MXBean</a>. A Java
* <p> A class implementing this interface is an
* {@link javax.management.MXBean}. A Java
* virtual machine has one or more implementations of this interface. The {@link
* java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans}
* method can be used to obtain the list of {@code BufferPoolMXBean} objects
@ -44,14 +44,13 @@ import java.lang.management.PlatformManagedObject;
* javax.management.MBeanServer MBeanServer}. The {@link
* javax.management.ObjectName ObjectName} that uniquely identifies the
* management interface within the {@code MBeanServer} takes the form:
* <blockquote>
* <tt>java.nio:type=BufferPool</tt><tt>,name=</tt><i>pool name</i>
* </blockquote>
* <pre>
* java.nio:type=BufferPool,name=<i>pool name</i>
* </pre>
* where <em>pool name</em> is the {@link #getName name} of the buffer pool.
*
* @since 1.7
*/
public interface BufferPoolMXBean extends PlatformManagedObject {
/**

View File

@ -40,8 +40,9 @@ import javax.management.NotCompliantMBeanException;
import javax.management.StandardEmitterMBean;
import javax.management.StandardMBean;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
@ -51,37 +52,63 @@ import javax.management.JMX;
import sun.management.ManagementFactoryHelper;
/**
* The <tt>ManagementFactory</tt> class is a factory class for getting
* The {@code ManagementFactory} class is a factory class for getting
* managed beans for the Java platform.
* This class consists of static methods each of which returns
* one or more <a href="#MXBean">platform MXBean(s)</a> representing
* one or more <i>platform MXBeans</i> representing
* the management interface of a component of the Java virtual
* machine.
* <p>
* <h4><a name="MXBean">Platform MXBeans</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.
* A JMX management application and the {@linkplain
* #getPlatformMBeanServer platform MBeanServer}
* can interoperate without requiring classes for MXBean specific
* data types.
* The data types being transmitted between the JMX connector
* server and the connector client are
* {@linkplain javax.management.openmbean.OpenType open types}
* and this allows interoperation across versions.
* See <a href="../../../javax/management/MXBean.html#MXBean-spec">
* the specification of MXBeans</a> for details.
*
* <a name="MXBeanNames"></a>
* <p>Each platform MXBean is a {@link PlatformManagedObject}
* and it has a unique
* {@link javax.management.ObjectName ObjectName} for
* registration in the platform {@code MBeanServer} as returned by
* by the {@link PlatformManagedObject#getObjectName getObjectName}
* method.
*
* <p>
* An application can access a platform MXBean in the following ways:
* <h5>1. Direct access to an MXBean interface</h5>
* <blockquote>
* <ul>
* <li><i>Direct access to an MXBean interface</i>
* <ol type="a">
* <li>Get the MXBean instance through the static factory method,
* or the {@link #getPlatformMXBeans(Class)} method
* and access the MXBean locally of the running
* <li>Get an MXBean instance by calling the
* {@link #getPlatformMXBean(Class) getPlatformMXBean} or
* {@link #getPlatformMXBeans(Class) getPlatformMXBeans} method
* and access the MXBean locally in the running
* virtual machine.
* </li>
* <li>Construct an MXBean proxy instance that forwards the
* method calls to a given {@link MBeanServer MBeanServer} by calling
* the {@link #newPlatformMXBeanProxy newPlatformMXBeanProxy} method
* or the {@link #getPlatformMXBeans(MBeanServerConnection, Class)}
* method.
* the {@link #getPlatformMXBean(MBeanServerConnection, Class)} or
* {@link #getPlatformMXBeans(MBeanServerConnection, Class)} method.
* The {@link #newPlatformMXBeanProxy newPlatformMXBeanProxy} method
* can also be used to construct an MXBean proxy instance of
* a given {@code ObjectName}.
* A proxy is typically constructed to remotely access
* an MXBean of another running virtual machine.
* </li>
* </ol></li>
* <li><i>Indirect access to an MXBean interface via MBeanServer</i>
* <ol type="a">
* <li>Go through the {@link #getPlatformMBeanServer
* platform MBeanServer} to access MXBeans locally or
* a specific <tt>MBeanServerConnection</tt> to access
* </ul>
* <h5>2. Indirect access to an MXBean interface via MBeanServer</h5>
* <ul>
* <li>Go through the platform {@code 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,
@ -89,133 +116,19 @@ import sun.management.ManagementFactoryHelper;
* and {@link javax.management.openmbean.TabularData TabularData}
* defined in
* {@link javax.management.openmbean.OpenType OpenType}.
* The mapping is specified below.
* The mapping is specified in
* the {@linkplain javax.management.MXBean MXBean} specification
* for details.
* </li>
* </ol></li>
* </ul>
*
* <h4><a name="MXBean">Platform MXBeans</a></h4>
* A platform MXBean is a <i>managed bean</i> that conforms to
* the JMX Instrumentation Specification and only uses
* a set of basic data types described below.
* See <a href="../../../javax/management/MXBean.html#MXBean-spec">
* the specification of MXBeans</a> for details.
* All platform MXBean interfaces extend {@link PlatformManagedObject}s
* and new methods may be added in these interfaces
* in future Java SE releases.
* <p>
* A JMX management application and the platform <tt>MBeanServer</tt>
* can interoperate without requiring classes for MXBean specific
* data types.
* The data types being transmitted between the JMX connector
* server and the connector client are
* {@linkplain javax.management.openmbean.OpenType open types}
* and this allows interoperation across versions.
* <p>
* The platform MXBean interfaces use only the following data types:
* <ul>
* <li>Primitive types such as <tt>int</tt>, <tt>long</tt>,
* <tt>boolean</tt>, etc</li>
* <li>Wrapper classes for primitive types such as
* {@link java.lang.Integer Integer}, {@link java.lang.Long Long},
* {@link java.lang.Boolean Boolean}, etc and
* {@link java.lang.String String}</li>
* <li>{@link java.lang.Enum Enum} classes</li>
* <li>Classes that define only getter methods and define a static
* <tt>from</tt> method with a
* {@link javax.management.openmbean.CompositeData CompositeData}
* argument to convert from an input <tt>CompositeData</tt> to
* an instance of that class
* </li>
* <li>{@link java.util.List List&lt;E&gt;}
* where <tt>E</tt> is a primitive type, a wrapper class,
* an enum class, or a class supporting conversion from a
* <tt>CompositeData</tt> to its class
* </li>
* <li>{@link java.util.Map Map&lt;K,V&gt;}
* where <tt>K</tt> and <tt>V</tt> are
* a primitive type, a wrapper class,
* an enum class, or a class supporting conversion from a
* <tt>CompositeData</tt> to its class
* </li>
* </ul>
*
* <p>
* When an attribute or operation of a platform MXBean
* is accessed via an <tt>MBeanServer</tt>, the data types are mapped
* as follows:
* <ul>
* <li>A primitive type or a wrapper class is mapped
* to the same type.
* </li>
* <li>An {@link Enum} is mapped to
* <tt>String</tt> whose value is the name of the enum constant.
* <li>A class that defines only getter methods and a static
* <tt>from</tt> method with a
* {@link javax.management.openmbean.CompositeData CompositeData}
* argument is mapped to
* {@link javax.management.openmbean.CompositeData CompositeData}.
* </li>
* <li><tt>Map&lt;K,V&gt;</tt> is mapped to
* {@link javax.management.openmbean.TabularData TabularData}
* whose row type is a
* {@link javax.management.openmbean.CompositeType CompositeType} with
* two items whose names are <i>"key"</i> and <i>"value"</i>
* and the item types are
* the corresponding mapped type of <tt>K</tt> and <tt>V</tt>
* respectively and the <i>"key"</i> is the index.
* </li>
* <li><tt>List&lt;E&gt;</tt> is mapped to an array with the mapped
* type of <tt>E</tt> as the element type.
* </li>
* <li>An array of element type <tt>E</tt> is mapped to
* an array of the same dimenions with the mapped type of <tt>E</tt>
* as the element type.</li>
* </ul>
*
* The {@link javax.management.MBeanInfo MBeanInfo}
* for a platform MXBean
* describes the data types of the attributes and operations
* as primitive or open types mapped as specified above.
*
* <p>
* For example, the {@link MemoryMXBean}
* interface has the following <i>getter</i> and <i>setter</i> methods:
*
* <blockquote><pre>
* public MemoryUsage getHeapMemoryUsage();
* public boolean isVerbose();
* public void setVerbose(boolean value);
* </pre></blockquote>
*
* These attributes in the <tt>MBeanInfo</tt>
* of the <tt>MemoryMXBean</tt> have the following names and types:
*
* <blockquote>
* <table border>
* <tr>
* <th>Attribute Name</th>
* <th>Type</th>
* </tr>
* <tr>
* <td><tt>HeapMemoryUsage</tt></td>
* <td>{@link MemoryUsage#from
* CompositeData representing MemoryUsage}</td>
* </tr>
* <tr>
* <td><tt>Verbose</tt></td>
* <td><tt>boolean</tt></td>
* </tr>
* </table>
* </blockquote>
*
* <h4><a name="MXBeanNames">MXBean Names</a></h4>
* Each platform MXBean for a Java virtual machine has a unique
* {@link javax.management.ObjectName ObjectName} for
* registration in the platform <tt>MBeanServer</tt> that can
* be obtained by calling the {@link PlatformManagedObject#getObjectName}
* method.
*
* <p>
* The {@link #getPlatformManagementInterfaces getPlatformManagementInterfaces}
* method returns all management interfaces supported in the Java virtual machine
* including the standard management interfaces listed in the tables
* below as well as the management interfaces extended by the JDK implementation.
* <p>
* A Java virtual machine has a single instance of the following management
* interfaces:
*
@ -228,27 +141,32 @@ import sun.management.ManagementFactoryHelper;
* <tr>
* <td> {@link ClassLoadingMXBean} </td>
* <td> {@link #CLASS_LOADING_MXBEAN_NAME
* <tt>java.lang:type=ClassLoading</tt>}</td>
* java.lang:type=ClassLoading}</td>
* </tr>
* <tr>
* <td> {@link MemoryMXBean} </td>
* <td> {@link #MEMORY_MXBEAN_NAME
* <tt>java.lang:type=Memory</tt>}</td>
* java.lang:type=Memory}</td>
* </tr>
* <tr>
* <td> {@link ThreadMXBean} </td>
* <td> {@link #THREAD_MXBEAN_NAME
* <tt>java.lang:type=Threading</tt>}</td>
* java.lang:type=Threading}</td>
* </tr>
* <tr>
* <td> {@link RuntimeMXBean} </td>
* <td> {@link #RUNTIME_MXBEAN_NAME
* <tt>java.lang:type=Runtime</tt>}</td>
* java.lang:type=Runtime}</td>
* </tr>
* <tr>
* <td> {@link OperatingSystemMXBean} </td>
* <td> {@link #OPERATING_SYSTEM_MXBEAN_NAME
* <tt>java.lang:type=OperatingSystem</tt>}</td>
* java.lang:type=OperatingSystem}</td>
* </tr>
* <tr>
* <td> {@link PlatformLoggingMXBean} </td>
* <td> {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME
* java.util.logging:type=Logging}</td>
* </tr>
* </table>
* </blockquote>
@ -266,7 +184,7 @@ import sun.management.ManagementFactoryHelper;
* <tr>
* <td> {@link CompilationMXBean} </td>
* <td> {@link #COMPILATION_MXBEAN_NAME
* <tt>java.lang:type=Compilation</tt>}</td>
* java.lang:type=Compilation}</td>
* </tr>
* </table>
* </blockquote>
@ -283,17 +201,21 @@ import sun.management.ManagementFactoryHelper;
* <tr>
* <td> {@link GarbageCollectorMXBean} </td>
* <td> {@link #GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
* <tt>java.lang:type=GarbageCollector</tt>}<tt>,name=</tt><i>collector's name</i></td>
* java.lang:type=GarbageCollector}<tt>,name=</tt><i>collector's name</i></td>
* </tr>
* <tr>
* <td> {@link MemoryManagerMXBean} </td>
* <td> {@link #MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
* <tt>java.lang:type=MemoryManager</tt>}<tt>,name=</tt><i>manager's name</i></td>
* java.lang:type=MemoryManager}<tt>,name=</tt><i>manager's name</i></td>
* </tr>
* <tr>
* <td> {@link MemoryPoolMXBean} </td>
* <td> {@link #MEMORY_POOL_MXBEAN_DOMAIN_TYPE
* <tt>java.lang:type=MemoryPool</tt>}<tt>,name=</tt><i>pool's name</i></td>
* java.lang:type=MemoryPool}<tt>,name=</tt><i>pool's name</i></td>
* </tr>
* <tr>
* <td> {@link BufferPoolMXBean} </td>
* <td> {@code java.nio:type=BufferPool,name=}<i>pool name</i></td>
* </tr>
* </table>
* </blockquote>
@ -302,7 +224,6 @@ import sun.management.ManagementFactoryHelper;
* JMX Specification</a>
* @see <a href="package-summary.html#examples">
* Ways to Access Management Metrics</a>
* @see java.util.logging.LoggingMXBean
* @see javax.management.MXBean
*
* @author Mandy Chung
@ -496,35 +417,35 @@ public class ManagementFactory {
/**
* Returns the platform {@link javax.management.MBeanServer MBeanServer}.
* On the first call to this method, it first creates the platform
* <tt>MBeanServer</tt> by calling the
* {@code MBeanServer} by calling the
* {@link javax.management.MBeanServerFactory#createMBeanServer
* MBeanServerFactory.createMBeanServer}
* method and registers the platform MXBeans in this platform
* <tt>MBeanServer</tt> using the <a href="#MXBeanNames">MXBean names</a>
* defined in the class description.
* method and registers each platform MXBean in this platform
* {@code MBeanServer} with its
* {@link PlatformManagedObject#getObjectName ObjectName}.
* This method, in subsequent calls, will simply return the
* initially created platform <tt>MBeanServer</tt>.
* initially created platform {@code MBeanServer}.
* <p>
* MXBeans that get created and destroyed dynamically, for example,
* memory {@link MemoryPoolMXBean pools} and
* {@link MemoryManagerMXBean managers},
* will automatically be registered and deregistered into the platform
* <tt>MBeanServer</tt>.
* {@code MBeanServer}.
* <p>
* If the system property <tt>javax.management.builder.initial</tt>
* is set, the platform <tt>MBeanServer</tt> creation will be done
* If the system property {@code javax.management.builder.initial}
* is set, the platform {@code MBeanServer} creation will be done
* by the specified {@link javax.management.MBeanServerBuilder}.
* <p>
* It is recommended that this platform MBeanServer also be used
* to register other application managed beans
* besides the platform MXBeans.
* This will allow all MBeans to be published through the same
* <tt>MBeanServer</tt> and hence allow for easier network publishing
* {@code MBeanServer} and hence allow for easier network publishing
* and discovery.
* Name conflicts with the platform MXBeans should be avoided.
*
* @return the platform <tt>MBeanServer</tt>; the platform
* MXBeans are registered into the platform <tt>MBeanServer</tt>
* @return the platform {@code MBeanServer}; the platform
* MXBeans are registered into the platform {@code MBeanServer}
* at the first time this method is called.
*
* @exception SecurityException if there is a security manager
@ -671,7 +592,9 @@ public class ManagementFactory {
try {
final ObjectName objName = new ObjectName(mxbeanName);
if (!connection.isInstanceOf(objName, interfaceClass.getName())) {
// skip the isInstanceOf check for LoggingMXBean
String intfName = interfaceClass.getName();
if (!connection.isInstanceOf(objName, intfName)) {
throw new IllegalArgumentException(mxbeanName +
" is not an instance of " + interfaceClass);
}
@ -683,55 +606,128 @@ public class ManagementFactory {
// create an MXBean proxy
return JMX.newMXBeanProxy(connection, objName, mxbeanInterface,
emitter);
} catch (InstanceNotFoundException e) {
final IllegalArgumentException iae =
new IllegalArgumentException(mxbeanName +
" not found in the connection.");
iae.initCause(e);
throw iae;
} catch (MalformedObjectNameException e) {
final IllegalArgumentException iae =
new IllegalArgumentException(mxbeanName +
" is not a valid ObjectName format.");
iae.initCause(e);
throw iae;
} catch (InstanceNotFoundException|MalformedObjectNameException e) {
throw new IllegalArgumentException(e);
}
}
/**
* Returns the list of platform MXBeans that implement
* the given {@code mxbeanInterface} in the running Java
* Returns the platform MXBean implementing
* the given {@code mxbeanInterface} which is specified
* to have one single instance in the Java virtual machine.
* This method may return {@code null} if the management interface
* is not implemented in the Java virtual machine (for example,
* a Java virtual machine with no compilation system does not
* implement {@link CompilationMXBean});
* otherwise, this method is equivalent to calling:
* <pre>
* {@link #getPlatformMXBeans(Class)
* getPlatformMXBeans(mxbeanInterface)}.get(0);
* </pre>
*
* @param mxbeanInterface a management interface for a platform
* MXBean with one single instance in the Java virtual machine
* if implemented.
*
* @return the platform MXBean that implements
* {@code mxbeanInterface}, or {@code null} if not exist.
*
* @throws IllegalArgumentException if {@code mxbeanInterface}
* is not a platform management interface or
* not a singleton platform MXBean.
*
* @since 1.7
*/
public static <T extends PlatformManagedObject>
T getPlatformMXBean(Class<T> mxbeanInterface) {
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null)
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface");
if (!pc.isSingleton())
throw new IllegalArgumentException(mxbeanInterface.getName() +
" can have zero or more than one instances");
return pc.getSingletonMXBean(mxbeanInterface);
}
/**
* Returns the list of platform MXBeans implementing
* the given {@code mxbeanInterface} in the Java
* virtual machine.
* The returned list may contain zero, one, or more instances.
* The number of instances in the returned list is defined
* in the specification of the given management interface.
* The order is undefined and there is no guarantee that
* the list returned is in the same order as previous invocations.
*
* @param mxbeanInterface a management interface for a platform
* MXBean
*
* @return the list of platform MXBeans that implements
* @return the list of platform MXBeans that implement
* {@code mxbeanInterface}.
*
* @throws IllegalArgumentException if {@code mxbeanInterface}
* is not a management interface for the platform.
* is not a platform management interface.
*
* @since 1.7
*/
public static <T extends PlatformManagedObject> List<T>
getPlatformMXBeans(Class<T> mxbeanInterface) {
String className = mxbeanInterface.getName();
for (PlatformComponent component: PlatformComponent.values()) {
// comparing the class name first instead of the Class instance
// to avoid causing unnecessary class loading of
// the other MXBean interfaces
if (className.equals(component.getMXBeanInterfaceName())) {
if (component.getMXBeanInterface() == mxbeanInterface) {
return component.getMXBeans(mxbeanInterface);
}
}
}
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not implemented by any of the platform MXBeans.");
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null)
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface");
return Collections.unmodifiableList(pc.getMXBeans(mxbeanInterface));
}
/**
* Returns the platform MXBean proxy for
* {@code mxbeanInterface} which is specified to have one single
* instance in a Java virtual machine and the proxy will
* forward the method calls through the given {@code MBeanServerConnection}.
* This method may return {@code null} if the management interface
* is not implemented in the Java virtual machine being monitored
* (for example, a Java virtual machine with no compilation system
* does not implement {@link CompilationMXBean});
* otherwise, this method is equivalent to calling:
* <pre>
* {@link #getPlatformMXBeans(MBeanServerConnection, Class)
* getPlatformMXBeans(connection, mxbeanInterface)}.get(0);
* </pre>
*
* @param connection the {@code MBeanServerConnection} to forward to.
* @param mxbeanInterface a management interface for a platform
* MXBean with one single instance in the Java virtual machine
* being monitored, if implemented.
*
* @return the platform MXBean proxy for
* forwarding the method calls of the {@code mxbeanInterface}
* through the given {@code MBeanServerConnection},
* or {@code null} if not exist.
*
* @throws IllegalArgumentException if {@code mxbeanInterface}
* is not a platform management interface or
* not a singleton platform MXBean.
* @throws java.io.IOException if a communication problem
* occurred when accessing the {@code MBeanServerConnection}.
*
* @see #newPlatformMXBeanProxy
* @since 1.7
*/
public static <T extends PlatformManagedObject>
T getPlatformMXBean(MBeanServerConnection connection,
Class<T> mxbeanInterface)
throws java.io.IOException
{
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null)
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface");
if (!pc.isSingleton())
throw new IllegalArgumentException(mxbeanInterface.getName() +
" can have zero or more than one instances");
return pc.getSingletonMXBean(connection, mxbeanInterface);
}
/**
@ -741,6 +737,8 @@ public class ManagementFactory {
* The returned list may contain zero, one, or more instances.
* The number of instances in the returned list is defined
* in the specification of the given management interface.
* The order is undefined and there is no guarantee that
* the list returned is in the same order as previous invocations.
*
* @param connection the {@code MBeanServerConnection} to forward to.
* @param mxbeanInterface a management interface for a platform
@ -751,54 +749,49 @@ public class ManagementFactory {
* through the given {@code MBeanServerConnection}.
*
* @throws IllegalArgumentException if {@code mxbeanInterface}
* is not a management interface for the platform.
* is not a platform management interface.
*
* @throws java.io.IOException if a communication problem
* occurred when accessing the {@code MBeanServerConnection}.
*
* @see #newPlatformMXBeanProxy
* @since 1.7
*/
public static <T extends PlatformManagedObject>
List<T> getPlatformMXBeans(MBeanServerConnection connection,
Class<T> mxbeanInterface)
List<T> getPlatformMXBeans(MBeanServerConnection connection,
Class<T> mxbeanInterface)
throws java.io.IOException
{
String className = mxbeanInterface.getName();
for (PlatformComponent component: PlatformComponent.values()) {
// comparing the class name first instead of the Class instance
// to avoid causing unnecessary class loading of
// the other MXBean interfaces
if (className.equals(component.getMXBeanInterfaceName())) {
if (component.getMXBeanInterface() == mxbeanInterface) {
return component.getMXBeans(connection,
mxbeanInterface);
}
}
PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
if (pc == null) {
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not a platform management interface");
}
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not implemented by any of the platform MXBeans.");
return Collections.unmodifiableList(pc.getMXBeans(connection, mxbeanInterface));
}
/**
* Returns a list of {@code Class} objects, subinterface of
* Returns the set of {@code Class} objects, subinterface of
* {@link PlatformManagedObject}, representing
* all management interfaces for
* monitoring and managing the Java platform.
*
* @return a list of {@code Class} objects, subinterface of
* @return the set of {@code Class} objects, subinterface of
* {@link PlatformManagedObject} representing
* the management interfaces for
* monitoring and managing the Java platform.
*
* @since 1.7
*/
public static List<Class<? extends PlatformManagedObject>> getAllPlatformMXBeanInterfaces() {
List<Class<? extends PlatformManagedObject>> result =
new ArrayList<>();
public static Set<Class<? extends PlatformManagedObject>>
getPlatformManagementInterfaces()
{
Set<Class<? extends PlatformManagedObject>> result =
new TreeSet<>();
for (PlatformComponent component: PlatformComponent.values()) {
result.add(component.getMXBeanInterface());
}
return result;
return Collections.unmodifiableSet(result);
}
private static final String NOTIF_EMITTER =
@ -810,7 +803,9 @@ public class ManagementFactory {
private static void addMXBean(final MBeanServer mbs, final PlatformManagedObject pmo) {
// Make DynamicMBean out of MXBean by wrapping it with a StandardMBean
final DynamicMBean dmbean;
if (pmo instanceof NotificationEmitter) {
if (pmo instanceof DynamicMBean) {
dmbean = DynamicMBean.class.cast(pmo);
} else if (pmo instanceof NotificationEmitter) {
dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo);
} else {
dmbean = new StandardMBean(pmo, null, true);

View File

@ -29,9 +29,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.PlatformLoggingMXBean;
import java.nio.BufferPoolMXBean;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@ -66,6 +66,7 @@ enum PlatformComponent {
CLASS_LOADING(
"java.lang.management.ClassLoadingMXBean",
"java.lang", "ClassLoading", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<ClassLoadingMXBean>() {
public List<ClassLoadingMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean());
@ -78,6 +79,7 @@ enum PlatformComponent {
COMPILATION(
"java.lang.management.CompilationMXBean",
"java.lang", "Compilation", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<CompilationMXBean>() {
public List<CompilationMXBean> getMXBeans() {
CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean();
@ -95,6 +97,7 @@ enum PlatformComponent {
MEMORY(
"java.lang.management.MemoryMXBean",
"java.lang", "Memory", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<MemoryMXBean>() {
public List<MemoryMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean());
@ -107,6 +110,7 @@ enum PlatformComponent {
GARBAGE_COLLECTOR(
"java.lang.management.GarbageCollectorMXBean",
"java.lang", "GarbageCollector", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<GarbageCollectorMXBean>() {
public List<GarbageCollectorMXBean> getMXBeans() {
return ManagementFactoryHelper.
@ -120,6 +124,7 @@ enum PlatformComponent {
MEMORY_MANAGER(
"java.lang.management.MemoryManagerMXBean",
"java.lang", "MemoryManager", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<MemoryManagerMXBean>() {
public List<MemoryManagerMXBean> getMXBeans() {
return ManagementFactoryHelper.getMemoryManagerMXBeans();
@ -133,6 +138,7 @@ enum PlatformComponent {
MEMORY_POOL(
"java.lang.management.MemoryPoolMXBean",
"java.lang", "MemoryPool", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<MemoryPoolMXBean>() {
public List<MemoryPoolMXBean> getMXBeans() {
return ManagementFactoryHelper.getMemoryPoolMXBeans();
@ -145,6 +151,7 @@ enum PlatformComponent {
OPERATING_SYSTEM(
"java.lang.management.OperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<OperatingSystemMXBean>() {
public List<OperatingSystemMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean());
@ -157,6 +164,7 @@ enum PlatformComponent {
RUNTIME(
"java.lang.management.RuntimeMXBean",
"java.lang", "Runtime", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<RuntimeMXBean>() {
public List<RuntimeMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean());
@ -169,6 +177,7 @@ enum PlatformComponent {
THREADING(
"java.lang.management.ThreadMXBean",
"java.lang", "Threading", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<ThreadMXBean>() {
public List<ThreadMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean());
@ -180,11 +189,17 @@ enum PlatformComponent {
* Logging facility.
*/
LOGGING(
"java.util.logging.PlatformLoggingMXBean",
"java.lang.management.PlatformLoggingMXBean",
"java.util.logging", "Logging", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<PlatformLoggingMXBean>() {
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 {
* Buffer pools.
*/
BUFFER_POOL(
"java.nio.BufferPoolMXBean",
"java.lang.management.BufferPoolMXBean",
"java.nio", "BufferPool", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<BufferPoolMXBean>() {
public List<BufferPoolMXBean> getMXBeans() {
return ManagementFactoryHelper.getBufferPoolMXBeans();
@ -209,6 +225,7 @@ enum PlatformComponent {
SUN_GARBAGE_COLLECTOR(
"com.sun.management.GarbageCollectorMXBean",
"java.lang", "GarbageCollector", keyProperties("name"),
false, // zero or more instances
new MXBeanFetcher<com.sun.management.GarbageCollectorMXBean>() {
public List<com.sun.management.GarbageCollectorMXBean> getMXBeans() {
return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class);
@ -222,6 +239,7 @@ enum PlatformComponent {
SUN_OPERATING_SYSTEM(
"com.sun.management.OperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<com.sun.management.OperatingSystemMXBean>() {
public List<com.sun.management.OperatingSystemMXBean> getMXBeans() {
return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class);
@ -234,6 +252,7 @@ enum PlatformComponent {
SUN_UNIX_OPERATING_SYSTEM(
"com.sun.management.UnixOperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<UnixOperatingSystemMXBean>() {
public List<UnixOperatingSystemMXBean> getMXBeans() {
return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class);
@ -246,6 +265,7 @@ enum PlatformComponent {
HOTSPOT_DIAGNOSTIC(
"com.sun.management.HotSpotDiagnosticMXBean",
"com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(),
true, // singleton
new MXBeanFetcher<HotSpotDiagnosticMXBean>() {
public List<HotSpotDiagnosticMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean());
@ -296,27 +316,19 @@ enum PlatformComponent {
private final Set<String> keyProperties;
private final MXBeanFetcher fetcher;
private final PlatformComponent[] subComponents;
private final boolean singleton;
private PlatformComponent(String intfName,
String domain, String type,
Set<String> keyProperties,
MXBeanFetcher fetcher) {
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,
boolean singleton,
MXBeanFetcher fetcher,
PlatformComponent... subComponents) {
this.mxbeanInterfaceName = intfName;
this.domain = domain;
this.type = type;
this.keyProperties = keyProperties;
this.singleton = singleton;
this.fetcher = fetcher;
this.subComponents = subComponents;
}
@ -338,6 +350,10 @@ enum PlatformComponent {
return set;
}
boolean isSingleton() {
return singleton;
}
String getMXBeanInterfaceName() {
return mxbeanInterfaceName;
}
@ -360,8 +376,35 @@ enum PlatformComponent {
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>
List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
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>
List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
throws java.io.IOException
{
List<T> result = new ArrayList<>();
@ -391,5 +434,34 @@ enum PlatformComponent {
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;
}

View File

@ -0,0 +1,138 @@
/*
* 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);
}

View File

@ -46,7 +46,7 @@ import javax.management.ObjectName;
* intended for the management interfaces for the platform to extend but
* not for applications.
*
* @see <a href="ManagementFactory.html#MXBean">Platform MXBeans</a>
* @see ManagementFactory
* @since 1.7
*/
public interface PlatformManagedObject {

View File

@ -27,160 +27,124 @@
<html>
<body bgcolor="white">
Provides the management interface for monitoring and management of the
Java virtual machine as well as the operating system on which the
Java virtual machine is running. It allows both local and remote
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>
Provides the management interfaces for monitoring and management of the
Java virtual machine and other components in the Java runtime.
It allows both local and remote
monitoring and management of the running Java virtual machine.
<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>
The {@link java.lang.management.ManagementFactory} class is the management
factory class for the Java platform. This class provides a set of
<p>The {@link java.lang.management.ManagementFactory} class is the management
factory class for the Java platform. This class provides a set of
static factory methods to obtain the MXBeans for the Java platform
to allow an application to access the MXBeans directly.
<p>A <em>platform MBeanServer</em> can be accessed with the
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer
getPlatformMBeanServer} method. On the first call to this method,
it creates the platform MBeanServer and registers all platform MXBeans
including platform MXBeans defined in other packages such as
{@link java.util.logging.LoggingMXBean}.
Each platform MXBean is registered with a unique name defined in the
{@link java.lang.management.ManagementFactory ManagementFactory} class
for constructing {@link javax.management.ObjectName ObjectName}.
This is a single MBeanServer that can be shared by different managed
it creates the platform MBeanServer and registers all platform MXBeans
including {@linkplain java.lang.management.PlatformManagedObject
platform MXBeans}.
Each platform MXBean is registered with a unique name defined in
the specification of the management interface.
This is a single MBeanServer that can be shared by different managed
components running within the same Java virtual machine.
<h4>Interoperability</h4>
A management application and a platform MBeanServer of a running
virtual machine can interoperate
<p>A management application and a platform MBeanServer of a running
virtual machine can interoperate
without requiring classes used by the platform MXBean interfaces.
The data types being transmitted between the JMX connector
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.
<p>A data type used by the MXBean interfaces are mapped to
an open type when being accessed via MBeanServer interface.
The data type mapping is specified in the
{@link java.lang.management.ManagementFactory ManagementFactory} class.
A data type used by the MXBean interfaces are mapped to an
open type when being accessed via MBeanServer interface.
See the <a href="../../../javax/management/MXBean.html#MXBean-spec">
MXBean</a> specification for details.
<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>
<ol>
<li>Call the methods in the MXBean directly within the same
Java virtual machine.
<blockquote><pre>
<b>1. Direct access to an MXBean interface</b>
<p>
<ul>
<li>Get an MXBean instance locally in the running Java virtual machine:<p>
<pre>
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean();
// Get the standard attribute "VmVendor"
String vendor = mxbean.getVmVendor();
</pre>
</blockquote>
</li>
<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);
<li>Go through a <tt>MBeanServerConnection</tt> connecting
to the <tt>platform MBeanServer</tt> of a running virtual machine.</li>
<blockquote><pre>
// Get the standard attribute "VmVendor"
String vendor = mxbean.getVmVendor();
</pre>
<p>
</li>
<li>Construct an MXBean proxy instance that forwards the
method calls to a given MBeanServer:<p>
<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 =
{@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;
// Connect to a running JVM (or itself) and get MBeanServerConnection
@ -190,7 +154,7 @@ There are three different ways to access the management interfaces.
try {
// Assuming the RuntimeMXBean has been registered in mbs
ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
// Get standard attribute "VmVendor"
String vendor = (String) mbs.getAttribute(oname, "VmVendor");
} catch (....) {
@ -198,36 +162,19 @@ There are three different ways to access the management interfaces.
// and MBeanServer.getAttribute method
...
}
</pre></blockquote>
<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>
</pre>
</li>
</ul>
<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
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
return the MBeans with the platform extension.
return the MXBeans with the platform extension.
<p>
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,
the applications accessing that vendor-specific attribute would have
to be modified to cope with versioning and compatibility issues.
<p>Below is an example showing how to access a platform-specific
attribute from Sun's implementation of the <tt>RuntimeMXBean</tt>.
<p>Below is an example showing how to access an attribute
from the platform extension:
<p>
1) Direct access to the Sun-specific MXBean interface
<blockquote><pre>
com.sun.management.RuntimeMXBean mxbean =
(com.sun.management.RuntimeMXBean) ManagementFactory.getRuntimeMXBean();
1) Direct access to the Oracle-specific MXBean interface
<blockquote>
<pre>
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"
BarType bar = mxbean.getBar();
for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
// Get the standard attribute "CollectionCount"
String count = mxbean.getCollectionCount();
// Get the platform-specific attribute "LastGcInfo"
GcInfo gcinfo = gc.getLastGcInfo();
...
}
</pre>
</blockquote>
<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>
MBeanServerConnection mbs;
@ -268,24 +219,17 @@ attribute from Sun's implementation of the <tt>RuntimeMXBean</tt>.
// that has the JVM MXBeans registered in it
...
try {
// Assuming the RuntimeMXBean has been registered in mbs
ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
// Get standard attribute "VmVendor"
String vendor = (String) mbs.getAttribute(oname, "VmVendor");
List&lt;com.sun.management.GarbageCollectorMXBean&gt; mxbeans =
ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class);
// Check if this MXBean contains Sun's extension
if (mbs.isInstanceOf(oname, "com.sun.management.RuntimeMXBean")) {
// Get platform-specific attribute "Bar"
BarType bar = (String) mbs.getAttribute(oname, "Bar");
}
} catch (....) {
// Catch the exceptions thrown by ObjectName constructor
// and MBeanServer methods
for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
// Get the standard attribute "CollectionCount"
String count = mxbean.getCollectionCount();
// Get the platform-specific attribute "LastGcInfo"
GcInfo gcinfo = gc.getLastGcInfo();
...
}
</pre></blockquote>
<p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor

View File

@ -26,6 +26,7 @@
package java.lang.reflect;
import java.security.AccessController;
import sun.reflect.Reflection;
import sun.reflect.ReflectionFactory;
import java.lang.annotation.Annotation;
@ -201,4 +202,73 @@ public class AccessibleObject implements AnnotatedElement {
public Annotation[] getDeclaredAnnotations() {
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
}
}

View File

@ -74,14 +74,6 @@ public final
private byte[] annotations;
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
// Accessor for factory
private GenericsFactory getFactory() {
@ -495,7 +487,7 @@ public final
* this object represents
*
* @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.
* @exception IllegalArgumentException if the number of actual
* and formal parameters differ; if an unwrapping
@ -518,16 +510,17 @@ public final
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class<?> caller = Reflection.getCallerClass(2);
if (securityCheckCache != caller) {
Reflection.ensureMemberAccess(caller, clazz, null, modifiers);
securityCheckCache = caller;
}
checkAccess(caller, clazz, null, modifiers);
}
}
if ((clazz.getModifiers() & Modifier.ENUM) != 0)
throw new IllegalArgumentException("Cannot reflectively create enum objects");
if (constructorAccessor == null) acquireConstructorAccessor();
return (T) constructorAccessor.newInstance(initargs);
ConstructorAccessor ca = constructorAccessor; // read volatile
if (ca == null) {
ca = acquireConstructorAccessor();
}
return (T) ca.newInstance(initargs);
}
/**
@ -560,18 +553,20 @@ public final
// ConstructorAccessor for a given Constructor. However, avoiding
// synchronization will probably make the implementation more
// scalable.
private void acquireConstructorAccessor() {
private ConstructorAccessor acquireConstructorAccessor() {
// First check to see if one has been created yet, and take it
// if so.
ConstructorAccessor tmp = null;
if (root != null) tmp = root.getConstructorAccessor();
if (tmp != null) {
constructorAccessor = tmp;
return;
} else {
// Otherwise fabricate one and propagate it up to the root
tmp = reflectionFactory.newConstructorAccessor(this);
setConstructorAccessor(tmp);
}
// Otherwise fabricate one and propagate it up to the root
tmp = reflectionFactory.newConstructorAccessor(this);
setConstructorAccessor(tmp);
return tmp;
}
// Returns ConstructorAccessor for this Constructor object, not

View File

@ -79,11 +79,6 @@ class Field extends AccessibleObject implements Member {
// potentially many Field objects pointing to it.)
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
private String getGenericSignature() {return signature;}
@ -340,7 +335,7 @@ class Field extends AccessibleObject implements Member {
* instance of the class or interface declaring the underlying
* 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
* {@code IllegalAccessException}.
* If the underlying field is static, the class that declared the
@ -360,8 +355,9 @@ class Field extends AccessibleObject implements Member {
* {@code obj}; primitive values are wrapped in an appropriate
* object before being returned
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof).
@ -383,8 +379,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the {@code boolean} field
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -410,8 +407,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the {@code byte} field
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -439,8 +437,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code char}
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -468,8 +467,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code short}
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -497,8 +497,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code int}
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -526,8 +527,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code long}
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -555,8 +557,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code float}
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -584,8 +587,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code double}
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@ -621,14 +625,14 @@ class Field extends AccessibleObject implements Member {
* an instance of the class or interface declaring the underlying
* 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
* {@code IllegalAccessException}.
*
* <p>If the underlying field is final, the method throws an
* {@code IllegalAccessException} unless
* {@code setAccessible(true)} has succeeded for this field
* and this field is non-static. Setting a final field in this way
* {@code IllegalAccessException} unless {@code setAccessible(true)}
* has succeeded for this {@code Field} object
* and the field is non-static. Setting a final field in this way
* is meaningful only during deserialization or reconstruction of
* instances of classes with blank final fields, before they are
* made available for access by other parts of a program. Use in
@ -658,8 +662,9 @@ class Field extends AccessibleObject implements Member {
* @param value the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -686,8 +691,9 @@ class Field extends AccessibleObject implements Member {
* @param z the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -715,8 +721,9 @@ class Field extends AccessibleObject implements Member {
* @param b the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -744,8 +751,9 @@ class Field extends AccessibleObject implements Member {
* @param c the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -773,8 +781,9 @@ class Field extends AccessibleObject implements Member {
* @param s the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -802,8 +811,9 @@ class Field extends AccessibleObject implements Member {
* @param i the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -831,8 +841,9 @@ class Field extends AccessibleObject implements Member {
* @param l the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -860,8 +871,9 @@ class Field extends AccessibleObject implements Member {
* @param f the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -889,8 +901,9 @@ class Field extends AccessibleObject implements Member {
* @param d the new value for the field of {@code obj}
* being modified
*
* @exception IllegalAccessException if the underlying field
* is inaccessible.
* @exception IllegalAccessException if this {@code Field} object
* is enforcing Java language access control and the underlying
* field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@ -936,6 +949,7 @@ class Field extends AccessibleObject implements Member {
tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
setFieldAccessor(tmp, overrideFinalCheck);
}
return tmp;
}
@ -965,21 +979,8 @@ class Field extends AccessibleObject implements Member {
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class<?> caller = Reflection.getCallerClass(4);
Class<?> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
? clazz
: obj.getClass());
synchronized (this) {
if ((securityCheckCache == caller)
&& (securityCheckTargetClassCache == targetClass)) {
return;
}
}
Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
synchronized (this) {
securityCheckCache = caller;
securityCheckTargetClassCache = targetClass;
}
checkAccess(caller, clazz, obj, modifiers);
}
}
}

View File

@ -83,11 +83,6 @@ public final
// potentially many Method objects pointing to it.)
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
private String getGenericSignature() {return signature;}
@ -402,28 +397,28 @@ public final
*/
public String toString() {
try {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) {
sb.append(Modifier.toString(mod) + " ");
sb.append(Modifier.toString(mod)).append(' ');
}
sb.append(Field.getTypeName(getReturnType()) + " ");
sb.append(Field.getTypeName(getDeclaringClass()) + ".");
sb.append(getName() + "(");
sb.append(Field.getTypeName(getReturnType())).append(' ');
sb.append(Field.getTypeName(getDeclaringClass())).append('.');
sb.append(getName()).append('(');
Class<?>[] params = parameterTypes; // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(Field.getTypeName(params[j]));
if (j < (params.length - 1))
sb.append(",");
sb.append(',');
}
sb.append(")");
sb.append(')');
Class<?>[] exceptions = exceptionTypes; // avoid clone
if (exceptions.length > 0) {
sb.append(" throws ");
for (int k = 0; k < exceptions.length; k++) {
sb.append(exceptions[k].getName());
if (k < (exceptions.length - 1))
sb.append(",");
sb.append(',');
}
}
return sb.toString();
@ -475,15 +470,15 @@ public final
StringBuilder sb = new StringBuilder();
int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) {
sb.append(Modifier.toString(mod) + " ");
sb.append(Modifier.toString(mod)).append(' ');
}
TypeVariable<?>[] typeparms = getTypeParameters();
if (typeparms.length > 0) {
boolean first = true;
sb.append("<");
sb.append('<');
for(TypeVariable<?> typeparm: typeparms) {
if (!first)
sb.append(",");
sb.append(',');
// Class objects can't occur here; no need to test
// and call Class.getName().
sb.append(typeparm.toString());
@ -494,10 +489,11 @@ public final
Type genRetType = getGenericReturnType();
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(getName() + "(");
sb.append(Field.getTypeName(getDeclaringClass())).append('.');
sb.append(getName()).append('(');
Type[] params = getGenericParameterTypes();
for (int j = 0; j < params.length; j++) {
String param = (params[j] instanceof Class)?
@ -507,9 +503,9 @@ public final
param = param.replaceFirst("\\[\\]$", "...");
sb.append(param);
if (j < (params.length - 1))
sb.append(",");
sb.append(',');
}
sb.append(")");
sb.append(')');
Type[] exceptions = getGenericExceptionTypes();
if (exceptions.length > 0) {
sb.append(" throws ");
@ -518,7 +514,7 @@ public final
((Class)exceptions[k]).getName():
exceptions[k].toString());
if (k < (exceptions.length - 1))
sb.append(",");
sb.append(',');
}
}
return sb.toString();
@ -565,7 +561,7 @@ public final
* {@code args}
*
* @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.
* @exception IllegalArgumentException if the method is an
* instance method and the specified object argument
@ -591,26 +587,15 @@ public final
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class<?> caller = Reflection.getCallerClass(1);
Class<?> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
? clazz
: obj.getClass());
boolean cached;
synchronized (this) {
cached = (securityCheckCache == caller)
&& (securityCheckTargetClassCache == targetClass);
}
if (!cached) {
Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
synchronized (this) {
securityCheckCache = caller;
securityCheckTargetClassCache = targetClass;
}
}
checkAccess(caller, clazz, obj, modifiers);
}
}
if (methodAccessor == null) acquireMethodAccessor();
return methodAccessor.invoke(obj, args);
MethodAccessor ma = methodAccessor; // read volatile
if (ma == null) {
ma = acquireMethodAccessor();
}
return ma.invoke(obj, args);
}
/**
@ -654,18 +639,20 @@ public final
// (though not efficient) to generate more than one MethodAccessor
// for a given Method. However, avoiding synchronization will
// 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
// if so
MethodAccessor tmp = null;
if (root != null) tmp = root.getMethodAccessor();
if (tmp != null) {
methodAccessor = tmp;
return;
} else {
// Otherwise fabricate one and propagate it up to the root
tmp = reflectionFactory.newMethodAccessor(this);
setMethodAccessor(tmp);
}
// Otherwise fabricate one and propagate it up to the root
tmp = reflectionFactory.newMethodAccessor(this);
setMethodAccessor(tmp);
return tmp;
}
// Returns MethodAccessor for this Method object, not looking up

View File

@ -2067,7 +2067,7 @@ public final class Files {
*
* @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
* be determined if the file is symbolic link or not.
* be determined if the file is a symbolic link or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
@ -2106,7 +2106,7 @@ public final class Files {
*
* @return {@code true} if the file is a directory; {@code false} if
* 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
* In the case of the default provider, and a security manager is
@ -2142,8 +2142,8 @@ public final class Files {
* options indicating how symbolic links are handled
*
* @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
* cannot be determined if the file is regular file or not.
* the file does not exist, is not a regular file, or it
* cannot be determined if the file is a regular file or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is

View File

@ -550,18 +550,21 @@ public interface Path
* <p> If this path is relative then its absolute path is first obtained,
* as if by invoking the {@link #toAbsolutePath toAbsolutePath} method.
*
* <p> The {@code resolveLinks} parameter specifies if symbolic links
* should be resolved. This parameter is ignored when symbolic links are
* not supported. Where supported, and the parameter has the value {@code
* true} then symbolic links are resolved to their final target. Where the
* parameter has the value {@code false} then this method does not resolve
* symbolic links. Some implementations allow special names such as
* "{@code ..}" to refer to the parent directory. When deriving the <em>real
* path</em>, and a "{@code ..}" (or equivalent) is preceded by a
* non-"{@code ..}" name then an implementation will typically causes both
* names to be removed. When not resolving symbolic links and the preceding
* name is a symbolic link then the names are only removed if it guaranteed
* that the resulting path will locate the same file as this path.
* <p> The {@code options} array may be used to indicate how symbolic links
* are handled. By default, symbolic links are resolved to their final
* target. If the option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is
* present then this method does not resolve symbolic links.
*
* Some implementations allow special names such as "{@code ..}" to refer to
* the parent directory. When deriving the <em>real path</em>, and a
* "{@code ..}" (or equivalent) is preceded by a non-"{@code ..}" name then
* an implementation will typically cause both names to be removed. When
* not resolving symbolic links and the preceding name is a symbolic link
* then the names are only removed if it guaranteed that the resulting 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
* located by this object
@ -576,7 +579,7 @@ public interface Path
* checkPropertyAccess} method is invoked to check access to the
* 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

View File

@ -3533,20 +3533,20 @@ public class Collections {
}
/**
* Returns a comparator that imposes the reverse of the <i>natural
* ordering</i> on a collection of objects that implement the
* <tt>Comparable</tt> interface. (The natural ordering is the ordering
* imposed by the objects' own <tt>compareTo</tt> method.) This enables a
* Returns a comparator that imposes the reverse of the <em>natural
* ordering</em> on a collection of objects that implement the
* {@code Comparable} interface. (The natural ordering is the ordering
* imposed by the objects' own {@code compareTo} method.) This enables a
* simple idiom for sorting (or maintaining) collections (or arrays) of
* objects that implement the <tt>Comparable</tt> interface in
* reverse-natural-order. For example, suppose a is an array of
* objects that implement the {@code Comparable} interface in
* reverse-natural-order. For example, suppose {@code a} is an array of
* strings. Then: <pre>
* Arrays.sort(a, Collections.reverseOrder());
* </pre> sorts the array in reverse-lexicographic (alphabetical) order.<p>
*
* 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
* the <tt>Comparable</tt> interface.
* @see Comparable
@ -3575,16 +3575,18 @@ public class Collections {
/**
* 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
* comparator that imposes the reverse of the <i>natural ordering</i> on a
* collection of objects that implement the Comparable interface).
* comparator that imposes the reverse of the <em>natural ordering</em> on
* a collection of objects that implement the Comparable interface).
*
* <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
* specified comparator
* @param cmp a comparator who's ordering is to be reversed by the returned
* comparator or {@code null}
* @return A comparator that imposes the reverse ordering of the
* specified comparator.
* @since 1.5
*/
public static <T> Comparator<T> reverseOrder(Comparator<T> cmp) {

View File

@ -241,7 +241,7 @@ class ComparableTimSort {
* pivot < all in [left, start), so pivot belongs at left. Note
* that if there are elements equal to pivot, left points to the
* 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
// Switch is just an optimization for arraycopy in default case

View File

@ -26,69 +26,70 @@
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
* ordering} of its keys, or by a {@link Comparator} typically
* provided at sorted map creation time. This order is reflected when
* 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
* ordering. (This interface is the map analogue of {@link
* SortedSet}.)
* ordering. (This interface is the map analogue of {@link 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
* such keys must be <i>mutually comparable</i>: <tt>k1.compareTo(k2)</tt> (or
* <tt>comparator.compare(k1, k2)</tt>) must not throw a
* <tt>ClassCastException</tt> for any keys <tt>k1</tt> and <tt>k2</tt> in
* such keys must be <em>mutually comparable</em>: {@code k1.compareTo(k2)} (or
* {@code comparator.compare(k1, k2)}) must not throw a
* {@code ClassCastException} for any keys {@code k1} and {@code k2} in
* the sorted map. Attempts to violate this restriction will cause the
* 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
* explicit comparator is provided) must be <i>consistent with equals</i> if
* the sorted map is to correctly implement the <tt>Map</tt> interface. (See
* the <tt>Comparable</tt> interface or <tt>Comparator</tt> interface for a
* precise definition of <i>consistent with equals</i>.) This is so because
* the <tt>Map</tt> interface is defined in terms of the <tt>equals</tt>
* explicit comparator is provided) must be <em>consistent with equals</em> if
* the sorted map is to correctly implement the {@code Map} interface. (See
* the {@code Comparable} interface or {@code Comparator} interface for a
* precise definition of <em>consistent with equals</em>.) This is so because
* the {@code Map} interface is defined in terms of the {@code equals}
* 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,
* 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
* contract of the <tt>Map</tt> interface.
* contract of the {@code Map} interface.
*
* <p>All general-purpose sorted map implementation classes should
* provide four "standard" constructors: 1) A void (no arguments)
* constructor, which creates an empty sorted map sorted according to
* the natural ordering of its keys. 2) A constructor with a
* single argument of type <tt>Comparator</tt>, which creates an empty
* sorted map sorted according to the specified comparator. 3) A
* constructor with a single argument of type <tt>Map</tt>, which
* creates a new map with the same key-value mappings as its argument,
* sorted according to the keys' natural ordering. 4) A constructor
* with a single argument of type <tt>SortedMap</tt>,
* which creates a new sorted map with the same key-value mappings and
* the same ordering as the input sorted map. There is no way to
* enforce this recommendation, as interfaces cannot contain
* constructors.
* <p>All general-purpose sorted map implementation classes should provide four
* "standard" constructors. It is not possible to enforce this recommendation
* though as required constructors cannot be specified by interfaces. The
* expected "standard" constructors for all sorted map implementations are:
* <ol>
* <li>A void (no arguments) constructor, which creates an empty sorted map
* sorted according to the natural ordering of its keys.</li>
* <li>A constructor with a single argument of type {@code Comparator}, which
* creates an empty sorted map sorted according to the specified comparator.</li>
* <li>A constructor with a single argument of type {@code Map}, which creates
* a new map with the same key-value mappings as its argument, sorted
* according to the keys' natural ordering.</li>
* <li>A constructor with a single argument of type {@code SortedMap}, which
* 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.
* Such ranges are <i>half-open</i>, that is, they include their low
* <p><strong>Note</strong>: several methods return submaps with restricted key
* 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
* <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
* the subrange from <tt>lowEndpoint</tt> to
* <tt>successor(highEndpoint)</tt>. For example, suppose that <tt>m</tt>
* the subrange from {@code lowEndpoint} to
* {@code successor(highEndpoint)}. For example, suppose that {@code m}
* 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
* between <tt>low</tt> and <tt>high</tt>, inclusive:<pre>
* containing all of the key-value mappings in {@code m} whose keys are
* between {@code low} and {@code high}, inclusive:<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
* view containing all of the key-value mappings in <tt>m</tt> whose keys
* are between <tt>low</tt> and <tt>high</tt>, exclusive:<pre>
* view containing all of the key-value mappings in {@code m} whose keys
* are between {@code low} and {@code high}, exclusive:<pre>
* SortedMap&lt;String, V&gt; sub = m.subMap(low+"\0", high);</pre>
*
* <p>This interface is a member of the
@ -112,96 +113,96 @@ package java.util;
public interface SortedMap<K,V> extends Map<K,V> {
/**
* 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.
*
* @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
*/
Comparator<? super K> comparator();
/**
* Returns a view of the portion of this map whose keys range from
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive. (If
* <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned map
* {@code fromKey}, inclusive, to {@code toKey}, exclusive. (If
* {@code fromKey} and {@code toKey} are equal, the returned map
* is empty.) The returned map is backed by this map, so changes
* in the returned map are reflected in this map, and vice-versa.
* The returned map 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.
*
* @param fromKey low endpoint (inclusive) 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
* <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive
* @throws ClassCastException if <tt>fromKey</tt> and <tt>toKey</tt>
* {@code fromKey}, inclusive, to {@code toKey}, exclusive
* @throws ClassCastException if {@code fromKey} and {@code toKey}
* cannot be compared to one another using this map's comparator
* (or, if the map has no comparator, using natural ordering).
* 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.
* @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
* @throws IllegalArgumentException if <tt>fromKey</tt> is greater than
* <tt>toKey</tt>; or if this map itself has a restricted
* range, and <tt>fromKey</tt> or <tt>toKey</tt> lies
* @throws IllegalArgumentException if {@code fromKey} is greater than
* {@code toKey}; or if this map itself has a restricted
* range, and {@code fromKey} or {@code toKey} lies
* outside the bounds of the range
*/
SortedMap<K,V> subMap(K fromKey, K toKey);
/**
* 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
* this map, and vice-versa. The returned map 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.
*
* @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
* less than <tt>toKey</tt>
* @throws ClassCastException if <tt>toKey</tt> is not compatible
* less than {@code toKey}
* @throws ClassCastException if {@code toKey} is not compatible
* 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
* exception if <tt>toKey</tt> cannot be compared to keys
* exception if {@code toKey} cannot be compared to keys
* 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
* @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
*/
SortedMap<K,V> headMap(K toKey);
/**
* 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
* reflected in this map, and vice-versa. The returned map
* 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.
*
* @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
* than or equal to <tt>fromKey</tt>
* @throws ClassCastException if <tt>fromKey</tt> is not compatible
* than or equal to {@code fromKey}
* @throws ClassCastException if {@code fromKey} is not compatible
* 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
* exception if <tt>fromKey</tt> cannot be compared to keys
* exception if {@code fromKey} cannot be compared to keys
* 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
* @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
*/
SortedMap<K,V> tailMap(K fromKey);
@ -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
* reflected in the set, and vice-versa. If the map is modified
* 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,
* which removes the corresponding mapping from the map, via the
* <tt>Iterator.remove</tt>, <tt>Set.remove</tt>,
* <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt>
* operations. It does not support the <tt>add</tt> or <tt>addAll</tt>
* {@code Iterator.remove}, {@code Set.remove},
* {@code removeAll}, {@code retainAll}, and {@code clear}
* operations. It does not support the {@code add} or {@code addAll}
* operations.
*
* @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> {
* The collection is backed by the map, so changes to the map are
* reflected in the collection, and vice-versa. If the map is
* 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
* supports element removal, which removes the corresponding
* mapping from the map, via the <tt>Iterator.remove</tt>,
* <tt>Collection.remove</tt>, <tt>removeAll</tt>,
* <tt>retainAll</tt> and <tt>clear</tt> operations. It does not
* support the <tt>add</tt> or <tt>addAll</tt> operations.
* mapping from the map, via the {@code Iterator.remove},
* {@code Collection.remove}, {@code removeAll},
* {@code retainAll} and {@code clear} operations. It does not
* support the {@code add} or {@code addAll} operations.
*
* @return a collection view of the values contained in this map,
* sorted in ascending key order
@ -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
* reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through
* the iterator's own <tt>remove</tt> operation, or through the
* <tt>setValue</tt> operation on a map entry returned by the
* the iterator's own {@code remove} operation, or through the
* {@code setValue} operation on a map entry returned by the
* iterator) the results of the iteration are undefined. The set
* supports element removal, which removes the corresponding
* mapping from the map, via the <tt>Iterator.remove</tt>,
* <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt> and
* <tt>clear</tt> operations. It does not support the
* <tt>add</tt> or <tt>addAll</tt> operations.
* mapping from the map, via the {@code Iterator.remove},
* {@code Set.remove}, {@code removeAll}, {@code retainAll} and
* {@code clear} operations. It does not support the
* {@code add} or {@code addAll} operations.
*
* @return a set view of the mappings contained in this map,
* sorted in ascending key order

View File

@ -274,7 +274,7 @@ class TimSort<T> {
* pivot < all in [left, start), so pivot belongs at left. Note
* that if there are elements equal to pivot, left points to the
* 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
// Switch is just an optimization for arraycopy in default case

View File

@ -415,6 +415,12 @@ class JarVerifier {
pendingBlocks = null;
signerCache = 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 {

View File

@ -1166,7 +1166,12 @@ public class LogManager {
private static LoggingMXBean loggingMXBean = null;
/**
* 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
*/
public final static String LOGGING_MXBEAN_NAME
@ -1174,20 +1179,20 @@ public class LogManager {
/**
* Returns <tt>LoggingMXBean</tt> for managing loggers.
* An alternative way to manage loggers is using
* the {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
* ManagementFactory.getPlatformMXBeans} method as follows:
* An alternative way to manage loggers is through the
* {@link java.lang.management.PlatformLoggingMXBean} interface
* that can be obtained by calling:
* <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>
*
* @return a {@link LoggingMXBean} object.
*
* @see PlatformLoggingMXBean
* @see java.lang.management.ManagementFactory
* @see java.lang.management.PlatformLoggingMXBean
* @since 1.5
*/
public static synchronized LoggingMXBean getLoggingMXBean() {
public static synchronized LoggingMXBean getLoggingMXBean() {
if (loggingMXBean == null) {
loggingMXBean = new Logging();
}

View File

@ -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>.
* This instance is an
* <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a>
* can be obtained by calling
* the {@link LogManager#getLoggingMXBean} method or from the
* This instance is an {@link javax.management.MXBean MXBean} that
* can be obtained by calling the {@link LogManager#getLoggingMXBean}
* method or from the
* {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
* platform <tt>MBeanServer</tt>}.
*
* The {@link javax.management.ObjectName ObjectName} for uniquely
* identifying the <tt>LoggingMXBean</tt> within an MBeanServer is:
* <blockquote>
* {@link LogManager#LOGGING_MXBEAN_NAME
* <tt>java.util.logging:type=Logging</tt>}
* </blockquote>
*
* The instance registered in the platform <tt>MBeanServer</tt> with
* this {@code ObjectName} is also a {@link PlatformLoggingMXBean}.
* <p>
* The {@link javax.management.ObjectName ObjectName} that uniquely identifies
* the management interface for logging within the {@code MBeanServer} is:
* <pre>
* {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
* </pre>
* <p>
* The instance registered in the platform {@code MBeanServer}
* is also a {@link java.lang.management.PlatformLoggingMXBean}.
*
* @author Ron Mann
* @author Mandy Chung
* @since 1.5
*
* @see PlatformLoggingMXBean
* @see java.lang.management.PlatformLoggingMXBean
*/
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
* of the logger names.
*
@ -89,7 +94,7 @@ public interface LoggingMXBean {
*
* @see Logger#getLevel
*/
public String getLoggerLevel( String loggerName );
public String getLoggerLevel(String loggerName);
/**
* Sets the specified logger to the specified new level.
@ -115,7 +120,7 @@ public interface LoggingMXBean {
*
* @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.

View File

@ -99,4 +99,9 @@ class LoggingProxyImpl implements LoggingProxy {
public String getLevelName(Object level) {
return ((Level) level).getName();
}
@Override
public String getProperty(String key) {
return LogManager.getLogManager().getProperty(key);
}
}

View File

@ -1,60 +0,0 @@
/*
* 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.util.logging;
import java.lang.management.PlatformManagedObject;
/**
* The {@linkplain PlatformManagedObject platform managed object} for the
* logging facility. This interface simply unifies {@link LoggingMXBean}
* {@link PlatformManagedObject};
* and it does not specify any new operations.
*
* <p>The {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
* ManagementFactory.getPlatformMXBeans} method can be used to obtain
* the {@code PlatformLoggingMXBean} object as follows:
* <pre>
* ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
* </pre>
* or from the {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
* platform <tt>MBeanServer</tt>}.
*
* The {@link javax.management.ObjectName ObjectName} for uniquely
* identifying the <tt>LoggingMXBean</tt> within an MBeanServer is:
* <blockquote>
* <tt>java.util.logging:type=Logging</tt>
* </blockquote>
*
* The {@link PlatformManagedObject#getObjectName} method
* can be used to obtain its {@code ObjectName}.
*
* @see java.lang.management.PlatformManagedObject
*
* @author Mandy Chung
* @since 1.7
*/
public interface PlatformLoggingMXBean extends LoggingMXBean, PlatformManagedObject {
}

View File

@ -29,31 +29,108 @@ package java.util.logging;
import java.io.*;
import java.text.*;
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.
*
* <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
* @see java.util.Formatter
*/
public class SimpleFormatter extends Formatter {
Date dat = new Date();
private final static String format = "{0,date} {0,time}";
private MessageFormat formatter;
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 string for printing the log record
private static final String format = LoggingSupport.getSimpleFormat();
private final Date dat = new Date();
/**
* Format the given LogRecord.
* <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}
* convenience method to localize and format the message field.
*
@ -61,42 +138,32 @@ public class SimpleFormatter extends Formatter {
* @return a formatted log record
*/
public synchronized String format(LogRecord record) {
StringBuffer sb = new StringBuffer();
// Minimize memory allocations here.
dat.setTime(record.getMillis());
args[0] = dat;
StringBuffer text = new StringBuffer();
if (formatter == null) {
formatter = new MessageFormat(format);
}
formatter.format(args, text, null);
sb.append(text);
sb.append(" ");
String source;
if (record.getSourceClassName() != null) {
sb.append(record.getSourceClassName());
} else {
sb.append(record.getLoggerName());
}
if (record.getSourceMethodName() != null) {
sb.append(" ");
sb.append(record.getSourceMethodName());
}
sb.append(lineSeparator);
String message = formatMessage(record);
sb.append(record.getLevel().getLocalizedName());
sb.append(": ");
sb.append(message);
sb.append(lineSeparator);
if (record.getThrown() != null) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw);
pw.close();
sb.append(sw.toString());
} catch (Exception ex) {
source = record.getSourceClassName();
if (record.getSourceMethodName() != null) {
source += " " + record.getSourceMethodName();
}
} else {
source = record.getLoggerName();
}
return sb.toString();
String message = formatMessage(record);
String throwable = "";
if (record.getThrown() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println();
record.getThrown().printStackTrace(pw);
pw.close();
throwable = sw.toString();
}
return String.format(format,
dat,
source,
record.getLoggerName(),
record.getLevel().getLocalizedName(),
message,
throwable);
}
}

View File

@ -206,14 +206,9 @@ class DeflaterOutputStream extends FilterOutputStream {
return;
}
if (!def.finished()) {
// Deflate no more than stride bytes at a time. This avoids
// 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()) {
deflate();
}
def.setInput(b, off, len);
while (!def.needsInput()) {
deflate();
}
}
}

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -51,7 +51,7 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters {
* @exception NullPointerException if builder is null
*/
public KeyStoreBuilderParameters(Builder builder) {
parameters = Collections.singletonList(builder);
parameters = Collections.singletonList(Objects.requireNonNull(builder));
}
/**
@ -64,11 +64,12 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters {
* @exception IllegalArgumentException if parameters is an empty list
*/
public KeyStoreBuilderParameters(List<Builder> parameters) {
this.parameters = Collections.unmodifiableList(
new ArrayList<Builder>(parameters));
if (this.parameters.isEmpty()) {
if (parameters.isEmpty()) {
throw new IllegalArgumentException();
}
this.parameters = Collections.unmodifiableList(
new ArrayList<Builder>(parameters));
}
/**

View File

@ -0,0 +1,378 @@
/*
* 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;
}
}

View File

@ -27,20 +27,18 @@ package sun.management;
import java.lang.management.*;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.MBeanRegistrationException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.RuntimeOperationsException;
import java.nio.BufferPoolMXBean;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import sun.security.action.LoadLibraryAction;
import java.util.logging.PlatformLoggingMXBean;
import sun.util.logging.LoggingSupport;
import java.util.ArrayList;
@ -139,61 +137,80 @@ public class ManagementFactoryHelper {
return result;
}
public static List<PlatformLoggingMXBean> getLoggingMXBean() {
public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
if (LoggingSupport.isAvailable()) {
return Collections.singletonList(createPlatformLoggingMXBean());
return PlatformLoggingImpl.instance;
} else {
return Collections.emptyList();
return null;
}
}
private final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
private static PlatformLoggingMXBean createPlatformLoggingMXBean() {
return new PlatformLoggingMXBean() {
private volatile ObjectName objname; // created lazily
@Override
public ObjectName getObjectName() {
ObjectName result = objname;
if (result == null) {
synchronized (this) {
if (objname == null) {
result = Util.newObjectName(LOGGING_MXBEAN_NAME);
objname = result;
}
}
}
return result;
}
@Override
public java.util.List<String> getLoggerNames() {
return LoggingSupport.getLoggerNames();
}
@Override
public String getLoggerLevel(String loggerName) {
return LoggingSupport.getLoggerLevel(loggerName);
}
@Override
public void setLoggerLevel(String loggerName, String levelName) {
LoggingSupport.setLoggerLevel(loggerName, levelName);
}
@Override
public String getParentLoggerName(String loggerName) {
return LoggingSupport.getParentLoggerName(loggerName);
}
};
// The logging MXBean object is an instance of
// PlatformLoggingMXBean and java.util.logging.LoggingMXBean
// 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 {
}
public static List<BufferPoolMXBean> getBufferPoolMXBeans() {
List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2);
pools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
.getDirectBufferPool()));
pools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
.getMappedBufferPool()));
return pools;
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
@Override
public ObjectName getObjectName() {
ObjectName result = objname;
if (result == null) {
synchronized (this) {
if (objname == null) {
result = Util.newObjectName(LOGGING_MXBEAN_NAME);
objname = result;
}
}
}
return result;
}
@Override
public java.util.List<String> getLoggerNames() {
return LoggingSupport.getLoggerNames();
}
@Override
public String getLoggerLevel(String loggerName) {
return LoggingSupport.getLoggerLevel(loggerName);
}
@Override
public void setLoggerLevel(String loggerName, String levelName) {
LoggingSupport.setLoggerLevel(loggerName, levelName);
}
@Override
public String getParentLoggerName(String loggerName) {
return LoggingSupport.getParentLoggerName(loggerName);
}
}
private static List<BufferPoolMXBean> bufferPools = null;
public static synchronized List<BufferPoolMXBean> getBufferPoolMXBeans() {
if (bufferPools == null) {
bufferPools = new ArrayList<>(2);
bufferPools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
.getDirectBufferPool()));
bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
.getMappedBufferPool()));
}
return bufferPools;
}
private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool";

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -36,8 +36,8 @@ public class Version {
"@@java_version@@";
private static final String java_runtime_name =
"@@java_runtime_name@@";
"@@java_runtime_name@@";
private static final String java_runtime_version =
"@@java_runtime_version@@";
@ -87,12 +87,26 @@ public class Version {
* Give a stream, it will print version info on it.
*/
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. */
ps.println(launcher_name + " version \"" + java_version + "\"");
/* 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. */
String java_vm_name = System.getProperty("java.vm.name");

View File

@ -26,6 +26,7 @@
package sun.nio.fs;
import java.util.*;
import java.nio.file.*;
/**
* Utility methods
@ -80,4 +81,21 @@ class Util {
}
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;
}
}

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -362,19 +362,15 @@ public class Realm implements Cloneable {
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);
/*
* The initiator at first location.
*/
tempList.add(cRealm);
tempList.add(sRealm);
int count = 0; // For debug only
if (DEBUG) {
tempTarget = sRealm;
}
tempTarget = sRealm;
out: do {
if (DEBUG) {
@ -384,8 +380,8 @@ public class Realm implements Cloneable {
}
if (intermediaries != null &&
!intermediaries.equals(PrincipalName.REALM_COMPONENT_SEPARATOR_STR))
{
!intermediaries.equals(".") &&
!intermediaries.equals(cRealm)) {
if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " +
count + ": intermediaries=[" +
@ -466,11 +462,15 @@ public class Realm implements Cloneable {
} while (true);
if (tempList.isEmpty()) {
return null;
}
// From (SREALM, T1, T2) to (CREALM, T2, T1)
retList = new String[tempList.size()];
try {
retList = tempList.toArray(retList);
} catch (ArrayStoreException exc) {
retList = null;
retList[0] = cRealm;
for (int i=1; i<tempList.size(); i++) {
retList[i] = tempList.elementAt(tempList.size()-i);
}
if (DEBUG && retList != null) {

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -694,47 +694,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange
// the preferable signature algorithm used by this ServerKeyExchange message
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
* key exchange.
@ -779,12 +738,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange
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
* stream, as if sent from server to client for use with
@ -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 temp = 6; // overhead for p, g, y(s) values.
@ -945,8 +945,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
* We support named curves only, no explicitly encoded curves.
*/
static final
class ECDH_ServerKeyExchange extends ServerKeyExchange
{
class ECDH_ServerKeyExchange extends ServerKeyExchange {
// constants for ECCurveType
private final static int CURVE_EXPLICIT_PRIME = 1;
@ -1120,10 +1119,12 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
}
int messageLength() {
int sigLen = (signatureBytes == null) ? 0 : 2 + signatureBytes.length;
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
sigLen += SignatureAndHashAlgorithm.sizeInRecord();
int sigLen = 0;
if (signatureBytes != null) {
sigLen = 2 + signatureBytes.length;
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
sigLen += SignatureAndHashAlgorithm.sizeInRecord();
}
}
return 4 + pointBytes.length + sigLen;
@ -1133,12 +1134,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
s.putInt8(CURVE_NAMED_CURVE);
s.putInt16(curveId);
s.putBytes8(pointBytes);
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
s.putInt8(preferableSignatureAlgorithm.getHashValue());
s.putInt8(preferableSignatureAlgorithm.getSignatureValue());
}
if (signatureBytes != null) {
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
s.putInt8(preferableSignatureAlgorithm.getHashValue());
s.putInt8(preferableSignatureAlgorithm.getSignatureValue());
}
s.putBytes16(signatureBytes);
}
}
@ -1147,9 +1149,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
s.println("*** ECDH ServerKeyExchange");
if (debug != null && Debug.isOn("verbose")) {
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
s.println("Signature Algorithm " +
preferableSignatureAlgorithm.getAlgorithmName());
if (signatureBytes == null) {
s.println("Anonymous");
} else {
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
s.println("Signature Algorithm " +
preferableSignatureAlgorithm.getAlgorithmName());
}
}
s.println("Server key: " + publicKey);

View File

@ -1238,10 +1238,11 @@ public class JarSigner {
// Provide a helpful message when TSA is beyond a firewall
error(rb.getString("unable.to.sign.jar.") +
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.") +
rb.getString("Supply.the.following.options.to.jarsigner.") +
"\n -J-Dhttp.proxyHost=<hostname> " +
"\n -J-Dhttp.proxyPort=<portnumber> ", e);
"\n -J-Dhttp.proxyHost=<hostname>" +
"\n -J-Dhttp.proxyPort=<portnumber>\n" +
rb.getString("or") +
"\n -J-Dhttps.proxyHost=<hostname> " +
"\n -J-Dhttps.proxyPort=<portnumber> ", e);
}
sfFilename = sf.getMetaName();

View File

@ -181,11 +181,10 @@ public class JarSignerResources extends java.util.ListResourceBundle {
{"TSA.location.", "TSA location: "},
{"TSA.certificate.", "TSA certificate: "},
{"no.response.from.the.Timestamping.Authority.",
"no response from the Timestamping Authority. "},
{"When.connecting.from.behind.a.firewall.then.an.HTTP.proxy.may.need.to.be.specified.",
"When connecting from behind a firewall then an HTTP proxy may need to be specified. "},
{"Supply.the.following.options.to.jarsigner.",
"Supply the following options to jarsigner: "},
"no response from the Timestamping Authority. When connecting"
+ " from behind a firewall an HTTP or HTTPS proxy may need to"
+ " be specified. Supply the following options to jarsigner:"},
{"or", "or"},
{"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."},
{"using.an.alternative.signing.mechanism",

View File

@ -1740,16 +1740,19 @@ public final class KeyTool {
KeyStore.TrustedCertificateEntry.class)) {
// We have a trusted certificate entry
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)) {
out.println(rb.getString("Entry.type.trustedCertEntry."));
out.println(mf);
printX509Cert((X509Certificate)cert, out);
} else if (rfc) {
out.println(rb.getString("Entry.type.trustedCertEntry."));
out.println(mf);
dumpCert(cert, out);
} else if (debug) {
out.println(cert.toString());
} else {
out.println(rb.getString("trustedCertEntry."));
out.println("trustedCertEntry, ");
out.println(rb.getString("Certificate.fingerprint.SHA1.")
+ getCertFingerPrint("SHA1", cert));
}
@ -1836,10 +1839,6 @@ public final class KeyTool {
(".WARNING.WARNING.WARNING."));
System.err.println(rb.getString
(".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
(".WARNING.WARNING.WARNING."));
System.err.println();
@ -3186,10 +3185,6 @@ public final class KeyTool {
(".WARNING.WARNING.WARNING."));
System.err.println(rb.getString
(".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
(".WARNING.WARNING.WARNING."));
System.err.println();

View File

@ -250,10 +250,10 @@ public final class TimestampedSigner extends ContentSigner {
* (<a href="http://www.ietf.org/rfc/rfc3280.txt">RFC 3280</a>).
* 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
* <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.
* @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) {
@ -279,7 +279,8 @@ public final class TimestampedSigner extends ContentSigner {
location = description.getAccessLocation();
if (location.getType() == GeneralNameInterface.NAME_URI) {
uri = (URIName) location.getName();
if (uri.getScheme().equalsIgnoreCase("http")) {
if (uri.getScheme().equalsIgnoreCase("http") ||
uri.getScheme().equalsIgnoreCase("https")) {
return uri.getName();
}
}

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -111,17 +111,15 @@ public class AuthResources extends java.util.ListResourceBundle {
// com.sun.security.auth.PolicyParser
{"expected.keystore.type", "expected keystore type"},
{"can.not.specify.Principal.with.a.",
"can not specify Principal with a "},
{"wildcard.class.without.a.wildcard.name",
"wildcard class without a wildcard name"},
{"can.not.specify.Principal.with.a.wildcard.class.without.a.wildcard.name",
"can not specify Principal with a wildcard class without a wildcard name"},
{"expected.codeBase.or.SignedBy", "expected codeBase or SignedBy"},
{"only.Principal.based.grant.entries.permitted",
"only Principal-based grant entries permitted"},
{"expected.permission.entry", "expected permission entry"},
{"number.", "number "},
{"expected.", "expected "},
{".read.end.of.file", ", read end of file"},
{"expected.expect.read.end.of.file.",
"expected {0}, read end of file"},
{"expected.read.end.of.file", "expected ';', read end of file"},
{"line.", "line "},
{".expected.", ": expected '"},
@ -136,6 +134,9 @@ public class AuthResources extends java.util.ListResourceBundle {
{"SolarisNumericUserPrincipal.",
"SolarisNumericUserPrincipal: "},
{"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"}
};

View File

@ -195,8 +195,7 @@ public class ManifestEntryVerifier {
Hashtable<String, CodeSigner[]> sigFileSigners)
throws JarException
{
// MANIFEST.MF should not be skipped. It has signers.
if (skip && !entry.getName().equals(JarFile.MANIFEST_NAME)) {
if (skip) {
return null;
}

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -304,8 +304,6 @@ public class Resources extends java.util.ListResourceBundle {
{"Certificate.chain.length.", "Certificate chain length: "},
{"Certificate.i.1.", "Certificate[{0,number,integer}]:"},
{"Certificate.fingerprint.SHA1.", "Certificate fingerprint (SHA1): "},
{"Entry.type.trustedCertEntry.", "Entry type: trustedCertEntry\n"},
{"trustedCertEntry.", "trustedCertEntry,"},
{"Keystore.type.", "Keystore type: "},
{"Keystore.provider.", "Keystore provider: "},
{"Your.keystore.contains.keyStore.size.entry",
@ -378,21 +376,15 @@ public class Resources extends java.util.ListResourceBundle {
{"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.the.srckeystore.",
"* 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.",
"* The integrity of the information stored in your keystore *\n" +
"* has NOT been verified! In order to verify its integrity, *\n" +
"* 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. *"},
{"Certificate.reply.does.not.contain.public.key.for.alias.",
"Certificate reply does not contain public key for <{0}>"},
{"Incomplete.certificate.chain.in.reply",

View File

@ -3457,13 +3457,18 @@ public class BidiBase {
*/
static final AttributedCharacterIterator.Attribute RUN_DIRECTION =
getTextAttribute("RUN_DIRECTION");
static final Boolean RUN_DIRECTION_LTR =
(Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING =
getTextAttribute("NUMERIC_SHAPING");
static final AttributedCharacterIterator.Attribute 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) {
try {
return Class.forName(name, true, null);
@ -3473,25 +3478,23 @@ public class BidiBase {
}
private static Object getStaticField(Class<?> clazz, String name) {
if (clazz == null) {
// fake attribute
return new AttributedCharacterIterator.Attribute(name) { };
} else {
try {
Field f = clazz.getField(name);
return f.get(null);
} catch (NoSuchFieldException x) {
throw new AssertionError(x);
} catch (IllegalAccessException x) {
throw new AssertionError(x);
}
try {
Field f = clazz.getField(name);
return f.get(null);
} catch (NoSuchFieldException | IllegalAccessException x) {
throw new AssertionError(x);
}
}
private static AttributedCharacterIterator.Attribute
getTextAttribute(String name)
{
return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
if (clazz == null) {
// fake attribute
return new AttributedCharacterIterator.Attribute(name) { };
} else {
return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
}
}
}

View File

@ -479,7 +479,7 @@ public class ZoneInfoFile {
String zi = System.getProperty("java.home") +
File.separator + "lib" + File.separator + "zi";
try {
zi = FileSystems.getDefault().getPath(zi).toRealPath(true).toString();
zi = FileSystems.getDefault().getPath(zi).toRealPath().toString();
} catch(Exception e) {
}
return zi;

View File

@ -60,4 +60,7 @@ public interface LoggingProxy {
public Object parseLevel(String levelName);
public String getLevelName(Object level);
// return the logging property
public String getProperty(String key);
}

View File

@ -29,6 +29,7 @@ package sun.util.logging;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Date;
/**
* Internal API to support JRE implementation to detect if the java.util.logging
@ -138,4 +139,42 @@ public class LoggingSupport {
ensureAvailable();
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;
}
}

View File

@ -316,12 +316,6 @@ public class PlatformLogger {
*/
static class LoggerProxy {
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;
volatile int levelValue;
@ -353,14 +347,14 @@ public class PlatformLogger {
if (level < levelValue || levelValue == OFF) {
return;
}
defaultStream.println(format(level, msg, null));
defaultStream.print(format(level, msg, null));
}
void doLog(int level, String msg, Throwable thrown) {
if (level < levelValue || levelValue == OFF) {
return;
}
defaultStream.println(format(level, msg, thrown));
defaultStream.print(format(level, msg, thrown));
}
void doLog(int level, String msg, Object... params) {
@ -368,7 +362,7 @@ public class PlatformLogger {
return;
}
String newMsg = formatMessage(msg, params);
defaultStream.println(format(level, newMsg, null));
defaultStream.print(format(level, newMsg, null));
}
public boolean isLoggable(int level) {
@ -378,12 +372,6 @@ public class PlatformLogger {
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
private String formatMessage(String format, Object... parameters) {
// Do the formatting.
@ -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) {
StringBuffer sb = new StringBuffer();
// Minimize memory allocations here.
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);
date.setTime(System.currentTimeMillis());
String throwable = "";
if (thrown != null) {
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
thrown.printStackTrace(pw);
pw.close();
sb.append(sw.toString());
} catch (Exception ex) {
throw new AssertionError(ex);
}
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println();
thrown.printStackTrace(pw);
pw.close();
throwable = sw.toString();
}
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

View File

@ -99,7 +99,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
synchronized(filesystems) {
Path realPath = null;
if (ensureFile(path)) {
realPath = path.toRealPath(true);
realPath = path.toRealPath();
if (filesystems.containsKey(realPath))
throw new FileSystemAlreadyExistsException();
}
@ -154,7 +154,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
synchronized (filesystems) {
ZipFileSystem zipfs = null;
try {
zipfs = filesystems.get(uriToPath(uri).toRealPath(true));
zipfs = filesystems.get(uriToPath(uri).toRealPath());
} catch (IOException x) {
// ignore the ioe from toRealPath(), return FSNFE
}
@ -310,7 +310,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
//////////////////////////////////////////////////////////////
void removeFileSystem(Path zfpath, ZipFileSystem zfs) throws IOException {
synchronized (filesystems) {
zfpath = zfpath.toRealPath(true);
zfpath = zfpath.toRealPath();
if (filesystems.get(zfpath) == zfs)
filesystems.remove(zfpath);
}

View File

@ -150,7 +150,7 @@ public class ZipPath implements Path {
}
@Override
public ZipPath toRealPath(boolean resolveLinks) throws IOException {
public ZipPath toRealPath(LinkOption... options) throws IOException {
ZipPath realPath = new ZipPath(zfs, getResolvedPath()).toAbsolutePath();
realPath.checkAccess();
return realPath;

View File

@ -43,6 +43,11 @@ java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Example to customize the SimpleFormatter output format
# to print one-line log message like this:
# <level>: <log message> [<date/time>]
#
# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
############################################################
# Facility specific properties.

View File

@ -129,34 +129,28 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
if ((*env)->GetBooleanField(env, this, setParamsID)) {
int level = (*env)->GetIntField(env, this, levelID);
int strategy = (*env)->GetIntField(env, this, strategyID);
in_buf = (jbyte *) malloc(this_len);
if (in_buf == 0) {
in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
if (in_buf == NULL) {
// Throw OOME only when length is not zero
if (this_len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
(*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
out_buf = (jbyte *) malloc(len);
if (out_buf == 0) {
free(in_buf);
out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
if (out_buf == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
if (len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
strm->next_in = (Bytef *) in_buf;
strm->next_out = (Bytef *) out_buf;
strm->next_in = (Bytef *) (in_buf + this_off);
strm->next_out = (Bytef *) (out_buf + off);
strm->avail_in = this_len;
strm->avail_out = len;
res = deflateParams(strm, level, strategy);
if (res == Z_OK) {
(*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
}
free(out_buf);
free(in_buf);
(*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
switch (res) {
case Z_OK:
@ -174,33 +168,28 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
}
} else {
jboolean finish = (*env)->GetBooleanField(env, this, finishID);
in_buf = (jbyte *) malloc(this_len);
if (in_buf == 0) {
in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
if (in_buf == NULL) {
if (this_len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
(*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
out_buf = (jbyte *) malloc(len);
if (out_buf == 0) {
free(in_buf);
out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
if (out_buf == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
if (len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
strm->next_in = (Bytef *) in_buf;
strm->next_out = (Bytef *) out_buf;
strm->next_in = (Bytef *) (in_buf + this_off);
strm->next_out = (Bytef *) (out_buf + off);
strm->avail_in = this_len;
strm->avail_out = len;
res = deflate(strm, finish ? Z_FINISH : flush);
if (res == Z_STREAM_END || res == Z_OK) {
(*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
}
free(out_buf);
free(in_buf);
(*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
switch (res) {
case Z_STREAM_END:

View File

@ -38,8 +38,6 @@
#include "zlib.h"
#include "java_util_zip_Inflater.h"
#define MIN2(x, y) ((x) < (y) ? (x) : (y))
#define ThrowDataFormatException(env, msg) \
JNU_ThrowByName(env, "java/util/zip/DataFormatException", msg)
@ -111,71 +109,50 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr,
jarray b, jint off, jint len)
{
z_stream *strm = jlong_to_ptr(addr);
jarray this_buf = (jarray)(*env)->GetObjectField(env, this, bufID);
jint this_off = (*env)->GetIntField(env, this, offID);
jint this_len = (*env)->GetIntField(env, this, lenID);
jbyte *in_buf;
jbyte *out_buf;
int ret;
/*
* Avoid excess copying.
* zlib stream usually has a few bytes of overhead for header info
* (depends on the underlying data)
*
* (a) 5 bytes per 16KB
* (b) 6 bytes for entire stream
* (c) 4 bytes for gzip header
* (d) 2 bytes for crc
*
* Use 20 bytes as the "safe cutoff" number.
*/
jint in_len = MIN2(this_len, len + 20);
jint consumed;
in_buf = (jbyte *) malloc(in_len);
if (in_buf == 0) {
if (in_len != 0)
in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
if (in_buf == NULL) {
if (this_len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
(*env)->GetByteArrayRegion(env, this_buf, this_off, in_len, in_buf);
out_buf = (jbyte *) malloc(len);
if (out_buf == 0) {
free(in_buf);
out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
if (out_buf == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
if (len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
strm->next_in = (Bytef *) in_buf;
strm->next_out = (Bytef *) out_buf;
strm->avail_in = in_len;
strm->next_in = (Bytef *) (in_buf + this_off);
strm->next_out = (Bytef *) (out_buf + off);
strm->avail_in = this_len;
strm->avail_out = len;
ret = inflate(strm, Z_PARTIAL_FLUSH);
if (ret == Z_STREAM_END || ret == Z_OK) {
(*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
}
free(out_buf);
free(in_buf);
(*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
switch (ret) {
case Z_STREAM_END:
(*env)->SetBooleanField(env, this, finishedID, JNI_TRUE);
/* fall through */
case Z_OK:
consumed = in_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off + consumed);
(*env)->SetIntField(env, this, lenID, this_len - consumed);
this_off += this_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off);
(*env)->SetIntField(env, this, lenID, strm->avail_in);
return len - strm->avail_out;
case Z_NEED_DICT:
(*env)->SetBooleanField(env, this, needDictID, JNI_TRUE);
/* Might have consumed some input here! */
consumed = in_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off + consumed);
(*env)->SetIntField(env, this, lenID, this_len - consumed);
this_off += this_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off);
(*env)->SetIntField(env, this, lenID, strm->avail_in);
return 0;
case Z_BUF_ERROR:
return 0;

View File

@ -0,0 +1,38 @@
# 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.
#
# List of JVMs that can be used as an option to java, javac, etc.
# Order is important -- first in this list is the default JVM.
# NOTE that this both this file and its format are UNSUPPORTED and
# WILL GO AWAY in a future release.
#
# You may also select a JVM in an arbitrary location with the
# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
# and may not be available in a future release.
#
-client KNOWN
-server KNOWN
-hotspot ERROR
-classic WARN
-native ERROR
-green ERROR

View File

@ -0,0 +1,38 @@
# 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.
#
# List of JVMs that can be used as an option to java, javac, etc.
# Order is important -- first in this list is the default JVM.
# NOTE that this both this file and its format are UNSUPPORTED and
# WILL GO AWAY in a future release.
#
# You may also select a JVM in an arbitrary location with the
# "-XXaltjvm=<jvm_dir>" option, but that too is unsupported
# and may not be available in a future release.
#
-client KNOWN
-server KNOWN
-hotspot ERROR
-classic WARN
-native ERROR
-green ERROR

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -135,6 +135,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
}
/*
* Return (potentially) platform specific display timeout for the
* tray icon
*/
static native long getTrayIconDisplayTimeout();
//---- ERROR HANDLER CODE ----//
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -230,7 +230,7 @@ public class XTrayIconPeer implements TrayIconPeer,
// Wait till the EmbeddedFrame is reparented
long start = System.currentTimeMillis();
final long PERIOD = 2000L;
final long PERIOD = XToolkit.getTrayIconDisplayTimeout();
XToolkit.awtLock();
try {
while (!isTrayIconDisplayed) {

View File

@ -56,11 +56,11 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
{
if (type == DosFileAttributeView.class) {
return (V) new LinuxDosFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
}
if (type == UserDefinedFileAttributeView.class) {
return (V) new LinuxUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
}
return super.getFileAttributeView(obj, type, options);
}
@ -72,11 +72,11 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
{
if (name.equals("dos")) {
return new LinuxDosFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
}
if (name.equals("user")) {
return new LinuxUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
}
return super.getFileAttributeView(obj, name, options);
}

View File

@ -57,11 +57,11 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
{
if (type == AclFileAttributeView.class) {
return (V) new SolarisAclFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
}
if (type == UserDefinedFileAttributeView.class) {
return(V) new SolarisUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
}
return super.getFileAttributeView(obj, type, options);
}
@ -73,10 +73,10 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
{
if (name.equals("acl"))
return new SolarisAclFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
if (name.equals("user"))
return new SolarisUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
followLinks(options));
Util.followLinks(options));
return super.getFileAttributeView(obj, name, options);
}
}

View File

@ -105,20 +105,6 @@ public abstract class UnixFileSystemProvider
return (UnixPath)obj;
}
boolean followLinks(LinkOption... options) {
boolean followLinks = true;
for (LinkOption option: options) {
if (option == LinkOption.NOFOLLOW_LINKS) {
followLinks = false;
continue;
}
if (option == null)
throw new NullPointerException();
throw new AssertionError("Should not get here");
}
return followLinks;
}
@Override
@SuppressWarnings("unchecked")
public <V extends FileAttributeView> V getFileAttributeView(Path obj,
@ -126,7 +112,7 @@ public abstract class UnixFileSystemProvider
LinkOption... options)
{
UnixPath file = UnixPath.toUnixPath(obj);
boolean followLinks = followLinks(options);
boolean followLinks = Util.followLinks(options);
if (type == BasicFileAttributeView.class)
return (V) UnixFileAttributeViews.createBasicView(file, followLinks);
if (type == PosixFileAttributeView.class)
@ -163,7 +149,7 @@ public abstract class UnixFileSystemProvider
LinkOption... options)
{
UnixPath file = UnixPath.toUnixPath(obj);
boolean followLinks = followLinks(options);
boolean followLinks = Util.followLinks(options);
if (name.equals("basic"))
return UnixFileAttributeViews.createBasicView(file, followLinks);
if (name.equals("posix"))

View File

@ -819,13 +819,13 @@ class UnixPath
}
@Override
public Path toRealPath(boolean resolveLinks) throws IOException {
public Path toRealPath(LinkOption... options) throws IOException {
checkRead();
UnixPath absolute = toAbsolutePath();
// if resolveLinks is true then use realpath
if (resolveLinks) {
// if resolving links then use realpath
if (Util.followLinks(options)) {
try {
byte[] rp = realpath(absolute);
return new UnixPath(getFileSystem(), rp);
@ -834,7 +834,7 @@ class UnixPath
}
}
// if resolveLinks is false then eliminate "." and also ".."
// if not resolving links then eliminate "." and also ".."
// where the previous element is not a link.
UnixPath result = fs.rootDirectory();
for (int i=0; i<absolute.getNameCount(); i++) {

View File

@ -81,20 +81,6 @@ class UnixSecureDirectoryStream
return (UnixPath)obj;
}
private boolean followLinks(LinkOption... options) {
boolean followLinks = true;
for (LinkOption option: options) {
if (option == LinkOption.NOFOLLOW_LINKS) {
followLinks = false;
continue;
}
if (option == null)
throw new NullPointerException();
throw new AssertionError("Should not get here");
}
return followLinks;
}
/**
* Opens sub-directory in this directory
*/
@ -105,7 +91,7 @@ class UnixSecureDirectoryStream
{
UnixPath file = getName(obj);
UnixPath child = ds.directory().resolve(file);
boolean followLinks = followLinks(options);
boolean followLinks = Util.followLinks(options);
// permission check using name resolved against original path of directory
SecurityManager sm = System.getSecurityManager();
@ -316,7 +302,7 @@ class UnixSecureDirectoryStream
LinkOption... options)
{
UnixPath file = getName(obj);
boolean followLinks = followLinks(options);
boolean followLinks = Util.followLinks(options);
return getFileAttributeViewImpl(file, type, followLinks);
}

View File

@ -1,5 +1,5 @@
/*
* 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -55,6 +55,11 @@
#endif
#endif
#ifdef JAVASE_EMBEDDED
#include <dlfcn.h>
#include <sys/stat.h>
#endif
/* Take an array of string pairs (map of key->value) and a string (key).
* Examine each pair in the map to see if the first string (key) matches the
* string. If so, store the second string of the pair (value) in the value and
@ -304,6 +309,36 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
return 1;
}
#ifdef JAVASE_EMBEDDED
/* Determine the default embedded toolkit based on whether lib/xawt/
* exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
*/
static char* getEmbeddedToolkit() {
Dl_info dlinfo;
char buf[MAXPATHLEN];
int32_t len;
char *p;
struct stat statbuf;
/* Get address of this library and the directory containing it. */
dladdr((void *)getEmbeddedToolkit, &dlinfo);
realpath((char *)dlinfo.dli_fname, buf);
len = strlen(buf);
p = strrchr(buf, '/');
/* Default AWT Toolkit on Linux and Solaris is XAWT. */
strncpy(p, "/xawt/", MAXPATHLEN-len-1);
/* Check if it exists */
if (stat(buf, &statbuf) == -1 && errno == ENOENT) {
/* No - this is a reduced-headless-jre so use special HToolkit */
return "sun.awt.HToolkit";
}
else {
/* Yes - this is a headful JRE so fallback to SE defaults */
return NULL;
}
}
#endif
/* This function gets called very early, before VM_CALLS are setup.
* Do not use any of the VM_CALLS entries!!!
*/
@ -328,7 +363,12 @@ GetJavaProperties(JNIEnv *env)
/* Java 2D properties */
sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
sprops.awt_toolkit = NULL;
#ifdef JAVASE_EMBEDDED
sprops.awt_toolkit = getEmbeddedToolkit();
if (sprops.awt_toolkit == NULL) // default as below
#endif
sprops.awt_toolkit = "sun.awt.X11.XToolkit";
/* This is used only for debugging of font problems. */
v = getenv("JAVA2D_FONTPATH");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2001, 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -33,6 +33,10 @@
*/
JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
{
#if defined(JAVASE_EMBEDDED) && defined(HEADLESS)
/* there are no AWT libs available at all */
return JNI_FALSE;
#else
if (awt == NULL) {
return JNI_FALSE;
}
@ -51,4 +55,5 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
}
return JNI_TRUE;
#endif
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2006, 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -110,6 +110,21 @@ Java_sun_awt_X11_XToolkit_initIDs
awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False;
}
/*
* Class: sun_awt_X11_XToolkit
* Method: getTrayIconDisplayTimeout
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout
(JNIEnv *env, jclass clazz)
{
#ifndef JAVASE_EMBEDDED
return (jlong) 2000;
#else
return (jlong) 10000;
#endif
}
/*
* Class: sun_awt_X11_XToolkit
* Method: getDefaultXColormap
@ -340,15 +355,34 @@ static uint32_t get_poll_timeout(jlong nextTaskTime);
#define AWT_READPIPE (awt_pipe_fds[0])
#define AWT_WRITEPIPE (awt_pipe_fds[1])
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
#ifdef JAVASE_EMBEDDED
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)4000000000) /* milliseconds */
#else
#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
#endif
#define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */
#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
#define TIMEOUT_TIMEDOUT 0
#define TIMEOUT_EVENTS 1
/* awt_poll_alg - AWT Poll Events Aging Algorithms */
#define AWT_POLL_FALSE 1
#define AWT_POLL_AGING_SLOW 2
#define AWT_POLL_AGING_FAST 3
#define AWT_POLL_THRESHOLD 1000 // msec, Block if delay is larger
#define AWT_POLL_BLOCK -1 // cause poll() block
// Static fields
#ifdef JAVASE_EMBEDDED
static int awt_poll_alg = AWT_POLL_AGING_FAST;
#else
static int awt_poll_alg = AWT_POLL_AGING_SLOW;
#endif
static uint32_t AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */
static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */
static pthread_t awt_MainThread = 0;
@ -417,6 +451,7 @@ awt_pipe_init() {
*/
static void readEnv() {
char * value;
int tmp_poll_alg;
static Boolean env_read = False;
if (env_read) return;
@ -451,6 +486,23 @@ static void readEnv() {
if (static_poll_timeout != 0) {
curPollTimeout = static_poll_timeout;
}
// non-blocking poll()
value = getenv("_AWT_POLL_ALG");
if (value != NULL) {
tmp_poll_alg = atoi(value);
switch(tmp_poll_alg) {
case AWT_POLL_FALSE:
case AWT_POLL_AGING_SLOW:
case AWT_POLL_AGING_FAST:
awt_poll_alg = tmp_poll_alg;
break;
default:
PRINT("Unknown value of _AWT_POLL_ALG, assuming Slow Aging Algorithm by default");
awt_poll_alg = AWT_POLL_AGING_SLOW;
break;
}
}
}
/**
@ -478,14 +530,29 @@ static void update_poll_timeout(int timeout_control) {
if (static_poll_timeout != 0) return;
// Update it otherwise
if (timeout_control == TIMEOUT_TIMEDOUT) {
/* add 1/4 (plus 1, in case the division truncates to 0) */
curPollTimeout += ((curPollTimeout>>2) + 1);
curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
} else if (timeout_control == TIMEOUT_EVENTS) {
/* subtract 1/4 (plus 1, in case the division truncates to 0) */
curPollTimeout -= ((curPollTimeout>>2) + 1);
curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
switch(awt_poll_alg) {
case AWT_POLL_AGING_SLOW:
if (timeout_control == TIMEOUT_TIMEDOUT) {
/* add 1/4 (plus 1, in case the division truncates to 0) */
curPollTimeout += ((curPollTimeout>>2) + 1);
curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
} else if (timeout_control == TIMEOUT_EVENTS) {
/* subtract 1/4 (plus 1, in case the division truncates to 0) */
curPollTimeout -= ((curPollTimeout>>2) + 1);
curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
}
break;
case AWT_POLL_AGING_FAST:
if (timeout_control == TIMEOUT_TIMEDOUT) {
curPollTimeout += ((curPollTimeout>>2) + 1);
curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
curPollTimeout = AWT_POLL_BLOCK;
} else if (timeout_control == TIMEOUT_EVENTS) {
curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
}
break;
}
}
@ -497,16 +564,37 @@ static void update_poll_timeout(int timeout_control) {
*/
static uint32_t get_poll_timeout(jlong nextTaskTime)
{
uint32_t ret_timeout;
uint32_t timeout;
uint32_t taskTimeout;
uint32_t flushTimeout;
jlong curTime = awtJNI_TimeMillis();
uint32_t timeout = curPollTimeout;
uint32_t taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
uint32_t flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
timeout = curPollTimeout;
switch(awt_poll_alg) {
case AWT_POLL_AGING_SLOW:
case AWT_POLL_AGING_FAST:
taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
// Adjust timeout to flush_time and task_time
return min(flushTimeout, min(taskTimeout, timeout));
} /* awt_get_poll_timeout() */
// Adjust timeout to flush_time and task_time
ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
if((int)curPollTimeout == AWT_POLL_BLOCK)
ret_timeout = AWT_POLL_BLOCK;
break;
case AWT_POLL_FALSE:
ret_timeout = (nextTaskTime > curTime) ?
(nextTaskTime - curTime) :
((nextTaskTime == -1) ? -1 : 0);
break;
}
return ret_timeout;
} /* get_poll_timeout() */
/*
* Waits for X/Xt events to appear on the pipe. Returns only when
@ -598,6 +686,8 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
if (result == 0) {
/* poll() timed out -- update timeout value */
update_poll_timeout(TIMEOUT_TIMEDOUT);
PRINT2("%s(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n",
performPoll, curPollTimeout);
}
if (pollFds[1].revents) {
int count;
@ -606,10 +696,14 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
do {
count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
} while (count == AWT_POLL_BUFSIZE );
PRINT2("%s(): data on the AWT pipe: curPollTimeout = %d \n",
performPoll, curPollTimeout);
}
if (pollFds[0].revents) {
// Events in X pipe
update_poll_timeout(TIMEOUT_EVENTS);
PRINT2("%s(): TIMEOUT_EVENTS curPollTimeout = %ld \n",
performPoll, curPollTimeout);
}
return;

View File

@ -150,20 +150,6 @@ public class WindowsFileSystemProvider
}
}
private boolean followLinks(LinkOption... options) {
boolean followLinks = true;
for (LinkOption option: options) {
if (option == LinkOption.NOFOLLOW_LINKS) {
followLinks = false;
continue;
}
if (option == null)
throw new NullPointerException();
throw new AssertionError("Should not get here");
}
return followLinks;
}
@Override
@SuppressWarnings("unchecked")
public <V extends FileAttributeView> V
@ -172,7 +158,7 @@ public class WindowsFileSystemProvider
WindowsPath file = WindowsPath.toWindowsPath(obj);
if (view == null)
throw new NullPointerException();
boolean followLinks = followLinks(options);
boolean followLinks = Util.followLinks(options);
if (view == BasicFileAttributeView.class)
return (V) WindowsFileAttributeViews.createBasicView(file, followLinks);
if (view == DosFileAttributeView.class)
@ -209,7 +195,7 @@ public class WindowsFileSystemProvider
@Override
public DynamicFileAttributeView getFileAttributeView(Path obj, String name, LinkOption... options) {
WindowsPath file = WindowsPath.toWindowsPath(obj);
boolean followLinks = followLinks(options);
boolean followLinks = Util.followLinks(options);
if (name.equals("basic"))
return WindowsFileAttributeViews.createBasicView(file, followLinks);
if (name.equals("dos"))

View File

@ -831,9 +831,9 @@ class WindowsPath extends AbstractPath {
}
@Override
public WindowsPath toRealPath(boolean resolveLinks) throws IOException {
public WindowsPath toRealPath(LinkOption... options) throws IOException {
checkRead();
String rp = WindowsLinkSupport.getRealPath(this, resolveLinks);
String rp = WindowsLinkSupport.getRealPath(this, Util.followLinks(options));
return createFromNormalizedPath(getFileSystem(), rp);
}

View File

@ -30,6 +30,7 @@
#include "management.h"
#include "com_sun_management_OperatingSystem.h"
#include <psapi.h>
#include <errno.h>
#include <stdlib.h>
@ -53,41 +54,12 @@ static jlong jlong_from(jint h, jint l) {
return result;
}
// From psapi.h
typedef struct _PROCESS_MEMORY_COUNTERS {
DWORD cb;
DWORD PageFaultCount;
SIZE_T PeakWorkingSetSize;
SIZE_T WorkingSetSize;
SIZE_T QuotaPeakPagedPoolUsage;
SIZE_T QuotaPagedPoolUsage;
SIZE_T QuotaPeakNonPagedPoolUsage;
SIZE_T QuotaNonPagedPoolUsage;
SIZE_T PagefileUsage;
SIZE_T PeakPagefileUsage;
} PROCESS_MEMORY_COUNTERS;
static HINSTANCE hInstPsapi = NULL;
typedef BOOL (WINAPI *LPFNGETPROCESSMEMORYINFO)(HANDLE, PROCESS_MEMORY_COUNTERS*, DWORD);
static jboolean is_nt = JNI_FALSE;
static HANDLE main_process;
JNIEXPORT void JNICALL
Java_com_sun_management_OperatingSystem_initialize
(JNIEnv *env, jclass cls)
{
OSVERSIONINFO oi;
oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&oi);
switch(oi.dwPlatformId) {
case VER_PLATFORM_WIN32_WINDOWS: is_nt = JNI_FALSE; break;
case VER_PLATFORM_WIN32_NT: is_nt = JNI_TRUE; break;
default:
throw_internal_error(env, "Unsupported Platform");
return;
}
main_process = GetCurrentProcess();
}
@ -95,31 +67,12 @@ JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getCommittedVirtualMemorySize0
(JNIEnv *env, jobject mbean)
{
/*
* In bytes. NT/2000/XP only - using GetProcessMemoryInfo from psapi.dll
*/
static LPFNGETPROCESSMEMORYINFO lpfnGetProcessMemoryInfo = NULL;
static volatile jboolean psapi_inited = JNI_FALSE;
PROCESS_MEMORY_COUNTERS pmc;
if (!is_nt) return -1;
if (!psapi_inited) {
psapi_inited = JNI_TRUE;
if ((hInstPsapi = LoadLibrary("PSAPI.DLL")) == NULL) return -1;
if ((lpfnGetProcessMemoryInfo = (LPFNGETPROCESSMEMORYINFO)
GetProcAddress( hInstPsapi, "GetProcessMemoryInfo")) == NULL) {
FreeLibrary(hInstPsapi);
return -1;
}
if (GetProcessMemoryInfo(main_process, &pmc, sizeof(PROCESS_MEMORY_COUNTERS)) == 0) {
return (jlong)-1L;
} else {
return (jlong) pmc.PagefileUsage;
}
if (lpfnGetProcessMemoryInfo == NULL) return -1;
lpfnGetProcessMemoryInfo(main_process, &pmc,
sizeof(PROCESS_MEMORY_COUNTERS));
return (jlong) pmc.PagefileUsage;
}
JNIEXPORT jlong JNICALL
@ -148,20 +101,15 @@ Java_com_sun_management_OperatingSystem_getProcessCpuTime
FILETIME process_creation_time, process_exit_time,
process_user_time, process_kernel_time;
// Windows NT only
if (is_nt) {
// Using static variables declared above
// Units are 100-ns intervals. Convert to ns.
GetProcessTimes(main_process, &process_creation_time,
&process_exit_time,
&process_kernel_time, &process_user_time);
return (jlong_from(process_user_time.dwHighDateTime,
process_user_time.dwLowDateTime) +
jlong_from(process_kernel_time.dwHighDateTime,
process_kernel_time.dwLowDateTime)) * 100;
} else {
return -1;
}
// Using static variables declared above
// Units are 100-ns intervals. Convert to ns.
GetProcessTimes(main_process, &process_creation_time,
&process_exit_time,
&process_kernel_time, &process_user_time);
return (jlong_from(process_user_time.dwHighDateTime,
process_user_time.dwLowDateTime) +
jlong_from(process_kernel_time.dwHighDateTime,
process_kernel_time.dwLowDateTime)) * 100;
}
JNIEXPORT jlong JNICALL

View File

@ -23,9 +23,9 @@
* questions.
*/
/* Access APIs for Win2K and above */
/* Access APIs for WinXP and above */
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#define _WIN32_WINNT 0x0501
#endif
#include <assert.h>
@ -60,13 +60,17 @@ static GetFinalPathNameByHandleProc GetFinalPathNameByHandle_func;
JNIEXPORT void JNICALL
Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls)
{
HANDLE handle;
HMODULE handle;
jclass fileClass = (*env)->FindClass(env, "java/io/File");
if (!fileClass) return;
ids.path =
(*env)->GetFieldID(env, fileClass, "path", "Ljava/lang/String;");
handle = LoadLibrary("kernel32");
if (handle != NULL) {
// GetFinalPathNameByHandle requires Windows Vista or newer
if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT),
(LPCWSTR)&CreateFileW, &handle) != 0)
{
GetFinalPathNameByHandle_func = (GetFinalPathNameByHandleProc)
GetProcAddress(handle, "GetFinalPathNameByHandleW");
}
@ -824,8 +828,6 @@ Java_java_io_WinNTFileSystem_getDriveDirectory(JNIEnv *env, jobject this,
return ret;
}
typedef BOOL (WINAPI* GetVolumePathNameProc) (LPCWSTR, LPWSTR, DWORD);
JNIEXPORT jlong JNICALL
Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
jobject file, jint t)
@ -834,14 +836,7 @@ Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
jlong rv = 0L;
WCHAR *pathbuf = fileToNTPath(env, file, ids.path);
HMODULE h = LoadLibrary("kernel32");
GetVolumePathNameProc getVolumePathNameW = NULL;
if (h) {
getVolumePathNameW
= (GetVolumePathNameProc)GetProcAddress(h, "GetVolumePathNameW");
}
if (getVolumePathNameW(pathbuf, volname, MAX_PATH_LENGTH)) {
if (GetVolumePathNameW(pathbuf, volname, MAX_PATH_LENGTH)) {
ULARGE_INTEGER totalSpace, freeSpace, usableSpace;
if (GetDiskFreeSpaceExW(volname, &usableSpace, &totalSpace, &freeSpace)) {
switch(t) {
@ -860,9 +855,6 @@ Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
}
}
if (h) {
FreeLibrary(h);
}
free(pathbuf);
return rv;
}

View File

@ -196,42 +196,23 @@ getHomeFromRegistry()
/*
* Code to figure out the user's home directory using shell32.dll
*/
typedef HRESULT (WINAPI *GetSpecialFolderType)(HWND, int, LPITEMIDLIST *);
typedef BOOL (WINAPI *GetPathFromIDListType)(LPCITEMIDLIST, LPSTR);
WCHAR*
getHomeFromShell32()
{
HMODULE lib = LoadLibraryW(L"SHELL32.DLL");
GetSpecialFolderType do_get_folder;
GetPathFromIDListType do_get_path;
HRESULT rc;
LPITEMIDLIST item_list = 0;
WCHAR *p;
WCHAR path[MAX_PATH+1];
int size = MAX_PATH+1;
if (lib == 0) {
// We can't load the library !!??
return NULL;
}
do_get_folder = (GetSpecialFolderType)GetProcAddress(lib, "SHGetSpecialFolderLocation");
do_get_path = (GetPathFromIDListType)GetProcAddress(lib, "SHGetPathFromIDListW");
if (do_get_folder == 0 || do_get_path == 0) {
// the library doesn't hold the right functions !!??
return NULL;
}
rc = (*do_get_folder)(NULL, CSIDL_DESKTOPDIRECTORY, &item_list);
rc = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &item_list);
if (!SUCCEEDED(rc)) {
// we can't find the shell folder.
return NULL;
}
path[0] = 0;
(*do_get_path)(item_list, (LPSTR)path);
SHGetPathFromIDListW(item_list, (LPWSTR)path);
/* Get the parent of Desktop directory */
p = wcsrchr(path, L'\\');
@ -253,17 +234,7 @@ getHomeFromShell32()
static boolean
haveMMX(void)
{
boolean mmx = 0;
HMODULE lib = LoadLibrary("KERNEL32");
if (lib != NULL) {
BOOL (WINAPI *isProcessorFeaturePresent)(DWORD) =
(BOOL (WINAPI *)(DWORD))
GetProcAddress(lib, "IsProcessorFeaturePresent");
if (isProcessorFeaturePresent != NULL)
mmx = isProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE);
FreeLibrary(lib);
}
return mmx;
return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE);
}
static const char *
@ -532,10 +503,19 @@ GetJavaProperties(JNIEnv* env)
if (uname != NULL && wcslen(uname) > 0) {
sprops.user_name = _wcsdup(uname);
} else {
WCHAR buf[100];
int buflen = sizeof(buf);
sprops.user_name =
GetUserNameW(buf, &buflen) ? _wcsdup(buf) : L"unknown";
DWORD buflen = 0;
if (GetUserNameW(NULL, &buflen) == 0 &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
uname = (WCHAR*)malloc(buflen * sizeof(WCHAR));
if (uname != NULL && GetUserNameW(uname, &buflen) == 0) {
free(uname);
uname = NULL;
}
} else {
uname = NULL;
}
sprops.user_name = (uname != NULL) ? uname : L"unknown";
}
}
@ -633,8 +613,8 @@ GetJavaProperties(JNIEnv* env)
/* Current directory */
{
WCHAR buf[MAX_PATH];
GetCurrentDirectoryW(sizeof(buf), buf);
sprops.user_dir = _wcsdup(buf);
if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0)
sprops.user_dir = _wcsdup(buf);
}
sprops.file_separator = "\\";

View File

@ -90,6 +90,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray ret = 0;
int retLen = 0;
jboolean preferIPv6Address;
static jfieldID ia_preferIPv6AddressID;
int error=0;
struct addrinfo hints, *res, *resNew = NULL;
@ -116,166 +117,163 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL);
if (NET_addrtransAvailable()) {
static jfieldID ia_preferIPv6AddressID;
if (ia_preferIPv6AddressID == NULL) {
jclass c = (*env)->FindClass(env,"java/net/InetAddress");
if (c) {
ia_preferIPv6AddressID =
(*env)->GetStaticFieldID(env, c, "preferIPv6Address", "Z");
}
if (ia_preferIPv6AddressID == NULL) {
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
}
if (ia_preferIPv6AddressID == NULL) {
jclass c = (*env)->FindClass(env,"java/net/InetAddress");
if (c) {
ia_preferIPv6AddressID =
(*env)->GetStaticFieldID(env, c, "preferIPv6Address", "Z");
}
/* get the address preference */
preferIPv6Address
= (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID);
/* Try once, with our static buffer. */
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res);
if (error) {
/* report error */
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
if (ia_preferIPv6AddressID == NULL) {
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
int i = 0;
int inetCount = 0, inet6Count = 0, inetIndex, inet6Index;
struct addrinfo *itr, *last, *iterator = res;
while (iterator != NULL) {
int skip = 0;
itr = resNew;
while (itr != NULL) {
if (iterator->ai_family == itr->ai_family &&
iterator->ai_addrlen == itr->ai_addrlen) {
if (itr->ai_family == AF_INET) { /* AF_INET */
struct sockaddr_in *addr1, *addr2;
addr1 = (struct sockaddr_in *)iterator->ai_addr;
addr2 = (struct sockaddr_in *)itr->ai_addr;
if (addr1->sin_addr.s_addr ==
addr2->sin_addr.s_addr) {
skip = 1;
break;
}
} else {
int t;
struct sockaddr_in6 *addr1, *addr2;
addr1 = (struct sockaddr_in6 *)iterator->ai_addr;
addr2 = (struct sockaddr_in6 *)itr->ai_addr;
}
}
/* get the address preference */
preferIPv6Address
= (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID);
for (t = 0; t < 16; t++) {
if (addr1->sin6_addr.s6_addr[t] !=
addr2->sin6_addr.s6_addr[t]) {
break;
}
}
if (t < 16) {
itr = itr->ai_next;
continue;
} else {
skip = 1;
/* Try once, with our static buffer. */
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
error = getaddrinfo(hostname, NULL, &hints, &res);
if (error) {
/* report error */
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
} else {
int i = 0;
int inetCount = 0, inet6Count = 0, inetIndex, inet6Index;
struct addrinfo *itr, *last, *iterator = res;
while (iterator != NULL) {
int skip = 0;
itr = resNew;
while (itr != NULL) {
if (iterator->ai_family == itr->ai_family &&
iterator->ai_addrlen == itr->ai_addrlen) {
if (itr->ai_family == AF_INET) { /* AF_INET */
struct sockaddr_in *addr1, *addr2;
addr1 = (struct sockaddr_in *)iterator->ai_addr;
addr2 = (struct sockaddr_in *)itr->ai_addr;
if (addr1->sin_addr.s_addr ==
addr2->sin_addr.s_addr) {
skip = 1;
break;
}
} else {
int t;
struct sockaddr_in6 *addr1, *addr2;
addr1 = (struct sockaddr_in6 *)iterator->ai_addr;
addr2 = (struct sockaddr_in6 *)itr->ai_addr;
for (t = 0; t < 16; t++) {
if (addr1->sin6_addr.s6_addr[t] !=
addr2->sin6_addr.s6_addr[t]) {
break;
}
}
} else if (iterator->ai_family != AF_INET &&
iterator->ai_family != AF_INET6) {
/* we can't handle other family types */
skip = 1;
break;
if (t < 16) {
itr = itr->ai_next;
continue;
} else {
skip = 1;
break;
}
}
itr = itr->ai_next;
} else if (iterator->ai_family != AF_INET &&
iterator->ai_family != AF_INET6) {
/* we can't handle other family types */
skip = 1;
break;
}
itr = itr->ai_next;
}
if (!skip) {
struct addrinfo *next
= (struct addrinfo*) malloc(sizeof(struct addrinfo));
if (!next) {
JNU_ThrowOutOfMemoryError(env, "heap allocation failed");
ret = NULL;
goto cleanupAndReturn;
}
memcpy(next, iterator, sizeof(struct addrinfo));
next->ai_next = NULL;
if (resNew == NULL) {
resNew = next;
} else {
last->ai_next = next;
}
last = next;
i++;
if (iterator->ai_family == AF_INET) {
inetCount ++;
} else if (iterator->ai_family == AF_INET6) {
inet6Count ++;
}
if (!skip) {
struct addrinfo *next
= (struct addrinfo*) malloc(sizeof(struct addrinfo));
if (!next) {
JNU_ThrowOutOfMemoryError(env, "heap allocation failed");
ret = NULL;
goto cleanupAndReturn;
}
iterator = iterator->ai_next;
}
retLen = i;
iterator = resNew;
i = 0;
ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL);
if (IS_NULL(ret)) {
/* we may have memory to free at the end of this */
goto cleanupAndReturn;
}
if (preferIPv6Address) {
inetIndex = inet6Count;
inet6Index = 0;
} else {
inetIndex = 0;
inet6Index = inetCount;
}
while (iterator != NULL) {
memcpy(next, iterator, sizeof(struct addrinfo));
next->ai_next = NULL;
if (resNew == NULL) {
resNew = next;
} else {
last->ai_next = next;
}
last = next;
i++;
if (iterator->ai_family == AF_INET) {
jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
if (IS_NULL(iaObj)) {
ret = NULL;
goto cleanupAndReturn;
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
inetIndex ++;
inetCount ++;
} else if (iterator->ai_family == AF_INET6) {
jint scope = 0;
jbyteArray ipaddress;
jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
if (IS_NULL(iaObj)) {
ret = NULL;
goto cleanupAndReturn;
}
ipaddress = (*env)->NewByteArray(env, 16);
if (IS_NULL(ipaddress)) {
ret = NULL;
goto cleanupAndReturn;
}
(*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
(jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
if (scope != 0) { /* zero is default value, no need to set */
(*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
}
(*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
inet6Index ++;
inet6Count ++;
}
iterator = iterator->ai_next;
}
iterator = iterator->ai_next;
}
retLen = i;
iterator = resNew;
i = 0;
ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL);
if (IS_NULL(ret)) {
/* we may have memory to free at the end of this */
goto cleanupAndReturn;
}
if (preferIPv6Address) {
inetIndex = inet6Count;
inet6Index = 0;
} else {
inetIndex = 0;
inet6Index = inetCount;
}
while (iterator != NULL) {
if (iterator->ai_family == AF_INET) {
jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
if (IS_NULL(iaObj)) {
ret = NULL;
goto cleanupAndReturn;
}
(*env)->SetIntField(env, iaObj, ni_iaaddressID,
ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
inetIndex ++;
} else if (iterator->ai_family == AF_INET6) {
jint scope = 0;
jbyteArray ipaddress;
jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
if (IS_NULL(iaObj)) {
ret = NULL;
goto cleanupAndReturn;
}
ipaddress = (*env)->NewByteArray(env, 16);
if (IS_NULL(ipaddress)) {
ret = NULL;
goto cleanupAndReturn;
}
(*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
(jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
if (scope != 0) { /* zero is default value, no need to set */
(*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
(*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
}
(*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
(*env)->SetObjectField(env, iaObj, ni_iahostID, host);
(*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
inet6Index ++;
}
iterator = iterator->ai_next;
}
}
@ -291,8 +289,7 @@ cleanupAndReturn:
JNU_ReleaseStringPlatformChars(env, host, hostname);
}
if (NET_addrtransAvailable())
(*freeaddrinfo_ptr)(res);
freeaddrinfo(res);
return ret;
}
@ -312,44 +309,41 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
int len = 0;
jbyte caddr[16];
if (NET_addrtransAvailable()) {
struct sockaddr_in him4;
struct sockaddr_in6 him6;
struct sockaddr *sa;
struct sockaddr_in him4;
struct sockaddr_in6 him6;
struct sockaddr *sa;
/*
* For IPv4 addresses construct a sockaddr_in structure.
*/
if ((*env)->GetArrayLength(env, addrArray) == 4) {
jint addr;
(*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
addr = ((caddr[0]<<24) & 0xff000000);
addr |= ((caddr[1] <<16) & 0xff0000);
addr |= ((caddr[2] <<8) & 0xff00);
addr |= (caddr[3] & 0xff);
memset((char *) &him4, 0, sizeof(him4));
him4.sin_addr.s_addr = (uint32_t) htonl(addr);
him4.sin_family = AF_INET;
sa = (struct sockaddr *) &him4;
len = sizeof(him4);
} else {
/*
* For IPv4 addresses construct a sockaddr_in structure.
* For IPv6 address construct a sockaddr_in6 structure.
*/
if ((*env)->GetArrayLength(env, addrArray) == 4) {
jint addr;
(*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
addr = ((caddr[0]<<24) & 0xff000000);
addr |= ((caddr[1] <<16) & 0xff0000);
addr |= ((caddr[2] <<8) & 0xff00);
addr |= (caddr[3] & 0xff);
memset((char *) &him4, 0, sizeof(him4));
him4.sin_addr.s_addr = (uint32_t) htonl(addr);
him4.sin_family = AF_INET;
sa = (struct sockaddr *) &him4;
len = sizeof(him4);
} else {
/*
* For IPv6 address construct a sockaddr_in6 structure.
*/
(*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
memset((char *) &him6, 0, sizeof(him6));
memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
him6.sin6_family = AF_INET6;
sa = (struct sockaddr *) &him6 ;
len = sizeof(him6) ;
}
(*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
memset((char *) &him6, 0, sizeof(him6));
memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
him6.sin6_family = AF_INET6;
sa = (struct sockaddr *) &him6 ;
len = sizeof(him6) ;
}
error = (*getnameinfo_ptr)(sa, len, host, NI_MAXHOST, NULL, 0,
NI_NAMEREQD);
error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
if (!error) {
ret = (*env)->NewStringUTF(env, host);
}
if (!error) {
ret = (*env)->NewStringUTF(env, host);
}
if (ret == NULL) {

View File

@ -53,36 +53,6 @@
* order and this ensures consistent device number across invocations.
*/
/* IP helper library routines */
int (PASCAL FAR *GetIpAddrTable_fn)();
int (PASCAL FAR *GetIfTable_fn)();
int (PASCAL FAR *GetFriendlyIfIndex_fn)();
int (PASCAL FAR *GetAdaptersAddresses_fn)();
int (PASCAL FAR *GetAdaptersInfo_fn)();
int (PASCAL FAR *GetNumberOfInterfaces_fn)();
/* Enumeration routines */
typedef int (*EnumerateNetInterfaces)(JNIEnv *, netif **);
typedef int(*EnumerateNetAddresses)(JNIEnv *, netif *, netaddr **);
static EnumerateNetInterfaces enumInterfaces_fn;
static EnumerateNetAddresses enumAddresses_fn;
/* Windows 9x routines are external (not needed on 64-bit) */
#ifndef _WIN64
extern int enumInterfaces_win9x(JNIEnv *, netif **);
extern int enumAddresses_win9x(JNIEnv *, netif *, netaddr **);
extern int init_win9x(void);
#endif
/* Windows 95/98/ME running */
static jboolean isW9x;
/* Windows version supports */
static jboolean os_supports_ipv6;
/* various JNI ids */
jclass ni_class; /* NetworkInterface */
@ -154,10 +124,10 @@ MIB_IFROW *getIF(jint index) {
*/
size = sizeof(MIB_IFTABLE);
tableP = (MIB_IFTABLE *)malloc(size);
count = (*GetIfTable_fn)(tableP, &size, TRUE);
count = GetIfTable(tableP, &size, TRUE);
if (count == ERROR_INSUFFICIENT_BUFFER || count == ERROR_BUFFER_OVERFLOW) {
tableP = (MIB_IFTABLE *)realloc(tableP, size);
count = (*GetIfTable_fn)(tableP, &size, TRUE);
count = GetIfTable(tableP, &size, TRUE);
}
if (count != NO_ERROR) {
@ -172,7 +142,7 @@ MIB_IFROW *getIF(jint index) {
/*
* Warning the real index is obtained by GetFriendlyIfIndex()
*/
ifindex = (*GetFriendlyIfIndex_fn)(ifrowP->dwIndex);
ifindex = GetFriendlyIfIndex(ifrowP->dwIndex);
if (ifindex == index) {
/*
* Create a copy of the entry so that we can free the table.
@ -199,7 +169,7 @@ MIB_IFROW *getIF(jint index) {
* occurs then netifPP be returned as list of netif structures or NULL
* if no interfaces are found.
*/
int enumInterfaces_win(JNIEnv *env, netif **netifPP)
int enumInterfaces(JNIEnv *env, netif **netifPP)
{
MIB_IFTABLE *tableP;
MIB_IFROW *ifrowP;
@ -215,32 +185,16 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP)
*/
size = sizeof(MIB_IFTABLE);
tableP = (MIB_IFTABLE *)malloc(size);
ret = (*GetIfTable_fn)(tableP, &size, TRUE);
ret = GetIfTable(tableP, &size, TRUE);
if (ret == ERROR_INSUFFICIENT_BUFFER || ret == ERROR_BUFFER_OVERFLOW) {
tableP = (MIB_IFTABLE *)realloc(tableP, size);
ret = (*GetIfTable_fn)(tableP, &size, TRUE);
ret = GetIfTable(tableP, &size, TRUE);
}
if (ret != NO_ERROR) {
if (tableP != NULL)
free(tableP);
#ifndef _WIN64
if (isW9x && ret == ERROR_NOT_SUPPORTED) {
/*
* If ERROR_NOT_SUPPORTED is returned on Windows 98 it means that
* IE5.0 has been installed. In this case we revert to the Windows 95
* approach and avoid using the IP Helper Library.
* See: http://support.microsoft.com/support/kb/articles/q234/5/73.asp
*/
enumInterfaces_fn = enumInterfaces_win9x;
enumAddresses_fn = enumAddresses_win9x;
init_win9x();
return (*enumInterfaces_fn)(env, netifPP);
}
#endif
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetIfTable function failed");
@ -328,7 +282,7 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP)
curr->displayName[ifrowP->dwDescrLen] = '\0';
curr->dwIndex = ifrowP->dwIndex;
curr->ifType = ifrowP->dwType;
curr->index = (*GetFriendlyIfIndex_fn)(ifrowP->dwIndex);
curr->index = GetFriendlyIfIndex(ifrowP->dwIndex);
/*
* Put the interface at tail of list as GetIfTable(,,TRUE) is
@ -384,10 +338,10 @@ int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP)
size = sizeof(MIB_IPADDRTABLE);
tableP = (MIB_IPADDRTABLE *)malloc(size);
ret = (*GetIpAddrTable_fn)(&tableP, &size, FALSE);
ret = GetIpAddrTable(tableP, &size, FALSE);
if (ret == ERROR_INSUFFICIENT_BUFFER || ret == ERROR_BUFFER_OVERFLOW) {
tableP = (MIB_IPADDRTABLE *)realloc(tableP, size);
ret = (*GetIpAddrTable_fn)(tableP, &size, FALSE);
ret = GetIpAddrTable(tableP, &size, FALSE);
}
if (ret != NO_ERROR) {
if (tableP) {
@ -477,71 +431,6 @@ int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP)
JNIEXPORT void JNICALL
Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
{
OSVERSIONINFO ver;
HANDLE h;
/*
* First check if this is a Windows 9x machine.
*/
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && ver.dwMajorVersion == 4) {
isW9x = JNI_TRUE;
}
/*
* Try to load the IP Helper Library and obtain the entry points we
* require. This will succeed on 98, NT SP4+, 2000 & XP. It will
* fail on Windows 95 (if IE hasn't been updated) and old versions
* of NT (IP helper library only appeared at SP4). If it fails on
* Windows 9x we will use the registry approach, otherwise if it
* fails we throw an Error indicating that we have an incompatible
* IP helper library.
*/
h = LoadLibrary("iphlpapi.dll");
if (h != NULL) {
GetIpAddrTable_fn =
(int (PASCAL FAR *)())GetProcAddress(h, "GetIpAddrTable");
GetIfTable_fn =
(int (PASCAL FAR *)())GetProcAddress(h, "GetIfTable");
GetFriendlyIfIndex_fn =
(int (PASCAL FAR *)())GetProcAddress(h, "GetFriendlyIfIndex");
GetNumberOfInterfaces_fn =
(int (PASCAL FAR *)())GetProcAddress(h, "GetNumberOfInterfaces");
GetAdaptersAddresses_fn =
(int (PASCAL FAR *)())GetProcAddress(h, "GetAdaptersAddresses");
GetAdaptersInfo_fn =
(int (PASCAL FAR *)())GetProcAddress(h, "GetAdaptersInfo");
}
/* IPv6 is supported on Windows versions if the following APIs avail */
os_supports_ipv6 = (GetAdaptersAddresses_fn != NULL) &&
(GetNumberOfInterfaces_fn != NULL) &&
(GetAdaptersInfo_fn != NULL);
if (GetIpAddrTable_fn == NULL ||
GetIfTable_fn == NULL ||
GetFriendlyIfIndex_fn == NULL) {
#ifndef _WIN64
if (isW9x) {
/* Use Windows 9x registry approach which requires initialization */
enumInterfaces_fn = enumInterfaces_win9x;
enumAddresses_fn = enumAddresses_win9x;
init_win9x();
} else
#endif
{
JNU_ThrowByName(env, "java/lang/Error",
"Incompatible IP helper library (iphlpapi.dll)");
return;
}
} else {
enumInterfaces_fn = enumInterfaces_win;
enumAddresses_fn = enumAddresses_win;
}
/*
* Get the various JNI ids that we require
*/
@ -581,7 +470,8 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
* populate the InetAddress array based on the IP addresses for this
* interface.
*/
jobject createNetworkInterface(JNIEnv *env, netif *ifs, int netaddrCount, netaddr *netaddrP)
jobject createNetworkInterface
(JNIEnv *env, netif *ifs, int netaddrCount, netaddr *netaddrP)
{
jobject netifObj;
jobject name, displayName;
@ -596,7 +486,8 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs, int netaddrCount, netadd
netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
name = (*env)->NewStringUTF(env, ifs->name);
if (ifs->dNameIsUnicode) {
displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName, wcslen ((PWCHAR)ifs->displayName));
displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
(jsize)wcslen ((PWCHAR)ifs->displayName));
} else {
displayName = (*env)->NewStringUTF(env, ifs->displayName);
}
@ -612,7 +503,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs, int netaddrCount, netadd
* Note that 0 is a valid number of addresses.
*/
if (netaddrCount < 0) {
netaddrCount = (*enumAddresses_fn)(env, ifs, &netaddrP);
netaddrCount = enumAddresses_win(env, ifs, &netaddrP);
if ((*env)->ExceptionOccurred(env)) {
free_netaddr(netaddrP);
return NULL;
@ -725,12 +616,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
const char *name_utf;
jobject netifObj = NULL;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_getByName0_XP (env, cls, name);
}
/* get the list of interfaces */
if ((*enumInterfaces_fn)(env, &ifList) < 0) {
if (enumInterfaces(env, &ifList) < 0) {
return NULL;
}
@ -771,12 +663,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0
netif *ifList, *curr;
jobject netifObj = NULL;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_getByIndex0_XP (env, cls, index);
}
/* get the list of interfaces */
if ((*enumInterfaces_fn)(env, &ifList) < 0) {
if (enumInterfaces(env, &ifList) < 0) {
return NULL;
}
@ -812,12 +705,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
jint addr = (*env)->GetIntField(env, iaObj, ni_iaAddr);
jobject netifObj = NULL;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_getByInetAddress0_XP (env, cls, iaObj);
}
/* get the list of interfaces */
if ((*enumInterfaces_fn)(env, &ifList) < 0) {
if (enumInterfaces(env, &ifList) < 0) {
return NULL;
}
@ -832,7 +726,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
netaddr *addrP;
/* enumerate the addresses on this interface */
count = (*enumAddresses_fn)(env, curr, &addrList);
count = enumAddresses_win(env, curr, &addrList);
if (count < 0) {
free_netif(ifList);
return NULL;
@ -881,14 +775,15 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll
jobjectArray netIFArr;
jint arr_index;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_getAll_XP (env, cls);
}
/*
* Get list of interfaces
*/
count = (*enumInterfaces_fn)(env, &ifList);
count = enumInterfaces(env, &ifList);
if (count < 0) {
return NULL;
}
@ -934,13 +829,16 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isUp0
(JNIEnv *env, jclass cls, jstring name, jint index) {
jboolean ret = JNI_FALSE;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_isUp0_XP(env, cls, name, index);
} else {
MIB_IFROW *ifRowP;
ifRowP = getIF(index);
if (ifRowP != NULL) {
ret = ifRowP->dwAdminStatus == 1 && (ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL || ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED);
ret = ifRowP->dwAdminStatus == 1 &&
(ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL ||
ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED);
free(ifRowP);
}
}
@ -952,11 +850,13 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isUp0
* Method: isP2P0
* Signature: (Ljava/lang/String;I)Z
*/
JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isP2P0(JNIEnv *env, jclass cls, jstring name, jint index) {
JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isP2P0
(JNIEnv *env, jclass cls, jstring name, jint index) {
MIB_IFROW *ifRowP;
jboolean ret = JNI_FALSE;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_isP2P0_XP(env, cls, name, index);
} else {
ifRowP = getIF(index);
@ -983,7 +883,8 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isLoopback0
MIB_IFROW *ifRowP;
jboolean ret = JNI_FALSE;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_isLoopback0_XP(env, cls, name, index);
} else {
ifRowP = getIF(index);
@ -1003,22 +904,8 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isLoopback0
*/
JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_supportsMulticast0
(JNIEnv *env, jclass cls, jstring name, jint index) {
MIB_IFROW *ifRowP;
jboolean ret = JNI_TRUE;
// Let's try to use the newer API (XP & 2003 only)
if (GetAdaptersAddresses_fn != NULL) {
ret = Java_java_net_NetworkInterface_supportsMulticast0_XP(env, cls,
return Java_java_net_NetworkInterface_supportsMulticast0_XP(env, cls,
name, index);
return ret;
}
ifRowP = getIF(index);
if (ifRowP != NULL) {
if (ifRowP->dwType == MIB_IF_TYPE_LOOPBACK)
ret = JNI_FALSE;
free(ifRowP);
}
return ret;
}
/*
@ -1026,12 +913,14 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_supportsMulticast0
* Method: getMacAddr0
* Signature: ([bLjava/lang/String;I)[b
*/
JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0(JNIEnv *env, jclass class, jbyteArray addrArray, jstring name, jint index) {
JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0
(JNIEnv *env, jclass class, jbyteArray addrArray, jstring name, jint index) {
jbyteArray ret = NULL;
int len;
MIB_IFROW *ifRowP;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_getMacAddr0_XP(env, class, name, index);
} else {
ifRowP = getIF(index);
@ -1058,11 +947,13 @@ JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0(JNIEnv *
* Method: getMTU0
* Signature: ([bLjava/lang/String;I)I
*/
JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclass class, jstring name, jint index) {
JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0
(JNIEnv *env, jclass class, jstring name, jint index) {
jint ret = -1;
MIB_IFROW *ifRowP;
if (os_supports_ipv6 && ipv6_available()) {
// Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
if (ipv6_available()) {
return Java_java_net_NetworkInterface_getMTU0_XP(env, class, name, index);
} else {
ifRowP = getIF(index);

View File

@ -87,338 +87,6 @@ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */
extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */
extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */
int enumInterfaces_win(JNIEnv *env, netif **netifPP);
/* We have included iphlpapi.h which includes iptypes.h which has the definition
* for MAX_ADAPTER_DESCRIPTION_LENGTH (along with the other definitions in this
* ifndef block). Therefore if MAX_ADAPTER_DESCRIPTION_LENGTH is defined we can
* be sure that the other definitions are also defined */
#ifndef MAX_ADAPTER_DESCRIPTION_LENGTH
/*
* Following includes come from iptypes.h
*/
#pragma warning(push)
#pragma warning(disable:4201)
#include <time.h>
// Definitions and structures used by getnetworkparams and getadaptersinfo apis
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128 // arb.
#define MAX_ADAPTER_NAME_LENGTH 256 // arb.
#define MAX_ADAPTER_ADDRESS_LENGTH 8 // arb.
#define DEFAULT_MINIMUM_ENTITIES 32 // arb.
#define MAX_HOSTNAME_LEN 128 // arb.
#define MAX_DOMAIN_NAME_LEN 128 // arb.
#define MAX_SCOPE_ID_LEN 256 // arb.
//
// types
//
// Node Type
#define BROADCAST_NODETYPE 1
#define PEER_TO_PEER_NODETYPE 2
#define MIXED_NODETYPE 4
#define HYBRID_NODETYPE 8
//
// IP_ADDRESS_STRING - store an IP address as a dotted decimal string
//
typedef struct {
char String[4 * 4];
} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
//
// IP_ADDR_STRING - store an IP address with its corresponding subnet mask,
// both as dotted decimal strings
//
typedef struct _IP_ADDR_STRING {
struct _IP_ADDR_STRING* Next;
IP_ADDRESS_STRING IpAddress;
IP_MASK_STRING IpMask;
DWORD Context;
} IP_ADDR_STRING, *PIP_ADDR_STRING;
//
// ADAPTER_INFO - per-adapter information. All IP addresses are stored as
// strings
//
typedef struct _IP_ADAPTER_INFO {
struct _IP_ADAPTER_INFO* Next;
DWORD ComboIndex;
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
UINT AddressLength;
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD Index;
UINT Type;
UINT DhcpEnabled;
PIP_ADDR_STRING CurrentIpAddress;
IP_ADDR_STRING IpAddressList;
IP_ADDR_STRING GatewayList;
IP_ADDR_STRING DhcpServer;
BOOL HaveWins;
IP_ADDR_STRING PrimaryWinsServer;
IP_ADDR_STRING SecondaryWinsServer;
time_t LeaseObtained;
time_t LeaseExpires;
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
#ifdef _WINSOCK2API_
//
// The following types require Winsock2.
//
typedef enum {
IpPrefixOriginOther = 0,
IpPrefixOriginManual,
IpPrefixOriginWellKnown,
IpPrefixOriginDhcp,
IpPrefixOriginRouterAdvertisement,
} IP_PREFIX_ORIGIN;
typedef enum {
IpSuffixOriginOther = 0,
IpSuffixOriginManual,
IpSuffixOriginWellKnown,
IpSuffixOriginDhcp,
IpSuffixOriginLinkLayerAddress,
IpSuffixOriginRandom,
} IP_SUFFIX_ORIGIN;
typedef enum {
IpDadStateInvalid = 0,
IpDadStateTentative,
IpDadStateDuplicate,
IpDadStateDeprecated,
IpDadStatePreferred,
} IP_DAD_STATE;
typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
};
};
struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
IP_PREFIX_ORIGIN PrefixOrigin;
IP_SUFFIX_ORIGIN SuffixOrigin;
IP_DAD_STATE DadState;
ULONG ValidLifetime;
ULONG PreferredLifetime;
ULONG LeaseLifetime;
} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
};
};
struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
};
};
struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
//
// Per-address Flags
//
#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x01
#define IP_ADAPTER_ADDRESS_TRANSIENT 0x02
typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Reserved;
};
};
struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
SOCKET_ADDRESS Address;
} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
typedef struct _IP_ADAPTER_PREFIX {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD Flags;
};
};
struct _IP_ADAPTER_PREFIX *Next;
SOCKET_ADDRESS Address;
ULONG PrefixLength;
} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
//
// Per-adapter Flags
//
#define IP_ADAPTER_DDNS_ENABLED 0x01
#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
#define IP_ADAPTER_DHCP_ENABLED 0x04
#define IP_ADAPTER_RECEIVE_ONLY 0x08
#define IP_ADAPTER_NO_MULTICAST 0x10
#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
//
// OperStatus values from RFC 2863
//
typedef enum {
IfOperStatusUp = 1,
IfOperStatusDown,
IfOperStatusTesting,
IfOperStatusUnknown,
IfOperStatusDormant,
IfOperStatusNotPresent,
IfOperStatusLowerLayerDown
} IF_OPER_STATUS;
//
// Scope levels from RFC 2373 used with ZoneIndices array.
//
typedef enum {
ScopeLevelInterface = 1,
ScopeLevelLink = 2,
ScopeLevelSubnet = 3,
ScopeLevelAdmin = 4,
ScopeLevelSite = 5,
ScopeLevelOrganization = 8,
ScopeLevelGlobal = 14
} SCOPE_LEVEL;
typedef struct _IP_ADAPTER_ADDRESSES {
union {
ULONGLONG Alignment;
struct {
ULONG Length;
DWORD IfIndex;
};
};
struct _IP_ADAPTER_ADDRESSES *Next;
PCHAR AdapterName;
PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
PWCHAR DnsSuffix;
PWCHAR Description;
PWCHAR FriendlyName;
BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD PhysicalAddressLength;
DWORD Flags;
DWORD Mtu;
DWORD IfType;
IF_OPER_STATUS OperStatus;
DWORD Ipv6IfIndex;
DWORD ZoneIndices[16];
PIP_ADAPTER_PREFIX FirstPrefix;
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
//
// Flags used as argument to GetAdaptersAddresses().
// "SKIP" flags are added when the default is to include the information.
// "INCLUDE" flags are added when the default is to skip the information.
//
#define GAA_FLAG_SKIP_UNICAST 0x0001
#define GAA_FLAG_SKIP_ANYCAST 0x0002
#define GAA_FLAG_SKIP_MULTICAST 0x0004
#define GAA_FLAG_SKIP_DNS_SERVER 0x0008
#define GAA_FLAG_INCLUDE_PREFIX 0x0010
#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
#endif /* _WINSOCK2API_ */
//
// IP_PER_ADAPTER_INFO - per-adapter IP information such as DNS server list.
//
typedef struct _IP_PER_ADAPTER_INFO {
UINT AutoconfigEnabled;
UINT AutoconfigActive;
PIP_ADDR_STRING CurrentDnsServer;
IP_ADDR_STRING DnsServerList;
} IP_PER_ADAPTER_INFO, *PIP_PER_ADAPTER_INFO;
//
// FIXED_INFO - the set of IP-related information which does not depend on DHCP
//
typedef struct {
char HostName[MAX_HOSTNAME_LEN + 4] ;
char DomainName[MAX_DOMAIN_NAME_LEN + 4];
PIP_ADDR_STRING CurrentDnsServer;
IP_ADDR_STRING DnsServerList;
UINT NodeType;
char ScopeId[MAX_SCOPE_ID_LEN + 4];
UINT EnableRouting;
UINT EnableProxy;
UINT EnableDns;
} FIXED_INFO, *PFIXED_INFO;
#pragma warning(pop)
#endif /*!MAX_ADAPTER_DESCRIPTION_LENGTH*/
#ifndef IP_INTERFACE_NAME_INFO_DEFINED
#define IP_INTERFACE_NAME_INFO_DEFINED
typedef struct ip_interface_name_info {
ULONG Index; // Interface Index
ULONG MediaType; // Interface Types - see ipifcons.h
UCHAR ConnectionType;
UCHAR AccessType;
GUID DeviceGuid; // Device GUID is the guid of the device
// that IP exposes
GUID InterfaceGuid; // Interface GUID, if not GUID_NULL is the
// GUID for the interface mapped to the device.
} IP_INTERFACE_NAME_INFO, *PIP_INTERFACE_NAME_INFO;
#endif
/* from ipifcons.h */
#ifndef IF_TYPE_PPP
#define IF_TYPE_PPP 23
#endif
#ifndef IF_TYPE_SOFTWARE_LOOPBACK
#define IF_TYPE_SOFTWARE_LOOPBACK 24
#endif
#ifndef IF_TYPE_SLIP
#define IF_TYPE_SLIP 28
#endif
#ifndef IF_TYPE_TUNNEL
#define IF_TYPE_TUNNEL 131
#endif
int enumInterfaces(JNIEnv *env, netif **netifPP);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -43,14 +43,6 @@
extern int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP);
int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);
/* IP helper library routines */
int (PASCAL FAR *GetIpAddrTable_fn)();
int (PASCAL FAR *GetIfTable_fn)();
int (PASCAL FAR *GetFriendlyIfIndex_fn)();
int (PASCAL FAR *GetAdaptersAddresses_fn)();
int (PASCAL FAR *GetAdaptersInfo_fn)();
int (PASCAL FAR *GetNumberOfInterfaces_fn)();
#ifdef DEBUG
void printnif (netif *nif) {
#ifdef _WIN64
@ -96,14 +88,14 @@ static int getAdapters (JNIEnv *env, IP_ADAPTER_ADDRESSES **adapters) {
flags = GAA_FLAG_SKIP_DNS_SERVER;
flags |= GAA_FLAG_SKIP_MULTICAST;
flags |= GAA_FLAG_INCLUDE_PREFIX;
ret = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
if (ret == ERROR_BUFFER_OVERFLOW) {
adapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
if (adapterInfo == 0) {
return -1;
}
bufsize = len;
ret = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
}
if (ret != ERROR_SUCCESS) {
free (adapterInfo);
@ -133,7 +125,7 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
flags = GAA_FLAG_SKIP_DNS_SERVER;
flags |= GAA_FLAG_SKIP_MULTICAST;
flags |= GAA_FLAG_INCLUDE_PREFIX;
val = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
if (val == ERROR_BUFFER_OVERFLOW) {
adapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
if (adapterInfo == 0) {
@ -141,7 +133,7 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
return NULL;
}
bufsize = len;
val = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
}
if (val != ERROR_SUCCESS) {
free (adapterInfo);
@ -182,7 +174,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
* as what previous JDK versions would return.
*/
ret = enumInterfaces_win (env, netifPP);
ret = enumInterfaces(env, netifPP);
if (ret == -1) {
return -1;
} else {
@ -221,7 +213,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
* (b) IPv6 information for IPv6 only interfaces (probably tunnels)
*
* For compatibility with previous releases we use the naming
* information gotten from enumInterfaces_win() for (a) entries
* information gotten from enumInterfaces() for (a) entries
* However, the index numbers are taken from the new API.
*
* The procedure is to go through the list of adapters returned
@ -439,7 +431,8 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
name = (*env)->NewStringUTF(env, ifs->name);
if (ifs->dNameIsUnicode) {
displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName, wcslen ((PWCHAR)ifs->displayName));
displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
(jsize)wcslen ((PWCHAR)ifs->displayName));
} else {
displayName = (*env)->NewStringUTF(env, ifs->displayName);
}

View File

@ -39,10 +39,6 @@
/* true if SO_RCVTIMEO is supported */
jboolean isRcvTimeoutSupported = JNI_TRUE;
LPFN_GETADDRINFO getaddrinfo_ptr = NULL;
LPFN_FREEADDRINFO freaddrinfo_ptr = NULL;
LPFN_GETNAMEINFO getnameinfo_ptr = NULL;
/*
* Table of Windows Sockets errors, the specific exception we
* throw for the error, and the error text.
@ -233,38 +229,15 @@ NET_GetFileDescriptorID(JNIEnv *env)
jint IPv6_supported()
{
HMODULE lib;
int fd = socket(AF_INET6, SOCK_STREAM, 0) ;
if (fd < 0) {
SOCKET s = socket(AF_INET6, SOCK_STREAM, 0) ;
if (s == INVALID_SOCKET) {
return JNI_FALSE;
}
closesocket (fd);
if ((lib = LoadLibrary ("ws2_32.dll")) == NULL) {
return JNI_FALSE;
}
if ((getaddrinfo_ptr = (LPFN_GETADDRINFO)GetProcAddress (lib, "getaddrinfo")) == NULL) {
FreeLibrary (lib);
return JNI_FALSE;
}
if ((freeaddrinfo_ptr = (LPFN_FREEADDRINFO)GetProcAddress (lib, "freeaddrinfo")) == NULL) {
FreeLibrary (lib);
return JNI_FALSE;
}
if ((getnameinfo_ptr = (LPFN_GETNAMEINFO)GetProcAddress (lib, "getnameinfo")) == NULL) {
FreeLibrary (lib);
return JNI_FALSE;
}
FreeLibrary(lib);
closesocket(s);
return JNI_TRUE;
}
jboolean NET_addrtransAvailable() {
return (jboolean)(getaddrinfo_ptr != NULL);
}
/*
* Return the default TOS value
*/
@ -664,7 +637,7 @@ NET_BindV6(struct ipv6bind* b) {
if (family == AF_INET && (b->addr->him4.sin_addr.s_addr != INADDR_ANY)) {
/* bind to v4 only */
int ret;
ret = NET_Bind (b->ipv4_fd, (struct sockaddr *)b->addr,
ret = NET_Bind ((int)b->ipv4_fd, (struct sockaddr *)b->addr,
sizeof (struct sockaddr_in));
if (ret == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
@ -676,7 +649,7 @@ NET_BindV6(struct ipv6bind* b) {
if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->him6.sin6_addr))) {
/* bind to v6 only */
int ret;
ret = NET_Bind (b->ipv6_fd, (struct sockaddr *)b->addr,
ret = NET_Bind ((int)b->ipv6_fd, (struct sockaddr *)b->addr,
sizeof (struct SOCKADDR_IN6));
if (ret == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
@ -691,15 +664,15 @@ NET_BindV6(struct ipv6bind* b) {
memset (&oaddr, 0, sizeof(oaddr));
if (family == AF_INET) {
ofamily = AF_INET6;
fd = b->ipv4_fd;
ofd = b->ipv6_fd;
fd = (int)b->ipv4_fd;
ofd = (int)b->ipv6_fd;
port = (u_short)GET_PORT (b->addr);
IN6ADDR_SETANY (&oaddr.him6);
oaddr.him6.sin6_port = port;
} else {
ofamily = AF_INET;
ofd = b->ipv4_fd;
fd = b->ipv6_fd;
ofd = (int)b->ipv4_fd;
fd = (int)b->ipv6_fd;
port = (u_short)GET_PORT (b->addr);
oaddr.him4.sin_family = AF_INET;
oaddr.him4.sin_port = port;
@ -744,11 +717,11 @@ NET_BindV6(struct ipv6bind* b) {
b->ipv6_fd = SOCKET_ERROR;
/* create two new sockets */
fd = socket (family, sotype, 0);
fd = (int)socket (family, sotype, 0);
if (fd == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
}
ofd = socket (ofamily, sotype, 0);
ofd = (int)socket (ofamily, sotype, 0);
if (ofd == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
}
@ -802,7 +775,7 @@ jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
DWORD b;
struct sockaddr_in6 route;
SOCKET fd = socket(AF_INET6, SOCK_STREAM, 0);
if (fd < 0) {
if (fd == INVALID_SOCKET) {
return 0;
}
@ -810,7 +783,7 @@ jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
(void *)target_addr, sizeof(struct sockaddr_in6),
(void *)&route, sizeof(struct sockaddr_in6),
&b, 0, 0);
if (ret < 0) {
if (ret == SOCKET_ERROR) {
// error
closesocket(fd);
return 0;
@ -1001,10 +974,10 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
}
int NET_Socket (int domain, int type, int protocol) {
int sock;
SOCKET sock;
sock = socket (domain, type, protocol);
if (sock != INVALID_SOCKET) {
SetHandleInformation((HANDLE)(uintptr_t)sock, HANDLE_FLAG_INHERIT, FALSE);
}
return sock;
return (int)sock;
}

View File

@ -209,10 +209,6 @@ int
);
#endif
LPFN_GETADDRINFO getaddrinfo_ptr;
LPFN_FREEADDRINFO freeaddrinfo_ptr;
LPFN_GETNAMEINFO getnameinfo_ptr;
/* used to disable connection reset messages on Windows XP */
#ifndef SIO_UDP_CONNRESET
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
@ -302,8 +298,6 @@ void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
void NET_ThrowSocketException(JNIEnv *env, char* msg);
jboolean NET_addrtransAvailable();
/*
* differs from NET_Timeout() as follows:
*

View File

@ -36,45 +36,6 @@
*/
#define ANY_ACCESS (FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE)
/*
* Function prototypes for security functions - we can't statically
* link because these functions aren't on Windows 9x.
*/
typedef BOOL (WINAPI *GetFileSecurityFunc)
(LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation,
PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
LPDWORD lpnLengthNeeded);
typedef BOOL (WINAPI *GetSecurityDescriptorOwnerFunc)
(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner,
LPBOOL lpbOwnerDefaulted);
typedef BOOL (WINAPI *GetSecurityDescriptorDaclFunc)
(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent,
PACL *pDacl, LPBOOL lpbDaclDefaulted);
typedef BOOL (WINAPI *GetAclInformationFunc)
(PACL pAcl, LPVOID pAclInformation, DWORD nAclInformationLength,
ACL_INFORMATION_CLASS dwAclInformationClass);
typedef BOOL (WINAPI *GetAceFunc)
(PACL pAcl, DWORD dwAceIndex, LPVOID *pAce);
typedef BOOL (WINAPI *EqualSidFunc)(PSID pSid1, PSID pSid2);
/* Addresses of the security functions */
static GetFileSecurityFunc GetFileSecurity_func;
static GetSecurityDescriptorOwnerFunc GetSecurityDescriptorOwner_func;
static GetSecurityDescriptorDaclFunc GetSecurityDescriptorDacl_func;
static GetAclInformationFunc GetAclInformation_func;
static GetAceFunc GetAce_func;
static EqualSidFunc EqualSid_func;
/* True if this OS is NT kernel based (NT/2000/XP) */
static int isNT;
/*
* Returns JNI_TRUE if the specified file is on a file system that supports
* persistent ACLs (On NTFS file systems returns true, on FAT32 file systems
@ -165,7 +126,7 @@ static SECURITY_DESCRIPTOR* getFileSecurityDescriptor(JNIEnv* env, const char* p
SECURITY_INFORMATION info =
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION;
(*GetFileSecurity_func)(path, info , 0, 0, &len);
GetFileSecurityA(path, info , 0, 0, &len);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
JNU_ThrowIOExceptionWithLastError(env, "GetFileSecurity failed");
return NULL;
@ -174,7 +135,7 @@ static SECURITY_DESCRIPTOR* getFileSecurityDescriptor(JNIEnv* env, const char* p
if (sd == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
} else {
if (!(*GetFileSecurity_func)(path, info, sd, len, &len)) {
if (!(*GetFileSecurityA)(path, info, sd, len, &len)) {
JNU_ThrowIOExceptionWithLastError(env, "GetFileSecurity failed");
free(sd);
return NULL;
@ -191,7 +152,7 @@ static SID* getFileOwner(JNIEnv* env, SECURITY_DESCRIPTOR* sd) {
SID* owner;
BOOL defaulted;
if (!(*GetSecurityDescriptorOwner_func)(sd, &owner, &defaulted)) {
if (!GetSecurityDescriptorOwner(sd, &owner, &defaulted)) {
JNU_ThrowIOExceptionWithLastError(env, "GetSecurityDescriptorOwner failed");
return NULL;
}
@ -206,7 +167,7 @@ static ACL* getFileDACL(JNIEnv* env, SECURITY_DESCRIPTOR* sd) {
ACL *acl;
int defaulted, present;
if (!(*GetSecurityDescriptorDacl_func)(sd, &present, &acl, &defaulted)) {
if (!GetSecurityDescriptorDacl(sd, &present, &acl, &defaulted)) {
JNU_ThrowIOExceptionWithLastError(env, "GetSecurityDescriptorDacl failed");
return NULL;
}
@ -235,8 +196,8 @@ static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
/*
* Get the ACE count
*/
if (!(*GetAclInformation_func)(acl, (void *) &acl_size_info, sizeof(acl_size_info),
AclSizeInformation)) {
if (!GetAclInformation(acl, (void *) &acl_size_info, sizeof(acl_size_info),
AclSizeInformation)) {
JNU_ThrowIOExceptionWithLastError(env, "GetAclInformation failed");
return JNI_FALSE;
}
@ -250,7 +211,7 @@ static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
ACCESS_ALLOWED_ACE *access;
SID* sid;
if (!(*GetAce_func)(acl, i, &ace)) {
if (!GetAce(acl, i, &ace)) {
JNU_ThrowIOExceptionWithLastError(env, "GetAce failed");
return -1;
}
@ -280,51 +241,7 @@ static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
JNIEXPORT void JNICALL Java_sun_management_FileSystemImpl_init0
(JNIEnv *env, jclass ignored)
{
OSVERSIONINFO ver;
HINSTANCE hInst;
/*
* Get the OS version. If dwPlatformId is VER_PLATFORM_WIN32_NT
* it means we're running on a Windows NT, 2000, or XP machine.
*/
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
isNT = (ver.dwPlatformId == VER_PLATFORM_WIN32_NT);
if (!isNT) {
return;
}
/*
* On NT/2000/XP we need the addresses of the security functions
*/
hInst = LoadLibrary("ADVAPI32.DLL");
if (hInst == NULL) {
JNU_ThrowIOExceptionWithLastError(env, "Unable to load ADVAPI32.DLL");
return;
}
GetFileSecurity_func = (GetFileSecurityFunc)GetProcAddress(hInst, "GetFileSecurityA");
GetSecurityDescriptorOwner_func =
(GetSecurityDescriptorOwnerFunc)GetProcAddress(hInst, "GetSecurityDescriptorOwner");
GetSecurityDescriptorDacl_func =
(GetSecurityDescriptorDaclFunc)GetProcAddress(hInst, "GetSecurityDescriptorDacl");
GetAclInformation_func =
(GetAclInformationFunc)GetProcAddress(hInst, "GetAclInformation");
GetAce_func = (GetAceFunc)GetProcAddress(hInst, "GetAce");
EqualSid_func = (EqualSidFunc)GetProcAddress(hInst, "EqualSid");
if (GetFileSecurity_func == NULL ||
GetSecurityDescriptorDacl_func == NULL ||
GetSecurityDescriptorDacl_func == NULL ||
GetAclInformation_func == NULL ||
GetAce_func == NULL ||
EqualSid_func == NULL)
{
JNU_ThrowIOExceptionWithLastError(env,
"Unable to get address of security functions");
return;
}
/* nothing to do */
}
/*
@ -339,10 +256,6 @@ JNIEXPORT jboolean JNICALL Java_sun_management_FileSystemImpl_isSecuritySupporte
jboolean isCopy;
const char* path;
if (!isNT) {
return JNI_FALSE;
}
path = JNU_GetStringPlatformChars(env, str, &isCopy);
if (path != NULL) {
res = isSecuritySupported(env, path);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2008, 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.
*
* This code is free software; you can redistribute it and/or modify it
@ -30,6 +30,7 @@
#include <iprtrmib.h>
#include <time.h>
#include <assert.h>
#include <iphlpapi.h>
#include "jni_util.h"
@ -42,93 +43,17 @@
#define IS_SL_FOUND(sts) (sts & STS_SL_FOUND)
#define IS_NS_FOUND(sts) (sts & STS_NS_FOUND)
/*
* Visual C++ SP3 (as required by J2SE 1.4.0) is missing some of
* the definitions required for the IP helper library routines that
* were added in Windows 98 & Windows 2000.
*/
#ifndef MAX_ADAPTER_NAME_LENGTH
#define MAX_ADAPTER_ADDRESS_LENGTH 8
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
#define MAX_ADAPTER_NAME_LENGTH 256
#define MAX_HOSTNAME_LEN 128
#define MAX_DOMAIN_NAME_LEN 128
#define MAX_SCOPE_ID_LEN 256
typedef struct {
char String[4 * 4];
} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
typedef struct _IP_ADDR_STRING {
struct _IP_ADDR_STRING* Next;
IP_ADDRESS_STRING IpAddress;
IP_MASK_STRING IpMask;
DWORD Context;
} IP_ADDR_STRING, *PIP_ADDR_STRING;
typedef struct _IP_ADAPTER_INFO {
struct _IP_ADAPTER_INFO* Next;
DWORD ComboIndex;
char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
UINT AddressLength;
BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
DWORD Index;
UINT Type;
UINT DhcpEnabled;
PIP_ADDR_STRING CurrentIpAddress;
IP_ADDR_STRING IpAddressList;
IP_ADDR_STRING GatewayList;
IP_ADDR_STRING DhcpServer;
BOOL HaveWins;
IP_ADDR_STRING PrimaryWinsServer;
IP_ADDR_STRING SecondaryWinsServer;
time_t LeaseObtained;
time_t LeaseExpires;
} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
typedef struct _FIXED_INFO {
char HostName[MAX_HOSTNAME_LEN + 4] ;
char DomainName[MAX_DOMAIN_NAME_LEN + 4];
PIP_ADDR_STRING CurrentDnsServer;
IP_ADDR_STRING DnsServerList;
UINT NodeType;
char ScopeId[MAX_SCOPE_ID_LEN + 4];
UINT EnableRouting;
UINT EnableProxy;
UINT EnableDns;
} FIXED_INFO, *PFIXED_INFO;
#endif
/* IP helper library routine used on 98/2000/XP */
static int (PASCAL FAR *GetNetworkParams_fn)();
static int (PASCAL FAR *GetAdaptersInfo_fn)();
static int (PASCAL FAR *NotifyAddrChange_fn)();
/*
* Routines to obtain domain name and name servers are OS specific
*/
typedef int (*LoadConfig)(char *sl, char *ns);
static LoadConfig loadconfig_fn;
/*
* JNI ids
*/
/* JNI ids */
static jfieldID searchlistID;
static jfieldID nameserversID;
/*
* Utility routine to append s2 to s1 with a space delimiter.
* strappend(s1="abc", "def") => "abc def"
* strappend(s1="", "def") => "def
*/
void strappend(char *s1, char *s2) {
int len;
size_t len;
if (s2[0] == '\0') /* nothing to append */
return;
@ -145,356 +70,6 @@ void strappend(char *s1, char *s2) {
strcat(s1, s2);
}
/*
* Windows 95/98/ME for static TCP/IP configuration.
*
* Use registry approach for statically configured TCP/IP settings.
* Registry entries described in "MS TCP/IP and Windows 95 Networking"
* (Microsoft TechNet site).
*/
static int loadStaticConfig9x(char *sl, char *ns) {
LONG ret;
HANDLE hKey;
DWORD dwLen;
ULONG ulType;
char result[MAX_STR_LEN];
int sts = STS_NO_CONFIG;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP",
0,
KEY_READ,
(PHKEY)&hKey);
if (ret == ERROR_SUCCESS) {
/*
* Determine suffix list
*/
result[0] = '\0';
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "SearchList", NULL, &ulType,
(LPBYTE)&result, &dwLen);
if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "Domain", NULL, &ulType,
(LPBYTE)&result, &dwLen);
}
if (ret == ERROR_SUCCESS) {
assert(ulType == REG_SZ);
if (strlen(result) > 0) {
strappend(sl, result);
sts |= STS_SL_FOUND;
}
}
/*
* Determine DNS name server(s)
*/
result[0] = '\0';
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "NameServer", NULL, &ulType,
(LPBYTE)&result, &dwLen);
if (ret == ERROR_SUCCESS) {
assert(ulType == REG_SZ);
if (strlen(result) > 0) {
strappend(ns, result);
sts |= STS_NS_FOUND;
}
}
RegCloseKey(hKey);
}
return sts;
}
/*
* Windows 95
*
* Use registry approach for statically configured TCP/IP settings
* (see loadStaticConfig9x).
*
* If DHCP is used we examine the DHCP vendor specific extensions. We parse
* this based on format described in RFC 2132.
*
* If Dial-up Networking (DUN) is used then this TCP/IP settings cannot
* be determined here.
*/
static int loadConfig95(char *sl, char *ns) {
int sts;
int index;
LONG ret;
HANDLE hKey;
DWORD dwLen;
ULONG ulType;
char optionInfo[MAX_STR_LEN];
/*
* First try static configuration - if found we are done.
*/
sts = loadStaticConfig9x(sl, ns);
if (IS_SL_FOUND(sts) && IS_NS_FOUND(sts)) {
return sts;
}
/*
* Try DHCP. DHCP information is stored in :-
* SYSTEM\CurrentControlSet\Services\VxD\DHCP\DhcpInfoXX
*
* The key is normally DhcpInfo00\OptionInfo (see Article Q255245 on
* Microsoft site). However when multiple cards are added & removed we
* have observed that it can be located in DhcpInfo{01,02, ...}.
* As a hack we search all DhcpInfoXX keys until we find OptionInfo.
*/
for (index=0; index<99; index++) {
char key[MAX_STR_LEN];
sprintf(key, "SYSTEM\\CurrentControlSet\\Services\\VxD\\DHCP\\DhcpInfo%02d",
index);
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, (PHKEY)&hKey);
if (ret != ERROR_SUCCESS) {
/* end of DhcpInfoXX entries */
break;
}
dwLen = sizeof(optionInfo);
ret = RegQueryValueEx(hKey, "OptionInfo", NULL, &ulType,
(LPBYTE)optionInfo, &dwLen);
RegCloseKey(hKey);
if (ret == ERROR_SUCCESS) {
/* OptionInfo found */
break;
}
}
/*
* If OptionInfo was found then we parse (as the 'options' field of
* the DHCP packet - see RFC 2132).
*/
if (ret == ERROR_SUCCESS) {
unsigned int pos = 0;
while (pos < dwLen) {
int code, len;
code = optionInfo[pos];
pos++;
if (pos >= dwLen) break; /* bad packet */
len = optionInfo[pos];
pos++;
if (pos+len > dwLen) break; /* bad packet */
/*
* Domain Name - see RFC 2132 section 3.17
*/
if (!IS_SL_FOUND(sts)) {
if (code == 0xf) {
char domain[MAX_STR_LEN];
assert(len < MAX_STR_LEN);
memcpy((void *)domain, (void *)&(optionInfo[pos]), (size_t)len);
domain[len] = '\0';
strappend(sl, domain);
sts |= STS_SL_FOUND;
}
}
/*
* DNS Option - see RFC 2132 section 3.8
*/
if (!IS_NS_FOUND(sts)) {
if (code == 6 && (len % 4) == 0) {
while (len > 0 && pos < dwLen) {
char addr[32];
sprintf(addr, "%d.%d.%d.%d",
(unsigned char)optionInfo[pos],
(unsigned char)optionInfo[pos+1],
(unsigned char)optionInfo[pos+2],
(unsigned char)optionInfo[pos+3]);
pos += 4;
len -= 4;
/*
* Append to list of name servers
*/
strappend(ns, addr);
sts |= STS_NS_FOUND;
}
}
}
/*
* Onto the next options
*/
pos += len;
}
}
return sts;
}
/*
* Windows 98/ME
*
* Use registry approach for statically configured TCP/IP settings
* (see loadStaticConfig9x).
*
* If configuration is not static then use IP helper library routine
* GetNetworkParams to obtain the network settings which include the
* domain name and the DNS servers. Note that we use the registry in
* preference to GetNetworkParams as the domain name is not populated
* by GetNetworkParams if the configuration is static.
*/
static int loadConfig98(char *sl, char *ns) {
FIXED_INFO *infoP;
ULONG size;
DWORD ret;
int sts;
/*
* Use registry approach to pick up static configuation.
*/
sts = loadStaticConfig9x(sl, ns);
if (IS_SL_FOUND(sts) && IS_NS_FOUND(sts)) {
return sts;
}
/*
* Use IP helper library to obtain dynamic configuration (DHCP and
* DUN).
*/
size = sizeof(FIXED_INFO);
infoP = (FIXED_INFO *)malloc(size);
if (infoP) {
ret = (*GetNetworkParams_fn)(infoP, &size);
if (ret == ERROR_BUFFER_OVERFLOW) {
infoP = (FIXED_INFO *)realloc(infoP, size);
if (infoP != NULL)
ret = (*GetNetworkParams_fn)(infoP, &size);
}
}
if (infoP == NULL) {
return sts;
}
if (ret == ERROR_SUCCESS) {
/*
* Use DomainName if search-list not specified.
*/
if (!IS_SL_FOUND(sts)) {
strappend(sl, infoP->DomainName);
sts |= STS_SL_FOUND;
}
/*
* Use DnsServerList if not statically configured.
*/
if (!IS_NS_FOUND(sts)) {
PIP_ADDR_STRING dnsP = &(infoP->DnsServerList);
do {
strappend(ns, (char *)&(dnsP->IpAddress));
dnsP = dnsP->Next;
} while (dnsP != NULL);
sts |= STS_NS_FOUND;
}
}
free(infoP);
return sts;
}
/*
* Windows NT
*
* Use registry approach based on settings described in "TCP/IP and
* NBT Configuration Parameters for Windows" - Article Q12062 on
* Microsoft site.
*
* All non-RAS TCP/IP settings are stored in HKEY_LOCAL_MACHINE in
* the SYSTEM\CurrentControlSet\Services\Tcpip\Parameters key.
*
* If SearchList if not provided then return Domain or DhcpDomain.
* If Domain is specified it overrides DhcpDomain even if DHCP is
* enabled.
*
* DNS name servers based on NameServer or DhcpNameServer settings.
* NameServer overrides DhcpNameServer even if DHCP is enabled.
*/
static int loadConfigNT(char *sl, char *ns) {
LONG ret;
HANDLE hKey;
DWORD dwLen;
ULONG ulType;
char result[MAX_STR_LEN];
int sts = STS_NO_CONFIG;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
0,
KEY_READ,
(PHKEY)&hKey);
if (ret != ERROR_SUCCESS) {
return sts;
}
/*
* Determine search list
*/
result[0] = '\0';
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "SearchList", NULL, &ulType,
(LPBYTE)&result, &dwLen);
if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "Domain", NULL, &ulType,
(LPBYTE)&result, &dwLen);
if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "DhcpDomain", NULL, &ulType,
(LPBYTE)&result, &dwLen);
}
}
if (ret == ERROR_SUCCESS) {
assert(ulType == REG_SZ);
if (strlen(result) > 0) {
strappend(sl, result);
sts |= STS_SL_FOUND;
}
}
/*
* Determine DNS name server(s)
*/
result[0] = '\0';
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "NameServer", NULL, &ulType,
(LPBYTE)&result, &dwLen);
if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
dwLen = sizeof(result);
ret = RegQueryValueEx(hKey, "DhcpNameServer", NULL, &ulType,
(LPBYTE)&result, &dwLen);
}
if (ret == ERROR_SUCCESS) {
assert(ulType == REG_SZ);
if (strlen(result) > 0) {
strappend(ns, result);
sts |= STS_NS_FOUND;
}
}
RegCloseKey(hKey);
return sts;
}
/*
* Windows 2000/XP
*
@ -510,7 +85,7 @@ static int loadConfigNT(char *sl, char *ns) {
* names of each adapter and then query the corresponding registry
* settings to obtain NameServer/DhcpNameServer and Domain/DhcpDomain.
*/
static int loadConfig2000(char *sl, char *ns) {
static int loadConfig(char *sl, char *ns) {
IP_ADAPTER_INFO *adapterP;
ULONG size;
DWORD ret;
@ -547,10 +122,10 @@ static int loadConfig2000(char *sl, char *ns) {
*/
size = sizeof(IP_ADAPTER_INFO);
adapterP = (IP_ADAPTER_INFO *)malloc(size);
ret = (*GetAdaptersInfo_fn)(adapterP, &size);
ret = GetAdaptersInfo(adapterP, &size);
if (ret == ERROR_BUFFER_OVERFLOW) {
adapterP = (IP_ADAPTER_INFO *)realloc(adapterP, size);
ret = (*GetAdaptersInfo_fn)(adapterP, &size);
ret = GetAdaptersInfo(adapterP, &size);
}
/*
@ -648,87 +223,15 @@ static int loadConfig2000(char *sl, char *ns) {
/*
* Initialization :-
*
* 1. Based on OS version set the function pointer for OS specific load
* configuration routine.
*
* 2. On 98/2000/XP load the IP helper library.
*
* 3. Initialize JNI field IDs.
*
* Initialize JNI field IDs.
*/
JNIEXPORT void JNICALL
Java_sun_net_dns_ResolverConfigurationImpl_init0(JNIEnv *env, jclass cls)
{
OSVERSIONINFO ver;
jboolean loadHelperLibrary = JNI_TRUE;
/*
* First we figure out which OS is running
*/
ver.dwOSVersionInfoSize = sizeof(ver);
GetVersionEx(&ver);
if (ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
if ((ver.dwMajorVersion == 4) && (ver.dwMinorVersion == 0)) {
/*
* Windows 95
*/
loadHelperLibrary = JNI_FALSE;
loadconfig_fn = loadConfig95;
} else {
/*
* Windows 98/ME
*/
loadHelperLibrary = JNI_TRUE;
loadconfig_fn = loadConfig98;
}
}
if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
if (ver.dwMajorVersion <= 4) {
/*
* Windows NT
*/
loadHelperLibrary = JNI_FALSE;
loadconfig_fn = loadConfigNT;
} else {
/*
* Windows 2000/XP
*/
loadHelperLibrary = JNI_TRUE;
loadconfig_fn = loadConfig2000;
}
}
/*
* On 98/2000/XP we load the IP Helper Library.
*/
if (loadHelperLibrary) {
HANDLE h = LoadLibrary("iphlpapi.dll");
if (h != NULL) {
GetNetworkParams_fn = (int (PASCAL FAR *)())GetProcAddress(h, "GetNetworkParams");
GetAdaptersInfo_fn = (int (PASCAL FAR *)())GetProcAddress(h, "GetAdaptersInfo");
NotifyAddrChange_fn = (int (PASCAL FAR *)())GetProcAddress(h, "NotifyAddrChange");
}
if (GetNetworkParams_fn == NULL || GetAdaptersInfo_fn == NULL) {
JNU_ThrowByName(env, "java/lang/UnsatisfiedLinkError", "iphlpapi.dll");
return;
}
}
/*
* Get JNI ids
*/
searchlistID = (*env)->GetStaticFieldID(env, cls, "os_searchlist",
"Ljava/lang/String;");
nameserversID = (*env)->GetStaticFieldID(env, cls, "os_nameservers",
"Ljava/lang/String;");
}
/*
@ -746,8 +249,7 @@ Java_sun_net_dns_ResolverConfigurationImpl_loadDNSconfig0(JNIEnv *env, jclass cl
searchlist[0] = '\0';
nameservers[0] = '\0';
/* call OS specific routine */
(void)(*loadconfig_fn)(searchlist, nameservers);
loadConfig(searchlist, nameservers);
/*
* Populate static fields in sun.net.DefaultResolverConfiguration
@ -772,17 +274,15 @@ Java_sun_net_dns_ResolverConfigurationImpl_notifyAddrChange0(JNIEnv *env, jclass
HANDLE h;
DWORD rc, xfer;
if (NotifyAddrChange_fn != NULL) {
ol.hEvent = (HANDLE)0;
rc = (*NotifyAddrChange_fn)(&h, &ol);
if (rc == ERROR_IO_PENDING) {
rc = GetOverlappedResult(h, &ol, &xfer, TRUE);
if (rc != 0) {
return 0; /* address changed */
}
ol.hEvent = (HANDLE)0;
rc = NotifyAddrChange(&h, &ol);
if (rc == ERROR_IO_PENDING) {
rc = GetOverlappedResult(h, &ol, &xfer, TRUE);
if (rc != 0) {
return 0; /* address changed */
}
}
/* NotifyAddrChange not support or error */
/* error */
return -1;
}

View File

@ -41,18 +41,6 @@
#define SECURITY_WIN32
#include "sspi.h"
/*
* OS calls loaded from DLL on intialization
*/
static FREE_CREDENTIALS_HANDLE_FN pFreeCredentialsHandle;
static ACQUIRE_CREDENTIALS_HANDLE_FN pAcquireCredentialsHandle;
static FREE_CONTEXT_BUFFER_FN pFreeContextBuffer;
static INITIALIZE_SECURITY_CONTEXT_FN pInitializeSecurityContext;
static COMPLETE_AUTH_TOKEN_FN pCompleteAuthToken;
static DELETE_SECURITY_CONTEXT_FN pDeleteSecurityContext;
static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle);
static jfieldID ntlm_ctxHandleID;
@ -63,48 +51,8 @@ static HINSTANCE lib = NULL;
JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_initFirst
(JNIEnv *env, jclass clazz)
{
OSVERSIONINFO version;
UCHAR libName[MAX_PATH];
ntlm_ctxHandleID = (*env)->GetFieldID(env, clazz, "ctxHandle", "J");
ntlm_crdHandleID = (*env)->GetFieldID(env, clazz, "crdHandle", "J");
version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
GetVersionEx (&version);
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
strcpy (libName, "security.dll" );
}
else if (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
strcpy (libName, "secur32.dll" );
}
lib = LoadLibrary (libName);
pFreeCredentialsHandle
= (FREE_CREDENTIALS_HANDLE_FN) GetProcAddress(
lib, "FreeCredentialsHandle" );
pAcquireCredentialsHandle
= (ACQUIRE_CREDENTIALS_HANDLE_FN) GetProcAddress(
lib, "AcquireCredentialsHandleA" );
pFreeContextBuffer
= (FREE_CONTEXT_BUFFER_FN) GetProcAddress(
lib, "FreeContextBuffer" );
pInitializeSecurityContext
= (INITIALIZE_SECURITY_CONTEXT_FN) GetProcAddress(
lib, "InitializeSecurityContextA" );
pCompleteAuthToken
= (COMPLETE_AUTH_TOKEN_FN) GetProcAddress(
lib, "CompleteAuthToken" );
pDeleteSecurityContext
= (DELETE_SECURITY_CONTEXT_FN) GetProcAddress(
lib, "DeleteSecurityContext" );
}
/*
@ -158,17 +106,17 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_get
if ( pUser != NULL ) {
AuthId.User = (unsigned char *) pUser;
AuthId.UserLength = strlen( pUser );
AuthId.UserLength = (unsigned long) strlen( pUser );
}
if ( pPassword != NULL ) {
AuthId.Password = (unsigned char *) pPassword;
AuthId.PasswordLength = strlen( pPassword );
AuthId.PasswordLength = (unsigned long) strlen( pPassword );
}
if ( pDomain != NULL ) {
AuthId.Domain = (unsigned char *) pDomain;
AuthId.DomainLength = strlen( pDomain );
AuthId.DomainLength = (unsigned long) strlen( pDomain );
}
AuthId.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
@ -176,7 +124,7 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_get
pAuthId = NULL;
}
ss = pAcquireCredentialsHandle(
ss = AcquireCredentialsHandleA(
NULL, "NTLM", SECPKG_CRED_OUTBOUND,
NULL, pAuthId, NULL, NULL,
pCred, &ltime
@ -258,7 +206,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
* need to send the out buffer if there are bytes to send
*/
ss = pInitializeSecurityContext(
ss = InitializeSecurityContextA(
pCred, pCtx, NULL, 0, 0, SECURITY_NATIVE_DREP,
lastToken ? &InBuffDesc : NULL, 0, newContext, &OutBuffDesc,
&ContextAttributes, &ltime
@ -274,7 +222,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
}
if ((ss == SEC_I_COMPLETE_NEEDED) || (ss == SEC_I_COMPLETE_AND_CONTINUE) ) {
ss = pCompleteAuthToken( pCtx, &OutBuffDesc );
ss = CompleteAuthToken( pCtx, &OutBuffDesc );
if (ss < 0) {
endSequence (pCred, pCtx);
@ -300,12 +248,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle) {
if (credHand != 0) {
pFreeCredentialsHandle (credHand);
free (credHand);
FreeCredentialsHandle(credHand);
free(credHand);
}
if (ctxHandle != 0) {
pDeleteSecurityContext(ctxHandle);
free (ctxHandle);
DeleteSecurityContext(ctxHandle);
free(ctxHandle);
}
}

View File

@ -24,7 +24,7 @@
*/
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#define _WIN32_WINNT 0x0501
#endif
#include <stdio.h>
@ -36,6 +36,7 @@
#include <windows.h>
#include <aclapi.h>
#include <winioctl.h>
#include <Sddl.h>
#include "jni.h"
#include "jni_util.h"
@ -77,40 +78,20 @@ static jfieldID backupResult_context;
/**
* Win32 APIs not defined in Visual Studio 2003 header files
* Win32 APIs not available in Windows XP
*/
typedef enum {
FindStreamInfoStandard
} MY_STREAM_INFO_LEVELS;
typedef struct _MY_WIN32_FIND_STREAM_DATA {
LARGE_INTEGER StreamSize;
WCHAR cStreamName[MAX_PATH + 36];
} MY_WIN32_FIND_STREAM_DATA;
typedef HANDLE (WINAPI* FindFirstStream_Proc)(LPCWSTR, MY_STREAM_INFO_LEVELS, LPVOID, DWORD);
typedef HANDLE (WINAPI* FindFirstStream_Proc)(LPCWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD);
typedef BOOL (WINAPI* FindNextStream_Proc)(HANDLE, LPVOID);
typedef BOOLEAN (WINAPI* CreateSymbolicLinkProc) (LPCWSTR, LPCWSTR, DWORD);
typedef BOOL (WINAPI* CreateHardLinkProc) (LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
typedef BOOL (WINAPI* GetFinalPathNameByHandleProc) (HANDLE, LPWSTR, DWORD, DWORD);
typedef BOOL (WINAPI* ConvertSidToStringSidProc) (PSID, LPWSTR*);
typedef BOOL (WINAPI* ConvertStringSidToSidProc) (LPWSTR, PSID*);
typedef DWORD (WINAPI* GetLengthSidProc) (PSID);
static FindFirstStream_Proc FindFirstStream_func;
static FindNextStream_Proc FindNextStream_func;
static CreateSymbolicLinkProc CreateSymbolicLink_func;
static CreateHardLinkProc CreateHardLink_func;
static GetFinalPathNameByHandleProc GetFinalPathNameByHandle_func;
static ConvertSidToStringSidProc ConvertSidToStringSid_func;
static ConvertStringSidToSidProc ConvertStringSidToSid_func;
static GetLengthSidProc GetLengthSid_func;
static void throwWindowsException(JNIEnv* env, DWORD lastError) {
jobject x = JNU_NewObjectByName(env, "sun/nio/fs/WindowsException",
"(I)V", lastError);
@ -190,33 +171,23 @@ Java_sun_nio_fs_WindowsNativeDispatcher_initIDs(JNIEnv* env, jclass this)
backupResult_bytesTransferred = (*env)->GetFieldID(env, clazz, "bytesTransferred", "I");
backupResult_context = (*env)->GetFieldID(env, clazz, "context", "J");
h = LoadLibrary("kernel32");
if (h != INVALID_HANDLE_VALUE) {
// get handle to kernel32
if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT),
(LPCWSTR)&CreateFileW, &h) != 0)
{
// requires Windows Server 2003 or newer
FindFirstStream_func =
(FindFirstStream_Proc)GetProcAddress(h, "FindFirstStreamW");
FindNextStream_func =
(FindNextStream_Proc)GetProcAddress(h, "FindNextStreamW");
// requires Windows Vista or newer
CreateSymbolicLink_func =
(CreateSymbolicLinkProc)GetProcAddress(h, "CreateSymbolicLinkW");
CreateHardLink_func =
(CreateHardLinkProc)GetProcAddress(h, "CreateHardLinkW");
GetFinalPathNameByHandle_func =
(GetFinalPathNameByHandleProc)GetProcAddress(h, "GetFinalPathNameByHandleW");
FreeLibrary(h);
}
h = LoadLibrary("advapi32");
if (h != INVALID_HANDLE_VALUE) {
ConvertSidToStringSid_func =
(ConvertSidToStringSidProc)GetProcAddress(h, "ConvertSidToStringSidW");
ConvertStringSidToSid_func =
(ConvertStringSidToSidProc)GetProcAddress(h, "ConvertStringSidToSidW");
GetLengthSid_func =
(GetLengthSidProc)GetProcAddress(h, "GetLengthSid");
FreeLibrary(h);
}
}
JNIEXPORT jstring JNICALL
@ -413,7 +384,7 @@ JNIEXPORT void JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstStream0(JNIEnv* env, jclass this,
jlong address, jobject obj)
{
MY_WIN32_FIND_STREAM_DATA data;
WIN32_FIND_STREAM_DATA data;
LPCWSTR lpFileName = jlong_to_ptr(address);
HANDLE handle;
@ -443,7 +414,7 @@ JNIEXPORT jstring JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_FindNextStream(JNIEnv* env, jclass this,
jlong handle)
{
MY_WIN32_FIND_STREAM_DATA data;
WIN32_FIND_STREAM_DATA data;
HANDLE h = (HANDLE)jlong_to_ptr(handle);
if (FindNextStream_func == NULL) {
@ -909,12 +880,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_GetLengthSid(JNIEnv* env,
jclass this, jlong address)
{
PSID sid = jlong_to_ptr(address);
if (GetLengthSid_func == NULL) {
JNU_ThrowInternalError(env, "Should not get here");
return 0;
}
return (jint)(*GetLengthSid_func)(sid);
return (jint)GetLengthSid(sid);
}
@ -924,13 +890,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_ConvertSidToStringSid(JNIEnv* env,
{
PSID sid = jlong_to_ptr(address);
LPWSTR string;
if (ConvertSidToStringSid_func == NULL) {
JNU_ThrowInternalError(env, "Should not get here");
return NULL;
}
if ((*ConvertSidToStringSid_func)(sid, &string) == 0) {
if (ConvertSidToStringSidW(sid, &string) == 0) {
throwWindowsException(env, GetLastError());
return NULL;
} else {
@ -947,15 +907,8 @@ Java_sun_nio_fs_WindowsNativeDispatcher_ConvertStringSidToSid0(JNIEnv* env,
{
LPWSTR lpStringSid = jlong_to_ptr(address);
PSID pSid;
if (ConvertStringSidToSid_func == NULL) {
JNU_ThrowInternalError(env, "Should not get here");
return (jlong)0;
}
if ((*ConvertStringSidToSid_func)(lpStringSid, &pSid) == 0)
if (ConvertStringSidToSidW(lpStringSid, &pSid) == 0)
throwWindowsException(env, GetLastError());
return ptr_to_jlong(pSid);
}
@ -1137,11 +1090,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_CreateHardLink0(JNIEnv* env,
LPCWSTR newFile = jlong_to_ptr(newFileAddress);
LPCWSTR existingFile = jlong_to_ptr(existingFileAddress);
if (CreateHardLink_func == NULL) {
JNU_ThrowInternalError(env, "Should not get here");
return;
}
if ((*CreateHardLink_func)(newFile, existingFile, NULL) == 0)
if (CreateHardLinkW(newFile, existingFile, NULL) == 0)
throwWindowsException(env, GetLastError());
}

Some files were not shown because too many files have changed in this diff Show More