提交 f93edc72 编写于 作者: Y yan

Merge

37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24 37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24
75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25
fb57027902e04ecafceae31a605e69b436c23d57 jdk7-b26
...@@ -41,7 +41,7 @@ endif ...@@ -41,7 +41,7 @@ endif
# Omit mirror since it's built with the apt tool. # Omit mirror since it's built with the apt tool.
SUBDIRS = $(SCRIPT_SUBDIR) image security crypto/provider jndi jmx \ SUBDIRS = $(SCRIPT_SUBDIR) image security crypto/provider jndi jmx \
java inputmethods org xml rowset net/httpserver net/ssl demo \ java inputmethods org xml rowset net/httpserver net/ssl demo \
tools jarsigner tools jarsigner tracing
all build clean clobber:: all build clean clobber::
$(SUBDIRS-loop) $(SUBDIRS-loop)
......
# #
# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -87,8 +87,7 @@ ...@@ -87,8 +87,7 @@
# sign Alias for sign-jar # sign Alias for sign-jar
# sign-jar Builds/signs sunjce_provider.jar (no install) # sign-jar Builds/signs sunjce_provider.jar (no install)
# #
# obfus Builds/obfuscates/signs/installs # obfus Builds/obfuscates/signs sunjce_provider.jar
# sunjce_provider.jar
# #
# release Builds all targets in preparation # release Builds all targets in preparation
# for workspace integration. # for workspace integration.
...@@ -101,8 +100,25 @@ ...@@ -101,8 +100,25 @@
BUILDDIR = ../../../.. BUILDDIR = ../../../..
PACKAGE = com.sun.crypto.provider PACKAGE = com.sun.crypto.provider
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# #
# Location for the newly built classfiles. # Location for the newly built classfiles.
...@@ -147,6 +163,8 @@ endif # OPENJDK ...@@ -147,6 +163,8 @@ endif # OPENJDK
# #
UNSIGNED_DIR = $(TEMPDIR)/unsigned UNSIGNED_DIR = $(TEMPDIR)/unsigned
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned sunjce_provider.jar file. # Build the unsigned sunjce_provider.jar file.
...@@ -184,44 +202,66 @@ ifndef OPENJDK ...@@ -184,44 +202,66 @@ ifndef OPENJDK
# Sign the provider jar file. Not needed for OpenJDK. # Sign the provider jar file. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
sign: sign-jar sign: sign-jar
sign-jar: $(SIGNED_DIR)/sunjce_provider.jar sign-jar: $(SIGNED_DIR)/sunjce_provider.jar
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/sunjce_provider.jar: $(UNSIGNED_DIR)/sunjce_provider.jar $(SIGNED_DIR)/sunjce_provider.jar: $(UNSIGNED_DIR)/sunjce_provider.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/sunjce_provider.jar:
@if [ ! -r $(UNSIGNED_DIR)/sunjce_provider.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunjce_provider.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/sunjce_provider.jar)
# ===================================================== # =====================================================
# Obfuscate/sign/install the JDK build. Not needed for OpenJDK. # Obfuscate/sign/install the JDK build. Not needed for OpenJDK.
# #
OBFUS_DIR = $(TEMPDIR)/obfus OBFUS_DIR = $(JCE_BUILD_DIR)/obfus/sunjce
CLOSED_DIR = $(BUILDDIR)/closed/com/sun/crypto/provider CLOSED_DIR = $(BUILDDIR)/closed/com/sun/crypto/provider
obfus: $(OBFUS_DIR)/sunjce_provider.jar obfus: $(OBFUS_DIR)/sunjce_provider.jar
$(release-warning) $(release-warning)
$(OBFUS_DIR)/sunjce_provider.jar: build-jar $(JCE_MANIFEST_FILE) ifndef ALT_JCE_BUILD_DIR
$(OBFUS_DIR)/sunjce_provider.jar: build-jar $(JCE_MANIFEST_FILE) \
$(OBFUS_DIR)/sunjce.dox
else
$(OBFUS_DIR)/sunjce_provider.jar: $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/sunjce.dox
@if [ ! -d $(CLASSDESTDIR) ] ; then \
$(ECHO) "Couldn't find $(CLASSDESTDIR)"; \
exit 1; \
fi
endif
@$(ECHO) ">>>Obfuscating SunJCE Provider..."
$(presign) $(presign)
$(preobfus) $(preobfus)
@$(ECHO) ">>>Obfuscating Sun JCE Provider..."
$(prep-target) $(prep-target)
$(CD) $(OBFUS_DIR); \ $(CD) $(OBFUS_DIR); \
$(OBFUSCATOR) -fv \ $(OBFUSCATOR) -fv sunjce.dox
$(CURRENT_DIRECTORY)/$(CLOSED_DIR)/obfus/sunjce.dox
@$(CD) $(OBFUS_DIR); $(java-vm-cleanup) @$(CD) $(OBFUS_DIR); $(java-vm-cleanup)
$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \
-C $(OBFUS_DIR)/build com \ -C $(OBFUS_DIR)/build com \
$(JAR_JFLAGS) $(JAR_JFLAGS)
$(sign-target) $(sign-target)
$(MKDIR) -p $(dir $(JAR_DESTFILE))
$(RM) $(JAR_DESTFILE)
$(CP) $@ $(JAR_DESTFILE)
@$(java-vm-cleanup) @$(java-vm-cleanup)
$(OBFUS_DIR)/sunjce.dox: $(CLOSED_DIR)/obfus/sunjce.dox
@$(ECHO) ">>>Creating sunjce.dox"
$(prep-target)
$(SED) "s:@@TEMPDIR@@:$(ABS_TEMPDIR):" $< > $@
# #
# The current obfuscator has a limitation in that it currently only # The current obfuscator has a limitation in that it currently only
# supports up to v49 class file format. Force v49 classfiles in our # supports up to v49 class file format. Force v49 classfiles in our
...@@ -235,9 +275,9 @@ TARGET_CLASS_VERSION = 5 ...@@ -235,9 +275,9 @@ TARGET_CLASS_VERSION = 5
# #
release: $(OBFUS_DIR)/sunjce_provider.jar release: $(OBFUS_DIR)/sunjce_provider.jar
$(RM) $(RELEASE_DIR)/sunjce_provider.jar $(RM) $(JCE_BUILD_DIR)/release/sunjce_provider.jar
$(MKDIR) -p $(RELEASE_DIR) $(MKDIR) -p $(JCE_BUILD_DIR)/release
$(CP) $(OBFUS_DIR)/sunjce_provider.jar $(RELEASE_DIR) $(CP) $(OBFUS_DIR)/sunjce_provider.jar $(JCE_BUILD_DIR)/release
$(release-warning) $(release-warning)
endif # OPENJDK endif # OPENJDK
...@@ -275,7 +315,7 @@ endif ...@@ -275,7 +315,7 @@ endif
# #
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar .PHONY: build-jar jar install-jar
ifndef OPENJDK ifndef OPENJDK
......
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
#
# Makefile for building tracing classes
#
BUILDDIR = ../../..
PACKAGE = com.sun.tracing
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = dtrace
all build:
$(SUBDIRS-loop)
clean clobber::
$(SUBDIRS-loop)
AUTO_FILES_JAVA_DIRS = com/sun/tracing
#
# Rules.
#
include $(BUILDDIR)/common/Classes.gmk
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
#
# Makefile for building dtrace extension
#
BUILDDIR = ../../../..
PACKAGE = com.sun.tracing.dtrace
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
AUTO_FILES_JAVA_DIRS = com/sun/tracing/dtrace
#
# Rules.
#
include $(BUILDDIR)/common/Classes.gmk
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
# So when it includes other files, it must use JDK_TOPDIR. # So when it includes other files, it must use JDK_TOPDIR.
# #
# Check for strange explicit settings (change to empty or true)
ifdef OPENJDK
ifneq ($(OPENJDK),true)
x:=$(error "OPENJDK (if defined) can only be set to true")
endif
endif
# #
# On Solaris, the 'make' utility from Sun will not work with these makefiles. # On Solaris, the 'make' utility from Sun will not work with these makefiles.
# This little rule is only understood by Sun's make, and is harmless # This little rule is only understood by Sun's make, and is harmless
...@@ -87,19 +94,6 @@ ifeq ($(CLOSED_SRC_DIR_EXISTS), false) ...@@ -87,19 +94,6 @@ ifeq ($(CLOSED_SRC_DIR_EXISTS), false)
OPENJDK = true OPENJDK = true
endif endif
# Check for strange explicit settings (change to empty or true)
ifdef OPENJDK
ifeq ($(OPENJDK),false)
# Silently treat as not defined
OPENJDK =
else
ifneq ($(OPENJDK),true)
dummy := $(warning "WARNING: OPENKJDK=$(OPENJDK) being treated as true")
OPENJDK = true
endif
endif
endif
# Define where closed directories are # Define where closed directories are
ifdef OPENJDK ifdef OPENJDK
CLOSED_SRC = CLOSED_SRC =
...@@ -309,6 +303,8 @@ BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses ...@@ -309,6 +303,8 @@ BUILDTOOLCLASSDIR = $(OUTPUTDIR)/btclasses
# for build tool jar files # for build tool jar files
BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars BUILDTOOLJARDIR = $(OUTPUTDIR)/btjars
ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars ABS_BUILDTOOLJARDIR = $(ABS_OUTPUTDIR)/btjars
# for generated tool class files
BUILDTOOLBINDIR = $(OUTPUTDIR)/btbins
# for generated java source files # for generated java source files
GENSRCDIR = $(OUTPUTDIR)/gensrc GENSRCDIR = $(OUTPUTDIR)/gensrc
# for generated C source files (not javah) # for generated C source files (not javah)
......
...@@ -231,12 +231,14 @@ classes : $(CLASSES_INIT) .delete.classlist .compile.classlist ...@@ -231,12 +231,14 @@ classes : $(CLASSES_INIT) .delete.classlist .compile.classlist
.compile.classlist : $(JAVA_SOURCE_LIST) .compile.classlist : $(JAVA_SOURCE_LIST)
@$(MKDIR) -p $(CLASSDESTDIR) @$(MKDIR) -p $(CLASSDESTDIR)
@if [ `$(CAT) $(JAVA_SOURCE_LIST) | $(WC) -l` -ge 1 ] ; then \ @$(RM) $<.filtered
$(ECHO) "# Java sources to be compiled: (listed in file $(JAVA_SOURCE_LIST))"; \ @$(CAT) $< | $(NAWK) 'length>0' | $(SORT) -u > $<.filtered
$(CAT) $(JAVA_SOURCE_LIST); \ @if [ `$(CAT) $<.filtered | $(WC) -l` -ge 1 ] ; then \
$(ECHO) "# Java sources to be compiled: (listed in file $<)"; \
$(CAT) $<.filtered; \
$(ECHO) "# Running javac:"; \ $(ECHO) "# Running javac:"; \
$(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
$(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$(JAVA_SOURCE_LIST); \ $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
fi fi
@$(java-vm-cleanup) @$(java-vm-cleanup)
......
...@@ -45,10 +45,8 @@ ifeq ($(PLATFORM), windows) ...@@ -45,10 +45,8 @@ ifeq ($(PLATFORM), windows)
NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo
ifeq ($(ARCH_DATA_MODEL), 32) ifeq ($(ARCH_DATA_MODEL), 32)
CC_VER = UNKNOWN CC_VER = UNKNOWN
CC_TYPE = UNKNOWN
else else
CC_VER = UNKNOWN CC_VER = UNKNOWN
CC_TYPE = UNKNOWN
endif endif
_LINK_VER :=$(shell $(LINK) 2>&1 | $(HEAD) -n 1) _LINK_VER :=$(shell $(LINK) 2>&1 | $(HEAD) -n 1)
LINK_VER :=$(call GetVersion,"$(_LINK_VER)") LINK_VER :=$(call GetVersion,"$(_LINK_VER)")
......
...@@ -47,13 +47,13 @@ ifeq ($(PLATFORM), windows) ...@@ -47,13 +47,13 @@ ifeq ($(PLATFORM), windows)
# unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake # unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake
NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo
# Compiler version and type (Always get word after "Version")
CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}')
# SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure... # SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure...
ifeq ($(ARCH_DATA_MODEL), 32) ifeq ($(ARCH_DATA_MODEL), 32)
CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$8}')
LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
CC_TYPE := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$5}')
CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
REQUIRED_CCTYPE = Optimizing
REQUIRED_CC_VER = 13.10.3077 REQUIRED_CC_VER = 13.10.3077
REQUIRED_LINK_VER = 7.10.3077 REQUIRED_LINK_VER = 7.10.3077
ifeq ($(CC_MAJORVER), 12) ifeq ($(CC_MAJORVER), 12)
...@@ -85,9 +85,7 @@ ifeq ($(PLATFORM), windows) ...@@ -85,9 +85,7 @@ ifeq ($(PLATFORM), windows)
endif endif
endif endif
else else
CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$7}')
LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}') LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
CC_TYPE := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$4}')
CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
CC_MINORVER :=$(call MinorVersion,$(CC_VER)) CC_MINORVER :=$(call MinorVersion,$(CC_VER))
CC_MICROVER :=$(call MicroVersion,$(CC_VER)) CC_MICROVER :=$(call MicroVersion,$(CC_VER))
......
...@@ -69,9 +69,8 @@ endif ...@@ -69,9 +69,8 @@ endif
# Get shared platform settings # Get shared platform settings
include $(JDK_MAKE_SHARED_DIR)/Platform.gmk include $(JDK_MAKE_SHARED_DIR)/Platform.gmk
# Default output directory # Default directory immediately above the "build" output directory (OUTPUTDIR)
BUILD_PARENT_DIRECTORY=$(TOPDIR) BUILD_PARENT_DIRECTORY=$(TOPDIR)
_OUTPUTDIR=$(TOPDIR)/build/$(PLATFORM)-$(ARCH)
# Get platform specific settings # Get platform specific settings
include $(JDK_MAKE_SHARED_DIR)/Defs.gmk include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
......
...@@ -67,16 +67,6 @@ ifeq ($(PLATFORM),windows) ...@@ -67,16 +67,6 @@ ifeq ($(PLATFORM),windows)
UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH) UTILS_DEVTOOL_PATH=$(DEVTOOLS_PATH)
endif endif
# Utilities ant and findbugs
ifndef ANT_HOME
ANT_HOME = $(JDK_DEVTOOLS_DIR)/share/ant/latest
endif
ANT = $(ANT_HOME)/bin/ant
ifndef FINDBUGS_HOME
FINDBUGS_HOME = $(JDK_DEVTOOLS_DIR)/share/findbugs/latest
endif
FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs
# Utilities # Utilities
ADB = $(UTILS_COMMAND_PATH)adb ADB = $(UTILS_COMMAND_PATH)adb
AR = $(UTILS_CCS_BIN_PATH)ar AR = $(UTILS_CCS_BIN_PATH)ar
......
# #
# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -265,7 +265,9 @@ ifdef BUILD_NUMBER ...@@ -265,7 +265,9 @@ ifdef BUILD_NUMBER
FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER) FULL_VERSION = $(RELEASE)-$(BUILD_NUMBER)
else else
BUILD_NUMBER = b00 BUILD_NUMBER = b00
USER_RELEASE_SUFFIX := $(shell echo $(USER)_`date '+%d_%b_%Y_%H_%M' | tr "A-Z" "a-z"`) BUILD_DATE := $(shell $(DATE) '+%Y_%m_%d_%H_%M')
CLEAN_USERNAME := $(shell $(ECHO) "$(USER)" | $(TR) -d -c '[:alnum:]')
USER_RELEASE_SUFFIX := $(shell $(ECHO) "$(CLEAN_USERNAME)_$(BUILD_DATE)" | $(TR) '[:upper:]' '[:lower:]' )
FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER) FULL_VERSION = $(RELEASE)-$(USER_RELEASE_SUFFIX)-$(BUILD_NUMBER)
endif endif
...@@ -449,11 +451,20 @@ endif ...@@ -449,11 +451,20 @@ endif
# Check for spaces and null value # Check for spaces and null value
OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR) OUTPUTDIR:=$(call AltCheckSpaces,OUTPUTDIR)
OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR) OUTPUTDIR:=$(call AltCheckValue,OUTPUTDIR)
#
# When signing the JCE framework and provider, we could be using built
# bits on a read-only filesystem. If so, this test will fail and crash
# the build.
#
ifndef IGNORE_WRITABLE_OUTPUTDIR_TEST
# Create the output directory and make sure it exists and is writable # Create the output directory and make sure it exists and is writable
_create_outputdir:=$(shell $(MKDIR) -p "$(OUTPUTDIR)" > $(DEV_NULL) 2>&1) _create_outputdir:=$(shell $(MKDIR) -p "$(OUTPUTDIR)" > $(DEV_NULL) 2>&1)
ifeq ($(call WriteDirExists,$(OUTPUTDIR),/dev/null),/dev/null) ifeq ($(call WriteDirExists,$(OUTPUTDIR),/dev/null),/dev/null)
_outputdir_error:=$(error "ERROR: OUTPUTDIR '$(OUTPUTDIR)' not created or not writable") _outputdir_error:=$(error "ERROR: OUTPUTDIR '$(OUTPUTDIR)' not created or not writable")
endif endif
endif
# Define absolute path if needed and check for spaces and null value # Define absolute path if needed and check for spaces and null value
ifndef ABS_OUTPUTDIR ifndef ABS_OUTPUTDIR
ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR)) ABS_OUTPUTDIR:=$(call FullPath,$(OUTPUTDIR))
...@@ -503,6 +514,24 @@ JDK_CUPS_HEADERS_PATH=$(JDK_DEVTOOLS_DIR)/share/cups/include ...@@ -503,6 +514,24 @@ JDK_CUPS_HEADERS_PATH=$(JDK_DEVTOOLS_DIR)/share/cups/include
endif endif
endif endif
# Utilities ant and findbugs
ifeq ($(ANT_HOME),)
ANT_HOME := $(call DirExists,/usr/share/ant,$(JDK_DEVTOOLS_DIR)/share/ant/latest,)
endif
ifeq ($(ANT_HOME),)
ANT = ant
else
ANT = $(ANT_HOME)/bin/ant
endif
ifeq ($(FINDBUGS_HOME),)
FINDBUGS_HOME := $(call DirExists,/usr/share/findbugs,$(JDK_DEVTOOLS_DIR)/share/findbugs/latest,)
endif
ifeq ($(FINDBUGS_HOME),)
FINDBUGS = findbugs
else
FINDBUGS = $(FINDBUGS_HOME)/bin/findbugs
endif
ifdef ALT_COPYRIGHT_YEAR ifdef ALT_COPYRIGHT_YEAR
COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR) COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR)
else else
......
...@@ -270,7 +270,7 @@ ifeq ($(SYSTEM_UNAME), Linux) ...@@ -270,7 +270,7 @@ ifeq ($(SYSTEM_UNAME), Linux)
REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]* REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]*
endif endif
# How much RAM does this machine have: # How much RAM does this machine have:
MB_OF_MEMORY := $(shell free -m | fgrep Mem: | sed -e 's@\ \ *@ @g' | cut -d' ' -f2) MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
endif endif
# Windows with and without CYGWIN will be slightly different # Windows with and without CYGWIN will be slightly different
...@@ -374,45 +374,35 @@ ifeq ($(PLATFORM), windows) ...@@ -374,45 +374,35 @@ ifeq ($(PLATFORM), windows)
REQUIRED_DXSDK_VER = 0x0700 REQUIRED_DXSDK_VER = 0x0700
OS_VENDOR = Microsoft OS_VENDOR = Microsoft
# How much RAM does this machine have: # How much RAM does this machine have:
MB_OF_MEMORY := $(shell \ ifeq ($(USING_CYGWIN),true)
if [ -f "C:/cygwin/bin/free.exe" ] ; then \ # CYGWIN has the 'free' utility
( C:/cygwin/bin/bash.exe -c "C:/cygwin/bin/free.exe -m" ) | \ _MB_OF_MEMORY := \
grep Mem: | \ $(shell free -m | grep Mem: | awk '{print $$2;}' )
sed -e 's@\ \ *@ @g' | cut -d' ' -f2 ; \ else
else \ # Windows 2000 has the mem utility, but two memory areas
echo "512"; \ # extended memory is what is beyond 1024M
fi) _B_OF_EXT_MEMORY := \
endif $(shell mem 2> $(DEV_NULL) | grep 'total contiguous extended memory' | awk '{print $$1;}')
ifeq ($(_B_OF_EXT_MEMORY),)
# Machines with 512Mb or less of real memory are considered low memory _B_OF_MEMORY := \
# build machines and adjustments will be made to prevent excessing $(shell mem 2> $(DEV_NULL) | grep 'total conventional memory' | awk '{print $$1;}')
# system swapping during the build. else
# If we don't know, assume 512. Subtract 128 from MB for VM MAX. _B_OF_MEMORY := \
# Don't set VM max over 1024-128=896. $(shell expr 1048576 '+' $(_B_OF_EXT_MEMORY) 2> $(DEV_NULL))
ifneq ($(MB_OF_MEMORY),) endif
LOW_MEMORY_MACHINE := $(shell \ ifeq ($(_B_OF_MEMORY),)
if [ $(MB_OF_MEMORY) -le 512 ] ; then \ # Windows 2003 has the systeminfo utility use it if mem doesn't work
echo "true"; \ _MB_OF_MEMORY := \
else \ $(shell systeminfo 2> $(DEV_NULL) | grep 'Total Physical Memory:' | awk '{print $$4;}' | sed -e 's@,@@')
echo "false"; \ else
fi) _MB_OF_MEMORY := $(shell expr $(_B_OF_MEMORY) '/' 1024 2> $(DEV_NULL))
MAX_VM_MEMORY := $(shell \ endif
if [ $(MB_OF_MEMORY) -le 1024 ] ; then \ endif
expr $(MB_OF_MEMORY) '-' 128 ; \ ifeq ($(shell expr $(_MB_OF_MEMORY) '+' 0 2> $(DEV_NULL)), $(_MB_OF_MEMORY))
else \ MB_OF_MEMORY := $(_MB_OF_MEMORY)
echo "896"; \ else
fi) MB_OF_MEMORY := 512
MIN_VM_MEMORY := $(shell \ endif
if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
expr $(MAX_VM_MEMORY) '-' 8 ; \
else \
echo "128"; \
fi)
else
MB_OF_MEMORY := unknown
LOW_MEMORY_MACHINE := true
MAX_VM_MEMORY := 384
MIN_VM_MEMORY := 128
endif endif
REQUIRED_ZIP_VER = 2.2 REQUIRED_ZIP_VER = 2.2
...@@ -452,6 +442,37 @@ ifneq ($(PLATFORM), windows) ...@@ -452,6 +442,37 @@ ifneq ($(PLATFORM), windows)
ARCH_VM_SUBDIR=jre/lib/$(LIBARCH) ARCH_VM_SUBDIR=jre/lib/$(LIBARCH)
endif endif
# Machines with 512Mb or less of real memory are considered low memory
# build machines and adjustments will be made to prevent excessing
# system swapping during the build.
# If we don't know, assume 512. Subtract 128 from MB for VM MAX.
# Don't set VM max over 1024-128=896.
ifneq ($(MB_OF_MEMORY),)
LOW_MEMORY_MACHINE := $(shell \
if [ $(MB_OF_MEMORY) -le 512 ] ; then \
echo "true"; \
else \
echo "false"; \
fi)
MAX_VM_MEMORY := $(shell \
if [ $(MB_OF_MEMORY) -le 1024 ] ; then \
expr $(MB_OF_MEMORY) '-' 128 2> $(DEV_NULL) ; \
else \
echo "896"; \
fi)
MIN_VM_MEMORY := $(shell \
if [ $(MAX_VM_MEMORY) -le 128 ] ; then \
expr $(MAX_VM_MEMORY) '-' 8 2> $(DEV_NULL) ; \
else \
echo "128"; \
fi)
else
MB_OF_MEMORY := unknown
LOW_MEMORY_MACHINE := true
MAX_VM_MEMORY := 384
MIN_VM_MEMORY := 128
endif
# If blanks in the username, use the first 4 words and pack them together # If blanks in the username, use the first 4 words and pack them together
_USER1:=$(subst ', ,$(_USER)) _USER1:=$(subst ', ,$(_USER))
_USER2:=$(subst ", ,$(_USER1)) _USER2:=$(subst ", ,$(_USER1))
......
...@@ -106,12 +106,20 @@ UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)") ...@@ -106,12 +106,20 @@ UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)")
BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)") BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)")
REQUIRED_ANT_VER := 1.6.3 REQUIRED_ANT_VER := 1.6.3
_ANT_VER :=$(shell $(ANT) -version 2>&1 ) ifeq ($(ANT_HOME),)
ANT_VER :=$(call GetVersion,"$(_ANT_VER)") _ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" $(ANT) -version 2>&1 )
else
_ANT_VER:=$(shell JAVACMD="$(BOOTDIR)/bin/java" ANT_HOME="$(ANT_HOME)" $(ANT) -version 2>&1 )
endif
ANT_VER:=$(call GetVersion,"$(_ANT_VER)")
REQUIRED_FINDBUGS_VER := 1.1 REQUIRED_FINDBUGS_VER := 1.2
_FINDBUGS_VER :=$(shell $(FINDBUGS) -version 2>&1 ) ifeq ($(FINDBUGS_HOME),)
FINDBUGS_VER :=$(call GetVersion,"$(_FINDBUGS_VER)") _FINDBUGS_VER:=$(shell $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 )
else
_FINDBUGS_VER:=$(shell FINDBUGS_HOME="$(FINDBUGS_HOME)" $(FINDBUGS) -javahome "$(BOOTDIR)" -textui -version 2>&1 )
endif
FINDBUGS_VER:=$(call GetVersion,"$(_FINDBUGS_VER)")
ifdef ALT_BINDIR ifdef ALT_BINDIR
ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1 | $(NAWK) -F'"' '{ print $$2 }') ALT_BINDIR_VERSION := $(shell $(ALT_BINDIR)/java$(EXE_SUFFIX) -version 2>&1 | $(NAWK) -F'"' '{ print $$2 }')
...@@ -780,21 +788,17 @@ sane-cacerts: ...@@ -780,21 +788,17 @@ sane-cacerts:
ifdef OPENJDK ifdef OPENJDK
#name of test program that prints out "Failed" if freetype is not good enough # The freetypecheck Makefile prints out "Failed" if not good enough
FREETYPE_VERSION_CHECK_NAME = freetype_versioncheck $(TEMPDIR)/freetypeinfo: FRC
FREETYPE_VERSION_CHECK = $(TEMPDIR)/$(FREETYPE_VERSION_CHECK_NAME)$(EXE_SUFFIX) @$(prep-target)
@(($(CD) $(BUILDDIR)/tools/freetypecheck && $(MAKE)) || \
$(ECHO) "Failed to build freetypecheck." ) > $@
sane-freetype: sane-freetype: $(TEMPDIR)/freetypeinfo
@-($(CD) $(BUILDDIR)/tools/freetypecheck && \ @if [ "`$(CAT) $< | $(GREP) Fail`" != "" ]; then \
$(MAKE) REQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION) \
FT_TEST=$(FREETYPE_VERSION_CHECK_NAME) \
FT_HEADERS=$(FREETYPE_HEADERS_PATH) \
FT_LIB=$(FREETYPE_LIB_PATH) \
XARCH=$(XARCH))
@if [ ! -r $(FREETYPE_VERSION_CHECK) -o \
"`$(FREETYPE_VERSION_CHECK) | $(GREP) Fail`" != "" ]; then \
$(ECHO) "ERROR: FreeType version " $(REQUIRED_FREETYPE_VERSION) \ $(ECHO) "ERROR: FreeType version " $(REQUIRED_FREETYPE_VERSION) \
"or higher is required. \n" >> $(ERROR_FILE) ; \ " or higher is required. \n" \
"`$(CAT) $<` \n" >> $(ERROR_FILE) ; \
fi fi
else else
...@@ -1331,7 +1335,7 @@ sane-compiler: sane-link ...@@ -1331,7 +1335,7 @@ sane-compiler: sane-link
ifndef OPENJDK ifndef OPENJDK
@if [ "$(CC_CHECK)" != "same" ]; then \ @if [ "$(CC_CHECK)" != "same" ]; then \
$(ECHO) "WARNING: The $(PLATFORM) compiler is not version $(COMPILER_VERSION) $(REQUIRED_CC_VER) \n" \ $(ECHO) "WARNING: The $(PLATFORM) compiler is not version $(COMPILER_VERSION) $(REQUIRED_CC_VER) \n" \
" Specifically the $(COMPILER_NAME) $(CC_TYPE) compiler. \n " \ " Specifically the $(COMPILER_NAME) compiler. \n " \
" $(YOU_ARE_USING) compiler version: $(CC_VER) \n" \ " $(YOU_ARE_USING) compiler version: $(CC_VER) \n" \
" The compiler was obtained from the following location: \n" \ " The compiler was obtained from the following location: \n" \
" $(COMPILER_PATH) \n" \ " $(COMPILER_PATH) \n" \
......
...@@ -272,6 +272,28 @@ SMARTCARDIO_DOCTITLE = "Java$(TRADEMARK) Smart Card I/O" ...@@ -272,6 +272,28 @@ SMARTCARDIO_DOCTITLE = "Java$(TRADEMARK) Smart Card I/O"
SMARTCARDIO_JAVADOCHEADER = "Java Smart Card I/O" SMARTCARDIO_JAVADOCHEADER = "Java Smart Card I/O"
# SMARTCARDIO_PKGS is located in NON_CORE_PKGS.gmk # SMARTCARDIO_PKGS is located in NON_CORE_PKGS.gmk
#
# Variables used by TRACING target
#
TRACING_SOURCEPATH = $(TOPDIR)/src/share/classes
TRACING_DOCDIR = $(DOCSDIR)/jre/api/tracing
TRACING_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-encoding ascii \
-nodeprecatedlist \
-d $(TRACING_DOCDIR) \
-sourcepath $(TRACING_SOURCEPATH) \
-windowtitle $(TRACING_WINDOWTITLE) \
-doctitle $(TRACING_DOCTITLE) \
-header $(TRACING_JAVADOCHEADER) \
-linkoffline ../../../../../api $(DOCSDIR)/api/
TRACING_WINDOWTITLE = "Tracing"
TRACING_DOCTITLE = "Java$(TRADEMARK) Platform Tracing"
TRACING_JAVADOCHEADER = "Platform Tracing"
# TRACING_PKGS is located in NON_CORE_PKGS.gmk
# #
# Variables used by HTTPSERVER target # Variables used by HTTPSERVER target
# #
...@@ -420,6 +442,7 @@ ALL_OTHER_TARGETS = \ ...@@ -420,6 +442,7 @@ ALL_OTHER_TARGETS = \
jaasdocs \ jaasdocs \
jgssdocs \ jgssdocs \
smartcardiodocs \ smartcardiodocs \
tracingdocs \
httpserverdocs \ httpserverdocs \
mgmtdocs \ mgmtdocs \
attachdocs \ attachdocs \
...@@ -585,6 +608,14 @@ smartcardiodocs: ...@@ -585,6 +608,14 @@ smartcardiodocs:
$(JAVADOC_CMD) $(SMARTCARDIO_JAVADOCFLAGS) \ $(JAVADOC_CMD) $(SMARTCARDIO_JAVADOCFLAGS) \
$(SMARTCARDIO_PKGS) $(SMARTCARDIO_PKGS)
.PHONY: tracingdocs
tracingdocs:
@# ######## api-tracing ############################
$(RM) -r $(TRACING_DOCDIR)
$(MKDIR) -p $(TRACING_DOCDIR)
$(JAVADOC) $(TRACING_JAVADOCFLAGS) \
$(TRACING_PKGS)
.PHONY: httpserverdocs .PHONY: httpserverdocs
httpserverdocs: httpserverdocs:
@# ######## api-httpserver ####################### @# ######## api-httpserver #######################
......
...@@ -84,6 +84,9 @@ TREEAPI_PKGS = com.sun.source.tree \ ...@@ -84,6 +84,9 @@ TREEAPI_PKGS = com.sun.source.tree \
SMARTCARDIO_PKGS = javax.smartcardio SMARTCARDIO_PKGS = javax.smartcardio
TRACING_PKGS = com.sun.tracing \
com.sun.tracing.dtrace
# non-core packages in rt.jar # non-core packages in rt.jar
NON_CORE_PKGS = $(DOMAPI_PKGS) \ NON_CORE_PKGS = $(DOMAPI_PKGS) \
$(MGMT_PKGS) \ $(MGMT_PKGS) \
...@@ -91,4 +94,5 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \ ...@@ -91,4 +94,5 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \
$(JGSS_PKGS) \ $(JGSS_PKGS) \
$(OLD_JSSE_PKGS) \ $(OLD_JSSE_PKGS) \
$(HTTPSERVER_PKGS) \ $(HTTPSERVER_PKGS) \
$(SMARTCARDIO_PKGS) $(SMARTCARDIO_PKGS) \
$(TRACING_PKGS)
...@@ -80,7 +80,8 @@ $(LocaleDataMetaInfo_Dest):$(LocaleDataMetaInfo_Src) $(LOCALEGEN_SH) ...@@ -80,7 +80,8 @@ $(LocaleDataMetaInfo_Dest):$(LocaleDataMetaInfo_Src) $(LOCALEGEN_SH)
@$(ECHO) $(subst .java,'\n',$(Euro_Resources_java)) >> $@.tmp.euro; @$(ECHO) $(subst .java,'\n',$(Euro_Resources_java)) >> $@.tmp.euro;
@$(ECHO) $(subst .properties,'\n',$(NonEuro_Resources_properties)) > $@.tmp.noneuro; @$(ECHO) $(subst .properties,'\n',$(NonEuro_Resources_properties)) > $@.tmp.noneuro;
@$(ECHO) $(subst .java,'\n',$(NonEuro_Resources_java)) >> $@.tmp.noneuro; @$(ECHO) $(subst .java,'\n',$(NonEuro_Resources_java)) >> $@.tmp.noneuro;
NAWK=$(NAWK) SED=$(SED) $(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.euro \ NAWK="$(NAWK)" SED="$(SED)" SORT="$(SORT)" \
$(SH) $(LOCALEGEN_SH) $(RESOURCE_NAMES) $@.tmp.euro \
$@.tmp.noneuro $< $@ $@.tmp.noneuro $< $@
@$(RM) $@.tmp.euro $@.tmp.noneuro; @$(RM) $@.tmp.euro $@.tmp.noneuro;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
# This script is to generate the supported locale list string and replace the # This script is to generate the supported locale list string and replace the
# LocaleDataMetaInfo-XLocales.java in <ws>/src/share/classes/sun/util # LocaleDataMetaInfo-XLocales.java in <ws>/src/share/classes/sun/util
# #
# NAWK & SED is passed in as environment variables. # SORT, NAWK & SED is passed in as environment variables.
# #
# A list of resource base name list; # A list of resource base name list;
...@@ -47,7 +47,7 @@ OUTPUT_FILE=$5 ...@@ -47,7 +47,7 @@ OUTPUT_FILE=$5
localelist= localelist=
getlocalelist() { getlocalelist() {
localelist="" localelist=""
localelist=`$NAWK -F$1_ '{print $2}' $2 | sort` localelist=`$NAWK -F$1_ '{print $2}' $2 | $SORT`
} }
sed_script="$SED -e \"s@^#warn .*@// -- This file was mechanically generated: Do not edit! -- //@\" " sed_script="$SED -e \"s@^#warn .*@// -- This file was mechanically generated: Do not edit! -- //@\" "
......
...@@ -33,6 +33,7 @@ FILES_java = \ ...@@ -33,6 +33,7 @@ FILES_java = \
sun/nio/cs/AbstractCharsetProvider.java \ sun/nio/cs/AbstractCharsetProvider.java \
sun/nio/cs/HistoricallyNamedCharset.java \ sun/nio/cs/HistoricallyNamedCharset.java \
sun/nio/cs/Surrogate.java \ sun/nio/cs/Surrogate.java \
sun/nio/cs/CharsetMapping.java \
sun/nio/cs/SingleByteEncoder.java \ sun/nio/cs/SingleByteEncoder.java \
sun/nio/cs/SingleByteDecoder.java \ sun/nio/cs/SingleByteDecoder.java \
sun/nio/cs/UnicodeEncoder.java \ sun/nio/cs/UnicodeEncoder.java \
......
...@@ -30,24 +30,10 @@ ...@@ -30,24 +30,10 @@
BUILDDIR = .. BUILDDIR = ..
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = \
javax/naming \
com/sun/naming/internal \
javax/net \
javax/script \
javax/security/auth \
javax/security/cert \
javax/security/sasl \
javax/smartcardio \
javax/tools \
javax/xml
# imageio uses xml, so build it last # imageio uses xml, so build it last
SUBDIRS = \ SUBDIRS = \
others \
accessibility \ accessibility \
print \ print \
swing \ swing \
...@@ -63,8 +49,3 @@ all build: ...@@ -63,8 +49,3 @@ all build:
clean clobber:: clean clobber::
$(SUBDIRS-loop) $(SUBDIRS-loop)
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
# #
# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -31,7 +31,7 @@ include $(BUILDDIR)/common/Release.gmk ...@@ -31,7 +31,7 @@ include $(BUILDDIR)/common/Release.gmk
JCE_MANIFEST_FILE = $(TEMPDIR)/manifest.mf JCE_MANIFEST_FILE = $(TEMPDIR)/manifest.mf
$(JCE_MANIFEST_FILE): $(MAINMANIFEST) $(JCE_MANIFEST_FILE): $(MAINMANIFEST)
$(prep-target) $(prep-target)
( $(SED) "s/@@RELEASE@@/$(RELEASE)/" $(MAINMANIFEST); \ ( $(SED) "s/@@RELEASE@@/$(RELEASE)/" $<; \
$(ECHO) "Extension-Name: javax.crypto"; \ $(ECHO) "Extension-Name: javax.crypto"; \
$(ECHO) "Implementation-Vendor-Id: com.sun"; ) > $@ $(ECHO) "Implementation-Vendor-Id: com.sun"; ) > $@
...@@ -75,6 +75,7 @@ endef ...@@ -75,6 +75,7 @@ endef
define sign-target define sign-target
$(BOOT_JARSIGNER_CMD) -keystore $(SIGNING_KEYSTORE) \ $(BOOT_JARSIGNER_CMD) -keystore $(SIGNING_KEYSTORE) \
$@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE) $@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE)
@$(java-vm-cleanup)
@$(ECHO) "\nJar codesigning finished." @$(ECHO) "\nJar codesigning finished."
endef endef
...@@ -88,13 +89,15 @@ define release-warning ...@@ -88,13 +89,15 @@ define release-warning
endef endef
# #
# Convenience macro for steps needed to sign a jar file. # Convenience macros for signing a jar file.
#
# Call through $(call sign-file, target file)
# #
define sign-file define sign-file
$(presign) $(presign)
$(install-file) $(prep-target)
$(CP) $1 $@
$(sign-target) $(sign-target)
@$(java-vm-cleanup)
endef endef
# #
......
# #
# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
# sign-jar Builds/signs jce.jar file (no install) # sign-jar Builds/signs jce.jar file (no install)
# sign-policy Builds/signs policy files (no install) # sign-policy Builds/signs policy files (no install)
# #
# obfus Builds/obfuscates/signs/installs jce.jar # obfus Builds/obfuscates/signs jce.jar
# #
# release Builds all targets in preparation # release Builds all targets in preparation
# for workspace integration. # for workspace integration.
...@@ -110,8 +110,24 @@ BUILDDIR = ../.. ...@@ -110,8 +110,24 @@ BUILDDIR = ../..
PACKAGE = javax.crypto PACKAGE = javax.crypto
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include Defs-jce.gmk
# #
# Location for the newly built classfiles. # Location for the newly built classfiles.
...@@ -158,6 +174,8 @@ endif # OPENJDK ...@@ -158,6 +174,8 @@ endif # OPENJDK
# #
UNSIGNED_DIR = $(TEMPDIR)/unsigned UNSIGNED_DIR = $(TEMPDIR)/unsigned
include Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned jce.jar file. Signing/obfuscation comes later. # Build the unsigned jce.jar file. Signing/obfuscation comes later.
...@@ -299,7 +317,7 @@ ifndef OPENJDK ...@@ -299,7 +317,7 @@ ifndef OPENJDK
# Sign the various jar files. Not needed for OpenJDK. # Sign the various jar files. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
SIGNED_POLICY_BUILDDIR = $(SIGNED_DIR)/policy SIGNED_POLICY_BUILDDIR = $(SIGNED_DIR)/policy
SIGNED_POLICY_FILES = \ SIGNED_POLICY_FILES = \
...@@ -312,61 +330,87 @@ sign-jar: $(SIGNED_DIR)/jce.jar ...@@ -312,61 +330,87 @@ sign-jar: $(SIGNED_DIR)/jce.jar
sign-policy: $(SIGNED_POLICY_FILES) sign-policy: $(SIGNED_POLICY_FILES)
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/jce.jar: $(UNSIGNED_DIR)/jce.jar $(SIGNED_DIR)/jce.jar: $(UNSIGNED_DIR)/jce.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/jce.jar:
@if [ ! -r $(UNSIGNED_DIR)/jce.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/jce.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/jce.jar)
$(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar
$(sign-file) $(call sign-file, $<)
$(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar
$(sign-file) $(call sign-file, $<)
$(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar
$(sign-file) $(call sign-file, $<)
$(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \ $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar: \
$(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar $(UNSIGNED_POLICY_BUILDDIR)/limited/local_policy.jar
$(sign-file) $(call sign-file, $<)
# ===================================================== # =====================================================
# Obfuscate/sign/install the JDK build. Not needed for OpenJDK. # Obfuscate/sign/install the JDK build. Not needed for OpenJDK.
# #
OBFUS_DIR = $(TEMPDIR)/obfus OBFUS_DIR = $(JCE_BUILD_DIR)/obfus/jce
CLOSED_DIR = $(BUILDDIR)/closed/javax/crypto CLOSED_DIR = $(BUILDDIR)/closed/javax/crypto
obfus: $(OBFUS_DIR)/jce.jar obfus: $(OBFUS_DIR)/jce.jar
$(release-warning) $(release-warning)
$(OBFUS_DIR)/jce.jar: build-jar $(JCE_MANIFEST_FILE) ifndef ALT_JCE_BUILD_DIR
$(OBFUS_DIR)/jce.jar: build-jar $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/framework.dox
else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(OBFUS_DIR)/jce.jar: $(JCE_MANIFEST_FILE) $(OBFUS_DIR)/framework.dox
@if [ ! -d $(CLASSDESTDIR) ] ; then \
$(ECHO) "Couldn't find $(CLASSDESTDIR)"; \
exit 1; \
fi
endif
@$(ECHO) ">>>Obfuscating JCE framework..."
$(presign) $(presign)
$(preobfus) $(preobfus)
@$(ECHO) ">>>Obfuscating JCE framework..."
$(prep-target) $(prep-target)
$(CD) $(OBFUS_DIR); \ $(CD) $(OBFUS_DIR); \
$(OBFUSCATOR) -fv \ $(OBFUSCATOR) -fv framework.dox
$(CURRENT_DIRECTORY)/$(CLOSED_DIR)/obfus/framework.dox
@$(CD) $(OBFUS_DIR); $(java-vm-cleanup) @$(CD) $(OBFUS_DIR); $(java-vm-cleanup)
@#
@# The sun.security.internal classes are currently not obfuscated @# The sun.security.internal classes are currently not obfuscated
@# due to an obfus problem. Manually copy them to the build directory @# due to an obfus problem. Manually copy them to the build directory
@# so that they are included in the jce.jar file. @# so that they are included in the jce.jar file.
@#
$(CP) -r $(CLASSDESTDIR)/sun $(OBFUS_DIR)/build $(CP) -r $(CLASSDESTDIR)/sun $(OBFUS_DIR)/build
$(RM) $(UNSIGNED_DIR)/jce.jar
$(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \ $(BOOT_JAR_CMD) cmf $(JCE_MANIFEST_FILE) $@ \
-C $(OBFUS_DIR)/build javax \ -C $(OBFUS_DIR)/build javax \
-C $(OBFUS_DIR)/build sun \ -C $(OBFUS_DIR)/build sun \
$(JAR_JFLAGS) $(JAR_JFLAGS)
$(sign-target) $(sign-target)
$(MKDIR) -p $(dir $(JAR_DESTFILE))
$(RM) $(JAR_DESTFILE)
$(CP) $@ $(JAR_DESTFILE)
@$(java-vm-cleanup) @$(java-vm-cleanup)
$(OBFUS_DIR)/framework.dox: $(CLOSED_DIR)/obfus/framework.dox
@$(ECHO) ">>>Creating framework.dox"
$(prep-target)
$(SED) "s:@@TEMPDIR@@:$(ABS_TEMPDIR):" $< > $@
# #
# The current obfuscator has a limitation in that it currently only # The current obfuscator has a limitation in that it currently only
# supports up to v49 class file format. Force v49 classfiles in our # supports up to v49 class file format. Force v49 classfiles in our
...@@ -380,26 +424,27 @@ TARGET_CLASS_VERSION = 5 ...@@ -380,26 +424,27 @@ TARGET_CLASS_VERSION = 5
# unlimited policy file distribution, etc. # unlimited policy file distribution, etc.
# #
release: $(OBFUS_DIR)/jce.jar sign-policy release: $(OBFUS_DIR)/jce.jar sign-policy $(CLOSED_DIR)/doc/COPYRIGHT.html \
$(CLOSED_DIR)/doc/README.txt
$(RM) -r \ $(RM) -r \
$(RELEASE_DIR)/UnlimitedJCEPolicy \ $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy \
$(RELEASE_DIR)/jce.jar \ $(JCE_BUILD_DIR)/release/jce.jar \
$(RELEASE_DIR)/US_export_policy.jar \ $(JCE_BUILD_DIR)/release/US_export_policy.jar \
$(RELEASE_DIR)/local_policy.jar \ $(JCE_BUILD_DIR)/release/local_policy.jar \
$(RELEASE_DIR)/UnlimitedJCEPolicy.zip $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy.zip
$(MKDIR) -p $(RELEASE_DIR)/UnlimitedJCEPolicy $(MKDIR) -p $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy
$(CP) $(OBFUS_DIR)/jce.jar $(RELEASE_DIR) $(CP) $(OBFUS_DIR)/jce.jar $(JCE_BUILD_DIR)/release
$(CP) -r \ $(CP) \
$(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/limited/US_export_policy.jar \
$(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/limited/local_policy.jar \
$(RELEASE_DIR) $(JCE_BUILD_DIR)/release
$(CP) \ $(CP) \
$(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/unlimited/US_export_policy.jar \
$(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \ $(SIGNED_POLICY_BUILDDIR)/unlimited/local_policy.jar \
$(RELEASE_DIR)/UnlimitedJCEPolicy $(CLOSED_DIR)/doc/COPYRIGHT.html \
$(CP) $(CLOSED_DIR)/doc/COPYRIGHT.html \ $(CLOSED_DIR)/doc/README.txt \
$(CLOSED_DIR)/doc/README.txt $(RELEASE_DIR)/UnlimitedJCEPolicy $(JCE_BUILD_DIR)/release/UnlimitedJCEPolicy
cd $(RELEASE_DIR) ; \ cd $(JCE_BUILD_DIR)/release ; \
$(ZIPEXE) -qr UnlimitedJCEPolicy.zip UnlimitedJCEPolicy $(ZIPEXE) -qr UnlimitedJCEPolicy.zip UnlimitedJCEPolicy
$(release-warning) $(release-warning)
...@@ -478,7 +523,8 @@ endif ...@@ -478,7 +523,8 @@ endif
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(POLICY_DESTDIR)/US_export_policy.jar \ $(RM) -r $(JAR_DESTFILE) $(POLICY_DESTDIR)/US_export_policy.jar \
$(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) $(POLICY_DESTDIR)/local_policy.jar $(DELETE_DIRS) $(TEMPDIR) \
$(JCE_BUILD_DIR)
.PHONY: build-jar jar build-policy unlimited limited install-jar \ .PHONY: build-jar jar build-policy unlimited limited install-jar \
install-limited install-unlimited install-limited install-unlimited
......
#
# Copyright 1998-2007 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#
# Makefile for building javax (other classes)
#
BUILDDIR = ../..
include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = \
javax/naming \
com/sun/naming/internal \
javax/net \
javax/script \
javax/security/auth \
javax/security/cert \
javax/security/sasl \
javax/smartcardio \
javax/tools \
javax/xml
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
...@@ -63,7 +63,7 @@ SUBDIRS = jar security javazic misc net audio $(RENDER_SUBDIR) image \ ...@@ -63,7 +63,7 @@ SUBDIRS = jar security javazic misc net audio $(RENDER_SUBDIR) image \
$(HEADLESS_SUBDIR) $(DGA_SUBDIR) \ $(HEADLESS_SUBDIR) $(DGA_SUBDIR) \
font jpeg cmm applet rmi beans $(JDBC_SUBDIR) \ font jpeg cmm applet rmi beans $(JDBC_SUBDIR) \
jawt text nio launcher management $(ORG_SUBDIR) \ jawt text nio launcher management $(ORG_SUBDIR) \
native2ascii serialver tools jconsole native2ascii serialver tools jconsole tracing
all build clean clobber:: all build clean clobber::
$(SUBDIRS-loop) $(SUBDIRS-loop)
......
# #
# Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved. # Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -73,11 +73,21 @@ build: $(CHARSETS_JAR) ...@@ -73,11 +73,21 @@ build: $(CHARSETS_JAR)
SERVICE_DESCRIPTION = java.nio.charset.spi.CharsetProvider SERVICE_DESCRIPTION = java.nio.charset.spi.CharsetProvider
SERVICE_DESCRIPTION_PATH = META-INF/services/$(SERVICE_DESCRIPTION) SERVICE_DESCRIPTION_PATH = META-INF/services/$(SERVICE_DESCRIPTION)
GENCSDATASRC = $(BUILDDIR)/tools/CharsetMapping
FILES_MAP = $(GENCSDATASRC)/sjis0213.map
FILES_DAT = $(CLASSDESTDIR)/sun/nio/cs/ext/sjis0213.dat
CHARSETMAPPING_JARFILE = $(BUILDTOOLJARDIR)/charsetmapping.jar
$(FILES_DAT): $(FILES_MAP)
@$(prep-target)
$(BOOT_JAVA_CMD) -jar $(CHARSETMAPPING_JARFILE) \
$(FILES_MAP) $(FILES_DAT)
$(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \ $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH): \
$(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH) $(SHARE_SRC)/classes/sun/nio/cs/ext/$(SERVICE_DESCRIPTION_PATH)
$(install-file) $(install-file)
$(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(CHARSETS_JAR): $(FILES_class) $(CLASSDESTDIR)/$(SERVICE_DESCRIPTION_PATH) $(FILES_DAT)
$(BOOT_JAR_CMD) cf $(CHARSETS_JAR) \ $(BOOT_JAR_CMD) cf $(CHARSETS_JAR) \
-C $(CLASSDESTDIR) sun \ -C $(CLASSDESTDIR) sun \
-C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \ -C $(CLASSDESTDIR) $(SERVICE_DESCRIPTION_PATH) \
......
# #
# Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -92,8 +92,25 @@ BUILDDIR = ../../.. ...@@ -92,8 +92,25 @@ BUILDDIR = ../../..
PACKAGE = sun.security.mscapi PACKAGE = sun.security.mscapi
LIBRARY = sunmscapi LIBRARY = sunmscapi
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
CPLUSPLUSLIBRARY=true CPLUSPLUSLIBRARY=true
...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt ...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt
$(build-warning) $(build-warning)
endif endif
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned sunmscapi.jar file. # Build the unsigned sunmscapi.jar file.
...@@ -200,14 +219,26 @@ ifndef OPENJDK ...@@ -200,14 +219,26 @@ ifndef OPENJDK
# Sign the provider jar file. Not needed for OpenJDK. # Sign the provider jar file. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
sign: sign-jar sign: sign-jar
sign-jar: $(SIGNED_DIR)/sunmscapi.jar sign-jar: $(SIGNED_DIR)/sunmscapi.jar
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/sunmscapi.jar:
@if [ ! -r $(UNSIGNED_DIR)/sunmscapi.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunmscapi.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/sunmscapi.jar)
# ===================================================== # =====================================================
...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar ...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunmscapi.jar: $(UNSIGNED_DIR)/sunmscapi.jar
# #
release: $(SIGNED_DIR)/sunmscapi.jar release: $(SIGNED_DIR)/sunmscapi.jar
$(RM) $(RELEASE_DIR)/sunmscapi.jar $(RM) $(JCE_BUILD_DIR)/release/sunmscapi.jar
$(MKDIR) -p $(RELEASE_DIR) $(MKDIR) -p $(JCE_BUILD_DIR)/release
$(CP) $(SIGNED_DIR)/sunmscapi.jar $(RELEASE_DIR) $(CP) $(SIGNED_DIR)/sunmscapi.jar $(JCE_BUILD_DIR)/release
$(release-warning) $(release-warning)
endif # OPENJDK endif # OPENJDK
...@@ -255,7 +286,7 @@ endif ...@@ -255,7 +286,7 @@ endif
# #
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar .PHONY: build-jar jar install-jar
ifndef OPENJDK ifndef OPENJDK
......
# #
# Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -92,8 +92,25 @@ BUILDDIR = ../../.. ...@@ -92,8 +92,25 @@ BUILDDIR = ../../..
PACKAGE = sun.security.pkcs11 PACKAGE = sun.security.pkcs11
LIBRARY = j2pkcs11 LIBRARY = j2pkcs11
PRODUCT = sun PRODUCT = sun
#
# The following is for when we need to do postprocessing
# (signing/obfuscation) against a read-only build. If the OUTPUTDIR
# isn't writable, the build currently crashes out.
#
ifndef OPENJDK
ifdef ALT_JCE_BUILD_DIR
# =====================================================
# Where to place the output, in case we're building from a read-only
# build area. (e.g. a release engineering build.)
JCE_BUILD_DIR=${ALT_JCE_BUILD_DIR}
IGNORE_WRITABLE_OUTPUTDIR_TEST=true
else
JCE_BUILD_DIR=${TEMPDIR}
endif
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# #
# C and Java Files # C and Java Files
...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt ...@@ -163,6 +180,8 @@ all: build-jar install-prebuilt
$(build-warning) $(build-warning)
endif endif
include $(BUILDDIR)/javax/crypto/Defs-jce.gmk
# ===================================================== # =====================================================
# Build the unsigned sunpkcs11.jar file. # Build the unsigned sunpkcs11.jar file.
...@@ -200,14 +219,26 @@ ifndef OPENJDK ...@@ -200,14 +219,26 @@ ifndef OPENJDK
# Sign the provider jar file. Not needed for OpenJDK. # Sign the provider jar file. Not needed for OpenJDK.
# #
SIGNED_DIR = $(TEMPDIR)/signed SIGNED_DIR = $(JCE_BUILD_DIR)/signed
sign: sign-jar sign: sign-jar
sign-jar: $(SIGNED_DIR)/sunpkcs11.jar sign-jar: $(SIGNED_DIR)/sunpkcs11.jar
ifndef ALT_JCE_BUILD_DIR
$(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar
$(sign-file) else
#
# We have to remove the build dependency, otherwise, we'll try to rebuild it
# which we can't do on a read-only filesystem.
#
$(SIGNED_DIR)/sunpkcs11.jar:
@if [ ! -r $(UNSIGNED_DIR)/sunpkcs11.jar ] ; then \
$(ECHO) "Couldn't find $(UNSIGNED_DIR)/sunpkcs11.jar"; \
exit 1; \
fi
endif
$(call sign-file, $(UNSIGNED_DIR)/sunpkcs11.jar)
# ===================================================== # =====================================================
...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar ...@@ -215,9 +246,9 @@ $(SIGNED_DIR)/sunpkcs11.jar: $(UNSIGNED_DIR)/sunpkcs11.jar
# #
release: $(SIGNED_DIR)/sunpkcs11.jar release: $(SIGNED_DIR)/sunpkcs11.jar
$(RM) $(RELEASE_DIR)/sunpkcs11.jar $(RM) $(JCE_BUILD_DIR)/release/sunpkcs11.jar
$(MKDIR) -p $(RELEASE_DIR) $(MKDIR) -p $(JCE_BUILD_DIR)/release
$(CP) $(SIGNED_DIR)/sunpkcs11.jar $(RELEASE_DIR) $(CP) $(SIGNED_DIR)/sunpkcs11.jar $(JCE_BUILD_DIR)/release
$(release-warning) $(release-warning)
endif # OPENJDK endif # OPENJDK
...@@ -255,7 +286,7 @@ endif ...@@ -255,7 +286,7 @@ endif
# #
clobber clean:: clobber clean::
$(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(RM) -r $(JAR_DESTFILE) $(TEMPDIR) $(JCE_BUILD_DIR)
.PHONY: build-jar jar install-jar .PHONY: build-jar jar install-jar
ifndef OPENJDK ifndef OPENJDK
......
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
#
# Makefile for building tracing package implementation classes
#
BUILDDIR = ../..
PACKAGE = sun.tracing
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = dtrace
all build:
$(SUBDIRS-loop)
clean clobber::
$(SUBDIRS-loop)
AUTO_FILES_JAVA_DIRS = sun/tracing
#
# Rules.
#
include $(BUILDDIR)/common/Classes.gmk
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
#
# Makefile for building dtrace extension
#
BUILDDIR = ../../..
PACKAGE = sun.tracing.dtrace
LIBRARY = jsdt
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# Use mapfile
#
FILES_m = mapfile-vers
include $(BUILDDIR)/common/Mapfile-vers.gmk
NATIVE_DTRACE_DIR=native/sun/tracing/dtrace
SRCDIR=$(SHARE_SRC)/$(NATIVE_DTRACE_DIR)
PSRCDIR=$(PLATFORM_SRC)/$(NATIVE_DTRACE_DIR)
FILES_c = JVM.c jvm_symbols_md.c
FILES_java = \
sun/tracing/dtrace/Activation.java \
sun/tracing/dtrace/DTraceProvider.java \
sun/tracing/dtrace/DTraceProbe.java \
sun/tracing/dtrace/DTraceProviderFactory.java \
sun/tracing/dtrace/JVM.java
FILES_export = $(FILES_java)
ifeq ($(PLATFORM), linux)
OTHER_LDLIBS += -ldl
endif
#
# Use JNI for generating header files
#
JAVAHFLAGS += -jni
#
# Don't need to link against -ljava
#
JAVALIB=
#
# Rules.
#
include $(BUILDDIR)/common/Library.gmk
#
# Add to ambient vpath so we pick up the library files
#
vpath %.c $(SRCDIR):$(PSRCDIR)
#
#ident "@(#)mapfile-vers 1.1 07/08/14"
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
#
# Define library interface.
SUNWprivate_1.1 {
global:
Java_sun_tracing_dtrace_JVM_isSupported0;
Java_sun_tracing_dtrace_JVM_activate0;
Java_sun_tracing_dtrace_JVM_dispose0;
Java_sun_tracing_dtrace_JVM_isEnabled0;
Java_sun_tracing_dtrace_JVM_defineClass0;
local:
*;
};
#
# Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#
# Makefile for building the charsetmapping tool
#
BUILDDIR = ../..
PACKAGE = build.tools.charsetmapping
PRODUCT = tools
PROGRAM = charsetmapping
include $(BUILDDIR)/common/Defs.gmk
BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
BUILDTOOL_MAIN = $(PKGDIR)/GenerateMapping.java
#
# Build tool jar rules.
#
include $(BUILDDIR)/common/BuildToolJar.gmk
此差异已折叠。
...@@ -40,6 +40,7 @@ SUBDIRS = \ ...@@ -40,6 +40,7 @@ SUBDIRS = \
dir_diff \ dir_diff \
dtdbuilder \ dtdbuilder \
fontchecker \ fontchecker \
freetypecheck \
generate_break_iterator \ generate_break_iterator \
GenerateCharacter \ GenerateCharacter \
generatecurrencydata \ generatecurrencydata \
...@@ -50,7 +51,8 @@ SUBDIRS = \ ...@@ -50,7 +51,8 @@ SUBDIRS = \
jdwpgen \ jdwpgen \
makeclasslist \ makeclasslist \
strip_properties \ strip_properties \
winver winver \
CharsetMapping
all build clean clobber:: all build clean clobber::
$(SUBDIRS-loop) $(SUBDIRS-loop)
...@@ -58,4 +60,5 @@ all build clean clobber:: ...@@ -58,4 +60,5 @@ all build clean clobber::
clean clobber:: clean clobber::
$(RM) -r $(BUILDTOOLCLASSDIR) $(RM) -r $(BUILDTOOLCLASSDIR)
$(RM) -r $(BUILDTOOLJARDIR) $(RM) -r $(BUILDTOOLJARDIR)
$(RM) -r $(BUILDTOOLBINDIR)
...@@ -22,55 +22,58 @@ ...@@ -22,55 +22,58 @@
# CA 95054 USA or visit www.sun.com if you need additional information or # CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions. # have any questions.
# Builds test program for freetype sanity check. # Builds and runs test program for freetype sanity check.
#
# Makefile should be called with following input parameters
# FT_TEST - full name of test program
# FT_HEADERS - path to freetype headers
# FT_LIB - location of directory with library
# XARCH - xarch option if required
BUILDDIR = ../.. BUILDDIR = ../..
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
#test program is expected in the TEMPDIR # Default name
FT_TEST_PATH = $(TEMPDIR)/$(FT_TEST) FT_TEST = $(BUILDTOOLBINDIR)/freetype_versioncheck$(EXE_SUFFIX)
all: $(FT_TEST_PATH) # Used on openjdk only
ifeq ($(OPENJDK),true)
# Start with CFLAGS (which gets us the required -xarch setting on solaris) # Start with CFLAGS (which gets us the required -xarch setting on solaris)
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
FT_OPTIONS = FT_OPTIONS = /nologo $(CC_OBJECT_OUTPUT_FLAG)$(TEMPDIR)
FREETYPE_DLL = $(FREETYPE_LIB_PATH)/freetype.dll
FT_LD_OPTIONS = $(FREETYPE_LIB_PATH)/freetype.lib
else else
FT_OPTIONS = $(CFLAGS) FT_OPTIONS = $(CFLAGS)
endif FT_LD_OPTIONS = -L$(FREETYPE_LIB_PATH)
# Add runtime lib search path to ensure test will be runnable
FT_OPTIONS += -I$(FT_HEADERS) -I$(FT_HEADERS)/freetype2
FT_OPTIONS += $(XARCH)
#add runtime library search path
ifeq ($(PLATFORM), windows)
FREETYPE_LIB=$(FT_LIB)/freetype.lib
FREETYPE_DLL=$(FT_LIB)/freetype.dll
DFLAG=/D
else
FT_OPTIONS += -L$(FT_LIB)
DFLAG = -D
#add runtime lib search path to ensure test will be runnable
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
FT_OPTIONS += -R $(FT_LIB) -lfreetype FT_LD_OPTIONS += -R $(FREETYPE_LIB_PATH) -lfreetype
else #linux else #linux
FT_OPTIONS += -Wl,-rpath -Wl,$(FT_LIB) -lfreetype FT_LD_OPTIONS += -Wl,-rpath -Wl,$(FREETYPE_LIB_PATH) -lfreetype
endif endif
endif endif
FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH)
FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH)/freetype2
FT_OPTIONS += -DREQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION)
FT_LD_OPTIONS += $(LFLAGS_$(COMPILER_VERSION))
FT_OPTIONS += $(DFLAG)REQUIRED_FREETYPE_VERSION=$(REQUIRED_FREETYPE_VERSION) # Create test program
all: $(FT_TEST)
@$(FT_TEST)
# On windows we need to copy dll to test dir # On windows we need to copy dll to test dir to ensure it will be found
# ti ensure it will be found in runtime # at runtime
$(FT_TEST_PATH): freetypecheck.c $(FT_TEST): freetypecheck.c
@$(CC) $(FT_OPTIONS) $(CC_PROGRAM_OUTPUT_FLAG)$@ $< $(FREETYPE_LIB) $(LFLAGS_$(COMPILER_VERSION)) @$(prep-target)
@$(CC) $(FT_OPTIONS) $(CC_PROGRAM_OUTPUT_FLAG)$@ $< $(FT_LD_OPTIONS)
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
@$(CP) $(FREETYPE_DLL) `dirname $@` @$(CP) $(FREETYPE_DLL) `dirname $@`
endif endif
else
# Inform user this is openjdk only
all:
@$(ECHO) "The freetype files are only used with OpenJDK"
endif
clean::
$(RM) $(FT_TEST)
...@@ -26,13 +26,16 @@ ...@@ -26,13 +26,16 @@
/* Test program for freetype sanity check. /* Test program for freetype sanity check.
Prints "Failed" messages to STDOUT if check fails. */ Prints "Failed" messages to STDOUT if check fails. */
#include <stdio.h>
#include <string.h>
#include "ft2build.h" #include "ft2build.h"
#include FT_FREETYPE_H #include FT_FREETYPE_H
#define QUOTEMACRO(x) QUOTEME(x) #define QUOTEMACRO(x) QUOTEME(x)
#define QUOTEME(x) #x #define QUOTEME(x) #x
int main(char** argv, int argc) { int main(int argc, char** argv) {
char v[50]; char v[50];
FT_Int major, minor, patch; FT_Int major, minor, patch;
FT_Library library; FT_Library library;
......
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package build.tools.charsetmapping;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.*;
public class CharsetMapping {
public final static char UNMAPPABLE_DECODING = '\uFFFD';
public final static int UNMAPPABLE_ENCODING = -1;
public static class Entry {
public int bs; //byte sequence reps
public int cp; //Unicode codepoint
public int cp2; //CC of composite
public Entry () {}
public Entry (int bytes, int cp, int cp2) {
this.bs = bytes;
this.cp = cp;
this.cp2 = cp2;
}
}
static Comparator<Entry> comparatorCP =
new Comparator<Entry>() {
public int compare(Entry m1, Entry m2) {
return m1.cp - m2.cp;
}
public boolean equals(Object obj) {
return this == obj;
}
};
public static class Parser {
static final Pattern basic = Pattern.compile("(?:0x)?(\\p{XDigit}++)\\s++(?:0x)?(\\p{XDigit}++)?\\s*+.*");
static final int gBS = 1;
static final int gCP = 2;
static final int gCP2 = 3;
BufferedReader reader;
boolean closed;
Matcher matcher;
int gbs, gcp, gcp2;
public Parser (InputStream in, Pattern p, int gbs, int gcp, int gcp2)
throws IOException
{
this.reader = new BufferedReader(new InputStreamReader(in));
this.closed = false;
this.matcher = p.matcher("");
this.gbs = gbs;
this.gcp = gcp;
this.gcp2 = gcp2;
}
public Parser (InputStream in, Pattern p) throws IOException {
this(in, p, gBS, gCP, gCP2);
}
public Parser (InputStream in) throws IOException {
this(in, basic, gBS, gCP, gCP2);
}
protected boolean isDirective(String line) {
return line.startsWith("#");
}
protected Entry parse(Matcher matcher, Entry mapping) {
mapping.bs = Integer.parseInt(matcher.group(gbs), 16);
mapping.cp = Integer.parseInt(matcher.group(gcp), 16);
if (gcp2 <= matcher.groupCount() &&
matcher.group(gcp2) != null)
mapping.cp2 = Integer.parseInt(matcher.group(gcp2), 16);
else
mapping.cp2 = 0;
return mapping;
}
public Entry next() throws Exception {
return next(new Entry());
}
// returns null and closes the input stream if the eof has beenreached.
public Entry next(Entry mapping) throws Exception {
if (closed)
return null;
String line;
while ((line = reader.readLine()) != null) {
if (isDirective(line))
continue;
matcher.reset(line);
if (!matcher.lookingAt()) {
//System.out.println("Missed: " + line);
continue;
}
return parse(matcher, mapping);
}
reader.close();
closed = true;
return null;
}
}
// tags of different charset mapping tables
private final static int MAP_SINGLEBYTE = 0x1; // 0..256 : c
private final static int MAP_DOUBLEBYTE1 = 0x2; // min..max: c
private final static int MAP_DOUBLEBYTE2 = 0x3; // min..max: c [DB2]
private final static int MAP_SUPPLEMENT = 0x5; // db,c
private final static int MAP_SUPPLEMENT_C2B = 0x6; // c,db
private final static int MAP_COMPOSITE = 0x7; // db,base,cc
private final static int MAP_INDEXC2B = 0x8; // index table of c->bb
private static final void writeShort(OutputStream out, int data)
throws IOException
{
out.write((data >>> 8) & 0xFF);
out.write((data ) & 0xFF);
}
private static final void writeShortArray(OutputStream out,
int type,
int[] array,
int off,
int size) // exclusive
throws IOException
{
writeShort(out, type);
writeShort(out, size);
for (int i = off; i < size; i++) {
writeShort(out, array[off+i]);
}
}
public static final void writeSIZE(OutputStream out, int data)
throws IOException
{
out.write((data >>> 24) & 0xFF);
out.write((data >>> 16) & 0xFF);
out.write((data >>> 8) & 0xFF);
out.write((data ) & 0xFF);
}
public static void writeINDEXC2B(OutputStream out, int[] indexC2B)
throws IOException
{
writeShort(out, MAP_INDEXC2B);
writeShort(out, indexC2B.length);
int off = 0;
for (int i = 0; i < indexC2B.length; i++) {
if (indexC2B[i] != 0) {
writeShort(out, off);
off += 256;
} else {
writeShort(out, -1);
}
}
}
public static void writeSINGLEBYTE(OutputStream out, int[] sb)
throws IOException
{
writeShortArray(out, MAP_SINGLEBYTE, sb, 0, 256);
}
private static void writeDOUBLEBYTE(OutputStream out,
int type,
int[] db,
int b1Min, int b1Max,
int b2Min, int b2Max)
throws IOException
{
writeShort(out, type);
writeShort(out, b1Min);
writeShort(out, b1Max);
writeShort(out, b2Min);
writeShort(out, b2Max);
writeShort(out, (b1Max - b1Min + 1) * (b2Max - b2Min + 1));
for (int b1 = b1Min; b1 <= b1Max; b1++) {
for (int b2 = b2Min; b2 <= b2Max; b2++) {
writeShort(out, db[b1 * 256 + b2]);
}
}
}
public static void writeDOUBLEBYTE1(OutputStream out,
int[] db,
int b1Min, int b1Max,
int b2Min, int b2Max)
throws IOException
{
writeDOUBLEBYTE(out, MAP_DOUBLEBYTE1, db, b1Min, b1Max, b2Min, b2Max);
}
public static void writeDOUBLEBYTE2(OutputStream out,
int[] db,
int b1Min, int b1Max,
int b2Min, int b2Max)
throws IOException
{
writeDOUBLEBYTE(out, MAP_DOUBLEBYTE2, db, b1Min, b1Max, b2Min, b2Max);
}
// the c2b table is output as well
public static void writeSUPPLEMENT(OutputStream out, Entry[] supp, int size)
throws IOException
{
writeShort(out, MAP_SUPPLEMENT);
writeShort(out, size * 2);
// db at first half, cc at the low half
for (int i = 0; i < size; i++) {
writeShort(out, supp[i].bs);
}
for (int i = 0; i < size; i++) {
writeShort(out, supp[i].cp);
}
//c2b
writeShort(out, MAP_SUPPLEMENT_C2B);
writeShort(out, size*2);
Arrays.sort(supp, 0, size, comparatorCP);
for (int i = 0; i < size; i++) {
writeShort(out, supp[i].cp);
}
for (int i = 0; i < size; i++) {
writeShort(out, supp[i].bs);
}
}
public static void writeCOMPOSITE(OutputStream out, Entry[] comp, int size)
throws IOException
{
writeShort(out, MAP_COMPOSITE);
writeShort(out, size*3);
// comp is sorted already
for (int i = 0; i < size; i++) {
writeShort(out, (char)comp[i].bs);
writeShort(out, (char)comp[i].cp);
writeShort(out, (char)comp[i].cp2);
}
}
}
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package build.tools.charsetmapping;
import java.io.*;
import java.util.regex.*;
import static build.tools.charsetmapping.CharsetMapping.*;
public class GenerateMapping {
public static void main(String argv[]) throws IOException {
if (argv.length < 2) {
System.out.println("Usage: java GenCSData fMap fDat");
System.exit(1);
}
genDataJIS0213(new FileInputStream(argv[0]),
new FileOutputStream(argv[1]));
}
// regex pattern to parse the "jis0213.map" file
static Pattern sjis0213 = Pattern.compile("0x(\\p{XDigit}++)\\s++U\\+(\\p{XDigit}++)(?:\\+(\\p{XDigit}++))?\\s++#.*");
private static void genDataJIS0213(InputStream in, OutputStream out)
{
int[] sb = new int[0x100]; // singlebyte
int[] db = new int[0x10000]; // doublebyte
int[] indexC2B = new int[256];
Entry[] supp = new Entry[0x10000];
Entry[] comp = new Entry[0x100];
int suppTotal = 0;
int compTotal = 0;
int b1Min1 = 0x81;
int b1Max1 = 0x9f;
int b1Min2 = 0xe0;
int b1Max2 = 0xfc;
int b2Min = 0x40;
int b2Max = 0xfe;
//init
for (int i = 0; i < 0x80; i++) sb[i] = i;
for (int i = 0x80; i < 0x100; i++) sb[i] = UNMAPPABLE_DECODING;
for (int i = 0; i < 0x10000; i++) db[i] = UNMAPPABLE_DECODING;
try {
Parser p = new Parser(in, sjis0213);
Entry e = null;
while ((e = p.next()) != null) {
if (e.cp2 != 0) {
comp[compTotal++] = e;
} else {
if (e.cp <= 0xffff) {
if (e.bs <= 0xff)
sb[e.bs] = e.cp;
else
db[e.bs] = e.cp;
indexC2B[e.cp>>8] = 1;
} else {
supp[suppTotal++] = e;
}
}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// c2b Index Table, always the first one
writeINDEXC2B(baos, indexC2B);
writeSINGLEBYTE(baos, sb);
writeDOUBLEBYTE1(baos, db, b1Min1, b1Max1, b2Min, b2Max);
writeDOUBLEBYTE2(baos, db, b1Min2, b1Max2, b2Min, b2Max);
writeSUPPLEMENT(baos, supp, suppTotal);
writeCOMPOSITE(baos, comp, compTotal);
writeSIZE(out, baos.size());
baos.writeTo(out);
out.close();
} catch (Exception x) {
x.printStackTrace();
}
}
}
文件模式从 100644 更改为 100755
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#define JAR_ERROR2 "Error: Unable to access jarfile %s" #define JAR_ERROR2 "Error: Unable to access jarfile %s"
#define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s" #define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s"
#define CLS_ERROR1 "Error: Could not find the main class.\n" JNI_ERROR #define CLS_ERROR1 "Error: Could not find the main class %s.\n" JNI_ERROR
#define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s" #define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s"
#define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR #define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR
#define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR #define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR
......
/* /*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -414,7 +414,7 @@ JavaMain(void * _args) ...@@ -414,7 +414,7 @@ JavaMain(void * _args)
mainClass = LoadClass(env, classname); mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */ if(mainClass == NULL) { /* exception occured */
ReportExceptionDescription(env); ReportExceptionDescription(env);
ReportErrorMessage(CLS_ERROR1); ReportErrorMessage(CLS_ERROR1, classname);
goto leave; goto leave;
} }
(*env)->ReleaseStringUTFChars(env, mainClassName, classname); (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
...@@ -433,7 +433,7 @@ JavaMain(void * _args) ...@@ -433,7 +433,7 @@ JavaMain(void * _args)
mainClass = LoadClass(env, classname); mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */ if(mainClass == NULL) { /* exception occured */
ReportExceptionDescription(env); ReportExceptionDescription(env);
ReportErrorMessage(CLS_ERROR1); ReportErrorMessage(CLS_ERROR1, classname);
goto leave; goto leave;
} }
(*env)->ReleaseStringUTFChars(env, mainClassName, classname); (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
......
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
# #
DisplayName.Devanagari = Devanagari Input Method DisplayName.Devanagari = Devanagari Input Method
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
# #
DisplayName.Thai = Thai Input Method DisplayName.Thai = Thai Input Method
...@@ -34,8 +34,6 @@ import java.util.Set; ...@@ -34,8 +34,6 @@ import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.security.AccessControlContext; import java.security.AccessControlContext;
import java.security.Permission; import java.security.Permission;
import java.security.ProtectionDomain; import java.security.ProtectionDomain;
...@@ -51,7 +49,6 @@ import javax.management.InstanceAlreadyExistsException; ...@@ -51,7 +49,6 @@ import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException; import javax.management.InstanceNotFoundException;
import javax.management.IntrospectionException; import javax.management.IntrospectionException;
import javax.management.InvalidAttributeValueException; import javax.management.InvalidAttributeValueException;
import javax.management.JMException;
import javax.management.JMRuntimeException; import javax.management.JMRuntimeException;
import javax.management.ListenerNotFoundException; import javax.management.ListenerNotFoundException;
import javax.management.MalformedObjectNameException; import javax.management.MalformedObjectNameException;
...@@ -84,11 +81,10 @@ import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER; ...@@ -84,11 +81,10 @@ import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
import com.sun.jmx.mbeanserver.DynamicMBean2; import com.sun.jmx.mbeanserver.DynamicMBean2;
import com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository; import com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository;
import com.sun.jmx.mbeanserver.MBeanInstantiator; import com.sun.jmx.mbeanserver.MBeanInstantiator;
import com.sun.jmx.mbeanserver.MXBeanSupport;
import com.sun.jmx.mbeanserver.Repository; import com.sun.jmx.mbeanserver.Repository;
import com.sun.jmx.mbeanserver.NamedObject; import com.sun.jmx.mbeanserver.NamedObject;
import com.sun.jmx.defaults.ServiceName;
import com.sun.jmx.mbeanserver.Introspector; import com.sun.jmx.mbeanserver.Introspector;
import com.sun.jmx.mbeanserver.Util;
import com.sun.jmx.remote.util.EnvHelp; import com.sun.jmx.remote.util.EnvHelp;
/** /**
...@@ -623,18 +619,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor { ...@@ -623,18 +619,9 @@ public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
List<String> result = new ArrayList<String>(domains.length); List<String> result = new ArrayList<String>(domains.length);
for (int i = 0; i < domains.length; i++) { for (int i = 0; i < domains.length; i++) {
try { try {
ObjectName domain = new ObjectName(domains[i] + ":x=x"); ObjectName domain = Util.newObjectName(domains[i] + ":x=x");
checkMBeanPermission((String) null, null, domain, "getDomains"); checkMBeanPermission((String) null, null, domain, "getDomains");
result.add(domains[i]); result.add(domains[i]);
} catch (MalformedObjectNameException e) {
// Should never occur... But let's log it just in case.
if (MBEANSERVER_LOGGER.isLoggable(Level.SEVERE)) {
MBEANSERVER_LOGGER.logp(Level.SEVERE,
DefaultMBeanServerInterceptor.class.getName(),
"getDomains",
"Failed to check permission for domain = " +
domains[i], e);
}
} catch (SecurityException e) { } catch (SecurityException e) {
// OK: Do not add this domain to the list // OK: Do not add this domain to the list
} }
......
...@@ -107,10 +107,7 @@ class MBeanAnalyzer<M> { ...@@ -107,10 +107,7 @@ class MBeanAnalyzer<M> {
private MBeanAnalyzer(Class<?> mbeanInterface, private MBeanAnalyzer(Class<?> mbeanInterface,
MBeanIntrospector<M> introspector) MBeanIntrospector<M> introspector)
throws NotCompliantMBeanException { throws NotCompliantMBeanException {
if (!mbeanInterface.isInterface()) { introspector.checkCompliance(mbeanInterface);
throw new NotCompliantMBeanException("Not an interface: " +
mbeanInterface.getName());
}
try { try {
initMaps(mbeanInterface, introspector); initMaps(mbeanInterface, introspector);
...@@ -121,11 +118,10 @@ class MBeanAnalyzer<M> { ...@@ -121,11 +118,10 @@ class MBeanAnalyzer<M> {
// Introspect the mbeanInterface and initialize this object's maps. // Introspect the mbeanInterface and initialize this object's maps.
// //
private void initMaps(Class<?> mbeanInterface, private void initMaps(Class<?> mbeanType,
MBeanIntrospector<M> introspector) throws Exception { MBeanIntrospector<M> introspector) throws Exception {
final Method[] methodArray = mbeanInterface.getMethods(); final List<Method> methods1 = introspector.getMethods(mbeanType);
final List<Method> methods = eliminateCovariantMethods(methods1);
final List<Method> methods = eliminateCovariantMethods(methodArray);
/* Run through the methods to detect inconsistencies and to enable /* Run through the methods to detect inconsistencies and to enable
us to give getter and setter together to visitAttribute. */ us to give getter and setter together to visitAttribute. */
...@@ -234,13 +230,13 @@ class MBeanAnalyzer<M> { ...@@ -234,13 +230,13 @@ class MBeanAnalyzer<M> {
but existing code may depend on it and users may be used to seeing but existing code may depend on it and users may be used to seeing
operations or attributes appear in a particular order. */ operations or attributes appear in a particular order. */
static List<Method> static List<Method>
eliminateCovariantMethods(Method[] methodArray) { eliminateCovariantMethods(List<Method> startMethods) {
// We are assuming that you never have very many methods with the // We are assuming that you never have very many methods with the
// same name, so it is OK to use algorithms that are quadratic // same name, so it is OK to use algorithms that are quadratic
// in the number of methods with the same name. // in the number of methods with the same name.
final int len = methodArray.length; final int len = startMethods.size();
final Method[] sorted = methodArray.clone(); final Method[] sorted = startMethods.toArray(new Method[len]);
Arrays.sort(sorted,MethodOrder.instance); Arrays.sort(sorted,MethodOrder.instance);
final Set<Method> overridden = newSet(); final Set<Method> overridden = newSet();
for (int i=1;i<len;i++) { for (int i=1;i<len;i++) {
...@@ -259,7 +255,7 @@ class MBeanAnalyzer<M> { ...@@ -259,7 +255,7 @@ class MBeanAnalyzer<M> {
} }
} }
final List<Method> methods = newList(Arrays.asList(methodArray)); final List<Method> methods = newList(startMethods);
methods.removeAll(overridden); methods.removeAll(overridden);
return methods; return methods;
} }
......
...@@ -34,6 +34,7 @@ import java.lang.reflect.Constructor; ...@@ -34,6 +34,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.WeakHashMap; import java.util.WeakHashMap;
...@@ -169,6 +170,19 @@ abstract class MBeanIntrospector<M> { ...@@ -169,6 +170,19 @@ abstract class MBeanIntrospector<M> {
*/ */
abstract Descriptor getMBeanDescriptor(Class<?> resourceClass); abstract Descriptor getMBeanDescriptor(Class<?> resourceClass);
void checkCompliance(Class<?> mbeanType) throws NotCompliantMBeanException {
if (!mbeanType.isInterface()) {
throw new NotCompliantMBeanException("Not an interface: " +
mbeanType.getName());
}
}
/**
* Get the methods to be analyzed to build the MBean interface.
*/
List<Method> getMethods(final Class<?> mbeanType) throws Exception {
return Arrays.asList(mbeanType.getMethods());
}
final PerInterface<M> getPerInterface(Class<?> mbeanInterface) final PerInterface<M> getPerInterface(Class<?> mbeanInterface)
throws NotCompliantMBeanException { throws NotCompliantMBeanException {
......
/*
* Copyright 2007 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package com.sun.jmx.mbeanserver;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import javax.management.NotCompliantMBeanException;
import javax.management.Notification;
/**
* <p>A variant of {@code StandardMBeanSupport} where the only
* methods included are public getters. This is used by
* {@code QueryNotificationFilter} to pretend that a Notification is
* an MBean so it can have a query evaluated on it. Standard queries
* never set attributes or invoke methods but custom queries could and
* we don't want to allow that. Also we don't want to fail if a
* Notification happens to have inconsistent types in a pair of getX and
* setX methods, and we want to include the Object.getClass() method.
*/
public class NotificationMBeanSupport extends StandardMBeanSupport {
public <T extends Notification> NotificationMBeanSupport(T n)
throws NotCompliantMBeanException {
super(n, Util.<Class<T>>cast(n.getClass()));
}
@Override
MBeanIntrospector<Method> getMBeanIntrospector() {
return introspector;
}
private static class Introspector extends StandardMBeanIntrospector {
@Override
void checkCompliance(Class<?> mbeanType) {}
@Override
List<Method> getMethods(final Class<?> mbeanType)
throws Exception {
List<Method> methods = new ArrayList<Method>();
for (Method m : mbeanType.getMethods()) {
String name = m.getName();
Class<?> ret = m.getReturnType();
if (m.getParameterTypes().length == 0) {
if ((name.startsWith("is") && name.length() > 2 &&
ret == boolean.class) ||
(name.startsWith("get") && name.length() > 3 &&
ret != void.class)) {
methods.add(m);
}
}
}
return methods;
}
}
private static final MBeanIntrospector<Method> introspector =
new Introspector();
}
...@@ -438,7 +438,7 @@ public abstract class OpenConverter { ...@@ -438,7 +438,7 @@ public abstract class OpenConverter {
c.getClassLoader() == null); c.getClassLoader() == null);
final List<Method> methods = final List<Method> methods =
MBeanAnalyzer.eliminateCovariantMethods(c.getMethods()); MBeanAnalyzer.eliminateCovariantMethods(Arrays.asList(c.getMethods()));
final SortedMap<String,Method> getterMap = newSortedMap(); final SortedMap<String,Method> getterMap = newSortedMap();
/* Select public methods that look like "T getX()" or "boolean /* Select public methods that look like "T getX()" or "boolean
...@@ -1118,11 +1118,11 @@ public abstract class OpenConverter { ...@@ -1118,11 +1118,11 @@ public abstract class OpenConverter {
final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class; final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class;
Class targetClass = getTargetClass(); Class targetClass = getTargetClass();
Constructor[] constrs = targetClass.getConstructors(); Constructor<?>[] constrs = targetClass.getConstructors();
// Applicable if and only if there are any annotated constructors // Applicable if and only if there are any annotated constructors
List<Constructor> annotatedConstrList = newList(); List<Constructor<?>> annotatedConstrList = newList();
for (Constructor constr : constrs) { for (Constructor<?> constr : constrs) {
if (Modifier.isPublic(constr.getModifiers()) if (Modifier.isPublic(constr.getModifiers())
&& constr.getAnnotation(propertyNamesClass) != null) && constr.getAnnotation(propertyNamesClass) != null)
annotatedConstrList.add(constr); annotatedConstrList.add(constr);
...@@ -1152,7 +1152,7 @@ public abstract class OpenConverter { ...@@ -1152,7 +1152,7 @@ public abstract class OpenConverter {
// Also remember the set of properties in that constructor // Also remember the set of properties in that constructor
// so we can test unambiguity. // so we can test unambiguity.
Set<BitSet> getterIndexSets = newSet(); Set<BitSet> getterIndexSets = newSet();
for (Constructor constr : annotatedConstrList) { for (Constructor<?> constr : annotatedConstrList) {
String[] propertyNames = String[] propertyNames =
constr.getAnnotation(propertyNamesClass).value(); constr.getAnnotation(propertyNamesClass).value();
...@@ -1309,10 +1309,10 @@ public abstract class OpenConverter { ...@@ -1309,10 +1309,10 @@ public abstract class OpenConverter {
} }
private static class Constr { private static class Constr {
final Constructor constructor; final Constructor<?> constructor;
final int[] paramIndexes; final int[] paramIndexes;
final BitSet presentParams; final BitSet presentParams;
Constr(Constructor constructor, int[] paramIndexes, Constr(Constructor<?> constructor, int[] paramIndexes,
BitSet presentParams) { BitSet presentParams) {
this.constructor = constructor; this.constructor = constructor;
this.paramIndexes = paramIndexes; this.paramIndexes = paramIndexes;
......
...@@ -415,17 +415,8 @@ public class Repository { ...@@ -415,17 +415,8 @@ public class Repository {
boolean to_default_domain = false; boolean to_default_domain = false;
// Set domain to default if domain is empty and not already set // Set domain to default if domain is empty and not already set
if (dom.length() == 0) { if (dom.length() == 0)
try { name = Util.newObjectName(domain + name.toString());
name = new ObjectName(domain + name.toString());
} catch (MalformedObjectNameException e) {
if (MBEANSERVER_LOGGER.isLoggable(Level.FINEST)) {
MBEANSERVER_LOGGER.logp(Level.FINEST,
Repository.class.getName(), "addMBean",
"Unexpected MalformedObjectNameException", e);
}
}
}
// Do we have default domain ? // Do we have default domain ?
if (dom == domain) { if (dom == domain) {
......
...@@ -38,6 +38,8 @@ import java.util.Map; ...@@ -38,6 +38,8 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
public class Util { public class Util {
static <K, V> Map<K, V> newMap() { static <K, V> Map<K, V> newMap() {
...@@ -85,6 +87,14 @@ public class Util { ...@@ -85,6 +87,14 @@ public class Util {
return new ArrayList<E>(c); return new ArrayList<E>(c);
} }
public static ObjectName newObjectName(String s) {
try {
return new ObjectName(s);
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException(e);
}
}
/* This method can be used by code that is deliberately violating the /* This method can be used by code that is deliberately violating the
* allowed checked casts. Rather than marking the whole method containing * allowed checked casts. Rather than marking the whole method containing
* the code with @SuppressWarnings, you can use a call to this method for * the code with @SuppressWarnings, you can use a call to this method for
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package com.sun.management; package com.sun.management;
import java.lang.management.PlatformManagedObject;
/** /**
* Diagnostic management interface for the HotSpot Virtual Machine. * Diagnostic management interface for the HotSpot Virtual Machine.
* The diagnostic MBean is registered to the platform MBeanServer * The diagnostic MBean is registered to the platform MBeanServer
...@@ -35,8 +37,13 @@ package com.sun.management; ...@@ -35,8 +37,13 @@ package com.sun.management;
* <blockquote> * <blockquote>
* <tt>com.sun.management:type=HotSpotDiagnostic</tt> * <tt>com.sun.management:type=HotSpotDiagnostic</tt>
* </blockquote> * </blockquote>
.*
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* @see ManagementFactory#getPlatformMXBeans(Class)
*/ */
public interface HotSpotDiagnosticMXBean { public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
/** /**
* Dumps the heap to the <tt>outputFile</tt> file in the same * Dumps the heap to the <tt>outputFile</tt> file in the same
* format as the hprof heap dump. * format as the hprof heap dump.
......
CTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html> <html>
<head> <head>
<!-- <!--
......
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing;
/**
* The {@code Probe} interface represents a tracepoint.
*
* A {@code Probe} instance is obtained by calling the
* {@code Provider.getProbe()} method of a provider instance created by
* {@code ProviderFactory.createProvider()}. A {@code Probe} can be used to
* trigger a probe manually (provided the correct arguments are passed to
* it), or to check a probe to see if anything is currently tracing it.
* <p>
* A tracing check can be used to avoid lengthy work that might be
* needed to set up the probe's arguments. However, checking
* whether the probe is enabled generally takes the same amount of time
* as actually triggering the probe. So, you should only check a probe's status
* without triggering it if setting up the arguments is very expensive.
* <p>
* Users do not need to implement this interface: instances are
* created automatically by the system when a {@code Provider)} instance is
* created.
* <p>
* @since 1.7
*/
public interface Probe {
/**
* Checks whether there is an active trace of this probe.
*
* @return true if an active trace is detected.
*/
boolean isEnabled();
/**
* Determines whether a tracepoint is enabled.
*
* Typically, users do not need to use this method. It is called
* automatically when a Provider's instance method is called. Calls to
* this method expect the arguments to match the declared parameters for
* the method associated with the probe.
*
* @param args the parameters to pass to the method.
* @throws IllegalArgumentException if the provided parameters do not
* match the method declaration for this probe.
*/
void trigger(Object ... args);
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* An annotation used to override the name of a probe.
* <p>
* This annotation can be added to a method in a user-defined {@code Provider}
* interface, to set the name that will be used for the generated probe
* associated with that method. Without this annotation, the name will be the
* name of the method.
* <p>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ProbeName {
String value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing;
/**
* {@code Provider} is a superinterface for user-defined tracing providers.
* <p>
* To define tracepoints, users must extend this interface
* and then use a {@code ProviderFactory} to create an instance of the
* newly-defined interface. Each method in the defined interface represents a
* tracepoint (or probe), which can be triggered by calling the associated
* method on the returned instance.
* <p>
* This interface also contains a {@code getProbe()} method, which can be
* used to get direct handles to the {@code Probe} objects themselves.
* {@code Probe} objects can be triggered manually, or they can be queried to
* check their state.
* <p>
* When an application has finished triggering probes, it should call
* {@code dispose()} to free up any system resources associated with the
* Provider.
* <p>
* All methods declared in a subclass of this interface should have a
* {@code void} return type. Methods can have parameters, and when called the
* values of the arguments will be passed to the tracing implementation.
* If any methods do not have a {@code void} return type, an
* {@code java.lang.IllegalArgumentException} will be thrown when the
* provider is registered.
* @since 1.7
*/
public interface Provider {
/**
* Retrieves a reference to a Probe object, which is used to check status
* or to trigger the probe manually.
*
* If the provided method parameter is not a method of the provider
* interface, or if the provider interface has been disposed, then
* this returns null
*
* @param method a method declared in the provider.
* @return the specified probe represented by that method, or null.
*/
Probe getProbe(java.lang.reflect.Method method);
/**
* Disposes system resources associated with this provider.
*
* After calling this method, triggering the probes will have no effect.
* Additional calls to this method after the first call are ignored.
*/
void dispose();
}
package com.sun.tracing;
import java.util.HashSet;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.util.logging.Logger;
import sun.tracing.NullProviderFactory;
import sun.tracing.PrintStreamProviderFactory;
import sun.tracing.MultiplexProviderFactory;
import sun.tracing.dtrace.DTraceProviderFactory;
/**
* {@code ProviderFactory} is a factory class used to create instances of
* providers.
*
* To enable tracing in an application, this class must be used to create
* instances of the provider interfaces defined by users.
* The system-defined factory is obtained by using the
* {@code getDefaultFactory()} static method. The resulting instance can be
* used to create any number of providers.
*
* @since 1.7
*/
public abstract class ProviderFactory {
protected ProviderFactory() {}
/**
* Creates an implementation of a Provider interface.
*
* @param cls the provider interface to be defined.
* @return an implementation of {@code cls}, whose methods, when called,
* will trigger tracepoints in the application.
* @throws NullPointerException if cls is null
* @throws IllegalArgumentException if the class definition contains
* non-void methods
*/
public abstract <T extends Provider> T createProvider(Class<T> cls);
/**
* Returns an implementation of a {@code ProviderFactory} which
* creates instances of Providers.
*
* The created Provider instances will be linked to all appropriate
* and enabled system-defined tracing mechanisms in the JDK.
*
* @return a {@code ProviderFactory} that is used to create Providers.
*/
public static ProviderFactory getDefaultFactory() {
HashSet<ProviderFactory> factories = new HashSet<ProviderFactory>();
// Try to instantiate a DTraceProviderFactory
String prop = null;
try { prop = System.getProperty("com.sun.tracing.dtrace"); }
catch (java.security.AccessControlException e) {
Logger.getAnonymousLogger().fine(
"Cannot access property com.sun.tracing.dtrace");
}
if ( (prop == null || !prop.equals("disable")) &&
DTraceProviderFactory.isSupported() ) {
factories.add(new DTraceProviderFactory());
}
// Try to instantiate an output stream factory
try { prop = System.getProperty("sun.tracing.stream"); }
catch (java.security.AccessControlException e) {
Logger.getAnonymousLogger().fine(
"Cannot access property sun.tracing.stream");
}
if (prop != null) {
for (String spec : prop.split(",")) {
PrintStream ps = getPrintStreamFromSpec(spec);
if (ps != null) {
factories.add(new PrintStreamProviderFactory(ps));
}
}
}
// See how many factories we instantiated, and return an appropriate
// factory that encapsulates that.
if (factories.size() == 0) {
return new NullProviderFactory();
} else if (factories.size() == 1) {
return factories.toArray(new ProviderFactory[1])[0];
} else {
return new MultiplexProviderFactory(factories);
}
}
private static PrintStream getPrintStreamFromSpec(String spec) {
try {
// spec is in the form of <class>.<field>, where <class> is
// a fully specified class name, and <field> is a static member
// in that class. The <field> must be a 'PrintStream' or subtype
// in order to be used.
int fieldpos = spec.lastIndexOf('.');
Class<?> cls = Class.forName(spec.substring(0, fieldpos));
Field f = cls.getField(spec.substring(fieldpos + 1));
Class<?> fieldType = f.getType();
return (PrintStream)f.get(null);
} catch (Exception e) {
Logger.getAnonymousLogger().warning(
"Could not parse sun.tracing.stream property: " + e);
}
return null;
}
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* An annotation used to specify the name of a provider.
* <p>
* This annotation can be added to a user-defined {@code Provider}
* interface, to set the name that will be used
* for the provider in the generated probes. Without this annotation,
* the simple class name of the provider interface is used.
* <p>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ProviderName {
String value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* This annotation describes the interface attributes of the probe arguments in
* a single provider.
*
* This annotation can be added to a user-defined {@code Provider} specification
* interface to set the stability attributes of the probe arguments, for
* all the probes specified in that provider.
* <p>
* If this annotation is not present, the interface attributes for the
* arguments are Private/Private/Unknown.
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface ArgsAttributes {
Attributes value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* This annotation describes the interface's field attributes
* for the probes in a provider.
*
* This annotation provides the contents of field-specific annotations
* that specify the stability attributes and dependency class of a
* particular field, for the probes in a provider.
* <p>
* The default interface attributes for unspecified fields is
* Private/Private/Unknown.
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({})
public @interface Attributes {
/**
* The stability level of the name.
*/
StabilityLevel name() default StabilityLevel.PRIVATE;
/**
* The stability level of the data.
*/
StabilityLevel data() default StabilityLevel.PRIVATE;
/**
* The interface attribute's dependency class.
*/
DependencyClass dependency() default DependencyClass.UNKNOWN;
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
/**
* Enumeration for the DTrace dependency classes.
*
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide for details, Chapter 39: Stability</a>
* @since 1.7
*/
public enum DependencyClass {
/**
* The interface has an unknown set of architectural dependencies.
*/
UNKNOWN (0),
/**
* The interface is specific to the CPU model of the current system.
*/
CPU (1),
/**
* The interface is specific to the hardware platform of the current
* system.
*/
PLATFORM (2),
/**
* The interface is specific to the hardware platform group of the
* current system.
*/
GROUP (3),
/**
* The interface is specific to the instruction set architecture (ISA)
* supported by the microprocessors on this system.
*/
ISA (4),
/**
* The interface is common to all Solaris systems regardless of the
* underlying hardware.
*/
COMMON (5);
public String toDisplayString() {
return toString().substring(0,1) +
toString().substring(1).toLowerCase();
}
public int getEncoding() { return encoding; }
private int encoding;
private DependencyClass(int encoding) {
this.encoding = encoding;
}
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* This annotation describes the interface attributes of the
* {@code function} field for a single provider.
*
* This annotation can be added to a user-defined {@code Provider} specification
* interface to set the stability attributes of the {@code function} field for
* all probes specified in that provider.
* <p>
* If this annotation is not present, the interface attributes for the
* {@code function} field are Private/Private/Unknown.
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface FunctionAttributes {
Attributes value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* An annotation used to specify the {@code function} field for a DTrace probe.
*
* This annotation can be added to a method in a user-defined Provider
* specification interface to set the {@code function} field that is used
* for the generated DTrace probe associated with that method.
* <p>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface FunctionName {
String value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* This annotation is used to describe the interface attributes of the
* {@code module} field for a single provider.
*
* This annotation can be added to a user-defined Provider specification
* interface to set the stability attributes of the {@code module} field for
* all probes specified in that provider.
* <p>
* If this annotation is not present, the interface attributes for the
* {@code module} field is Private/Private/Unknown.
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface ModuleAttributes {
Attributes value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* An annotation used to specify the {@code module} field for a DTrace probe.
*
* This annotation can be added to a method in a user-defined Provider
* specification interface to set the {@code module} field that will be used
* for the generated DTrace probe associated with that method.
* <p>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ModuleName {
String value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* This annotation describes the interface attributes of the
* {@code name} field for a single provider.
*
* This annotation can be added to a user-defined Provider specification
* interface to set the stability attributes of the {@code name} field for
* all probes specified in that provider.
* <p>
* If this annotation is not present, the interface attributes for the
* {@code name} field will be Private/Private/Unknown.
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface NameAttributes {
Attributes value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;
/**
* This annotation is used to describe the interface attributes of the
* {@code provider} field for a single provider.
*
* This annotation can be added to a user-defined Provider specification
* interface to set the stability attributes of the {@code provider} field for
* all probes specified in that provider.
* <p>
* If this annotation is not present, the interface attributes for the
* {@code provider} field will be Private/Private/Unknown.
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface ProviderAttributes {
Attributes value();
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package com.sun.tracing.dtrace;
/**
* Enumeration for the DTrace stability levels.
*
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
* @since 1.7
*/
public enum StabilityLevel {
/**
* The interface is private to DTrace and represents an implementation
* detail of DTrace.
*/
INTERNAL (0),
/**
* The interface is private to Sun for use by other Sun products. It is
* not yet publicly documented for use by customers and ISVs.
*/
PRIVATE (1),
/**
* The interface is supported in the current release but is scheduled
* to be removed, most likely in a future minor release.
*/
OBSOLETE (2),
/**
* The interface is controlled by an entity other than Sun.
*/
EXTERNAL (3),
/**
* The interface gives developers early access to new or
* rapidly changing technology or to an implementation artifact that is
* essential for observing or debugging system behavior. A more
* stable solution is anticipated in the future.
*/
UNSTABLE (4),
/**
* The interface might eventually become Standard or Stable but is
* still in transition.
*/
EVOLVING (5),
/**
* The interface is a mature interface under Sun's control.
*/
STABLE (6),
/**
* The interface complies with an industry standard.
*/
STANDARD (7);
String toDisplayString() {
return toString().substring(0,1) +
toString().substring(1).toLowerCase();
}
public int getEncoding() { return encoding; }
private int encoding;
private StabilityLevel(int encoding) {
this.encoding = encoding;
}
}
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* This package contains annotations and enumerations that are used to
* add DTrace-specific information to a tracing provider.
* <p>
* The DTrace-specific annotations modify the attributes of a DTrace provider
* implementation when it is used by the tracing subsystem. The annotations are
* added to a {@code com.sun.tracing} provider specification to control
* specific attributes of the provider as it relates to DTrace.
* <p>
* Any other tracing subsystems supported by the system will ignore these
* annotations.
* <p>
* DTrace probes have additional fields and stability attributes that are
* not accounted for in the generic tracing package. If unspecified, the
* default values are used for the stability and dependency attributes of
* probes, as well as for the module and field names of the generated probes.
* The values can be specified by adding the appropriate annotations to the
* provider specification.
* <p>
* The {@code FunctionName} annotation is used to annotate the tracepoint
* methods defined in the provider specification. The value of this annotation
* is used as the {@code function} field in the generated DTrace probes. It
* is typically set to the name of the enclosing function where the
* tracepoint is triggered.
* <p>
* The {@code ModuleName} annotation is used to annotate the provider
* specification itself and applies to all the probes in the provider. It
* sets the value of the {@code module} field in the generated DTrace probes.
* <p>
* The remaining annotations, are also applied to the provider itself, and
* are used to set the stability and dependency attributes of all probes in
* that provider. Each probe field and the probe arguments can be
* independently assigned interface attributes to control the stability
* ratings of the probes.
* <p>
* Here is an example of how to declare a provider, specifying additional DTrace
* data:
<PRE>
&#064;ProviderName("my_app_provider")
&#064;ModuleName("app.jar")
&#064;ProviderAttributes(&#064;Attributes={
name=StabilityLevel.STABLE,data=StabilityLevel.STABLE,
dependency=DependencyClass.COMMON})
&#064;ProbeAttributes(&#064;Attributes={
name=StabilityLevel.STABLE,data=StabilityLevel.STABLE,
dependency=DependencyClass.COMMON})
&#064;ModuleAttributes(&#064;Attributes={name=StabilityLevel.UNSTABLE})
public class MyProvider {
&#064;FunctionName("main") void startProbe();
}
</PRE>
* <p>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlms?a=view">Solaris Dynamic Tracing Guide, Chapter 34: Statically Defined Tracing for User Applications</a>
* @see <a href="http://docs.sun.com/app/docs/doc/817-6223/6mlkidlnp?a=view">Solaris Dynamic Tracing Guide, Chapter 39: Stability</a>
*/
package com.sun.tracing.dtrace;
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/**
* This package provides a mechanism for defining and
* inserting tracepoints into Java-technology based applications, which
* can then be monitored by the tracing tools available on the system.
* <p>
* To add tracepoints to a program, you must first decide where to place the
* tracepoints, what the logical names are for these points, what information
* will be available to the tracing mechanisms at each point, and decide upon
* any logical grouping.
* <p>
* You add instrumentation to a program in three steps:
* <ul>
* <li>First, declare tracepoints by creating interfaces to define
* them, and include these interfaces in the program definition.
* The declared interfaces are standard Java technology-based
* interfaces and are compiled with the program.</li>
* <li>Second, add code in the application to create an instance of the
* interface at some point during the initialization of the application,
* using a factory class provided by the system. The reference to the
* instance can be stored as a global static, or passed as context to all
* the places where it is needed.</li>
* <li>Finally, add the actual tracepoints to the desired locations in the
* application by inserting a call to one of the methods defined in the
* interface, via the factory-created reference.</li>
* </ul>
* <p>
* The method calls representing the tracepoints have no logical
* impact on the program. The side effect of the call is that any
* activated tracing mechanisms will be notified that the tracepoint has
* been hit, and will take whatever actions are appropriate (for example,
* logging the tracepoint, or triggering a DTrace probe, etc.). In most
* cases, the impact on performance of adding tracepoints to the application
* will be minimal.
* <p>
* Each logical grouping of tracepoints should be defined in a common
* interface, called a <i>provider</i>. An application can have one or many
* providers. Each provider is independent and can be created whenever
* it is appropriate for that provider, for example, when a subsytem is
* initialized. Providers should be disposed of when they are no longer
* needed, to free up any associated system resources. Each tracepoint
* in a provider is represented by a method in that interface. These methods
* are referred to as <i>probes</i>. The method signature determines the probe
* parameters. A call to the method with the specified parameters triggers
* the probe and makes its parameter values visible to any associated tracing
* mechanism.
* <p>
* User-defined interfaces which represent providers must extend the
* {@code Provider} interface. To activate the system-defined
* tracing mechanisms, you must obtain an instance of the
* {@code ProviderFactory} class, and pass the class of the provider to
* the {@code createProvider()} method. The returned instance is then used to
* trigger the probes later in the application.
* <p>
* In addition to triggering the probes, the provider instance can be used
* to obtain direct references to the {@code Probe} objects, which can be used
* directly for triggering, or can be queried to determine whether the probe is
* currently being traced. The {@code Provider} interface also defines a
* {@code Provider.dispose()} method which is used to free up any resources
* that might be associated with that provider.
* <p>
* When a probe is triggered, any activated tracing system will be given
* the provider name, the probe name, and the values of the probe arguments.
* The tracing system is free to consume this data is whatever way is
* appropriate.
* By default, the provider name is the same as the class name of the interface
* that defines the provider. Similarly, the probe name is
* the name of the method that defines the probe. These default values
* can be over-ridden by annotations. The provider definition can be
* annotated with the {@code @ProviderName} annotation, whose value will
* indicate the provider name that the tracing system will use. Similarly,
* the {@code @ProbeName} annotation annotates a declared method and
* indicates the probe name that should be used in the place of the
* method name. These annotations can be used to define providers and
* probes with the same name, in cases where the semantics of the Java language
* may prevent this.
* <p>
* Here is a very small and simple usage example:
* <p>
*
<PRE>
import com.sun.tracing.Provider;
import com.sun.tracing.ProviderFactory;
interface MyProvider extends Provider {
void startProbe();
void finishProbe(int value);
}
public class MyApplication {
public static void main(String argv[]) {
ProviderFactory factory = ProviderFactory.getDefaultFactory();
MyProvider trace = factory.createProvider(MyProvider.class);
trace.startProbe();
int result = foo();
trace.finishProbe(result);
trace.dispose();
}
}
</PRE>
* <p>
* The Java Development Kit (JDK) currently only includes one system-defined
* tracing framework: DTrace. DTrace is enabled automatically whenever an
* application is run on a system and a JDK release that supports it. When
* DTrace is enabled, probes are made available for listing and matching by
* DTrace scripts as soon as the provider is created. At the tracepoint, an
* associated DTrace script is informed of the creation of the provider, and
* it takes whatever action it is designed to take. Tracepoints in the
* program have the following DTrace probe names:<br>
* {@code <provider><pid>:<module>:<function>:<probe>}
* Where:
* <ul>
* <li>{@code <provider>} the provider name as specified by the application</li>
* <li>{@code <pid>} the operating system process ID</li>
* <li>{@code <module>} undefined, unless specified by the application</li>
* <li>{@code <function>} undefined, unless specified by the application</li>
* <li>{@code <probe>} the probe name as specified by the application</li>
* </ul>
* <p>
* The {@code com.sun.tracing.dtrace} package contains additional
* annotations that can be used to control the names used for the
* <code>module</code> and <code>function</code> fields, as well as annotations
* that can be added to the provider to control probe stability and dependency
* attributes.
* <p>
* Integer, float and string probe parameters are made available to DTrace
* using
* the built-in argument variables, {@code arg0 ... arg_n}. Integer-types
* are passed by value (boxed values are unboxed), floating-point types are
* passed as encoded integer
* arguments, and {@code java.lang.String} objects are converted
* to UTF8 strings, so they can be read into the DTrace script using the
* {@code copyinstr()} intrinsic. Non-string and non-boxed primitive
* reference arguments are only
* placeholders and have no value.
* <p>
* Using the example above, with a theoretical process ID of 123, these are
* the probes that can be traced from DTrace:
<PRE>
MyProvider123:::startProbe
MyProvider123:::finishProbe
</PRE>
* When {@code finishProbe} executes, {@code arg0} will contain the
* value of {@code result}.
* <p>
* The DTrace tracing mechanism is enabled for all providers, apart from in the
* following circumstances:
* <ul>
* <li>DTrace is not supported on the underlying system.</li>
* <li>The property {@code com.sun.tracing.dtrace} is set to "disable".</li>
* <li>The RuntimePermission {@code com.sun.tracing.dtrace.createProvider}
* is denied to the process.</li>
* </ul>
* <p>
*/
package com.sun.tracing;
...@@ -1553,7 +1553,7 @@ class MetaData { ...@@ -1553,7 +1553,7 @@ class MetaData {
private static String[] getConstructorProperties(Class type) { private static String[] getConstructorProperties(Class type) {
String[] names = null; String[] names = null;
int length = 0; int length = 0;
for (Constructor constructor : type.getConstructors()) { for (Constructor<?> constructor : type.getConstructors()) {
String[] value = getAnnotationValue(constructor); String[] value = getAnnotationValue(constructor);
if ((value != null) && (length < value.length) && isValid(constructor, value)) { if ((value != null) && (length < value.length) && isValid(constructor, value)) {
names = value; names = value;
...@@ -1563,14 +1563,14 @@ class MetaData { ...@@ -1563,14 +1563,14 @@ class MetaData {
return names; return names;
} }
private static String[] getAnnotationValue(Constructor constructor) { private static String[] getAnnotationValue(Constructor<?> constructor) {
ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class); ConstructorProperties annotation = constructor.getAnnotation(ConstructorProperties.class);
return (annotation != null) return (annotation != null)
? annotation.value() ? annotation.value()
: null; : null;
} }
private static boolean isValid(Constructor constructor, String[] names) { private static boolean isValid(Constructor<?> constructor, String[] names) {
Class[] parameters = constructor.getParameterTypes(); Class[] parameters = constructor.getParameterTypes();
if (names.length != parameters.length) { if (names.length != parameters.length) {
return false; return false;
......
...@@ -636,7 +636,11 @@ public interface Instrumentation { ...@@ -636,7 +636,11 @@ public interface Instrumentation {
* @param transformer * @param transformer
* The ClassFileTransformer which wraps using this prefix. * The ClassFileTransformer which wraps using this prefix.
* @param prefix * @param prefix
* The prefix which has been applied to wrapped native methods. * The prefix to apply to wrapped native methods when
* retrying a failed native method resolution. If prefix
* is either <code>null</code> or the empty string, then
* failed native method resolutions are not retried for
* this transformer.
* @throws java.lang.NullPointerException if passed a <code>null</code> transformer. * @throws java.lang.NullPointerException if passed a <code>null</code> transformer.
* @throws java.lang.UnsupportedOperationException if the current configuration of * @throws java.lang.UnsupportedOperationException if the current configuration of
* the JVM does not allow setting a native method prefix * the JVM does not allow setting a native method prefix
......
...@@ -35,7 +35,7 @@ package java.lang.management; ...@@ -35,7 +35,7 @@ package java.lang.management;
* that can be obtained by calling * that can be obtained by calling
* the {@link ManagementFactory#getClassLoadingMXBean} method or * the {@link ManagementFactory#getClassLoadingMXBean} method or
* from the {@link ManagementFactory#getPlatformMBeanServer * from the {@link ManagementFactory#getPlatformMBeanServer
* platform <tt>MBeanServer</tt>} method. * platform <tt>MBeanServer</tt>}.
* *
* <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for * <p>The <tt>ObjectName</tt> for uniquely identifying the MXBean for
* the class loading system within an <tt>MBeanServer</tt> is: * the class loading system within an <tt>MBeanServer</tt> is:
...@@ -44,6 +44,10 @@ package java.lang.management; ...@@ -44,6 +44,10 @@ package java.lang.management;
* <tt>java.lang:type=ClassLoading</tt>} * <tt>java.lang:type=ClassLoading</tt>}
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -52,7 +56,7 @@ package java.lang.management; ...@@ -52,7 +56,7 @@ package java.lang.management;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface ClassLoadingMXBean { public interface ClassLoadingMXBean extends PlatformManagedObject {
/** /**
* Returns the total number of classes that have been loaded since * Returns the total number of classes that have been loaded since
......
...@@ -44,6 +44,10 @@ package java.lang.management; ...@@ -44,6 +44,10 @@ package java.lang.management;
* <tt>java.lang:type=Compilation</tt>} * <tt>java.lang:type=Compilation</tt>}
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -52,7 +56,7 @@ package java.lang.management; ...@@ -52,7 +56,7 @@ package java.lang.management;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface CompilationMXBean { public interface CompilationMXBean extends PlatformManagedObject {
/** /**
* Returns the name of the Just-in-time (JIT) compiler. * Returns the name of the Just-in-time (JIT) compiler.
* *
......
...@@ -48,9 +48,13 @@ package java.lang.management; ...@@ -48,9 +48,13 @@ package java.lang.management;
* <tt>java.lang:type=GarbageCollector</tt>}<tt>,name=</tt><i>collector's name</i> * <tt>java.lang:type=GarbageCollector</tt>}<tt>,name=</tt><i>collector's name</i>
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* A platform usually includes additional platform-dependent information * A platform usually includes additional platform-dependent information
* specific to a garbage collection algorithm for monitoring. * specific to a garbage collection algorithm for monitoring.
* *
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see MemoryMXBean * @see MemoryMXBean
* *
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
......
...@@ -24,17 +24,31 @@ ...@@ -24,17 +24,31 @@
*/ */
package java.lang.management; package java.lang.management;
import javax.management.DynamicMBean;
import javax.management.MBeanServer; import javax.management.MBeanServer;
import javax.management.MBeanServerConnection; import javax.management.MBeanServerConnection;
import javax.management.MBeanServerFactory;
import javax.management.MBeanServerPermission; import javax.management.MBeanServerPermission;
import javax.management.NotificationEmitter;
import javax.management.ObjectInstance;
import javax.management.ObjectName; import javax.management.ObjectName;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException; import javax.management.InstanceNotFoundException;
import javax.management.MalformedObjectNameException; import javax.management.MalformedObjectNameException;
import javax.management.MBeanRegistrationException;
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.List;
import java.security.AccessController; import java.security.AccessController;
import java.security.Permission; import java.security.Permission;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import javax.management.JMX; import javax.management.JMX;
import sun.management.ManagementFactoryHelper;
/** /**
* The <tt>ManagementFactory</tt> class is a factory class for getting * The <tt>ManagementFactory</tt> class is a factory class for getting
...@@ -49,13 +63,16 @@ import javax.management.JMX; ...@@ -49,13 +63,16 @@ import javax.management.JMX;
* <ul> * <ul>
* <li><i>Direct access to an MXBean interface</i> * <li><i>Direct access to an MXBean interface</i>
* <ol type="a"> * <ol type="a">
* <li>Get the MXBean instance through the static factory method * <li>Get the MXBean instance through the static factory method,
* or the {@link #getPlatformMXBeans(Class)} method
* and access the MXBean locally of the running * and access the MXBean locally of the running
* virtual machine. * virtual machine.
* </li> * </li>
* <li>Construct an MXBean proxy instance that forwards the * <li>Construct an MXBean proxy instance that forwards the
* method calls to a given {@link MBeanServer MBeanServer} by calling * method calls to a given {@link MBeanServer MBeanServer} by calling
* {@link #newPlatformMXBeanProxy newPlatfromMXBeanProxy}. * the {@link #newPlatformMXBeanProxy newPlatformMXBeanProxy} method
* or the {@link #getPlatformMXBeans(MBeanServerConnection, Class)}
* method.
* A proxy is typically constructed to remotely access * A proxy is typically constructed to remotely access
* an MXBean of another running virtual machine. * an MXBean of another running virtual machine.
* </li> * </li>
...@@ -83,6 +100,10 @@ import javax.management.JMX; ...@@ -83,6 +100,10 @@ import javax.management.JMX;
* a set of basic data types described below. * a set of basic data types described below.
* See <a href="../../../javax/management/MXBean.html#MXBean-spec"> * See <a href="../../../javax/management/MXBean.html#MXBean-spec">
* the specification of MXBeans</a> for details. * 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> * A JMX management application and the platform <tt>MBeanServer</tt>
* can interoperate without requiring classes for MXBean specific * can interoperate without requiring classes for MXBean specific
* data types. * data types.
...@@ -191,7 +212,10 @@ import javax.management.JMX; ...@@ -191,7 +212,10 @@ import javax.management.JMX;
* <h4><a name="MXBeanNames">MXBean Names</a></h4> * <h4><a name="MXBeanNames">MXBean Names</a></h4>
* Each platform MXBean for a Java virtual machine has a unique * Each platform MXBean for a Java virtual machine has a unique
* {@link javax.management.ObjectName ObjectName} for * {@link javax.management.ObjectName ObjectName} for
* registration in the platform <tt>MBeanServer</tt>. * registration in the platform <tt>MBeanServer</tt> that can
* be obtained by calling the {@link PlatformManagedObject#getObjectName}
* method.
*
* A Java virtual machine has a single instance of the following management * A Java virtual machine has a single instance of the following management
* interfaces: * interfaces:
* *
...@@ -275,7 +299,7 @@ import javax.management.JMX; ...@@ -275,7 +299,7 @@ import javax.management.JMX;
* </blockquote> * </blockquote>
* *
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
* Ways to Access Management Metrics</a> * Ways to Access Management Metrics</a>
* @see java.util.logging.LoggingMXBean * @see java.util.logging.LoggingMXBean
...@@ -368,7 +392,7 @@ public class ManagementFactory { ...@@ -368,7 +392,7 @@ public class ManagementFactory {
* the Java virtual machine. * the Java virtual machine.
*/ */
public static ClassLoadingMXBean getClassLoadingMXBean() { public static ClassLoadingMXBean getClassLoadingMXBean() {
return sun.management.ManagementFactory.getClassLoadingMXBean(); return ManagementFactoryHelper.getClassLoadingMXBean();
} }
/** /**
...@@ -378,7 +402,7 @@ public class ManagementFactory { ...@@ -378,7 +402,7 @@ public class ManagementFactory {
* @return a {@link MemoryMXBean} object for the Java virtual machine. * @return a {@link MemoryMXBean} object for the Java virtual machine.
*/ */
public static MemoryMXBean getMemoryMXBean() { public static MemoryMXBean getMemoryMXBean() {
return sun.management.ManagementFactory.getMemoryMXBean(); return ManagementFactoryHelper.getMemoryMXBean();
} }
/** /**
...@@ -388,7 +412,7 @@ public class ManagementFactory { ...@@ -388,7 +412,7 @@ public class ManagementFactory {
* @return a {@link ThreadMXBean} object for the Java virtual machine. * @return a {@link ThreadMXBean} object for the Java virtual machine.
*/ */
public static ThreadMXBean getThreadMXBean() { public static ThreadMXBean getThreadMXBean() {
return sun.management.ManagementFactory.getThreadMXBean(); return ManagementFactoryHelper.getThreadMXBean();
} }
/** /**
...@@ -399,7 +423,7 @@ public class ManagementFactory { ...@@ -399,7 +423,7 @@ public class ManagementFactory {
*/ */
public static RuntimeMXBean getRuntimeMXBean() { public static RuntimeMXBean getRuntimeMXBean() {
return sun.management.ManagementFactory.getRuntimeMXBean(); return ManagementFactoryHelper.getRuntimeMXBean();
} }
/** /**
...@@ -412,7 +436,7 @@ public class ManagementFactory { ...@@ -412,7 +436,7 @@ public class ManagementFactory {
* no compilation system. * no compilation system.
*/ */
public static CompilationMXBean getCompilationMXBean() { public static CompilationMXBean getCompilationMXBean() {
return sun.management.ManagementFactory.getCompilationMXBean(); return ManagementFactoryHelper.getCompilationMXBean();
} }
/** /**
...@@ -423,7 +447,7 @@ public class ManagementFactory { ...@@ -423,7 +447,7 @@ public class ManagementFactory {
* the Java virtual machine. * the Java virtual machine.
*/ */
public static OperatingSystemMXBean getOperatingSystemMXBean() { public static OperatingSystemMXBean getOperatingSystemMXBean() {
return sun.management.ManagementFactory.getOperatingSystemMXBean(); return ManagementFactoryHelper.getOperatingSystemMXBean();
} }
/** /**
...@@ -436,7 +460,7 @@ public class ManagementFactory { ...@@ -436,7 +460,7 @@ public class ManagementFactory {
* *
*/ */
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() { public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
return sun.management.ManagementFactory.getMemoryPoolMXBeans(); return ManagementFactoryHelper.getMemoryPoolMXBeans();
} }
/** /**
...@@ -449,7 +473,7 @@ public class ManagementFactory { ...@@ -449,7 +473,7 @@ public class ManagementFactory {
* *
*/ */
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() { public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
return sun.management.ManagementFactory.getMemoryManagerMXBeans(); return ManagementFactoryHelper.getMemoryManagerMXBeans();
} }
...@@ -465,7 +489,7 @@ public class ManagementFactory { ...@@ -465,7 +489,7 @@ public class ManagementFactory {
* *
*/ */
public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() { public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
return sun.management.ManagementFactory.getGarbageCollectorMXBeans(); return ManagementFactoryHelper.getGarbageCollectorMXBeans();
} }
private static MBeanServer platformMBeanServer; private static MBeanServer platformMBeanServer;
...@@ -518,8 +542,25 @@ public class ManagementFactory { ...@@ -518,8 +542,25 @@ public class ManagementFactory {
} }
if (platformMBeanServer == null) { if (platformMBeanServer == null) {
platformMBeanServer = platformMBeanServer = MBeanServerFactory.createMBeanServer();
sun.management.ManagementFactory.createPlatformMBeanServer(); for (PlatformComponent pc : PlatformComponent.values()) {
List<? extends PlatformManagedObject> list =
pc.getMXBeans(pc.getMXBeanInterface());
for (PlatformManagedObject o : list) {
// Each PlatformComponent represents one management
// interface. Some MXBean may extend another one.
// The MXBean instances for one platform component
// (returned by pc.getMXBeans()) might be also
// the MXBean instances for another platform component.
// e.g. com.sun.management.GarbageCollectorMXBean
//
// So need to check if an MXBean instance is registered
// before registering into the platform MBeanServer
if (!platformMBeanServer.isRegistered(o.getObjectName())) {
addMXBean(platformMBeanServer, o);
}
}
}
} }
return platformMBeanServer; return platformMBeanServer;
} }
...@@ -657,6 +698,136 @@ public class ManagementFactory { ...@@ -657,6 +698,136 @@ public class ManagementFactory {
} }
} }
/**
* Returns the list of platform MXBeans that implement
* the given {@code mxbeanInterface} in the running 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.
*
* @param mxbeanInterface a management interface for a platform
* MXBean
*
* @return the list of platform MXBeans that implements
* {@code mxbeanInterface}.
*
* @throws IllegalArgumentException if {@code mxbeanInterface}
* is not a management interface for the platform.
*
* @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.");
}
/**
* Returns the list of the platform MXBean proxies for
* forwarding the method calls of the {@code mxbeanInterface}
* through the given {@code MBeanServerConnection}.
* 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.
*
* @param connection the {@code MBeanServerConnection} to forward to.
* @param mxbeanInterface a management interface for a platform
* MXBean
*
* @return the list of platform MXBean proxies for
* forwarding the method calls of the {@code mxbeanInterface}
* through the given {@code MBeanServerConnection}.
*
* @throws IllegalArgumentException if {@code mxbeanInterface}
* is not a management interface for the platform.
*
* @throws java.io.IOException if a communication problem
* occurred when accessing the {@code MBeanServerConnection}.
*
* @since 1.7
*/
public static <T extends PlatformManagedObject>
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);
}
}
}
throw new IllegalArgumentException(mxbeanInterface.getName() +
" is not implemented by any of the platform MXBeans.");
}
/**
* Returns a list 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
* {@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<Class<? extends PlatformManagedObject>>();
for (PlatformComponent component: PlatformComponent.values()) {
result.add(component.getMXBeanInterface());
}
return result;
}
private static final String NOTIF_EMITTER = private static final String NOTIF_EMITTER =
"javax.management.NotificationEmitter"; "javax.management.NotificationEmitter";
/**
* Registers an MXBean.
*/
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) {
dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo);
} else {
dmbean = new StandardMBean(pmo, null, true);
}
try {
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
public Void run() throws InstanceAlreadyExistsException,
MBeanRegistrationException,
NotCompliantMBeanException {
mbs.registerMBean(dmbean, pmo.getObjectName());
return null;
}
});
} catch (PrivilegedActionException e) {
throw new RuntimeException(e.getException());
}
}
} }
...@@ -46,6 +46,9 @@ import javax.management.openmbean.CompositeData; ...@@ -46,6 +46,9 @@ import javax.management.openmbean.CompositeData;
* <tt>java.lang:type=Memory</tt>} * <tt>java.lang:type=Memory</tt>}
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* <h4> Memory </h4> * <h4> Memory </h4>
* The memory system of the Java virtual machine manages * The memory system of the Java virtual machine manages
* the following kinds of memory: * the following kinds of memory:
...@@ -190,6 +193,7 @@ import javax.management.openmbean.CompositeData; ...@@ -190,6 +193,7 @@ import javax.management.openmbean.CompositeData;
* emitter.addNotificationListener(listener, null, null); * emitter.addNotificationListener(listener, null, null);
* </pre></blockquote> * </pre></blockquote>
* *
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -198,7 +202,7 @@ import javax.management.openmbean.CompositeData; ...@@ -198,7 +202,7 @@ import javax.management.openmbean.CompositeData;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface MemoryMXBean { public interface MemoryMXBean extends PlatformManagedObject {
/** /**
* Returns the approximate number of objects for which * Returns the approximate number of objects for which
* finalization is pending. * finalization is pending.
......
...@@ -45,6 +45,10 @@ package java.lang.management; ...@@ -45,6 +45,10 @@ package java.lang.management;
* <tt>java.lang:type=MemoryManager</tt>}<tt>,name=</tt><i>manager's name</i> * <tt>java.lang:type=MemoryManager</tt>}<tt>,name=</tt><i>manager's name</i>
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see MemoryMXBean * @see MemoryMXBean
* *
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
...@@ -55,7 +59,7 @@ package java.lang.management; ...@@ -55,7 +59,7 @@ package java.lang.management;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface MemoryManagerMXBean { public interface MemoryManagerMXBean extends PlatformManagedObject {
/** /**
* Returns the name representing this memory manager. * Returns the name representing this memory manager.
* *
......
...@@ -46,6 +46,9 @@ package java.lang.management; ...@@ -46,6 +46,9 @@ package java.lang.management;
* <tt>java.lang:type=MemoryPool</tt>}<tt>,name=</tt><i>pool's name</i> * <tt>java.lang:type=MemoryPool</tt>}<tt>,name=</tt><i>pool's name</i>
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* <h4>Memory Type</h4> * <h4>Memory Type</h4>
* <p>The Java virtual machine has a heap for object allocation and also * <p>The Java virtual machine has a heap for object allocation and also
* maintains non-heap memory for the method area and the Java virtual * maintains non-heap memory for the method area and the Java virtual
...@@ -349,6 +352,7 @@ package java.lang.management; ...@@ -349,6 +352,7 @@ package java.lang.management;
* described above for the <a href="#UsageThreshold">usage threshold</a> * described above for the <a href="#UsageThreshold">usage threshold</a>
* in a similar fashion. * in a similar fashion.
* *
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -357,7 +361,7 @@ package java.lang.management; ...@@ -357,7 +361,7 @@ package java.lang.management;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface MemoryPoolMXBean { public interface MemoryPoolMXBean extends PlatformManagedObject {
/** /**
* Returns the name representing this memory pool. * Returns the name representing this memory pool.
* *
......
...@@ -44,10 +44,14 @@ package java.lang.management; ...@@ -44,10 +44,14 @@ package java.lang.management;
* <tt>java.lang:type=OperatingSystem</tt>} * <tt>java.lang:type=OperatingSystem</tt>}
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* <p> This interface defines several convenient methods for accessing * <p> This interface defines several convenient methods for accessing
* system properties about the operating system on which the Java * system properties about the operating system on which the Java
* virtual machine is running. * virtual machine is running.
* *
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -56,7 +60,7 @@ package java.lang.management; ...@@ -56,7 +60,7 @@ package java.lang.management;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface OperatingSystemMXBean { public interface OperatingSystemMXBean extends PlatformManagedObject {
/** /**
* Returns the operating system name. * Returns the operating system name.
* This method is equivalent to <tt>System.getProperty("os.name")</tt>. * This method is equivalent to <tt>System.getProperty("os.name")</tt>.
......
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package java.lang.management;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.LoggingMXBean;
import java.util.logging.LogManager;
import javax.management.MBeanServerConnection;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.UnixOperatingSystemMXBean;
import sun.management.ManagementFactoryHelper;
/**
* This enum class defines the list of platform components
* that provides monitoring and management support.
* Each enum represents one MXBean interface. A MXBean
* instance could implement one or more MXBean interfaces.
*
* For example, com.sun.management.GarbageCollectorMXBean
* extends java.lang.management.GarbageCollectorMXBean
* and there is one set of garbage collection MXBean instances,
* each of which implements both c.s.m. and j.l.m. interfaces.
* There are two separate enums GARBAGE_COLLECTOR
* and SUN_GARBAGE_COLLECTOR so that ManagementFactory.getPlatformMXBeans(Class)
* will return the list of MXBeans of the specified type.
*
* To add a new MXBean interface for the Java platform,
* add a new enum constant and implement the MXBeanFetcher.
*/
enum PlatformComponent {
/**
* Class loading system of the Java virtual machine.
*/
CLASS_LOADING(
"java.lang.management.ClassLoadingMXBean",
"java.lang", "ClassLoading", defaultKeyProperties(),
new MXBeanFetcher<ClassLoadingMXBean>() {
public List<ClassLoadingMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean());
}
}),
/**
* Compilation system of the Java virtual machine.
*/
COMPILATION(
"java.lang.management.CompilationMXBean",
"java.lang", "Compilation", defaultKeyProperties(),
new MXBeanFetcher<CompilationMXBean>() {
public List<CompilationMXBean> getMXBeans() {
CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean();
if (m == null) {
return Collections.emptyList();
} else {
return Collections.singletonList(m);
}
}
}),
/**
* Memory system of the Java virtual machine.
*/
MEMORY(
"java.lang.management.MemoryMXBean",
"java.lang", "Memory", defaultKeyProperties(),
new MXBeanFetcher<MemoryMXBean>() {
public List<MemoryMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean());
}
}),
/**
* Garbage Collector in the Java virtual machine.
*/
GARBAGE_COLLECTOR(
"java.lang.management.GarbageCollectorMXBean",
"java.lang", "GarbageCollector", keyProperties("name"),
new MXBeanFetcher<GarbageCollectorMXBean>() {
public List<GarbageCollectorMXBean> getMXBeans() {
return ManagementFactoryHelper.
getGarbageCollectorMXBeans();
}
}),
/**
* Memory manager in the Java virtual machine.
*/
MEMORY_MANAGER(
"java.lang.management.MemoryManagerMXBean",
"java.lang", "MemoryManager", keyProperties("name"),
new MXBeanFetcher<MemoryManagerMXBean>() {
public List<MemoryManagerMXBean> getMXBeans() {
return ManagementFactoryHelper.getMemoryManagerMXBeans();
}
},
GARBAGE_COLLECTOR),
/**
* Memory pool in the Java virtual machine.
*/
MEMORY_POOL(
"java.lang.management.MemoryPoolMXBean",
"java.lang", "MemoryPool", keyProperties("name"),
new MXBeanFetcher<MemoryPoolMXBean>() {
public List<MemoryPoolMXBean> getMXBeans() {
return ManagementFactoryHelper.getMemoryPoolMXBeans();
}
}),
/**
* Operating system on which the Java virtual machine is running
*/
OPERATING_SYSTEM(
"java.lang.management.OperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(),
new MXBeanFetcher<OperatingSystemMXBean>() {
public List<OperatingSystemMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean());
}
}),
/**
* Runtime system of the Java virtual machine.
*/
RUNTIME(
"java.lang.management.RuntimeMXBean",
"java.lang", "Runtime", defaultKeyProperties(),
new MXBeanFetcher<RuntimeMXBean>() {
public List<RuntimeMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean());
}
}),
/**
* Threading system of the Java virtual machine.
*/
THREADING(
"java.lang.management.ThreadMXBean",
"java.lang", "Threading", defaultKeyProperties(),
new MXBeanFetcher<ThreadMXBean>() {
public List<ThreadMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean());
}
}),
/**
* Logging facility.
*/
LOGGING(
"java.util.logging.LoggingMXBean",
"java.util.logging", "Logging", defaultKeyProperties(),
new MXBeanFetcher<LoggingMXBean>() {
public List<LoggingMXBean> getMXBeans() {
return Collections.singletonList(LogManager.getLoggingMXBean());
}
}),
// Sun Platform Extension
/**
* Sun extension garbage collector that performs collections in cycles.
*/
SUN_GARBAGE_COLLECTOR(
"com.sun.management.GarbageCollectorMXBean",
"java.lang", "GarbageCollector", keyProperties("name"),
new MXBeanFetcher<com.sun.management.GarbageCollectorMXBean>() {
public List<com.sun.management.GarbageCollectorMXBean> getMXBeans() {
return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class);
}
}),
/**
* Sun extension operating system on which the Java virtual machine
* is running.
*/
SUN_OPERATING_SYSTEM(
"com.sun.management.OperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(),
new MXBeanFetcher<com.sun.management.OperatingSystemMXBean>() {
public List<com.sun.management.OperatingSystemMXBean> getMXBeans() {
return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class);
}
}),
/**
* Unix operating system.
*/
SUN_UNIX_OPERATING_SYSTEM(
"com.sun.management.UnixOperatingSystemMXBean",
"java.lang", "OperatingSystem", defaultKeyProperties(),
new MXBeanFetcher<UnixOperatingSystemMXBean>() {
public List<UnixOperatingSystemMXBean> getMXBeans() {
return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class);
}
}),
/**
* Diagnostic support for the HotSpot Virtual Machine.
*/
HOTSPOT_DIAGNOSTIC(
"com.sun.management.HotSpotDiagnosticMXBean",
"com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(),
new MXBeanFetcher<HotSpotDiagnosticMXBean>() {
public List<HotSpotDiagnosticMXBean> getMXBeans() {
return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean());
}
});
/**
* A task that returns the MXBeans for a component.
*/
interface MXBeanFetcher<T extends PlatformManagedObject> {
public List<T> getMXBeans();
}
/*
* Returns a list of the GC MXBeans of the given type.
*/
private static <T extends GarbageCollectorMXBean>
List<T> getGcMXBeanList(Class<T> gcMXBeanIntf) {
List<GarbageCollectorMXBean> list =
ManagementFactoryHelper.getGarbageCollectorMXBeans();
List<T> result = new ArrayList<T>(list.size());
for (GarbageCollectorMXBean m : list) {
if (gcMXBeanIntf.isInstance(m)) {
result.add(gcMXBeanIntf.cast(m));
}
}
return result;
}
/*
* Returns the OS mxbean instance of the given type.
*/
private static <T extends OperatingSystemMXBean>
List<T> getOSMXBeanList(Class<T> osMXBeanIntf) {
OperatingSystemMXBean m =
ManagementFactoryHelper.getOperatingSystemMXBean();
if (osMXBeanIntf.isInstance(m)) {
return Collections.singletonList(osMXBeanIntf.cast(m));
} else {
return Collections.emptyList();
}
}
private final String mxbeanInterfaceName;
private final String domain;
private final String type;
private final Set<String> keyProperties;
private final MXBeanFetcher fetcher;
private final PlatformComponent[] subComponents;
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,
MXBeanFetcher fetcher,
PlatformComponent... subComponents) {
this.mxbeanInterfaceName = intfName;
this.domain = domain;
this.type = type;
this.keyProperties = keyProperties;
this.fetcher = fetcher;
this.subComponents = subComponents;
}
private static Set<String> defaultKeyProps;
private static Set<String> defaultKeyProperties() {
if (defaultKeyProps == null) {
defaultKeyProps = Collections.singleton("type");
}
return defaultKeyProps;
}
private static Set<String> keyProperties(String... keyNames) {
Set<String> set = new HashSet<String>();
set.add("type");
for (String s : keyNames) {
set.add(s);
}
return set;
}
String getMXBeanInterfaceName() {
return mxbeanInterfaceName;
}
@SuppressWarnings("unchecked")
Class<? extends PlatformManagedObject> getMXBeanInterface() {
try {
// Lazy loading the MXBean interface only when it is needed
return (Class<? extends PlatformManagedObject>)
Class.forName(mxbeanInterfaceName, false, null);
} catch (ClassNotFoundException x) {
throw new AssertionError(x);
}
}
@SuppressWarnings("unchecked")
<T extends PlatformManagedObject>
List<T> getMXBeans(Class<T> mxbeanInterface)
{
return fetcher.getMXBeans();
}
<T extends PlatformManagedObject>
List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
throws java.io.IOException
{
List<T> result = new ArrayList<T>();
for (ObjectName on : getObjectNames(mbs)) {
result.add(ManagementFactory.
newPlatformMXBeanProxy(mbs,
on.getCanonicalName(),
mxbeanInterface)
);
}
return result;
}
private Set<ObjectName> getObjectNames(MBeanServerConnection mbs)
throws java.io.IOException
{
String domainAndType = domain + ":type=" + type;
if (keyProperties.size() > 1) {
// if there are more than 1 key properties (i.e. other than "type")
domainAndType += ",*";
}
ObjectName on = com.sun.jmx.mbeanserver.Util.newObjectName(domainAndType);
Set<ObjectName> set = mbs.queryNames(on, null);
for (PlatformComponent pc : subComponents) {
set.addAll(pc.getObjectNames(mbs));
}
return set;
}
private static final long serialVersionUID = 6992337162326171013L;
}
/*
* Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package java.lang.management;
import javax.management.ObjectName;
/**
* A platform managed object is a {@linkplain javax.management.MXBean JMX MXBean}
* for monitoring and managing a component in the Java platform.
* Each platform managed object has a unique
* <a href="ManagementFactory.html#MXBean">object name</a>
* for the {@linkplain ManagementFactory.getPlatformMBeanServer
* platform MBeanServer} access.
* All platform MXBeans will implement this interface.
*
* <p>
* Note:
* The platform MXBean interfaces (i.e. all subinterfaces
* of {@code PlatformManagedObject}) are implemented
* by the Java platform only. New methods may be added in these interfaces
* in future Java SE releases.
* In addition, this {@code PlatformManagedObject} interface is only
* intended for the management interfaces for the platform to extend but
* not for applications.
*
* @see <a href="ManagementFactory.html#MXBean">Platform MXBeans</a>
* @since 1.7
*/
public interface PlatformManagedObject {
/**
* Returns an {@link ObjectName ObjectName} instance representing
* the object name of this platform managed object.
*
* @return an {@link ObjectName ObjectName} instance representing
* the object name of this platform managed object.
*/
public ObjectName getObjectName();
}
...@@ -44,9 +44,13 @@ package java.lang.management; ...@@ -44,9 +44,13 @@ package java.lang.management;
* <tt>java.lang:type=Runtime</tt>} * <tt>java.lang:type=Runtime</tt>}
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* <p> This interface defines several convenient methods for accessing * <p> This interface defines several convenient methods for accessing
* system properties about the Java virtual machine. * system properties about the Java virtual machine.
* *
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -55,7 +59,7 @@ package java.lang.management; ...@@ -55,7 +59,7 @@ package java.lang.management;
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
*/ */
public interface RuntimeMXBean { public interface RuntimeMXBean extends PlatformManagedObject {
/** /**
* Returns the name representing the running Java virtual machine. * Returns the name representing the running Java virtual machine.
* The returned name string can be any arbitrary string and * The returned name string can be any arbitrary string and
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package java.lang.management; package java.lang.management;
import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeData;
import sun.management.ManagementFactoryHelper;
import sun.management.ThreadInfoCompositeData; import sun.management.ThreadInfoCompositeData;
import static java.lang.Thread.State.*; import static java.lang.Thread.State.*;
...@@ -220,12 +221,9 @@ public class ThreadInfo { ...@@ -220,12 +221,9 @@ public class ThreadInfo {
LockInfo[] lockedSynchronizers) { LockInfo[] lockedSynchronizers) {
this.threadId = t.getId(); this.threadId = t.getId();
this.threadName = t.getName(); this.threadName = t.getName();
this.threadState = this.threadState = ManagementFactoryHelper.toThreadState(state);
sun.management.ManagementFactory.toThreadState(state); this.suspended = ManagementFactoryHelper.isThreadSuspended(state);
this.suspended = this.inNative = ManagementFactoryHelper.isThreadRunningNative(state);
sun.management.ManagementFactory.isThreadSuspended(state);
this.inNative =
sun.management.ManagementFactory.isThreadRunningNative(state);
this.blockedCount = blockedCount; this.blockedCount = blockedCount;
this.blockedTime = blockedTime; this.blockedTime = blockedTime;
this.waitedCount = waitedCount; this.waitedCount = waitedCount;
......
...@@ -46,6 +46,9 @@ import java.util.Map; ...@@ -46,6 +46,9 @@ import java.util.Map;
* <tt>java.lang:type=Threading</tt>} * <tt>java.lang:type=Threading</tt>}
* </blockquote> * </blockquote>
* *
* It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* <h4>Thread ID</h4> * <h4>Thread ID</h4>
* Thread ID is a positive long value returned by calling the * Thread ID is a positive long value returned by calling the
* {@link java.lang.Thread#getId} method for a thread. * {@link java.lang.Thread#getId} method for a thread.
...@@ -108,6 +111,7 @@ import java.util.Map; ...@@ -108,6 +111,7 @@ import java.util.Map;
* {@link #findDeadlockedThreads} methods to find deadlocks in * {@link #findDeadlockedThreads} methods to find deadlocks in
* the running application. * the running application.
* *
* @see ManagementFactory#getPlatformMXBeans(Class)
* @see <a href="../../../javax/management/package-summary.html"> * @see <a href="../../../javax/management/package-summary.html">
* JMX Specification.</a> * JMX Specification.</a>
* @see <a href="package-summary.html#examples"> * @see <a href="package-summary.html#examples">
...@@ -117,7 +121,7 @@ import java.util.Map; ...@@ -117,7 +121,7 @@ import java.util.Map;
* @since 1.5 * @since 1.5
*/ */
public interface ThreadMXBean { public interface ThreadMXBean extends PlatformManagedObject {
/** /**
* Returns the current number of live threads including both * Returns the current number of live threads including both
* daemon and non-daemon threads. * daemon and non-daemon threads.
......
...@@ -29,6 +29,8 @@ import java.util.Enumeration; ...@@ -29,6 +29,8 @@ import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import javax.management.ObjectName;
/** /**
* Logging is the implementation class of LoggingMXBean. * Logging is the implementation class of LoggingMXBean.
* *
...@@ -115,4 +117,7 @@ class Logging implements LoggingMXBean { ...@@ -115,4 +117,7 @@ class Logging implements LoggingMXBean {
} }
} }
public ObjectName getObjectName() {
return com.sun.jmx.mbeanserver.Util.newObjectName(LogManager.LOGGING_MXBEAN_NAME);
}
} }
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package java.util.logging; package java.util.logging;
import java.lang.management.PlatformManagedObject;
/** /**
* The management interface for the logging facility. * The management interface for the logging facility.
* *
...@@ -43,14 +45,17 @@ package java.util.logging; ...@@ -43,14 +45,17 @@ package java.util.logging;
* <tt>java.util.logging:type=Logging</tt>} * <tt>java.util.logging:type=Logging</tt>}
* </blockquote> * </blockquote>
* *
* @see java.lang.management.ManagementFactory * It can be obtained by calling the
* {@link PlatformManagedObject#getObjectName} method.
*
* @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
* *
* @author Ron Mann * @author Ron Mann
* @author Mandy Chung * @author Mandy Chung
* @since 1.5 * @since 1.5
* *
*/ */
public interface LoggingMXBean { public interface LoggingMXBean extends PlatformManagedObject {
/** /**
* Returns the list of currently registered loggers. This method * Returns the list of currently registered loggers. This method
......
...@@ -2844,7 +2844,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2844,7 +2844,15 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
/** /**
* Utility method for parsing unicode escape sequences. * Utility method for parsing unicode escape sequences.
*/ */
private int u() { private int cursor() {
return cursor;
}
private void setcursor(int pos) {
cursor = pos;
}
private int uxxxx() {
int n = 0; int n = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
int ch = read(); int ch = read();
...@@ -2856,6 +2864,20 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2856,6 +2864,20 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
return n; return n;
} }
private int u() {
int n = uxxxx();
if (Character.isHighSurrogate((char)n)) {
int cur = cursor();
if (read() == '\\' && read() == 'u') {
int n2 = uxxxx();
if (Character.isLowSurrogate((char)n2))
return Character.toCodePoint((char)n, (char)n2);
}
setcursor(cur);
}
return n;
}
// //
// Utility methods for code point support // Utility methods for code point support
// //
......
...@@ -50,7 +50,7 @@ import javax.management.loading.ClassLoaderRepository; ...@@ -50,7 +50,7 @@ import javax.management.loading.ClassLoaderRepository;
* server. A Java object cannot be registered in the MBean server * server. A Java object cannot be registered in the MBean server
* unless it is a JMX compliant MBean.</p> * unless it is a JMX compliant MBean.</p>
* *
* <p>When an MBean is registered or unregistered in the MBean server * <p id="notif">When an MBean is registered or unregistered in the MBean server
* a {@link javax.management.MBeanServerNotification * a {@link javax.management.MBeanServerNotification
* MBeanServerNotification} Notification is emitted. To register an * MBeanServerNotification} Notification is emitted. To register an
* object as listener to MBeanServerNotifications you should call the * object as listener to MBeanServerNotifications you should call the
...@@ -258,27 +258,43 @@ import javax.management.loading.ClassLoaderRepository; ...@@ -258,27 +258,43 @@ import javax.management.loading.ClassLoaderRepository;
*/ */
public interface MBeanServer extends MBeanServerConnection { public interface MBeanServer extends MBeanServerConnection {
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name) public ObjectInstance createMBean(String className, ObjectName name)
throws ReflectionException, InstanceAlreadyExistsException, throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException; NotCompliantMBeanException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name, public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName) ObjectName loaderName)
throws ReflectionException, InstanceAlreadyExistsException, throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException; NotCompliantMBeanException, InstanceNotFoundException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name, public ObjectInstance createMBean(String className, ObjectName name,
Object params[], String signature[]) Object params[], String signature[])
throws ReflectionException, InstanceAlreadyExistsException, throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException, MBeanException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException; NotCompliantMBeanException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
* <p>If this method successfully creates an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public ObjectInstance createMBean(String className, ObjectName name, public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, Object params[], ObjectName loaderName, Object params[],
String signature[]) String signature[])
...@@ -287,12 +303,15 @@ public interface MBeanServer extends MBeanServerConnection { ...@@ -287,12 +303,15 @@ public interface MBeanServer extends MBeanServerConnection {
NotCompliantMBeanException, InstanceNotFoundException; NotCompliantMBeanException, InstanceNotFoundException;
/** /**
* Registers a pre-existing object as an MBean with the MBean * <p>Registers a pre-existing object as an MBean with the MBean
* server. If the object name given is null, the MBean must * server. If the object name given is null, the MBean must
* provide its own name by implementing the {@link * provide its own name by implementing the {@link
* javax.management.MBeanRegistration MBeanRegistration} interface * javax.management.MBeanRegistration MBeanRegistration} interface
* and returning the name from the {@link * and returning the name from the {@link
* MBeanRegistration#preRegister preRegister} method. * MBeanRegistration#preRegister preRegister} method.</p>
*
* <p>If this method successfully registers an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
* *
* @param object The MBean to be registered as an MBean. * @param object The MBean to be registered as an MBean.
* @param name The object name of the MBean. May be null. * @param name The object name of the MBean. May be null.
...@@ -319,7 +338,12 @@ public interface MBeanServer extends MBeanServerConnection { ...@@ -319,7 +338,12 @@ public interface MBeanServer extends MBeanServerConnection {
throws InstanceAlreadyExistsException, MBeanRegistrationException, throws InstanceAlreadyExistsException, MBeanRegistrationException,
NotCompliantMBeanException; NotCompliantMBeanException;
// doc comment inherited from MBeanServerConnection /**
* {@inheritDoc}
*
* <p>If this method successfully unregisters an MBean, a notification
* is sent as described <a href="#notif">above</a>.</p>
*/
public void unregisterMBean(ObjectName name) public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException; throws InstanceNotFoundException, MBeanRegistrationException;
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package javax.management; package javax.management;
import com.sun.jmx.mbeanserver.GetPropertyAction; import com.sun.jmx.mbeanserver.GetPropertyAction;
import com.sun.jmx.mbeanserver.Util;
import java.io.IOException; import java.io.IOException;
import java.io.InvalidObjectException; import java.io.InvalidObjectException;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
...@@ -1386,12 +1387,7 @@ public class ObjectName extends ToQueryString ...@@ -1386,12 +1387,7 @@ public class ObjectName extends ToQueryString
throws NullPointerException { throws NullPointerException {
if (name.getClass().equals(ObjectName.class)) if (name.getClass().equals(ObjectName.class))
return name; return name;
try { return Util.newObjectName(name.getSerializedNameString());
return new ObjectName(name.getSerializedNameString());
} catch (MalformedObjectNameException e) {
throw new IllegalArgumentException("Unexpected: " + e);
// can't happen
}
} }
/** /**
...@@ -1950,14 +1946,7 @@ public class ObjectName extends ToQueryString ...@@ -1950,14 +1946,7 @@ public class ObjectName extends ToQueryString
* *
* @since 1.6 * @since 1.6
*/ */
public static final ObjectName WILDCARD; public static final ObjectName WILDCARD = Util.newObjectName("*:*");
static {
try {
WILDCARD = new ObjectName("*:*");
} catch (MalformedObjectNameException e) {
throw new Error("Can't initialize wildcard name", e);
}
}
// Category : Utilities <=================================== // Category : Utilities <===================================
......
/*
* Copyright 2007 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package javax.management;
import com.sun.jmx.mbeanserver.NotificationMBeanSupport;
import com.sun.jmx.mbeanserver.Util;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.Set;
/**
* <p>General-purpose notification filter. This filter can be used to
* filter notifications from a possibly-remote MBean. Most filtering
* decisions can be coded using this filter, which avoids having to
* write a custom implementation of the {@link NotificationFilter}
* class. Writing a custom implementation requires you to deploy it
* on both the client and the server in the remote case, so using this class
* instead is recommended where possible.</p>
*
* <!-- <p>Because this class was introduced in version 2.0 of the JMX API,
* it may not be present on a remote JMX agent that is running an earlier
* version. The method {@link JMX#addListenerWithFilter JMX.addListenerWithFilter}
* can be used when you cannot be sure whether this class is present in the
* agent you are connecting to.</p> -->
*
* <p>This class uses the {@linkplain Query Query API} to specify the
* filtering logic. For example, to select only notifications where the
* {@linkplain Notification#getType() type} is {@code "com.example.mytype"},
* you could use</p>
*
* <pre>
* NotificationFilter filter =
* new QueryNotificationFilter("Type = 'com.example.mytype'");
* </pre>
*
* <p>or equivalently</p>
*
* <pre>
* NotificationFilter filter =
* new QueryNotificationFilter(
* Query.eq(Query.attr("Type"), Query.value("com.example.mytype")));
* </pre>
*
* <p>(This particular example could also use
* {@link NotificationFilterSupport}.)</p>
*
* <p>Here are some other examples of filters you can specify with this class.</p>
*
* <dl>
*
* <dt>{@code QueryNotificationFilter("Type = 'com.example.type1' or
* Type = 'com.example.type2'")}
* <dd>Notifications where the type is either of the given strings.
*
* <dt>{@code QueryNotificationFilter("Type in ('com.example.type1',
* 'com.example.type2')")}
* <dd>Another way to write the previous example.
*
* <dt>{@code QueryNotificationFilter("SequenceNumber > 1000")}
* <dd>Notifications where the {@linkplain Notification#getSequenceNumber()
* sequence number} is greater than 1000.
*
* <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class, null)}
* <dd>Notifications where the notification class is
* {@link AttributeChangeNotification} or a subclass of it.
*
* <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class,
* "AttributeName = 'Size'")}
* <dd>Notifications where the notification class is
* {@link AttributeChangeNotification} or a subclass, and where the
* {@linkplain AttributeChangeNotification#getAttributeName() name of the
* changed attribute} is {@code Size}.
*
* <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class,
* "AttributeName = 'Size' and NewValue - OldValue > 100")}
* <dd>As above, but the difference between the
* {@linkplain AttributeChangeNotification#getNewValue() new value} and the
* {@linkplain AttributeChangeNotification#getOldValue() old value} must be
* greater than 100.
*
* <dt>{@code QueryNotificationFilter("like 'com.example.mydomain:*'")}
* <dd>Notifications where the {@linkplain Notification#getSource() source}
* is an ObjectName that matches the pattern.
*
* <dt>{@code QueryNotificationFilter("Source.canonicalName like
* 'com.example.mydomain:%'")}
* <dd>Another way to write the previous example.
*
* <dt>{@code QueryNotificationFilter(MBeanServerNotification.class,
* "Type = 'JMX.mbean.registered' and MBeanName.canonicalName like
* 'com.example.mydomain:%'")}
* <dd>Notifications of class {@link MBeanServerNotification} representing
* an object registered in the domain {@code com.example.mydomain}.
*
* </dl>
*
* <h4>How it works</h4>
*
* <p>Although the examples above are clear, looking closely at the
* Query API reveals a subtlety. A {@link QueryExp} is evaluated on
* an {@link ObjectName}, not a {@code Notification}.</p>
*
* <p>Every time a {@code Notification} is to be filtered by a
* {@code QueryNotificationFilter}, a special {@link MBeanServer} is created.
* This {@code MBeanServer} contains exactly one MBean, which represents the
* {@code Notification}. If the {@linkplain Notification#getSource()
* source} of the notification is an {@code ObjectName}, which is
* recommended practice, then the name of the MBean representing the
* {@code Notification} will be this {@code ObjectName}. Otherwise the
* name is unspecified.</p>
*
* <p>The query specified in the {@code QueryNotificationFilter} constructor
* is evaluated against this {@code MBeanServer} and {@code ObjectName},
* and the filter returns true if and only if the query does. If the
* query throws an exception, then the filter will return false.</p>
*
* <p>The MBean representing the {@code Notification} has one attribute for
* every property of the {@code Notification}. Specifically, for every public
* method {@code T getX()} in the {@code NotificationClass}, the MBean will
* have an attribute called {@code X} of type {@code T}. For example, if the
* {@code Notification} is an {@code AttributeChangeNotification}, then the
* MBean will have an attribute called {@code AttributeName} of type
* {@code "java.lang.String"}, corresponding to the method {@link
* AttributeChangeNotification#getAttributeName}.</p>
*
* <p>Query evaluation usually involves calls to the methods of {@code
* MBeanServer}. The methods have the following behavior:</p>
*
* <ul>
* <li>The {@link MBeanServer#getAttribute getAttribute} method returns the
* value of the corresponding property.
* <li>The {@link MBeanServer#getObjectInstance getObjectInstance}
* method returns an {@link ObjectInstance} where the {@link
* ObjectInstance#getObjectName ObjectName} is the name of the MBean and the
* {@link ObjectInstance#getClassName ClassName} is the class name of the
* {@code Notification}.
* <li>The {@link MBeanServer#isInstanceOf isInstanceOf} method returns true
* if and only if the {@code Notification}'s {@code ClassLoader} can load the
* named class, and the {@code Notification} is an {@linkplain Class#isInstance
* instance} of that class.
* </ul>
*
* <p>These are the only {@code MBeanServer} methods that are needed to
* evaluate standard queries. The behavior of the other {@code MBeanServer}
* methods is unspecified.</p>
*
* @since 1.7
*/
public class QueryNotificationFilter implements NotificationFilter {
private static final long serialVersionUID = -8408613922660635231L;
private static final ObjectName DEFAULT_NAME =
Util.newObjectName(":type=Notification");
private static final QueryExp trueQuery;
static {
ValueExp zero = Query.value(0);
trueQuery = Query.eq(zero, zero);
}
private final QueryExp query;
/**
* Construct a {@code QueryNotificationFilter} that evaluates the given
* {@code QueryExp} to determine whether to accept a notification.
*
* @param query the {@code QueryExp} to evaluate. Can be null,
* in which case all notifications are accepted.
*/
public QueryNotificationFilter(QueryExp query) {
if (query == null)
this.query = trueQuery;
else
this.query = query;
}
/**
* Construct a {@code QueryNotificationFilter} that evaluates the query
* in the given string to determine whether to accept a notification.
* The string is converted into a {@code QueryExp} using
* {@link Query#fromString Query.fromString}.
*
* @param query the string specifying the query to evaluate. Can be null,
* in which case all notifications are accepted.
*
* @throws IllegalArgumentException if the string is not a valid
* query string.
*/
public QueryNotificationFilter(String query) {
this(Query.fromString(query));
}
/**
* <p>Construct a {@code QueryNotificationFilter} that evaluates the query
* in the given string to determine whether to accept a notification,
* and where the notification must also be an instance of the given class.
* The string is converted into a {@code QueryExp} using
* {@link Query#fromString Query.fromString}.</p>
*
* @param notifClass the class that the notification must be an instance of.
* Cannot be null.
*
* @param query the string specifying the query to evaluate. Can be null,
* in which case all notifications are accepted.
*
* @throws IllegalArgumentException if the string is not a valid
* query string, or if {@code notifClass} is null.
*/
public QueryNotificationFilter(
Class<? extends Notification> notifClass, String query) {
this(Query.and(Query.isInstanceOf(Query.value(notNull(notifClass).getName())),
Query.fromString(query)));
}
private static <T> T notNull(T x) {
if (x == null)
throw new IllegalArgumentException("Null argument");
return x;
}
/**
* Retrieve the query that this notification filter will evaluate for
* each notification.
*
* @return the query.
*/
public QueryExp getQuery() {
return query;
}
public boolean isNotificationEnabled(Notification notification) {
ObjectName name;
Object source = notification.getSource();
if (source instanceof ObjectName)
name = (ObjectName) source;
else
name = DEFAULT_NAME;
MBS mbsImpl = new MBS(notification, name);
MBeanServer mbs = (MBeanServer) Proxy.newProxyInstance(
MBeanServer.class.getClassLoader(),
new Class<?>[] {MBeanServer.class},
new ForwardIH(mbsImpl));
return evalQuery(query, mbs, name);
}
private static boolean evalQuery(
QueryExp query, MBeanServer mbs, ObjectName name) {
MBeanServer oldMBS = QueryEval.getMBeanServer();
try {
if (mbs != null)
query.setMBeanServer(mbs);
return query.apply(name);
} catch (Exception e) {
return false;
} finally {
query.setMBeanServer(oldMBS);
}
}
private static class ForwardIH implements InvocationHandler {
private final MBS mbs;
ForwardIH(MBS mbs) {
this.mbs = mbs;
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
Method forward;
try {
forward = MBS.class.getMethod(
method.getName(), method.getParameterTypes());
} catch (NoSuchMethodException e) {
throw new UnsupportedOperationException(method.getName());
}
try {
return forward.invoke(mbs, args);
} catch (InvocationTargetException e) {
throw e.getCause();
}
}
}
private static class MBS {
private final Notification notification;
private final ObjectName objectName;
private final ObjectInstance objectInstance;
private volatile DynamicMBean mbean;
MBS(Notification n, ObjectName name) {
this.notification = n;
this.objectName = name;
this.objectInstance = new ObjectInstance(name, n.getClass().getName());
}
private void checkName(ObjectName name) throws InstanceNotFoundException {
if (!objectName.equals(name))
throw new InstanceNotFoundException(String.valueOf(name));
}
private DynamicMBean mbean(ObjectName name)
throws InstanceNotFoundException, ReflectionException {
if (mbean == null) {
try {
mbean = new NotificationMBeanSupport(notification);
} catch (NotCompliantMBeanException e) {
throw new ReflectionException(e);
}
}
return mbean;
}
public ObjectInstance getObjectInstance(ObjectName name)
throws InstanceNotFoundException {
checkName(name);
return objectInstance;
}
public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
Set<ObjectName> names = queryNames(name, query);
switch (names.size()) {
case 0:
return Collections.emptySet();
case 1:
return Collections.singleton(objectInstance);
default:
throw new UnsupportedOperationException("Internal error");
}
}
public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
if ((name != null && !name.apply(objectName)) ||
(query != null && !evalQuery(query, null, name)))
return Collections.emptySet();
return Collections.singleton(objectName);
}
public boolean isRegistered(ObjectName name) {
return objectName.equals(name);
}
public Integer getMBeanCount() {
return 1;
}
public Object getAttribute(ObjectName name, String attribute)
throws MBeanException, AttributeNotFoundException,
InstanceNotFoundException, ReflectionException {
return mbean(name).getAttribute(attribute);
}
public AttributeList getAttributes(ObjectName name, String[] attributes)
throws InstanceNotFoundException, ReflectionException {
return mbean(name).getAttributes(attributes);
}
public String getDefaultDomain() {
return objectName.getDomain();
}
public String[] getDomains() {
return new String[] {objectName.getDomain()};
}
public MBeanInfo getMBeanInfo(ObjectName name)
throws InstanceNotFoundException, ReflectionException {
return mbean(name).getMBeanInfo();
}
public boolean isInstanceOf(ObjectName name, String className)
throws InstanceNotFoundException {
try {
mbean(name);
ClassLoader loader = notification.getClass().getClassLoader();
Class<?> c = Class.forName(className, false, loader);
return c.isInstance(notification);
} catch (ReflectionException e) {
return false;
} catch (ClassNotFoundException e) {
return false;
}
}
public ClassLoader getClassLoaderFor(ObjectName mbeanName)
throws InstanceNotFoundException {
checkName(mbeanName);
return notification.getClass().getClassLoader();
}
}
}
...@@ -48,6 +48,7 @@ import java.util.logging.Level; ...@@ -48,6 +48,7 @@ import java.util.logging.Level;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Vector;
import javax.management.Attribute; import javax.management.Attribute;
import javax.management.AttributeChangeNotification; import javax.management.AttributeChangeNotification;
import javax.management.AttributeChangeNotificationFilter; import javax.management.AttributeChangeNotificationFilter;
...@@ -132,8 +133,6 @@ public class RequiredModelMBean ...@@ -132,8 +133,6 @@ public class RequiredModelMBean
* and operations will be executed */ * and operations will be executed */
private Object managedResource = null; private Object managedResource = null;
private static final String currClass = "RequiredModelMBean";
/* records the registering in MBeanServer */ /* records the registering in MBeanServer */
private boolean registered = false; private boolean registered = false;
private transient MBeanServer server = null; private transient MBeanServer server = null;
...@@ -2488,10 +2487,13 @@ public class RequiredModelMBean ...@@ -2488,10 +2487,13 @@ public class RequiredModelMBean
} }
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
Vector<String> enabledAttrs = currFilter.getEnabledAttributes();
String s = (enabledAttrs.size() > 1) ?
"[" + enabledAttrs.firstElement() + ", ...]" :
enabledAttrs.toString();
MODELMBEAN_LOGGER.logp(Level.FINER, MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(), mth, RequiredModelMBean.class.getName(), mth,
"Set attribute change filter to " + "Set attribute change filter to " + s);
currFilter.getEnabledAttributes().firstElement());
} }
attributeBroadcaster.addNotificationListener(inlistener,currFilter, attributeBroadcaster.addNotificationListener(inlistener,currFilter,
......
...@@ -303,15 +303,24 @@ public class InstrumentationImpl implements Instrumentation { ...@@ -303,15 +303,24 @@ public class InstrumentationImpl implements Instrumentation {
NoSuchMethodException firstExc = null; NoSuchMethodException firstExc = null;
boolean twoArgAgent = false; boolean twoArgAgent = false;
// The agent class has a premain or agentmain method that has 1 or 2 // The agent class must have a premain or agentmain method that
// arguments. We first check for a signature of (String, Instrumentation), // has 1 or 2 arguments. We check in the following order:
// and if not found we check for (String). If neither is found then we //
// throw the NoSuchMethodException from the first attempt so that the // 1) declared with a signature of (String, Instrumentation)
// exception text indicates the lookup failed for the 2-arg method // 2) declared with a signature of (String)
// (same as JDK5.0). // 3) inherited with a signature of (String, Instrumentation)
// 4) inherited with a signature of (String)
//
// So the declared version of either 1-arg or 2-arg always takes
// primary precedence over an inherited version. After that, the
// 2-arg version takes precedence over the 1-arg version.
//
// If no method is found then we throw the NoSuchMethodException
// from the first attempt so that the exception text indicates
// the lookup failed for the 2-arg method (same as JDK5.0).
try { try {
m = javaAgentClass.getMethod( methodname, m = javaAgentClass.getDeclaredMethod( methodname,
new Class[] { new Class[] {
String.class, String.class,
java.lang.instrument.Instrumentation.class java.lang.instrument.Instrumentation.class
...@@ -323,19 +332,49 @@ public class InstrumentationImpl implements Instrumentation { ...@@ -323,19 +332,49 @@ public class InstrumentationImpl implements Instrumentation {
firstExc = x; firstExc = x;
} }
// check for the 1-arg method
if (m == null) { if (m == null) {
// now try the declared 1-arg method
try {
m = javaAgentClass.getDeclaredMethod(methodname,
new Class[] { String.class });
} catch (NoSuchMethodException x) {
// ignore this exception because we'll try
// two arg inheritance next
}
}
if (m == null) {
// now try the inherited 2-arg method
try {
m = javaAgentClass.getMethod( methodname,
new Class[] {
String.class,
java.lang.instrument.Instrumentation.class
}
);
twoArgAgent = true;
} catch (NoSuchMethodException x) {
// ignore this exception because we'll try
// one arg inheritance next
}
}
if (m == null) {
// finally try the inherited 1-arg method
try { try {
m = javaAgentClass.getMethod(methodname, new Class[] { String.class }); m = javaAgentClass.getMethod(methodname,
new Class[] { String.class });
} catch (NoSuchMethodException x) { } catch (NoSuchMethodException x) {
// Neither method exists so we throw the first NoSuchMethodException // none of the methods exists so we throw the
// as per 5.0 // first NoSuchMethodException as per 5.0
throw firstExc; throw firstExc;
} }
} }
// the premain method should not be required to be public, // the premain method should not be required to be public,
// make it accessible so we can call it // make it accessible so we can call it
// Note: The spec says the following:
// The agent class must implement a public static premain method...
setAccessible(m, true); setAccessible(m, true);
// invoke the 1 or 2-arg method // invoke the 1 or 2-arg method
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
package sun.management; package sun.management;
import java.lang.management.ClassLoadingMXBean; import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
import javax.management.ObjectName;
/** /**
* Implementation class for the class loading subsystem. * Implementation class for the class loading subsystem.
...@@ -62,9 +64,13 @@ class ClassLoadingImpl implements ClassLoadingMXBean { ...@@ -62,9 +64,13 @@ class ClassLoadingImpl implements ClassLoadingMXBean {
} }
public void setVerbose(boolean value) { public void setVerbose(boolean value) {
ManagementFactory.checkControlAccess(); Util.checkControlAccess();
setVerboseClass(value); setVerboseClass(value);
} }
native static void setVerboseClass(boolean value); native static void setVerboseClass(boolean value);
public ObjectName getObjectName() {
return Util.newObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
}
} }
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
package sun.management; package sun.management;
import java.lang.management.CompilationMXBean; import java.lang.management.CompilationMXBean;
import java.lang.management.ManagementFactory;
import javax.management.ObjectName;
/** /**
* Implementation class for the compilation subsystem. * Implementation class for the compilation subsystem.
...@@ -46,7 +48,7 @@ class CompilationImpl implements CompilationMXBean { ...@@ -46,7 +48,7 @@ class CompilationImpl implements CompilationMXBean {
this.jvm = vm; this.jvm = vm;
this.name = jvm.getCompilerName(); this.name = jvm.getCompilerName();
if (name == null) { if (name == null) {
throw new InternalError("Null compiler name"); throw new AssertionError("Null compiler name");
} }
} }
...@@ -67,4 +69,9 @@ class CompilationImpl implements CompilationMXBean { ...@@ -67,4 +69,9 @@ class CompilationImpl implements CompilationMXBean {
return jvm.getTotalCompileTime(); return jvm.getTotalCompileTime();
} }
public ObjectName getObjectName() {
return Util.newObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
}
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册