Merge
This commit is contained in:
commit
12320dbfc3
jdk
make
src/share
classes
com/sun/security/auth
java
awt
lang
ArithmeticException.javaCharSequence.javaCharacter.javaNullPointerException.javaOutOfMemoryError.javaThrowable.java
management
BufferPoolMXBean.javaManagementFactory.javaPlatformComponent.javaPlatformLoggingMXBean.javaPlatformManagedObject.javapackage.html
reflect
nio/file
util
javax
imageio/metadata
net/ssl
swing
sun
awt
font
java2d
management
misc
nio/fs
security
krb5
ssl
tools
util
text/bidi
util
demo/applets
ArcTest
BarChart
Blink
CardTest
Clock
DitherTest
DrawTest
53
jdk/make/common/Defs-embedded.gmk
Normal file
53
jdk/make/common/Defs-embedded.gmk
Normal 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
|
||||
|
@ -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
|
||||
#
|
||||
|
@ -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.
|
||||
|
232
jdk/make/common/Release-embedded.gmk
Normal file
232
jdk/make/common/Release-embedded.gmk
Normal 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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
#
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
#
|
||||
|
@ -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}
|
||||
|
@ -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, , )
|
||||
|
@ -39,7 +39,8 @@ SUBDIRS = \
|
||||
Notepad \
|
||||
SampleTree \
|
||||
SwingApplet \
|
||||
TableExample
|
||||
TableExample \
|
||||
TransparentRuler
|
||||
|
||||
# Some demos aren't currently included in OpenJDK
|
||||
ifndef OPENJDK
|
||||
|
44
jdk/make/mkdemo/jfc/TransparentRuler/Makefile
Normal file
44
jdk/make/mkdemo/jfc/TransparentRuler/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile to build the TransparentRuler demo.
|
||||
#
|
||||
|
||||
BUILDDIR = ../../..
|
||||
PRODUCT = demo/jfc
|
||||
DEMONAME = TransparentRuler
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
DEMO_ROOT = $(SHARE_SRC)/demo/jfc/$(DEMONAME)
|
||||
DEMO_TOPFILES = ./README.txt
|
||||
DEMO_MAINCLASS = transparentruler.Ruler
|
||||
DEMO_DESTDIR = $(DEMODIR)/jfc/$(DEMONAME)
|
||||
|
||||
|
||||
#
|
||||
# Demo jar building rules.
|
||||
#
|
||||
include $(BUILDDIR)/common/Demo.gmk
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -21,4 +21,4 @@
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
tzdata2011d
|
||||
tzdata2011e
|
||||
|
@ -734,6 +734,48 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou
|
||||
# http://www.timeanddate.com/news/time/morocco-starts-dst-2010.html
|
||||
# </a>
|
||||
|
||||
# From Dan Abitol (2011-03-30):
|
||||
# ...Rules for Africa/Casablanca are the following (24h format)
|
||||
# The 3rd april 2011 at 00:00:00, [it] will be 3rd april 1:00:00
|
||||
# The 31th july 2011 at 00:59:59, [it] will be 31th July 00:00:00
|
||||
# ...Official links of change in morocco
|
||||
# The change was broadcast on the FM Radio
|
||||
# I ve called ANRT (telecom regulations in Morocco) at
|
||||
# +212.537.71.84.00
|
||||
# <a href="http://www.anrt.net.ma/fr/">
|
||||
# http://www.anrt.net.ma/fr/
|
||||
# </a>
|
||||
# They said that
|
||||
# <a href="http://www.map.ma/fr/sections/accueil/l_heure_legale_au_ma/view">
|
||||
# http://www.map.ma/fr/sections/accueil/l_heure_legale_au_ma/view
|
||||
# </a>
|
||||
# is the official publication to look at.
|
||||
# They said that the decision was already taken.
|
||||
#
|
||||
# More articles in the press
|
||||
# <a href="http://www.yabiladi.com/articles/details/5058/secret-l-heure-d-ete-maroc-lev">
|
||||
# http://www.yabiladi.com/articles/details/5058/secret-l-heure-d-ete-maroc-lev
|
||||
# </a>
|
||||
# e.html
|
||||
# <a href="http://www.lematin.ma/Actualite/Express/Article.asp?id=148923">
|
||||
# http://www.lematin.ma/Actualite/Express/Article.asp?id=148923
|
||||
# </a>
|
||||
# <a href="http://www.lavieeco.com/actualite/Le-Maroc-passe-sur-GMT%2B1-a-partir-de-dim">
|
||||
# http://www.lavieeco.com/actualite/Le-Maroc-passe-sur-GMT%2B1-a-partir-de-dim
|
||||
# anche-prochain-5538.html
|
||||
# </a>
|
||||
|
||||
# From Petr Machata (2011-03-30):
|
||||
# They have it written in English here:
|
||||
# <a href="http://www.map.ma/eng/sections/home/morocco_to_spring_fo/view">
|
||||
# http://www.map.ma/eng/sections/home/morocco_to_spring_fo/view
|
||||
# </a>
|
||||
#
|
||||
# It says there that "Morocco will resume its standard time on July 31,
|
||||
# 2011 at midnight." Now they don't say whether they mean midnight of
|
||||
# wall clock time (i.e. 11pm UTC), but that's what I would assume. It has
|
||||
# also been like that in the past.
|
||||
|
||||
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
|
||||
Rule Morocco 1939 only - Sep 12 0:00 1:00 S
|
||||
@ -757,6 +799,8 @@ Rule Morocco 2009 only - Jun 1 0:00 1:00 S
|
||||
Rule Morocco 2009 only - Aug 21 0:00 0 -
|
||||
Rule Morocco 2010 only - May 2 0:00 1:00 S
|
||||
Rule Morocco 2010 only - Aug 8 0:00 0 -
|
||||
Rule Morocco 2011 only - Apr 3 0:00 1:00 S
|
||||
Rule Morocco 2011 only - Jul 31 0 0 -
|
||||
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
|
||||
Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
|
||||
0:00 Morocco WE%sT 1984 Mar 16
|
||||
|
@ -1193,6 +1193,19 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
|
||||
# From Arthur David Olson (2011-03-02):
|
||||
# The emol.com article mentions a water shortage as the cause of the
|
||||
# postponement, which may mean that it's not a permanent change.
|
||||
|
||||
# From Glenn Eychaner (2011-03-28):
|
||||
# The article:
|
||||
# <a href="http://diario.elmercurio.com/2011/03/28/_portada/_portada/noticias/7565897A-CA86-49E6-9E03-660B21A4883E.htm?id=3D{7565897A-CA86-49E6-9E03-660B21A4883E}">
|
||||
# http://diario.elmercurio.com/2011/03/28/_portada/_portada/noticias/7565897A-CA86-49E6-9E03-660B21A4883E.htm?id=3D{7565897A-CA86-49E6-9E03-660B21A4883E}
|
||||
# </a>
|
||||
#
|
||||
# In English:
|
||||
# Chile's clocks will go back an hour this year on the 7th of May instead
|
||||
# of this Saturday. They will go forward again the 3rd Saturday in
|
||||
# August, not in October as they have since 1968. This is a pilot plan
|
||||
# which will be reevaluated in 2012.
|
||||
|
||||
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
|
||||
Rule Chile 1927 1932 - Sep 1 0:00 1:00 S
|
||||
Rule Chile 1928 1932 - Apr 1 0:00 0 -
|
||||
@ -1222,13 +1235,16 @@ Rule Chile 1997 only - Mar 30 3:00u 0 -
|
||||
Rule Chile 1998 only - Mar Sun>=9 3:00u 0 -
|
||||
Rule Chile 1998 only - Sep 27 4:00u 1:00 S
|
||||
Rule Chile 1999 only - Apr 4 3:00u 0 -
|
||||
Rule Chile 1999 max - Oct Sun>=9 4:00u 1:00 S
|
||||
Rule Chile 1999 2010 - Oct Sun>=9 4:00u 1:00 S
|
||||
Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S
|
||||
Rule Chile 2012 max - Oct Sun>=9 4:00u 1:00 S
|
||||
Rule Chile 2000 2007 - Mar Sun>=9 3:00u 0 -
|
||||
# N.B.: the end of March 29 in Chile is March 30 in Universal time,
|
||||
# which is used below in specifying the transition.
|
||||
Rule Chile 2008 only - Mar 30 3:00u 0 -
|
||||
Rule Chile 2009 only - Mar Sun>=9 3:00u 0 -
|
||||
Rule Chile 2010 2011 - Apr Sun>=1 3:00u 0 -
|
||||
Rule Chile 2010 only - Apr Sun>=1 3:00u 0 -
|
||||
Rule Chile 2011 only - May Sun>=2 3:00u 0 -
|
||||
Rule Chile 2012 max - Mar Sun>=9 3:00u 0 -
|
||||
# IATA SSIM anomalies: (1992-02) says 1992-03-14;
|
||||
# (1996-09) says 1998-03-08. Ignore these.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
@ -158,6 +158,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_awt_X11_XRobotPeer_mouseReleaseImpl;
|
||||
Java_sun_awt_X11_XRobotPeer_mouseWheelImpl;
|
||||
Java_sun_awt_X11_XRobotPeer_setup;
|
||||
Java_sun_awt_X11_XRobotPeer__1dispose;
|
||||
Java_sun_awt_X11_XToolkit_getNumberOfButtonsImpl;
|
||||
Java_java_awt_Component_initIDs;
|
||||
Java_java_awt_Container_initIDs;
|
||||
@ -225,6 +226,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_awt_X11GraphicsConfig_destroyBackBuffer;
|
||||
Java_sun_awt_X11GraphicsConfig_swapBuffers;
|
||||
Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable;
|
||||
Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout;
|
||||
Java_java_awt_Insets_initIDs;
|
||||
Java_java_awt_KeyboardFocusManager_initIDs;
|
||||
Java_java_awt_Font_initIDs;
|
||||
|
@ -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();
|
||||
|
@ -5821,7 +5821,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
* <code>InputMethodRequests</code> instance.
|
||||
* If listener <code>l</code> is <code>null</code>,
|
||||
* no exception is thrown and no action is performed.
|
||||
* <p>Refer to <a href="doc-files/AWTThreadIssues.html#ListenersThreads"
|
||||
* <p>Refer to <a href="{@docRoot}/java/awt/doc-files/AWTThreadIssues.html#ListenersThreads"
|
||||
* >AWT Threading Issues</a> for details on AWT's threading model.
|
||||
*
|
||||
* @param l the input method listener
|
||||
|
@ -43,7 +43,7 @@ import java.awt.geom.Rectangle2D;
|
||||
* object that describes the trajectory path of the <code>Shape</code>
|
||||
* outline.
|
||||
* <p>
|
||||
* <b>Definition of insideness:</b>
|
||||
* <a name="def_insideness"><b>Definition of insideness:</b></a>
|
||||
* A point is considered to lie inside a
|
||||
* <code>Shape</code> if and only if:
|
||||
* <ul>
|
||||
@ -88,6 +88,32 @@ public interface Shape {
|
||||
* <code>getBounds2D</code> method generally returns a
|
||||
* tighter bounding box due to its greater flexibility in
|
||||
* representation.
|
||||
*
|
||||
* <p>
|
||||
* Note that the <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
|
||||
* definition of insideness</a> can lead to situations where points
|
||||
* on the defining outline of the {@code shape} may not be considered
|
||||
* contained in the returned {@code bounds} object, but only in cases
|
||||
* where those points are also not considered contained in the original
|
||||
* {@code shape}.
|
||||
* </p>
|
||||
* <p>
|
||||
* If a {@code point} is inside the {@code shape} according to the
|
||||
* {@link #contains(double x, double y) contains(point)} method, then
|
||||
* it must be inside the returned {@code Rectangle} bounds object
|
||||
* according to the {@link #contains(double x, double y) contains(point)}
|
||||
* method of the {@code bounds}. Specifically:
|
||||
* </p>
|
||||
* <p>
|
||||
* {@code shape.contains(x,y)} requires {@code bounds.contains(x,y)}
|
||||
* </p>
|
||||
* <p>
|
||||
* If a {@code point} is not inside the {@code shape}, then it might
|
||||
* still be contained in the {@code bounds} object:
|
||||
* </p>
|
||||
* <p>
|
||||
* {@code bounds.contains(x,y)} does not imply {@code shape.contains(x,y)}
|
||||
* </p>
|
||||
* @return an integer <code>Rectangle</code> that completely encloses
|
||||
* the <code>Shape</code>.
|
||||
* @see #getBounds2D
|
||||
@ -107,6 +133,32 @@ public interface Shape {
|
||||
* to overflow problems since the return value can be an instance of
|
||||
* the <code>Rectangle2D</code> that uses double precision values to
|
||||
* store the dimensions.
|
||||
*
|
||||
* <p>
|
||||
* Note that the <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
|
||||
* definition of insideness</a> can lead to situations where points
|
||||
* on the defining outline of the {@code shape} may not be considered
|
||||
* contained in the returned {@code bounds} object, but only in cases
|
||||
* where those points are also not considered contained in the original
|
||||
* {@code shape}.
|
||||
* </p>
|
||||
* <p>
|
||||
* If a {@code point} is inside the {@code shape} according to the
|
||||
* {@link #contains(Point2D p) contains(point)} method, then it must
|
||||
* be inside the returned {@code Rectangle2D} bounds object according
|
||||
* to the {@link #contains(Point2D p) contains(point)} method of the
|
||||
* {@code bounds}. Specifically:
|
||||
* </p>
|
||||
* <p>
|
||||
* {@code shape.contains(p)} requires {@code bounds.contains(p)}
|
||||
* </p>
|
||||
* <p>
|
||||
* If a {@code point} is not inside the {@code shape}, then it might
|
||||
* still be contained in the {@code bounds} object:
|
||||
* </p>
|
||||
* <p>
|
||||
* {@code bounds.contains(p)} does not imply {@code shape.contains(p)}
|
||||
* </p>
|
||||
* @return an instance of <code>Rectangle2D</code> that is a
|
||||
* high-precision bounding box of the <code>Shape</code>.
|
||||
* @see #getBounds
|
||||
@ -116,7 +168,9 @@ public interface Shape {
|
||||
|
||||
/**
|
||||
* Tests if the specified coordinates are inside the boundary of the
|
||||
* <code>Shape</code>.
|
||||
* <code>Shape</code>, as described by the
|
||||
* <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
|
||||
* definition of insideness</a>.
|
||||
* @param x the specified X coordinate to be tested
|
||||
* @param y the specified Y coordinate to be tested
|
||||
* @return <code>true</code> if the specified coordinates are inside
|
||||
@ -128,7 +182,9 @@ public interface Shape {
|
||||
|
||||
/**
|
||||
* Tests if a specified {@link Point2D} is inside the boundary
|
||||
* of the <code>Shape</code>.
|
||||
* of the <code>Shape</code>, as described by the
|
||||
* <a href="{@docRoot}/java/awt/Shape.html#def_insideness">
|
||||
* definition of insideness</a>.
|
||||
* @param p the specified <code>Point2D</code> to be tested
|
||||
* @return <code>true</code> if the specified <code>Point2D</code> is
|
||||
* inside the boundary of the <code>Shape</code>;
|
||||
|
@ -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) {
|
||||
@ -1157,12 +1157,9 @@ public abstract class Toolkit {
|
||||
* takes JobAttributes and PageAttributes objects. This object
|
||||
* may be updated to reflect the user's job choices on exit. May
|
||||
* be null.
|
||||
*
|
||||
* @return a <code>PrintJob</code> object, or <code>null</code> if the
|
||||
* user cancelled the print job.
|
||||
* @throws NullPointerException if frame is null. This exception is
|
||||
* always thrown when GraphicsEnvironment.isHeadless() returns
|
||||
* true.
|
||||
* @throws NullPointerException if frame is null
|
||||
* @throws SecurityException if this thread is not allowed to initiate a
|
||||
* print job request
|
||||
* @see java.awt.GraphicsEnvironment#isHeadless
|
||||
@ -1201,12 +1198,9 @@ public abstract class Toolkit {
|
||||
* job. The attributes will be updated to reflect the user's
|
||||
* choices as outlined in the PageAttributes documentation. May be
|
||||
* null.
|
||||
*
|
||||
* @return a <code>PrintJob</code> object, or <code>null</code> if the
|
||||
* user cancelled the print job.
|
||||
* @throws NullPointerException if frame is null and either jobAttributes
|
||||
* is null or jobAttributes.getDialog() returns
|
||||
* JobAttributes.DialogType.NATIVE.
|
||||
* @throws NullPointerException if frame is null
|
||||
* @throws IllegalArgumentException if pageAttributes specifies differing
|
||||
* cross feed and feed resolutions. Also if this thread has
|
||||
* access to the file system and jobAttributes specifies
|
||||
@ -1218,9 +1212,6 @@ public abstract class Toolkit {
|
||||
* opportunity to select a file and proceed with printing.
|
||||
* The dialog will ensure that the selected output file
|
||||
* is valid before returning from this method.
|
||||
* <p>
|
||||
* This exception is always thrown when GraphicsEnvironment.isHeadless()
|
||||
* returns true.
|
||||
* @throws SecurityException if this thread is not allowed to initiate a
|
||||
* print job request, or if jobAttributes specifies print to file,
|
||||
* and this thread is not allowed to access the file system
|
||||
@ -1236,10 +1227,6 @@ public abstract class Toolkit {
|
||||
PageAttributes pageAttributes) {
|
||||
// Override to add printing support with new job/page control classes
|
||||
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
if (this != Toolkit.getDefaultToolkit()) {
|
||||
return Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle,
|
||||
jobAttributes,
|
||||
|
@ -408,7 +408,12 @@ public final class BandedSampleModel extends ComponentSampleModel
|
||||
*/
|
||||
public int[] getPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException
|
||||
("Coordinate out of bounds!");
|
||||
}
|
||||
@ -690,7 +695,12 @@ public final class BandedSampleModel extends ComponentSampleModel
|
||||
*/
|
||||
public void setPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException
|
||||
("Coordinate out of bounds!");
|
||||
}
|
||||
|
@ -739,7 +739,12 @@ public class ComponentSampleModel extends SampleModel
|
||||
*/
|
||||
public int[] getPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || y > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException
|
||||
("Coordinate out of bounds!");
|
||||
}
|
||||
@ -1025,7 +1030,12 @@ public class ComponentSampleModel extends SampleModel
|
||||
*/
|
||||
public void setPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException
|
||||
("Coordinate out of bounds!");
|
||||
}
|
||||
|
@ -361,8 +361,8 @@ public abstract class SampleModel
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x1 < x || x1 > width ||
|
||||
y < 0 || y1 < y || y1 > height)
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
@ -588,6 +588,15 @@ public abstract class SampleModel
|
||||
int type = getTransferType();
|
||||
int numDataElems = getNumDataElements();
|
||||
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
|
||||
case DataBuffer.TYPE_BYTE:
|
||||
@ -595,8 +604,8 @@ public abstract class SampleModel
|
||||
byte[] barray = (byte[])obj;
|
||||
byte[] btemp = new byte[numDataElems];
|
||||
|
||||
for (int i=y; i<y+h; i++) {
|
||||
for (int j=x; j<x+w; j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numDataElems; k++) {
|
||||
btemp[k] = barray[cnt++];
|
||||
}
|
||||
@ -612,8 +621,8 @@ public abstract class SampleModel
|
||||
short[] sarray = (short[])obj;
|
||||
short[] stemp = new short[numDataElems];
|
||||
|
||||
for (int i=y; i<y+h; i++) {
|
||||
for (int j=x; j<x+w; j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numDataElems; k++) {
|
||||
stemp[k] = sarray[cnt++];
|
||||
}
|
||||
@ -628,8 +637,8 @@ public abstract class SampleModel
|
||||
int[] iArray = (int[])obj;
|
||||
int[] itemp = new int[numDataElems];
|
||||
|
||||
for (int i=y; i<y+h; i++) {
|
||||
for (int j=x; j<x+w; j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numDataElems; k++) {
|
||||
itemp[k] = iArray[cnt++];
|
||||
}
|
||||
@ -644,8 +653,8 @@ public abstract class SampleModel
|
||||
float[] fArray = (float[])obj;
|
||||
float[] ftemp = new float[numDataElems];
|
||||
|
||||
for (int i=y; i<y+h; i++) {
|
||||
for (int j=x; j<x+w; j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numDataElems; k++) {
|
||||
ftemp[k] = fArray[cnt++];
|
||||
}
|
||||
@ -660,8 +669,8 @@ public abstract class SampleModel
|
||||
double[] dArray = (double[])obj;
|
||||
double[] dtemp = new double[numDataElems];
|
||||
|
||||
for (int i=y; i<y+h; i++) {
|
||||
for (int j=x; j<x+w; j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numDataElems; k++) {
|
||||
dtemp[k] = dArray[cnt++];
|
||||
}
|
||||
@ -759,14 +768,22 @@ public abstract class SampleModel
|
||||
|
||||
int pixels[];
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
if (iArray != null)
|
||||
pixels = iArray;
|
||||
else
|
||||
pixels = new int[numBands * w * h];
|
||||
|
||||
for (int i=y; i<(h+y); i++) {
|
||||
for (int j=x; j<(w+x); j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for(int k=0; k<numBands; k++) {
|
||||
pixels[Offset++] = getSample(j, i, k, data);
|
||||
}
|
||||
@ -799,14 +816,22 @@ public abstract class SampleModel
|
||||
|
||||
float pixels[];
|
||||
int Offset = 0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
if (fArray != null)
|
||||
pixels = fArray;
|
||||
else
|
||||
pixels = new float[numBands * w * h];
|
||||
|
||||
for (int i=y; i<(h+y); i++) {
|
||||
for(int j=x; j<(w+x); j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for(int j=x; j<x1; j++) {
|
||||
for(int k=0; k<numBands; k++) {
|
||||
pixels[Offset++] = getSampleFloat(j, i, k, data);
|
||||
}
|
||||
@ -838,6 +863,14 @@ public abstract class SampleModel
|
||||
double dArray[], DataBuffer data) {
|
||||
double pixels[];
|
||||
int Offset = 0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
if (dArray != null)
|
||||
pixels = dArray;
|
||||
@ -845,8 +878,8 @@ public abstract class SampleModel
|
||||
pixels = new double[numBands * w * h];
|
||||
|
||||
// Fix 4217412
|
||||
for (int i=y; i<(h+y); i++) {
|
||||
for (int j=x; j<(w+x); j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numBands; k++) {
|
||||
pixels[Offset++] = getSampleDouble(j, i, k, data);
|
||||
}
|
||||
@ -1146,9 +1179,17 @@ public abstract class SampleModel
|
||||
public void setPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
for (int i=y; i<(y+h); i++) {
|
||||
for (int j=x; j<(x+w); j++) {
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numBands; k++) {
|
||||
setSample(j, i, k, iArray[Offset++], data);
|
||||
}
|
||||
@ -1176,9 +1217,17 @@ public abstract class SampleModel
|
||||
public void setPixels(int x, int y, int w, int h,
|
||||
float fArray[], DataBuffer data) {
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
for (int i=y; i<(y+h); i++) {
|
||||
for (int j=x; j<(x+w); j++) {
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for(int k=0; k<numBands; k++) {
|
||||
setSample(j, i, k, fArray[Offset++], data);
|
||||
}
|
||||
@ -1206,9 +1255,17 @@ public abstract class SampleModel
|
||||
public void setPixels(int x, int y, int w, int h,
|
||||
double dArray[], DataBuffer data) {
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
for (int i=y; i<(y+h); i++) {
|
||||
for (int j=x; j<(x+w); j++) {
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
for (int k=0; k<numBands; k++) {
|
||||
setSample(j, i, k, dArray[Offset++], data);
|
||||
}
|
||||
@ -1315,9 +1372,16 @@ public abstract class SampleModel
|
||||
int iArray[], DataBuffer data) {
|
||||
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
for (int i=y; i<(y+h); i++) {
|
||||
for (int j=x; j<(x+w); j++) {
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
setSample(j, i, b, iArray[Offset++], data);
|
||||
}
|
||||
}
|
||||
@ -1345,9 +1409,17 @@ public abstract class SampleModel
|
||||
public void setSamples(int x, int y, int w, int h, int b,
|
||||
float fArray[], DataBuffer data) {
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
for (int i=y; i<(y+h); i++) {
|
||||
for (int j=x; j<(x+w); j++) {
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
setSample(j, i, b, fArray[Offset++], data);
|
||||
}
|
||||
}
|
||||
@ -1375,9 +1447,18 @@ public abstract class SampleModel
|
||||
public void setSamples(int x, int y, int w, int h, int b,
|
||||
double dArray[], DataBuffer data) {
|
||||
int Offset=0;
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
for (int i=y; i<(y+h); i++) {
|
||||
for (int j=x; j<(x+w); j++) {
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
|
||||
}
|
||||
|
||||
for (int i=y; i<y1; i++) {
|
||||
for (int j=x; j<x1; j++) {
|
||||
setSample(j, i, b, dArray[Offset++], data);
|
||||
}
|
||||
}
|
||||
|
@ -461,7 +461,12 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
||||
*/
|
||||
public int[] getPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException
|
||||
("Coordinate out of bounds!");
|
||||
}
|
||||
@ -659,7 +664,12 @@ public class SinglePixelPackedSampleModel extends SampleModel
|
||||
*/
|
||||
public void setPixels(int x, int y, int w, int h,
|
||||
int iArray[], DataBuffer data) {
|
||||
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
|
||||
int x1 = x + w;
|
||||
int y1 = y + h;
|
||||
|
||||
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
|
||||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
|
||||
{
|
||||
throw new ArrayIndexOutOfBoundsException
|
||||
("Coordinate out of bounds!");
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -66,7 +66,7 @@ public interface CharSequence {
|
||||
* indexing. </p>
|
||||
*
|
||||
* <p>If the <code>char</code> value specified by the index is a
|
||||
* <a href="Character.html#unicode">surrogate</a>, the surrogate
|
||||
* <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
|
||||
* value is returned.
|
||||
*
|
||||
* @param index the index of the <code>char</code> value to be returned
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
||||
/**
|
@ -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<E>}
|
||||
* 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<K,V>}
|
||||
* 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<K,V></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<E></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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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 {
|
||||
|
@ -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<com.sun.management.GarbageCollectorMXBean> 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<com.sun.management.GarbageCollectorMXBean> 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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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<String, V> 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<String, V> 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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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<{@link PlatformLoggingMXBean}> 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();
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ public class IIOMetadataNode implements Element, NodeList {
|
||||
/**
|
||||
* Equivalent to <code>getNodeName</code>.
|
||||
*
|
||||
* @return the node name, as a <code>String</code
|
||||
* @return the node name, as a <code>String</code>
|
||||
*/
|
||||
public String getTagName() {
|
||||
return nodeName;
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -476,7 +476,7 @@ public final class JLayer<V extends Component>
|
||||
* for this {@code JLayer} and the {@code JLayer}
|
||||
* is displayable.
|
||||
* <p/>
|
||||
* The following example shows how to correclty use this method
|
||||
* The following example shows how to correctly use this method
|
||||
* in the {@code LayerUI} implementations:
|
||||
* <pre>
|
||||
* public void installUI(JComponent c) {
|
||||
@ -834,7 +834,7 @@ public final class JLayer<V extends Component>
|
||||
}
|
||||
|
||||
/**
|
||||
* First, implementatation of this method iterates through
|
||||
* First, implementation of this method iterates through
|
||||
* glassPane's child components and returns {@code true}
|
||||
* if any of them is visible and contains passed x,y point.
|
||||
* After that it checks if no mouseListeners is attached to this component
|
||||
|
@ -203,6 +203,12 @@ public class PopupFactory {
|
||||
popupType = HEAVY_WEIGHT_POPUP;
|
||||
break;
|
||||
}
|
||||
} else if (c instanceof Window) {
|
||||
Window w = (Window) c;
|
||||
if (!w.isOpaque() || w.getOpacity() < 1 || w.getShape() != null) {
|
||||
popupType = HEAVY_WEIGHT_POPUP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
c = c.getParent();
|
||||
}
|
||||
|
@ -727,6 +727,9 @@ public class SpringLayout implements LayoutManager2 {
|
||||
* For any other <code>String</code> value passed as the edge,
|
||||
* no action is taken. For a <code>null</code> edge, a
|
||||
* <code>NullPointerException</code> is thrown.
|
||||
* <p/>
|
||||
* <b>Note:</b> This method can affect {@code x} and {@code y} values
|
||||
* previously set for this {@code Constraints}.
|
||||
*
|
||||
* @param edgeName the edge to be set
|
||||
* @param s the spring controlling the specified edge
|
||||
|
@ -25,9 +25,7 @@
|
||||
|
||||
package javax.swing.plaf;
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
@ -38,7 +36,7 @@ import java.io.Serializable;
|
||||
/**
|
||||
* The base class for all {@link javax.swing.JLayer}'s UI delegates.
|
||||
* <p/>
|
||||
* {@link #paint(java.awt.Graphics, javax.swing.JComponent)} method performes the
|
||||
* {@link #paint(java.awt.Graphics, javax.swing.JComponent)} method performs the
|
||||
* painting of the {@code JLayer}
|
||||
* and {@link #eventDispatched(AWTEvent, JLayer)} method is notified
|
||||
* about any {@code AWTEvent}s which have been generated by a {@code JLayer}
|
||||
@ -165,7 +163,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.COMPONENT_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -197,7 +195,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.FOCUS_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -229,7 +227,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -261,7 +259,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -293,7 +291,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -325,7 +323,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -357,7 +355,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.INPUT_METHOD_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -389,7 +387,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.HIERARCHY_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -421,7 +419,7 @@ public class LayerUI<V extends Component>
|
||||
* l.setLayerEventMask(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
|
||||
* }
|
||||
*
|
||||
* public void unistallUI(JComponent c) {
|
||||
* public void uninstallUI(JComponent c) {
|
||||
* super.uninstallUI(c);
|
||||
* JLayer l = (JLayer) c;
|
||||
* l.setLayerEventMask(0);
|
||||
@ -691,7 +689,7 @@ public class LayerUI<V extends Component>
|
||||
* Otherwise, the default implementation is used.
|
||||
*
|
||||
* @param c {@code JLayer} to return preferred size for
|
||||
* @return maximun size for the passed {@code JLayer}
|
||||
* @return maximum size for the passed {@code JLayer}
|
||||
*/
|
||||
public Dimension getMaximumSize(JComponent c) {
|
||||
JLayer l = (JLayer) c;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, 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
|
||||
@ -26,13 +26,11 @@ package javax.swing.plaf.nimbus;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Color;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -58,7 +56,9 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
|
||||
@Override
|
||||
protected Object[] getExtendedCacheKeys(JComponent c) {
|
||||
return new Object[] {c.getBackground()};
|
||||
return (c != null)
|
||||
? new Object[] { c.getBackground() }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,6 +85,7 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
*/
|
||||
protected void doPaint(Graphics2D g, JComponent c, int width, int height,
|
||||
Object[] extendedCacheKeys) {
|
||||
Color color = (c == null) ? Color.BLACK : c.getBackground();
|
||||
BufferedImage img1 = new BufferedImage(IMG_SIZE,IMG_SIZE,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
BufferedImage img2 = new BufferedImage(IMG_SIZE,IMG_SIZE,
|
||||
@ -93,14 +94,14 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
Graphics2D g2 = (Graphics2D)img1.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setColor(c.getBackground());
|
||||
g2.setColor(color);
|
||||
g2.fillRoundRect(2,0,26,26,RADIUS,RADIUS);
|
||||
g2.dispose();
|
||||
// draw shadow
|
||||
InnerShadowEffect effect = new InnerShadowEffect();
|
||||
effect.setDistance(1);
|
||||
effect.setSize(3);
|
||||
effect.setColor(getLighter(c.getBackground(),2.1f));
|
||||
effect.setColor(getLighter(color, 2.1f));
|
||||
effect.setAngle(90);
|
||||
effect.applyEffect(img1,img2,IMG_SIZE,IMG_SIZE);
|
||||
// draw outline to img2
|
||||
@ -108,7 +109,7 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setClip(0,28,IMG_SIZE,1);
|
||||
g2.setColor(getLighter(c.getBackground(),0.90f));
|
||||
g2.setColor(getLighter(color, 0.90f));
|
||||
g2.drawRoundRect(2,1,25,25,RADIUS,RADIUS);
|
||||
g2.dispose();
|
||||
// draw final image
|
||||
@ -150,7 +151,7 @@ class LoweredBorder extends AbstractRegionPainter implements Border {
|
||||
* @param c the component for which this border insets value applies
|
||||
*/
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return INSETS;
|
||||
return (Insets) INSETS.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -786,9 +786,9 @@ public class SynthTableUI extends BasicTableUI
|
||||
hasFocus, row, column);
|
||||
|
||||
setIcon(null);
|
||||
Class columnClass = table.getColumnClass(column);
|
||||
configureValue(value, columnClass);
|
||||
|
||||
if (table != null) {
|
||||
configureValue(value, table.getColumnClass(column));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,10 @@ public abstract class FontConfiguration {
|
||||
* one to ensure proper static initialisation takes place.
|
||||
*/
|
||||
public FontConfiguration(SunFontManager fm) {
|
||||
if (FontUtilities.debugFonts()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Creating standard Font Configuration");
|
||||
}
|
||||
if (FontUtilities.debugFonts() && logger == null) {
|
||||
logger = PlatformLogger.getLogger("sun.awt.FontConfiguration");
|
||||
}
|
||||
@ -111,6 +115,10 @@ public abstract class FontConfiguration {
|
||||
boolean preferLocaleFonts,
|
||||
boolean preferPropFonts) {
|
||||
fontManager = fm;
|
||||
if (FontUtilities.debugFonts()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Creating alternate Font Configuration");
|
||||
}
|
||||
this.preferLocaleFonts = preferLocaleFonts;
|
||||
this.preferPropFonts = preferPropFonts;
|
||||
/* fontConfig should be initialised by default constructor, and
|
||||
|
378
jdk/src/share/classes/sun/awt/HToolkit.java
Normal file
378
jdk/src/share/classes/sun/awt/HToolkit.java
Normal 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;
|
||||
}
|
||||
}
|
@ -320,8 +320,7 @@ public class HeadlessToolkit extends Toolkit
|
||||
// Should never happen
|
||||
throw new HeadlessException();
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"PrintJob not supported in a headless environment");
|
||||
throw new NullPointerException("frame must not be null");
|
||||
}
|
||||
|
||||
public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
|
||||
@ -330,8 +329,7 @@ public class HeadlessToolkit extends Toolkit
|
||||
// Should never happen
|
||||
throw new HeadlessException();
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"PrintJob not supported in a headless environment");
|
||||
throw new NullPointerException("frame must not be null");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -54,4 +54,11 @@ public interface FontManagerForSGE extends FontManager {
|
||||
public Font[] getAllInstalledFonts();
|
||||
|
||||
public String[] getInstalledFontFamilyNames(Locale requestedLocale);
|
||||
|
||||
/* Modifies the behaviour of a subsequent call to preferLocaleFonts()
|
||||
* to use Mincho instead of Gothic for dialoginput in JA locales
|
||||
* on windows. Not needed on other platforms.
|
||||
*/
|
||||
public void useAlternateFontforJALocales();
|
||||
|
||||
}
|
||||
|
@ -2874,7 +2874,10 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
* on windows. Not needed on other platforms.
|
||||
*/
|
||||
public synchronized void useAlternateFontforJALocales() {
|
||||
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Entered useAlternateFontforJALocales().");
|
||||
}
|
||||
if (!FontUtilities.isWindows) {
|
||||
return;
|
||||
}
|
||||
@ -2897,7 +2900,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
|
||||
public synchronized void preferLocaleFonts() {
|
||||
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger().info("Entered preferLocaleFonts().");
|
||||
}
|
||||
/* Test if re-ordering will have any effect */
|
||||
if (!FontConfiguration.willReorderForStartupLocale()) {
|
||||
return;
|
||||
@ -2928,7 +2933,10 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
|
||||
public synchronized void preferProportionalFonts() {
|
||||
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Entered preferProportionalFonts().");
|
||||
}
|
||||
/* If no proportional fonts are configured, there's no need
|
||||
* to take any action.
|
||||
*/
|
||||
@ -3456,6 +3464,11 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
initCompositeFonts(FontConfiguration fontConfig,
|
||||
ConcurrentHashMap<String, Font2D> altNameCache) {
|
||||
|
||||
if (FontUtilities.isLogging()) {
|
||||
FontUtilities.getLogger()
|
||||
.info("Initialising composite fonts");
|
||||
}
|
||||
|
||||
int numCoreFonts = fontConfig.getNumberCoreFonts();
|
||||
String[] fcFonts = fontConfig.getPlatformFontNames();
|
||||
for (int f=0; f<fcFonts.length; f++) {
|
||||
|
@ -185,6 +185,18 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
FontManager fm = FontManagerFactory.getInstance();
|
||||
return (FontManagerForSGE) fm;
|
||||
}
|
||||
|
||||
/* Modifies the behaviour of a subsequent call to preferLocaleFonts()
|
||||
* to use Mincho instead of Gothic for dialoginput in JA locales
|
||||
* on windows. Not needed on other platforms.
|
||||
*
|
||||
* DO NOT MOVE OR RENAME OR OTHERWISE ALTER THIS METHOD.
|
||||
* ITS USED BY SOME NON-JRE INTERNAL CODE.
|
||||
*/
|
||||
public static void useAlternateFontforJALocales() {
|
||||
getFontManagerForSGE().useAlternateFontforJALocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all fonts available in this environment.
|
||||
*/
|
||||
|
@ -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";
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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",
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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"}
|
||||
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,22 +29,24 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.*;
|
||||
|
||||
|
||||
/**
|
||||
* An interactive test of the Graphics.drawArc and Graphics.fillArc
|
||||
* routines. Can be run either as a standalone application by
|
||||
* typing "java ArcTest" or as an applet in the AppletViewer.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ArcTest extends Applet {
|
||||
|
||||
ArcControls controls; // The controls for marking and filling arcs
|
||||
ArcCanvas canvas; // The drawing area to display arcs
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
setLayout(new BorderLayout());
|
||||
canvas = new ArcCanvas();
|
||||
@ -52,19 +54,23 @@ public class ArcTest extends Applet {
|
||||
add("South", controls = new ArcControls(canvas));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
remove(controls);
|
||||
remove(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
controls.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
controls.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEvent(AWTEvent e) {
|
||||
if (e.getID() == Event.WINDOW_DESTROY) {
|
||||
System.exit(0);
|
||||
@ -80,20 +86,28 @@ public class ArcTest extends Applet {
|
||||
|
||||
f.add("Center", arcTest);
|
||||
f.setSize(300, 300);
|
||||
f.show();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "An interactive test of the Graphics.drawArc and \nGraphics.fillArc routines. Can be run \neither as a standalone application by typing 'java ArcTest' \nor as an applet in the AppletViewer.";
|
||||
return "An interactive test of the Graphics.drawArc and \nGraphics."
|
||||
+ "fillArc routines. Can be run \neither as a standalone "
|
||||
+ "application by typing 'java ArcTest' \nor as an applet in "
|
||||
+ "the AppletViewer.";
|
||||
}
|
||||
}
|
||||
|
||||
class ArcCanvas extends Canvas {
|
||||
int startAngle = 0;
|
||||
int extent = 45;
|
||||
boolean filled = false;
|
||||
Font font = new java.awt.Font("SansSerif", Font.PLAIN, 12);
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class ArcCanvas extends Canvas {
|
||||
|
||||
int startAngle = 0;
|
||||
int extent = 45;
|
||||
boolean filled = false;
|
||||
Font font = new java.awt.Font("SansSerif", Font.PLAIN, 12);
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Rectangle r = getBounds();
|
||||
int hlines = r.height / 10;
|
||||
@ -134,12 +148,16 @@ class ArcCanvas extends Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class ArcControls extends Panel
|
||||
implements ActionListener {
|
||||
implements ActionListener {
|
||||
|
||||
TextField startTF;
|
||||
TextField extentTF;
|
||||
ArcCanvas canvas;
|
||||
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public ArcControls(ArcCanvas canvas) {
|
||||
Button b = null;
|
||||
|
||||
@ -154,18 +172,19 @@ class ArcControls extends Panel
|
||||
add(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ev) {
|
||||
String label = ev.getActionCommand();
|
||||
|
||||
int start, extent;
|
||||
try {
|
||||
start = Integer.parseInt(startTF.getText().trim());
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
start = 0;
|
||||
}
|
||||
try {
|
||||
extent = Integer.parseInt(extentTF.getText().trim());
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
extent = 0;
|
||||
}
|
||||
|
||||
@ -173,6 +192,8 @@ class ArcControls extends Panel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class IntegerTextField extends TextField {
|
||||
|
||||
String oldText = null;
|
||||
@ -188,6 +209,7 @@ class IntegerTextField extends TextField {
|
||||
// function, but this is neater, since ideally, it would prevent
|
||||
// the text from appearing at all. Sigh. See bugid 4100317/4114565.
|
||||
//
|
||||
@Override
|
||||
protected void processEvent(AWTEvent evt) {
|
||||
int id = evt.getID();
|
||||
if (id != KeyEvent.KEY_TYPED) {
|
||||
@ -200,8 +222,8 @@ class IntegerTextField extends TextField {
|
||||
|
||||
// Digits, backspace, and delete are okay
|
||||
// Note that the minus sign is allowed, but not the decimal
|
||||
if (Character.isDigit(c) || (c == '\b') || (c == '\u007f') ||
|
||||
(c == '\u002d')) {
|
||||
if (Character.isDigit(c) || (c == '\b') || (c == '\u007f') || (c
|
||||
== '\u002d')) {
|
||||
super.processEvent(evt);
|
||||
return;
|
||||
}
|
||||
@ -215,6 +237,7 @@ class IntegerTextField extends TextField {
|
||||
// so we can revert to it on a TextEvent (paste, or
|
||||
// legal key in the wrong location) with bad text
|
||||
//
|
||||
@Override
|
||||
protected void processTextEvent(TextEvent te) {
|
||||
// The empty string is okay, too
|
||||
String newText = getText();
|
||||
@ -233,12 +256,11 @@ class IntegerTextField extends TextField {
|
||||
// Note that the empty string is not allowed.
|
||||
//
|
||||
private boolean textIsInteger(String textToCheck) {
|
||||
int value = -1;
|
||||
|
||||
try {
|
||||
value = Integer.parseInt(textToCheck, 10);
|
||||
Integer.parseInt(textToCheck, 10);
|
||||
return true;
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,28 +29,26 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
/**
|
||||
* A simple bar chart demo
|
||||
* @author Sami Shaio
|
||||
* @modified 06/21/00 Daniel Peek : refactored, comments
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class BarChart extends java.applet.Applet {
|
||||
|
||||
private static final int VERTICAL = 0;
|
||||
private static final int HORIZONTAL = 1;
|
||||
|
||||
private static final int SOLID = 0;
|
||||
private static final int STRIPED = 1;
|
||||
|
||||
private int orientation;
|
||||
private String title;
|
||||
private Font font;
|
||||
private FontMetrics metrics;
|
||||
private int fontHeight = 15;
|
||||
private int columns;
|
||||
private int values[];
|
||||
private Color colors[];
|
||||
@ -61,6 +59,7 @@ public class BarChart extends java.applet.Applet {
|
||||
private int barSpacing = 10;
|
||||
private int maxValue = 0;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
getSettings();
|
||||
@ -70,7 +69,7 @@ public class BarChart extends java.applet.Applet {
|
||||
styles = new int[columns];
|
||||
colors = new Color[columns];
|
||||
|
||||
for (int i=0; i < columns; i++) {
|
||||
for (int i = 0; i < columns; i++) {
|
||||
parseValue(i);
|
||||
parseLabel(i);
|
||||
parseStyle(i);
|
||||
@ -112,7 +111,7 @@ public class BarChart extends java.applet.Applet {
|
||||
}
|
||||
|
||||
private void parseValue(int i) {
|
||||
String temp = getParameter("C" + (i+1));
|
||||
String temp = getParameter("C" + (i + 1));
|
||||
try {
|
||||
values[i] = Integer.parseInt(temp);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -124,18 +123,17 @@ public class BarChart extends java.applet.Applet {
|
||||
}
|
||||
|
||||
private void parseLabel(int i) {
|
||||
String temp = getParameter("C" + (i+1) + "_label");
|
||||
if (temp==null) {
|
||||
String temp = getParameter("C" + (i + 1) + "_label");
|
||||
if (temp == null) {
|
||||
labels[i] = "";
|
||||
} else {
|
||||
labels[i] = temp;
|
||||
}
|
||||
maxLabelWidth = Math.max(metrics.stringWidth
|
||||
((String) (labels[i])), maxLabelWidth);
|
||||
maxLabelWidth = Math.max(metrics.stringWidth(labels[i]), maxLabelWidth);
|
||||
}
|
||||
|
||||
private void parseStyle(int i) {
|
||||
String temp = getParameter("C" + (i+1) + "_style");
|
||||
String temp = getParameter("C" + (i + 1) + "_style");
|
||||
if (temp == null || temp.equalsIgnoreCase("solid")) {
|
||||
styles[i] = SOLID;
|
||||
} else if (temp.equalsIgnoreCase("striped")) {
|
||||
@ -146,7 +144,7 @@ public class BarChart extends java.applet.Applet {
|
||||
}
|
||||
|
||||
private void parseColor(int i) {
|
||||
String temp = getParameter("C" + (i+1) + "_color");
|
||||
String temp = getParameter("C" + (i + 1) + "_color");
|
||||
if (temp != null) {
|
||||
temp = temp.toLowerCase();
|
||||
if (temp.equals("red")) {
|
||||
@ -179,6 +177,7 @@ public class BarChart extends java.applet.Applet {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
// draw the title centered at the bottom of the bar graph
|
||||
g.setColor(Color.black);
|
||||
@ -192,7 +191,7 @@ public class BarChart extends java.applet.Applet {
|
||||
g.drawString(title, cx, cy);
|
||||
|
||||
// draw the bars and their titles
|
||||
if(orientation == HORIZONTAL) {
|
||||
if (orientation == HORIZONTAL) {
|
||||
paintHorizontal(g);
|
||||
} else { // VERTICAL
|
||||
paintVertical(g);
|
||||
@ -208,12 +207,13 @@ public class BarChart extends java.applet.Applet {
|
||||
|
||||
// set the X coordinate for this bar and label and center it
|
||||
int widthOfItems = maxLabelWidth + 3 + (maxValue * scale) + 5
|
||||
+ metrics.stringWidth(Integer.toString(maxValue));
|
||||
+ metrics.stringWidth(Integer.toString(maxValue));
|
||||
cx = Math.max((getSize().width - widthOfItems) / 2, 0);
|
||||
|
||||
// set the Y coordinate for this bar and label
|
||||
cy = getSize().height - metrics.getDescent() - metrics.getHeight()
|
||||
- barSpacing - ((columns - i - 1) * (barSpacing + barHeight));
|
||||
- barSpacing
|
||||
- ((columns - i - 1) * (barSpacing + barHeight));
|
||||
|
||||
// draw the label
|
||||
g.setColor(Color.black);
|
||||
@ -223,7 +223,7 @@ public class BarChart extends java.applet.Applet {
|
||||
|
||||
// draw the shadow
|
||||
g.fillRect(cx + 4, cy - barHeight + 4,
|
||||
(values[i] * scale), barHeight);
|
||||
(values[i] * scale), barHeight);
|
||||
|
||||
// draw the bar
|
||||
g.setColor(colors[i]);
|
||||
@ -233,7 +233,7 @@ public class BarChart extends java.applet.Applet {
|
||||
}
|
||||
} else { // SOLID
|
||||
g.fillRect(cx, cy - barHeight,
|
||||
(values[i] * scale) + 1, barHeight + 1);
|
||||
(values[i] * scale) + 1, barHeight + 1);
|
||||
}
|
||||
cx += (values[i] * scale) + 4;
|
||||
|
||||
@ -255,7 +255,7 @@ public class BarChart extends java.applet.Applet {
|
||||
|
||||
// Y coordinate for this label and bar
|
||||
int cy = getSize().height - metrics.getHeight()
|
||||
- metrics.getDescent() - 4;
|
||||
- metrics.getDescent() - 4;
|
||||
|
||||
// draw the label
|
||||
g.setColor(Color.black);
|
||||
@ -264,18 +264,18 @@ public class BarChart extends java.applet.Applet {
|
||||
|
||||
// draw the shadow
|
||||
g.fillRect(cx + 4, cy - (values[i] * scale) - 4,
|
||||
barWidth, (values[i] * scale));
|
||||
barWidth, (values[i] * scale));
|
||||
|
||||
// draw the bar
|
||||
g.setColor(colors[i]);
|
||||
if (styles[i] == STRIPED) {
|
||||
for (int k=0; k <= values[i] * scale; k+=2) {
|
||||
for (int k = 0; k <= values[i] * scale; k += 2) {
|
||||
g.drawLine(cx, cy - k,
|
||||
cx + barWidth, cy - k);
|
||||
cx + barWidth, cy - k);
|
||||
}
|
||||
} else {
|
||||
g.fillRect(cx, cy - (values[i] * scale),
|
||||
barWidth + 1, (values[i] * scale) + 1);
|
||||
barWidth + 1, (values[i] * scale) + 1);
|
||||
}
|
||||
cy -= (values[i] * scale) + 5;
|
||||
|
||||
@ -285,28 +285,30 @@ public class BarChart extends java.applet.Applet {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "Title: Bar Chart \n"
|
||||
+ "Author: Sami Shaio \n"
|
||||
+ "A simple bar chart demo.";
|
||||
+ "Author: Sami Shaio \n"
|
||||
+ "A simple bar chart demo.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] getParameterInfo() {
|
||||
String[][] info = {
|
||||
{"title", "string", "The title of bar graph. Default is 'Chart'"},
|
||||
{"scale", "int", "The scale of the bar graph. Default is 10."},
|
||||
{"columns", "int", "The number of columns/rows. Default is 5."},
|
||||
{"orientation", "{VERTICAL, HORIZONTAL}",
|
||||
"The orienation of the bar graph. Default is VERTICAL."},
|
||||
{"c#", "int", "Subsitute a number for #. "
|
||||
+ "The value/size of bar #. Default is 0."},
|
||||
{"c#_label", "string", "The label for bar #. "
|
||||
+ "Default is an empty label."},
|
||||
{"c#_style", "{SOLID, STRIPED}", "The style of bar #. "
|
||||
+ "Default is SOLID."},
|
||||
{"c#_color", "{RED, GREEN, BLUE, PINK, ORANGE, MAGENTA, CYAN, "
|
||||
+ "WHITE, YELLOW, GRAY, DARKGRAY}",
|
||||
"The color of bar #. Default is GRAY."}
|
||||
{ "title", "string", "The title of bar graph. Default is 'Chart'" },
|
||||
{ "scale", "int", "The scale of the bar graph. Default is 10." },
|
||||
{ "columns", "int", "The number of columns/rows. Default is 5." },
|
||||
{ "orientation", "{VERTICAL, HORIZONTAL}",
|
||||
"The orienation of the bar graph. Default is VERTICAL." },
|
||||
{ "c#", "int", "Subsitute a number for #. "
|
||||
+ "The value/size of bar #. Default is 0." },
|
||||
{ "c#_label", "string", "The label for bar #. "
|
||||
+ "Default is an empty label." },
|
||||
{ "c#_style", "{SOLID, STRIPED}", "The style of bar #. "
|
||||
+ "Default is SOLID." },
|
||||
{ "c#_color", "{RED, GREEN, BLUE, PINK, ORANGE, MAGENTA, CYAN, "
|
||||
+ "WHITE, YELLOW, GRAY, DARKGRAY}",
|
||||
"The color of bar #. Default is GRAY." }
|
||||
};
|
||||
return info;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,92 +29,106 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
/**
|
||||
* I love blinking things.
|
||||
*
|
||||
* @author Arthur van Hoff
|
||||
* @modified 04/24/96 Jim Hagen use getBackground
|
||||
* @modified 02/05/98 Mike McCloskey removed use of deprecated methods
|
||||
* @modified 04/23/99 Josh Bloch, use timer instead of explicit multithreading.
|
||||
* @modified 07/10/00 Daniel Peek brought to code conventions, minor changes
|
||||
* @author 04/24/96 Jim Hagen use getBackground
|
||||
* @author 02/05/98 Mike McCloskey removed use of deprecated methods
|
||||
* @author 04/23/99 Josh Bloch, use timer instead of explicit multithreading.
|
||||
* @author 07/10/00 Daniel Peek brought to code conventions, minor changes
|
||||
*/
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Blink extends java.applet.Applet {
|
||||
|
||||
private static final long serialVersionUID = -775844794477507646L;
|
||||
private Timer timer; // Schedules the blinking
|
||||
private String labelString; // The label for the window
|
||||
private int delay; // the delay time between blinks
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
String blinkFrequency = getParameter("speed");
|
||||
delay = (blinkFrequency == null) ? 400 :
|
||||
(1000 / Integer.parseInt(blinkFrequency));
|
||||
delay = (blinkFrequency == null) ? 400
|
||||
: (1000 / Integer.parseInt(blinkFrequency));
|
||||
labelString = getParameter("lbl");
|
||||
if (labelString == null)
|
||||
if (labelString == null) {
|
||||
labelString = "Blink";
|
||||
}
|
||||
Font font = new java.awt.Font("Serif", Font.PLAIN, 24);
|
||||
setFont(font);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
timer = new Timer(); //creates a new timer to schedule the blinking
|
||||
timer.schedule(new TimerTask() { //creates a timertask to schedule
|
||||
|
||||
// overrides the run method to provide functionality
|
||||
@Override
|
||||
public void run() {
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
, delay, delay);
|
||||
}, delay, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
int fontSize = g.getFont().getSize();
|
||||
int x = 0, y = fontSize, space;
|
||||
int red = (int) ( 50 * Math.random());
|
||||
int green = (int) ( 50 * Math.random());
|
||||
int blue = (int) (256 * Math.random());
|
||||
int red = (int) (50 * Math.random());
|
||||
int green = (int) (50 * Math.random());
|
||||
int blue = (int) (256 * Math.random());
|
||||
Dimension d = getSize();
|
||||
g.setColor(Color.black);
|
||||
FontMetrics fm = g.getFontMetrics();
|
||||
space = fm.stringWidth(" ");
|
||||
for (StringTokenizer t = new StringTokenizer(labelString);
|
||||
t.hasMoreTokens();) {
|
||||
t.hasMoreTokens();) {
|
||||
String word = t.nextToken();
|
||||
int w = fm.stringWidth(word) + space;
|
||||
if (x + w > d.width) {
|
||||
x = 0;
|
||||
y += fontSize; //move word to next line if it doesn't fit
|
||||
}
|
||||
if (Math.random() < 0.5)
|
||||
g.setColor(new java.awt.Color((red + y*30) % 256,
|
||||
(green + x/3) % 256, blue));
|
||||
else
|
||||
if (Math.random() < 0.5) {
|
||||
g.setColor(new java.awt.Color((red + y * 30) % 256,
|
||||
(green + x / 3) % 256, blue));
|
||||
} else {
|
||||
g.setColor(getBackground());
|
||||
}
|
||||
g.drawString(word, x, y);
|
||||
x += w; //shift to the right to draw the next word
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
timer.cancel(); //stops the timer
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "Title: Blinker\n"
|
||||
+ "Author: Arthur van Hoff\n"
|
||||
+ "Displays multicolored blinking text.";
|
||||
+ "Author: Arthur van Hoff\n"
|
||||
+ "Displays multicolored blinking text.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] getParameterInfo() {
|
||||
String pinfo[][] = {
|
||||
{"speed", "string", "The blink frequency"},
|
||||
{"lbl", "string", "The text to blink."},
|
||||
};
|
||||
{ "speed", "string", "The blink frequency" },
|
||||
{ "lbl", "string", "The text to blink." }, };
|
||||
return pinfo;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,14 +29,27 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.applet.Applet;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
final class CardPanel extends Panel {
|
||||
|
||||
class CardPanel extends Panel {
|
||||
ActionListener listener;
|
||||
|
||||
Panel create(LayoutManager layout) {
|
||||
@ -83,16 +96,21 @@ class CardPanel extends Panel {
|
||||
add("six", create(new GridLayout(2, 2, 10, 10)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(200, 100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CardTest extends Applet
|
||||
implements ActionListener,
|
||||
ItemListener {
|
||||
implements ActionListener,
|
||||
ItemListener {
|
||||
|
||||
CardPanel cards;
|
||||
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public CardTest() {
|
||||
setLayout(new BorderLayout());
|
||||
add("Center", cards = new CardPanel(this));
|
||||
@ -127,24 +145,26 @@ public class CardTest extends Applet
|
||||
p.add(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
((CardLayout)cards.getLayout()).show(cards,
|
||||
(String)(e.getItem()));
|
||||
((CardLayout) cards.getLayout()).show(cards,
|
||||
(String) (e.getItem()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String arg = e.getActionCommand();
|
||||
|
||||
if ("first".equals(arg)) {
|
||||
((CardLayout)cards.getLayout()).first(cards);
|
||||
((CardLayout) cards.getLayout()).first(cards);
|
||||
} else if ("next".equals(arg)) {
|
||||
((CardLayout)cards.getLayout()).next(cards);
|
||||
((CardLayout) cards.getLayout()).next(cards);
|
||||
} else if ("previous".equals(arg)) {
|
||||
((CardLayout)cards.getLayout()).previous(cards);
|
||||
((CardLayout) cards.getLayout()).previous(cards);
|
||||
} else if ("last".equals(arg)) {
|
||||
((CardLayout)cards.getLayout()).last(cards);
|
||||
((CardLayout) cards.getLayout()).last(cards);
|
||||
} else {
|
||||
((CardLayout)cards.getLayout()).show(cards,(String)arg);
|
||||
((CardLayout) cards.getLayout()).show(cards, arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,9 +176,10 @@ public class CardTest extends Applet
|
||||
|
||||
f.add("Center", cardTest);
|
||||
f.setSize(300, 300);
|
||||
f.show();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "Demonstrates the different types of layout managers.";
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,24 +29,28 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.applet.*;
|
||||
import java.text.*;
|
||||
import java.applet.Applet;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
/**
|
||||
* Time!
|
||||
*
|
||||
* @author Rachel Gollub
|
||||
* @modified Daniel Peek replaced circle drawing calculation, few more changes
|
||||
* @author Daniel Peek replaced circle drawing calculation, few more changes
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class Clock extends Applet implements Runnable {
|
||||
|
||||
private volatile Thread timer; // The thread that displays clock
|
||||
private int lastxs, lastys, lastxm,
|
||||
lastym, lastxh, lastyh; // Dimensions used to draw hands
|
||||
lastym, lastxh, lastyh; // Dimensions used to draw hands
|
||||
private SimpleDateFormat formatter; // Formats the date displayed
|
||||
private String lastdate; // String to hold date displayed
|
||||
private Font clockFaceFont; // Font for number display on clock
|
||||
@ -55,11 +59,11 @@ public class Clock extends Applet implements Runnable {
|
||||
private Color numberColor; // Color of second hand and numbers
|
||||
private int xcenter = 80, ycenter = 55; // Center position
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
int x,y;
|
||||
lastxs = lastys = lastxm = lastym = lastxh = lastyh = 0;
|
||||
formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy",
|
||||
Locale.getDefault());
|
||||
formatter = new SimpleDateFormat("EEE MMM dd hh:mm:ss yyyy",
|
||||
Locale.getDefault());
|
||||
currentDate = new Date();
|
||||
lastdate = formatter.format(currentDate);
|
||||
clockFaceFont = new Font("Serif", Font.PLAIN, 14);
|
||||
@ -68,26 +72,29 @@ public class Clock extends Applet implements Runnable {
|
||||
|
||||
try {
|
||||
setBackground(new Color(Integer.parseInt(getParameter("bgcolor"),
|
||||
16)));
|
||||
16)));
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
try {
|
||||
handColor = new Color(Integer.parseInt(getParameter("fgcolor1"),
|
||||
16));
|
||||
16));
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
try {
|
||||
numberColor = new Color(Integer.parseInt(getParameter("fgcolor2"),
|
||||
16));
|
||||
16));
|
||||
} catch (NullPointerException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
resize(300,300); // Set clock window size
|
||||
resize(300, 300); // Set clock window size
|
||||
}
|
||||
|
||||
// Paint is the main part of the program
|
||||
/**
|
||||
* Paint is the main part of the program
|
||||
*/
|
||||
@Override
|
||||
public void update(Graphics g) {
|
||||
int xh, yh, xm, ym, xs, ys;
|
||||
int s = 0, m = 10, h = 10;
|
||||
@ -119,10 +126,12 @@ public class Clock extends Applet implements Runnable {
|
||||
ys = (int) (Math.sin(s * Math.PI / 30 - Math.PI / 2) * 45 + ycenter);
|
||||
xm = (int) (Math.cos(m * Math.PI / 30 - Math.PI / 2) * 40 + xcenter);
|
||||
ym = (int) (Math.sin(m * Math.PI / 30 - Math.PI / 2) * 40 + ycenter);
|
||||
xh = (int) (Math.cos((h*30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30
|
||||
+ xcenter);
|
||||
yh = (int) (Math.sin((h*30 + m / 2) * Math.PI / 180 - Math.PI / 2) * 30
|
||||
+ ycenter);
|
||||
xh = (int) (Math.cos((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2)
|
||||
* 30
|
||||
+ xcenter);
|
||||
yh = (int) (Math.sin((h * 30 + m / 2) * Math.PI / 180 - Math.PI / 2)
|
||||
* 30
|
||||
+ ycenter);
|
||||
|
||||
// Get the date to print at the bottom
|
||||
formatter.applyPattern("EEE MMM dd HH:mm:ss yyyy");
|
||||
@ -136,12 +145,12 @@ public class Clock extends Applet implements Runnable {
|
||||
g.drawString(lastdate, 5, 125);
|
||||
}
|
||||
if (xm != lastxm || ym != lastym) {
|
||||
g.drawLine(xcenter, ycenter-1, lastxm, lastym);
|
||||
g.drawLine(xcenter-1, ycenter, lastxm, lastym);
|
||||
g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
|
||||
g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
|
||||
}
|
||||
if (xh != lastxh || yh != lastyh) {
|
||||
g.drawLine(xcenter, ycenter-1, lastxh, lastyh);
|
||||
g.drawLine(xcenter-1, ycenter, lastxh, lastyh);
|
||||
g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
|
||||
g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
|
||||
}
|
||||
|
||||
// Draw date and hands
|
||||
@ -149,73 +158,83 @@ public class Clock extends Applet implements Runnable {
|
||||
g.drawString(today, 5, 125);
|
||||
g.drawLine(xcenter, ycenter, xs, ys);
|
||||
g.setColor(handColor);
|
||||
g.drawLine(xcenter, ycenter-1, xm, ym);
|
||||
g.drawLine(xcenter-1, ycenter, xm, ym);
|
||||
g.drawLine(xcenter, ycenter-1, xh, yh);
|
||||
g.drawLine(xcenter-1, ycenter, xh, yh);
|
||||
lastxs = xs; lastys = ys;
|
||||
lastxm = xm; lastym = ym;
|
||||
lastxh = xh; lastyh = yh;
|
||||
g.drawLine(xcenter, ycenter - 1, xm, ym);
|
||||
g.drawLine(xcenter - 1, ycenter, xm, ym);
|
||||
g.drawLine(xcenter, ycenter - 1, xh, yh);
|
||||
g.drawLine(xcenter - 1, ycenter, xh, yh);
|
||||
lastxs = xs;
|
||||
lastys = ys;
|
||||
lastxm = xm;
|
||||
lastym = ym;
|
||||
lastxh = xh;
|
||||
lastyh = yh;
|
||||
lastdate = today;
|
||||
currentDate = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
g.setFont(clockFaceFont);
|
||||
// Draw the circle and numbers
|
||||
g.setColor(handColor);
|
||||
g.drawArc(xcenter-50, ycenter-50, 100, 100, 0, 360);
|
||||
g.drawArc(xcenter - 50, ycenter - 50, 100, 100, 0, 360);
|
||||
g.setColor(numberColor);
|
||||
g.drawString("9", xcenter-45, ycenter+3);
|
||||
g.drawString("3", xcenter+40, ycenter+3);
|
||||
g.drawString("12", xcenter-5, ycenter-37);
|
||||
g.drawString("6", xcenter-3, ycenter+45);
|
||||
g.drawString("9", xcenter - 45, ycenter + 3);
|
||||
g.drawString("3", xcenter + 40, ycenter + 3);
|
||||
g.drawString("12", xcenter - 5, ycenter - 37);
|
||||
g.drawString("6", xcenter - 3, ycenter + 45);
|
||||
|
||||
// Draw date and hands
|
||||
g.setColor(numberColor);
|
||||
g.drawString(lastdate, 5, 125);
|
||||
g.drawLine(xcenter, ycenter, lastxs, lastys);
|
||||
g.setColor(handColor);
|
||||
g.drawLine(xcenter, ycenter-1, lastxm, lastym);
|
||||
g.drawLine(xcenter-1, ycenter, lastxm, lastym);
|
||||
g.drawLine(xcenter, ycenter-1, lastxh, lastyh);
|
||||
g.drawLine(xcenter-1, ycenter, lastxh, lastyh);
|
||||
g.drawLine(xcenter, ycenter - 1, lastxm, lastym);
|
||||
g.drawLine(xcenter - 1, ycenter, lastxm, lastym);
|
||||
g.drawLine(xcenter, ycenter - 1, lastxh, lastyh);
|
||||
g.drawLine(xcenter - 1, ycenter, lastxh, lastyh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
timer = new Thread(this);
|
||||
timer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
timer = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("SleepWhileHoldingLock")
|
||||
public void run() {
|
||||
Thread me = Thread.currentThread();
|
||||
while (timer == me) {
|
||||
try {
|
||||
Thread.currentThread().sleep(100);
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "Title: A Clock \n"
|
||||
+ "Author: Rachel Gollub, 1995 \n"
|
||||
+ "An analog clock.";
|
||||
+ "Author: Rachel Gollub, 1995 \n"
|
||||
+ "An analog clock.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] getParameterInfo() {
|
||||
String[][] info = {
|
||||
{"bgcolor", "hexadecimal RGB number",
|
||||
"The background color. Default is the color of your browser."},
|
||||
{"fgcolor1", "hexadecimal RGB number",
|
||||
"The color of the hands and dial. Default is blue."},
|
||||
{"fgcolor2", "hexadecimal RGB number",
|
||||
"The color of the second hand and numbers. Default is dark gray."}
|
||||
{ "bgcolor", "hexadecimal RGB number",
|
||||
"The background color. Default is the color of your browser." },
|
||||
{ "fgcolor1", "hexadecimal RGB number",
|
||||
"The color of the hands and dial. Default is blue." },
|
||||
{ "fgcolor2", "hexadecimal RGB number",
|
||||
"The color of the second hand and numbers. Default is dark gray." }
|
||||
};
|
||||
return info;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,25 +29,43 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Button;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Label;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.Panel;
|
||||
import java.awt.TextField;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.TextEvent;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.MemoryImageSource;
|
||||
|
||||
|
||||
enum DitherMethod {
|
||||
|
||||
NOOP, RED, GREEN, BLUE, ALPHA, SATURATION
|
||||
};
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class DitherTest extends Applet implements Runnable {
|
||||
final private static int NOOP = 0;
|
||||
final private static int RED = 1;
|
||||
final private static int GREEN = 2;
|
||||
final private static int BLUE = 3;
|
||||
final private static int ALPHA = 4;
|
||||
final private static int SATURATION = 5;
|
||||
|
||||
private Thread runner;
|
||||
|
||||
private DitherControls XControls;
|
||||
private DitherControls YControls;
|
||||
private DitherCanvas canvas;
|
||||
@ -62,6 +80,7 @@ public class DitherTest extends Applet implements Runnable {
|
||||
ditherTest.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
String xspec = null, yspec = null;
|
||||
int xvals[] = new int[2];
|
||||
@ -70,7 +89,7 @@ public class DitherTest extends Applet implements Runnable {
|
||||
try {
|
||||
xspec = getParameter("xaxis");
|
||||
yspec = getParameter("yaxis");
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (NullPointerException ignored) {
|
||||
//only occurs if run as application
|
||||
}
|
||||
|
||||
@ -80,44 +99,34 @@ public class DitherTest extends Applet implements Runnable {
|
||||
if (yspec == null) {
|
||||
yspec = "blue";
|
||||
}
|
||||
int xmethod = colormethod(xspec, xvals);
|
||||
int ymethod = colormethod(yspec, yvals);
|
||||
DitherMethod xmethod = colorMethod(xspec, xvals);
|
||||
DitherMethod ymethod = colorMethod(yspec, yvals);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
XControls = new DitherControls(this, xvals[0], xvals[1],
|
||||
xmethod, false);
|
||||
xmethod, false);
|
||||
YControls = new DitherControls(this, yvals[0], yvals[1],
|
||||
ymethod, true);
|
||||
ymethod, true);
|
||||
YControls.addRenderButton();
|
||||
add("North", XControls);
|
||||
add("South", YControls);
|
||||
add("Center", canvas = new DitherCanvas());
|
||||
}
|
||||
|
||||
private int colormethod(String s, int vals[]) {
|
||||
int method = NOOP;
|
||||
private DitherMethod colorMethod(String s, int vals[]) {
|
||||
DitherMethod method = DitherMethod.NOOP;
|
||||
if (s == null) {
|
||||
s = "";
|
||||
}
|
||||
String lower = s.toLowerCase();
|
||||
int len = 0;
|
||||
if (lower.startsWith("red")) {
|
||||
method = RED;
|
||||
lower = lower.substring(3);
|
||||
} else if (lower.startsWith("green")) {
|
||||
method = GREEN;
|
||||
lower = lower.substring(5);
|
||||
} else if (lower.startsWith("blue")) {
|
||||
method = BLUE;
|
||||
lower = lower.substring(4);
|
||||
} else if (lower.startsWith("alpha")) {
|
||||
method = ALPHA;
|
||||
lower = lower.substring(5);
|
||||
} else if (lower.startsWith("saturation")) {
|
||||
method = SATURATION;
|
||||
lower = lower.substring(10);
|
||||
|
||||
for (DitherMethod m : DitherMethod.values()) {
|
||||
if (lower.startsWith(m.toString().toLowerCase())) {
|
||||
method = m;
|
||||
lower = lower.substring(m.toString().length());
|
||||
}
|
||||
}
|
||||
if (method == NOOP) {
|
||||
if (method == DitherMethod.NOOP) {
|
||||
vals[0] = 0;
|
||||
vals[1] = 0;
|
||||
return method;
|
||||
@ -132,7 +141,7 @@ public class DitherTest extends Applet implements Runnable {
|
||||
begval = Integer.parseInt(lower.substring(0, dash));
|
||||
endval = Integer.parseInt(lower.substring(dash + 1));
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
|
||||
if (begval < 0) {
|
||||
@ -173,16 +182,14 @@ public class DitherTest extends Applet implements Runnable {
|
||||
c[0] = c[1] = c[2] = 0;
|
||||
c[3] = 255;
|
||||
if (xmethod < ymethod) {
|
||||
applymethod(c, xmethod, i, width, xvals);
|
||||
applymethod(c, ymethod, j, height, yvals);
|
||||
applyMethod(c, xmethod, i, width, xvals);
|
||||
applyMethod(c, ymethod, j, height, yvals);
|
||||
} else {
|
||||
applymethod(c, ymethod, j, height, yvals);
|
||||
applymethod(c, xmethod, i, width, xvals);
|
||||
applyMethod(c, ymethod, j, height, yvals);
|
||||
applyMethod(c, xmethod, i, width, xvals);
|
||||
}
|
||||
pixels[index++] = ((c[3] << 24) |
|
||||
(c[0] << 16) |
|
||||
(c[1] << 8) |
|
||||
c[2]);
|
||||
pixels[index++] = ((c[3] << 24) | (c[0] << 16) | (c[1] << 8)
|
||||
| c[2]);
|
||||
}
|
||||
|
||||
// Poll once per row to see if we've been told to stop.
|
||||
@ -191,51 +198,54 @@ public class DitherTest extends Applet implements Runnable {
|
||||
}
|
||||
}
|
||||
return createImage(new MemoryImageSource(width, height,
|
||||
ColorModel.getRGBdefault(), pixels, 0, width));
|
||||
ColorModel.getRGBdefault(), pixels, 0, width));
|
||||
}
|
||||
|
||||
private void applymethod(int c[], int method, int step,
|
||||
int total, int vals[]) {
|
||||
if (method == NOOP) {
|
||||
private void applyMethod(int c[], int methodIndex, int step,
|
||||
int total, int vals[]) {
|
||||
DitherMethod method = DitherMethod.values()[methodIndex];
|
||||
if (method == DitherMethod.NOOP) {
|
||||
return;
|
||||
}
|
||||
int val = ((total < 2)
|
||||
? vals[0]
|
||||
: vals[0] + ((vals[1] - vals[0]) * step / (total - 1)));
|
||||
? vals[0]
|
||||
: vals[0] + ((vals[1] - vals[0]) * step / (total - 1)));
|
||||
switch (method) {
|
||||
case RED:
|
||||
c[0] = val;
|
||||
break;
|
||||
case GREEN:
|
||||
c[1] = val;
|
||||
break;
|
||||
case BLUE:
|
||||
c[2] = val;
|
||||
break;
|
||||
case ALPHA:
|
||||
c[3] = val;
|
||||
break;
|
||||
case SATURATION:
|
||||
int max = Math.max(Math.max(c[0], c[1]), c[2]);
|
||||
int min = max * (255 - val) / 255;
|
||||
if (c[0] == 0) {
|
||||
c[0] = min;
|
||||
}
|
||||
if (c[1] == 0) {
|
||||
c[1] = min;
|
||||
}
|
||||
if (c[2] == 0) {
|
||||
c[2] = min;
|
||||
}
|
||||
break;
|
||||
case RED:
|
||||
c[0] = val;
|
||||
break;
|
||||
case GREEN:
|
||||
c[1] = val;
|
||||
break;
|
||||
case BLUE:
|
||||
c[2] = val;
|
||||
break;
|
||||
case ALPHA:
|
||||
c[3] = val;
|
||||
break;
|
||||
case SATURATION:
|
||||
int max = Math.max(Math.max(c[0], c[1]), c[2]);
|
||||
int min = max * (255 - val) / 255;
|
||||
if (c[0] == 0) {
|
||||
c[0] = min;
|
||||
}
|
||||
if (c[1] == 0) {
|
||||
c[1] = min;
|
||||
}
|
||||
if (c[2] == 0) {
|
||||
c[2] = min;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
runner = new Thread(this);
|
||||
runner.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
canvas.setImage(null); // Wipe previous image
|
||||
Image img = calculateImage();
|
||||
@ -244,35 +254,43 @@ public class DitherTest extends Applet implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
runner = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
remove(XControls);
|
||||
remove(YControls);
|
||||
remove(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "An interactive demonstration of dithering.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] getParameterInfo() {
|
||||
String[][] info = {
|
||||
{"xaxis", "{RED, GREEN, BLUE, ALPHA, SATURATION}",
|
||||
"The color of the Y axis. Default is RED."},
|
||||
{"yaxis", "{RED, GREEN, BLUE, ALPHA, SATURATION}",
|
||||
"The color of the X axis. Default is BLUE."}
|
||||
{ "xaxis", "{RED, GREEN, BLUE, ALPHA, SATURATION}",
|
||||
"The color of the Y axis. Default is RED." },
|
||||
{ "yaxis", "{RED, GREEN, BLUE, ALPHA, SATURATION}",
|
||||
"The color of the X axis. Default is BLUE." }
|
||||
};
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class DitherCanvas extends Canvas {
|
||||
|
||||
private Image img;
|
||||
private static String calcString = "Calculating...";
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
int w = getSize().width;
|
||||
int h = getSize().height;
|
||||
@ -288,14 +306,17 @@ class DitherCanvas extends Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Graphics g) {
|
||||
paint(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(20, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(200, 200);
|
||||
}
|
||||
@ -310,29 +331,29 @@ class DitherCanvas extends Canvas {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class DitherControls extends Panel implements ActionListener {
|
||||
|
||||
private CardinalTextField start;
|
||||
private CardinalTextField end;
|
||||
private Button button;
|
||||
private Choice choice;
|
||||
private DitherTest applet;
|
||||
|
||||
private static LayoutManager dcLayout = new FlowLayout(FlowLayout.CENTER,
|
||||
10, 5);
|
||||
10, 5);
|
||||
|
||||
public DitherControls(DitherTest app, int s, int e, int type,
|
||||
boolean vertical) {
|
||||
public DitherControls(DitherTest app, int s, int e, DitherMethod type,
|
||||
boolean vertical) {
|
||||
applet = app;
|
||||
setLayout(dcLayout);
|
||||
add(new Label(vertical ? "Vertical" : "Horizontal"));
|
||||
add(choice = new Choice());
|
||||
choice.addItem("Noop");
|
||||
choice.addItem("Red");
|
||||
choice.addItem("Green");
|
||||
choice.addItem("Blue");
|
||||
choice.addItem("Alpha");
|
||||
choice.addItem("Saturation");
|
||||
choice.select(type);
|
||||
for (DitherMethod m : DitherMethod.values()) {
|
||||
choice.addItem(m.toString().substring(0, 1)
|
||||
+ m.toString().substring(1).toLowerCase());
|
||||
}
|
||||
choice.select(type.ordinal());
|
||||
add(start = new CardinalTextField(Integer.toString(s), 4));
|
||||
add(end = new CardinalTextField(Integer.toString(e), 4));
|
||||
}
|
||||
@ -369,6 +390,7 @@ class DitherControls extends Panel implements ActionListener {
|
||||
}
|
||||
|
||||
/* called when user clicks the button */
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getSource() == button) {
|
||||
applet.start();
|
||||
@ -376,6 +398,8 @@ class DitherControls extends Panel implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class CardinalTextField extends TextField {
|
||||
|
||||
String oldText = null;
|
||||
@ -391,6 +415,7 @@ class CardinalTextField extends TextField {
|
||||
// function, but this is neater, since ideally, it would prevent
|
||||
// the text from appearing at all. Sigh. See bugid 4100317/4114565.
|
||||
//
|
||||
@Override
|
||||
protected void processEvent(AWTEvent evt) {
|
||||
int id = evt.getID();
|
||||
if (id != KeyEvent.KEY_TYPED) {
|
||||
@ -420,6 +445,7 @@ class CardinalTextField extends TextField {
|
||||
// Note: it would be easy to extend this to an eight-bit
|
||||
// TextField (range 0-255), but I'll leave it as-is.
|
||||
//
|
||||
@Override
|
||||
protected void processTextEvent(TextEvent te) {
|
||||
// The empty string is okay, too
|
||||
String newText = getText();
|
||||
@ -436,11 +462,8 @@ class CardinalTextField extends TextField {
|
||||
// Returns true for Cardinal (non-negative) numbers
|
||||
// Note that the empty string is not allowed
|
||||
private boolean textIsCardinal(String textToCheck) {
|
||||
int value = -1;
|
||||
|
||||
try {
|
||||
value = Integer.parseInt(textToCheck, 10);
|
||||
return (value >= 0);
|
||||
return Integer.parseInt(textToCheck, 10) >= 0;
|
||||
} catch (NumberFormatException nfe) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -29,27 +29,46 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
import java.applet.*;
|
||||
import java.applet.Applet;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.CheckboxGroup;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class DrawTest extends Applet{
|
||||
@SuppressWarnings("serial")
|
||||
public class DrawTest extends Applet {
|
||||
|
||||
DrawPanel panel;
|
||||
DrawControls controls;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
setLayout(new BorderLayout());
|
||||
panel = new DrawPanel();
|
||||
controls = new DrawControls(panel);
|
||||
add("Center", panel);
|
||||
add("South",controls);
|
||||
add("South", controls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
remove(panel);
|
||||
remove(controls);
|
||||
@ -63,22 +82,28 @@ public class DrawTest extends Applet{
|
||||
|
||||
f.add("Center", drawTest);
|
||||
f.setSize(300, 300);
|
||||
f.show();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAppletInfo() {
|
||||
return "A simple drawing program.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
|
||||
public static final int LINES = 0;
|
||||
public static final int POINTS = 1;
|
||||
int mode = LINES;
|
||||
Vector lines = new Vector();
|
||||
Vector colors = new Vector();
|
||||
int x1,y1;
|
||||
int x2,y2;
|
||||
int mode = LINES;
|
||||
List<Rectangle> lines = new ArrayList<Rectangle>();
|
||||
List<Color> colors = new ArrayList<Color>();
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public DrawPanel() {
|
||||
setBackground(Color.white);
|
||||
addMouseMotionListener(this);
|
||||
@ -87,16 +112,16 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
|
||||
public void setDrawMode(int mode) {
|
||||
switch (mode) {
|
||||
case LINES:
|
||||
case POINTS:
|
||||
this.mode = mode;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
case LINES:
|
||||
case POINTS:
|
||||
this.mode = mode;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
e.consume();
|
||||
switch (mode) {
|
||||
@ -106,8 +131,8 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
break;
|
||||
case POINTS:
|
||||
default:
|
||||
colors.addElement(getForeground());
|
||||
lines.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
|
||||
colors.add(getForeground());
|
||||
lines.add(new Rectangle(x1, y1, e.getX(), e.getY()));
|
||||
x1 = e.getX();
|
||||
y1 = e.getY();
|
||||
break;
|
||||
@ -115,9 +140,11 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
e.consume();
|
||||
switch (mode) {
|
||||
@ -128,8 +155,8 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
break;
|
||||
case POINTS:
|
||||
default:
|
||||
colors.addElement(getForeground());
|
||||
lines.addElement(new Rectangle(e.getX(), e.getY(), -1, -1));
|
||||
colors.add(getForeground());
|
||||
lines.add(new Rectangle(e.getX(), e.getY(), -1, -1));
|
||||
x1 = e.getX();
|
||||
y1 = e.getY();
|
||||
repaint();
|
||||
@ -137,12 +164,13 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
e.consume();
|
||||
switch (mode) {
|
||||
case LINES:
|
||||
colors.addElement(getForeground());
|
||||
lines.addElement(new Rectangle(x1, y1, e.getX(), e.getY()));
|
||||
colors.add(getForeground());
|
||||
lines.add(new Rectangle(x1, y1, e.getX(), e.getY()));
|
||||
x2 = -1;
|
||||
break;
|
||||
case POINTS:
|
||||
@ -152,23 +180,27 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
int np = lines.size();
|
||||
|
||||
/* draw the current lines */
|
||||
g.setColor(getForeground());
|
||||
for (int i=0; i < np; i++) {
|
||||
Rectangle p = (Rectangle)lines.elementAt(i);
|
||||
g.setColor((Color)colors.elementAt(i));
|
||||
for (int i = 0; i < np; i++) {
|
||||
Rectangle p = lines.get(i);
|
||||
g.setColor(colors.get(i));
|
||||
if (p.width != -1) {
|
||||
g.drawLine(p.x, p.y, p.width, p.height);
|
||||
} else {
|
||||
@ -185,9 +217,12 @@ class DrawPanel extends Panel implements MouseListener, MouseMotionListener {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
class DrawControls extends Panel implements ItemListener {
|
||||
|
||||
DrawPanel target;
|
||||
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
public DrawControls(DrawPanel target) {
|
||||
this.target = target;
|
||||
setLayout(new FlowLayout());
|
||||
@ -222,33 +257,35 @@ class DrawControls extends Panel implements ItemListener {
|
||||
add(shapes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Rectangle r = getBounds();
|
||||
g.setColor(Color.lightGray);
|
||||
g.draw3DRect(0, 0, r.width, r.height, false);
|
||||
|
||||
int n = getComponentCount();
|
||||
for(int i=0; i<n; i++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
Component comp = getComponent(i);
|
||||
if (comp instanceof Checkbox) {
|
||||
Point loc = comp.getLocation();
|
||||
Dimension d = comp.getSize();
|
||||
g.setColor(comp.getForeground());
|
||||
g.drawRect(loc.x-1, loc.y-1, d.width+1, d.height+1);
|
||||
g.drawRect(loc.x - 1, loc.y - 1, d.width + 1, d.height + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getSource() instanceof Checkbox) {
|
||||
target.setForeground(((Component)e.getSource()).getForeground());
|
||||
} else if (e.getSource() instanceof Choice) {
|
||||
String choice = (String) e.getItem();
|
||||
if (choice.equals("Lines")) {
|
||||
target.setDrawMode(DrawPanel.LINES);
|
||||
} else if (choice.equals("Points")) {
|
||||
target.setDrawMode(DrawPanel.POINTS);
|
||||
}
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getSource() instanceof Checkbox) {
|
||||
target.setForeground(((Component) e.getSource()).getForeground());
|
||||
} else if (e.getSource() instanceof Choice) {
|
||||
String choice = (String) e.getItem();
|
||||
if (choice.equals("Lines")) {
|
||||
target.setDrawMode(DrawPanel.LINES);
|
||||
} else if (choice.equals("Points")) {
|
||||
target.setDrawMode(DrawPanel.POINTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user