Merge
This commit is contained in:
commit
73cad1123e
@ -141,3 +141,4 @@ a4f28069d44a379cda99dd1d921d19f819726d22 jdk8-b15
|
||||
4e06ae613e99549835896720c7a68c29ad5543f5 jdk8-b16
|
||||
7010bd24cdd07bc7daef80702f39124854dec36c jdk8-b18
|
||||
237bc29afbfc6f56a4fe4a6008e2befb59c44bac jdk8-b19
|
||||
5a5eaf6374bcbe23530899579fed17a05b7705f3 jdk8-b20
|
||||
|
@ -141,3 +141,4 @@ e59c47de1ad8982ff3b0e843773a6902b36c2337 jdk8-b14
|
||||
82dc033975bb9b553b4ef97b6d483eda8de32e0f jdk8-b16
|
||||
312cf15d16577ef198b033d2a4cc0a52369b7343 jdk8-b18
|
||||
e1366c5d84ef984095a332bcee70b3938232d07d jdk8-b19
|
||||
51d8b6cb18c0978ecfa4f33e1537d35ee01b69fa jdk8-b20
|
||||
|
@ -208,3 +208,4 @@ a2fef924d8e6f37dac2a887315e3502876cc8e24 hs23-b08
|
||||
61165f53f1656b9f99e4fb806429bf98b99d59c3 jdk8-b18
|
||||
4bcf61041217f8677dcec18e90e9196acc945bba hs23-b09
|
||||
9232e0ecbc2cec54dcc8f93004fb00c214446460 jdk8-b19
|
||||
fe2c8764998112b7fefcd7d41599714813ae4327 jdk8-b20
|
||||
|
@ -141,3 +141,4 @@ bcc739229f6384786c7ac0b52c1822c85674dcf1 jdk8-b13
|
||||
09eb517404b059607aca30cdd1af83ffc57eafeb jdk8-b16
|
||||
ebec6a7e8d4e481d205a2109ddeea8121d76db7f jdk8-b18
|
||||
dffeb62b1a7fc8b316bf58fe5479323f3661894e jdk8-b19
|
||||
f052abb8f37444ba77858913887d0d92795dd6b8 jdk8-b20
|
||||
|
@ -141,3 +141,4 @@ c9ab96ff23d52d85d5dcce1f9c0fd7a3de418c74 jdk8-b15
|
||||
3d45ab79643d5b4cc7e050ae2d9c08b4d89d665e jdk8-b16
|
||||
54928c8850f5498670dd43d6c9299f36de1a6746 jdk8-b18
|
||||
b73b733214aa43648d69a2da51e6b48fda902a2d jdk8-b19
|
||||
2b2818e3386f4510c390f6aea90d77e1c6a5bf9e jdk8-b20
|
||||
|
@ -96,6 +96,10 @@
|
||||
</replaceregexp>
|
||||
|
||||
<mkdir dir="${build.classes.dir}/META-INF/services"/>
|
||||
<copy todir="${build.classes.dir}/META-INF"
|
||||
file="${secondary.src.dir}/META-INF/mailcap.default"/>
|
||||
<copy todir="${build.classes.dir}/META-INF"
|
||||
file="${secondary.src.dir}/META-INF/mimetypes.default"/>
|
||||
<copy todir="${build.classes.dir}/META-INF/services"
|
||||
file="${primary.src.dir}/com/sun/tools/etc/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory"/>
|
||||
<copy todir="${build.classes.dir}/META-INF/services"
|
||||
@ -118,6 +122,7 @@
|
||||
<!-- Set up source to use drop.dir. -->
|
||||
<target name="-use-drop" depends="-set-props">
|
||||
<property name="primary.src.dir" value="${jaxws_src.src.dir}"/>
|
||||
<property name="secondary.src.dir" value="${jaf_src.src.dir}"/>
|
||||
<path id="src.dir.id">
|
||||
<pathelement path="${primary.src.dir}"/>
|
||||
<pathelement path="${jaf_src.src.dir}"/>
|
||||
|
@ -141,3 +141,4 @@ b71d1acfae5240d8c1359443cd02b5ddb587231c jdk8-b17
|
||||
929597c6e777f742ad252660045ebaa4a3ea4772 jdk8-b16
|
||||
334bd51fb3f321cd6777416ae7bafac71a84140a jdk8-b18
|
||||
3778f85773055e81eab6c5ef828935ecca241810 jdk8-b19
|
||||
39e938cd1b82ec3aab0a9aa66fd8a0457cd0c9c2 jdk8-b20
|
||||
|
@ -32,6 +32,9 @@
|
||||
BUILDDIR = ../../../../..
|
||||
PACKAGE = com.sun.demo.jvmti.hprof
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -28,6 +28,9 @@
|
||||
BUILDDIR = ../../../../..
|
||||
PACKAGE = com.sun.java.browser.net
|
||||
PRODUCT = plugin
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -30,6 +30,9 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = com.sun.tools
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
AUTO_FILES_JAVA_DIRS = com/sun/tools/extcheck
|
||||
|
@ -28,6 +28,9 @@ BUILDDIR = ../../../..
|
||||
PACKAGE = com.sun.tools.attach
|
||||
LIBRARY = attach
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
ifeq ($(PLATFORM), solaris)
|
||||
|
@ -30,6 +30,9 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = com.sun.tracing
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
SUBDIRS = dtrace
|
||||
|
@ -29,6 +29,9 @@
|
||||
BUILDDIR = ../../../..
|
||||
PACKAGE = com.sun.tracing.dtrace
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
AUTO_FILES_JAVA_DIRS = com/sun/tracing/dtrace
|
||||
|
@ -72,7 +72,6 @@ FDDLIBM_SUFFIX = a
|
||||
SCRIPT_SUFFIX =
|
||||
# CC compiler object code output directive flag value
|
||||
CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
|
||||
CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
|
||||
|
||||
# Default OBJCOPY comes from GNU Binutils on Linux:
|
||||
DEF_OBJCOPY=/usr/bin/objcopy
|
||||
|
@ -72,7 +72,6 @@ FDDLIBM_SUFFIX = a
|
||||
SCRIPT_SUFFIX =
|
||||
# CC compiler object code output directive flag value
|
||||
CC_OBJECT_OUTPUT_FLAG = -o #trailing blank required!
|
||||
CC_PROGRAM_OUTPUT_FLAG = -o #trailing blank required!
|
||||
|
||||
ifdef ENABLE_FULL_DEBUG_SYMBOLS
|
||||
# Only check for Full Debug Symbols support on Solaris if it is
|
||||
|
@ -36,7 +36,6 @@ include $(JDK_MAKE_SHARED_DIR)/Defs.gmk
|
||||
|
||||
# CC compiler object code output directive flag value
|
||||
CC_OBJECT_OUTPUT_FLAG = -Fo
|
||||
CC_PROGRAM_OUTPUT_FLAG = -Fe
|
||||
|
||||
# The suffix applied to the library name for FDLIBM
|
||||
FDDLIBM_SUFFIX = lib
|
||||
|
@ -319,9 +319,12 @@ $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS)
|
||||
@$(prep-target)
|
||||
ifeq ($(PLATFORM),windows)
|
||||
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
|
||||
endif
|
||||
$(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \
|
||||
$(LINK.demo) $(SHARED_LIBRARY_FLAG) -Fe$@ \
|
||||
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
|
||||
else
|
||||
$(LINK.demo) $(SHARED_LIBRARY_FLAG) -o $@ \
|
||||
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
|
||||
endif
|
||||
@$(call binary_file_verification,$@)
|
||||
|
||||
# Generation of any javah include file, make sure objects are dependent on it
|
||||
|
@ -323,6 +323,7 @@ TOOLS = \
|
||||
sun/tools/jar \
|
||||
sun/tools/java \
|
||||
sun/tools/javac \
|
||||
sun/tools/jcmd \
|
||||
sun/tools/jps \
|
||||
sun/tools/jstat \
|
||||
sun/tools/jstatd \
|
||||
@ -435,6 +436,7 @@ NOTJRETOOLS = \
|
||||
apt$(EXE_SUFFIX) \
|
||||
javah$(EXE_SUFFIX) \
|
||||
javap$(EXE_SUFFIX) \
|
||||
jcmd$(EXE_SUFFIX) \
|
||||
jdb$(EXE_SUFFIX) \
|
||||
jps$(EXE_SUFFIX) \
|
||||
jrunscript$(EXE_SUFFIX) \
|
||||
@ -544,6 +546,7 @@ $(NOT_RT_JAR_LIST): FRC
|
||||
$(ECHO) "sun/tools/javac/" >> $@
|
||||
$(ECHO) "com/sun/tools/classfile/" >> $@
|
||||
$(ECHO) "com/sun/tools/javap/" >> $@
|
||||
$(ECHO) "sun/tools/jcmd/" >> $@
|
||||
$(ECHO) "sun/tools/jconsole/" >> $@
|
||||
$(ECHO) "sun/tools/jps/" >> $@
|
||||
$(ECHO) "sun/tools/jstat/" >> $@
|
||||
|
@ -147,8 +147,8 @@ ifeq ($(SYSTEM_UNAME), SunOS)
|
||||
endif
|
||||
# Suffix for file bundles used in previous release
|
||||
BUNDLE_FILE_SUFFIX=.tar
|
||||
# How much RAM does this machine have:
|
||||
MB_OF_MEMORY=$(shell /usr/sbin/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3)
|
||||
# How much RAM does this machine have (zones send an error to stderr):
|
||||
MB_OF_MEMORY:=$(shell /usr/sbin/prtconf 2>/dev/null | fgrep 'Memory size:' | expand | cut -d' ' -f3)
|
||||
endif
|
||||
|
||||
# Platform settings specific to Linux
|
||||
|
@ -38,6 +38,9 @@ MS_RUNTIME_STATIC=true
|
||||
|
||||
FILES_m = mapfile-vers
|
||||
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
# Use the mapfile-vers (See the mapfile located with this Makefile)
|
||||
|
@ -54,6 +54,9 @@ SUNWprivate_1.1 {
|
||||
Java_sun_management_GcInfoBuilder_getLastGcInfo0;
|
||||
Java_sun_management_GcInfoBuilder_getNumGcExtAttributes;
|
||||
Java_sun_management_HotSpotDiagnostic_dumpHeap;
|
||||
Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0;
|
||||
Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0;
|
||||
Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0;
|
||||
Java_sun_management_HotspotThread_getInternalThreadCount;
|
||||
Java_sun_management_HotspotThread_getInternalThreadTimes0;
|
||||
Java_sun_management_MemoryImpl_getMemoryManagers0;
|
||||
|
@ -31,6 +31,9 @@ BUILDDIR = ../..
|
||||
|
||||
PACKAGE = java.rmi
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
AUTO_FILES_JAVA_DIRS = java/rmi
|
||||
|
@ -26,6 +26,8 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = java.text
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = java.text
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -32,6 +32,8 @@ BUILDDIR = ../..
|
||||
|
||||
PACKAGE = java.util.resources
|
||||
PRODUCT = java
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = java.accessibility
|
||||
PRODUCT = java
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -28,6 +28,9 @@
|
||||
#
|
||||
|
||||
BUILDDIR = ../..
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -28,8 +28,8 @@
|
||||
#
|
||||
|
||||
BUILDDIR = ../..
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
|
@ -31,6 +31,9 @@ BUILDDIR = ../..
|
||||
PACKAGE = com.sun.tools.example.debug.tty
|
||||
PRODUCT = jpda
|
||||
PROGRAM = jdb
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
# This program must contain a manifest that defines the execution level
|
||||
|
@ -64,6 +64,7 @@ $(call make-launcher, javac, com.sun.tools.javac.Main, , )
|
||||
$(call make-launcher, javadoc, com.sun.tools.javadoc.Main, , )
|
||||
$(call make-launcher, javah, com.sun.tools.javah.Main, , )
|
||||
$(call make-launcher, javap, com.sun.tools.javap.Main, , )
|
||||
$(call make-launcher, jcmd, sun.tools.jcmd.JCmd, , )
|
||||
$(call make-launcher, jconsole, sun.tools.jconsole.JConsole, \
|
||||
-J-Djconsole.showOutputViewer, )
|
||||
$(call make-launcher, jdb, com.sun.tools.example.debug.tty.TTY, , )
|
||||
|
@ -26,6 +26,9 @@
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = sun.launcher
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -30,6 +30,9 @@
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = sun.tools.serialver
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -31,6 +31,8 @@ BUILDDIR = ../..
|
||||
|
||||
PACKAGE = sun.text
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
|
@ -42,6 +42,7 @@ AUTO_FILES_JAVA_DIRS = \
|
||||
sun/tools/jstack \
|
||||
sun/tools/jstat \
|
||||
sun/tools/jstatd \
|
||||
sun/tools/jcmd \
|
||||
com/sun/tools/hat \
|
||||
com/sun/tools/script/shell \
|
||||
sun/jvmstat
|
||||
|
@ -26,6 +26,9 @@
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = sun.util
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -40,18 +40,19 @@ ifeq ($(PLATFORM), windows)
|
||||
FT_OPTIONS = /nologo /c
|
||||
FREETYPE_DLL = $(FREETYPE_LIB_PATH)/freetype.dll
|
||||
FT_LD_OPTIONS = $(FREETYPE_LIB_PATH)/freetype.lib
|
||||
ifdef MT
|
||||
FT_LD_OPTIONS += /manifest
|
||||
endif
|
||||
ifdef MT
|
||||
FT_LD_OPTIONS += /manifest
|
||||
endif
|
||||
else
|
||||
FT_OPTIONS = $(CFLAGS)
|
||||
FT_LD_OPTIONS = -L$(FREETYPE_LIB_PATH)
|
||||
# Add runtime lib search path to ensure test will be runnable
|
||||
ifeq ($(PLATFORM), solaris)
|
||||
FT_LD_OPTIONS += -R $(FREETYPE_LIB_PATH) -lfreetype
|
||||
else #linux
|
||||
FT_LD_OPTIONS += -Wl,-rpath -Wl,$(FREETYPE_LIB_PATH) -lfreetype
|
||||
ifeq ($(PLATFORM), linux)
|
||||
FT_LD_OPTIONS += -Wl,-rpath -Wl,$(FREETYPE_LIB_PATH)
|
||||
else # other unix
|
||||
FT_LD_OPTIONS += -R $(FREETYPE_LIB_PATH)
|
||||
endif
|
||||
FT_LD_OPTIONS += -lfreetype
|
||||
endif
|
||||
FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH)
|
||||
FT_OPTIONS += -I$(FREETYPE_HEADERS_PATH)/freetype2
|
||||
@ -70,12 +71,12 @@ ifeq ($(PLATFORM), windows)
|
||||
$(CC) $(FT_OPTIONS) $(CC_OBJECT_OUTPUT_FLAG)$(FT_OBJ) $<
|
||||
$(LINK) $(FT_LD_OPTIONS) /OUT:$(FT_TEST) $(FT_OBJ)
|
||||
$(CP) $(FREETYPE_DLL) $(@D)/
|
||||
ifdef MT
|
||||
ifdef MT
|
||||
$(CP) $(MSVCRNN_DLL_PATH)/$(MSVCRNN_DLL) $(@D)/
|
||||
$(MT) /manifest $(FT_TEST).manifest /outputresource:$(FT_TEST);#1
|
||||
endif
|
||||
endif
|
||||
else
|
||||
@$(CC) $(FT_OPTIONS) $(CC_PROGRAM_OUTPUT_FLAG)$@ $< $(FT_LD_OPTIONS)
|
||||
@$(CC) $(FT_OPTIONS) -o $@ $< $(FT_LD_OPTIONS)
|
||||
endif
|
||||
|
||||
else
|
||||
|
124
jdk/src/linux/doc/man/jcmd.1
Normal file
124
jdk/src/linux/doc/man/jcmd.1
Normal file
@ -0,0 +1,124 @@
|
||||
." Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
."
|
||||
." This code is free software; you can redistribute it and/or modify it
|
||||
." under the terms of the GNU General Public License version 2 only, as
|
||||
." published by the Free Software Foundation.
|
||||
."
|
||||
." This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
." version 2 for more details (a copy is included in the LICENSE file that
|
||||
." accompanied this code).
|
||||
."
|
||||
." You should have received a copy of the GNU General Public License version
|
||||
." 2 along with this work; if not, write to the Free Software Foundation,
|
||||
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
."
|
||||
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
." or visit www.oracle.com if you need additional information or have any
|
||||
." questions.
|
||||
."
|
||||
.TH jcmd 1 "22 Novembre 2011"
|
||||
|
||||
.LP
|
||||
.SH "Name"
|
||||
jcmd \- Diagnostic Command
|
||||
.br
|
||||
|
||||
.LP
|
||||
.SH "SYNOPSIS"
|
||||
.LP
|
||||
.nf
|
||||
\f3
|
||||
.fl
|
||||
\fP\f3jcmd\fP [ option ]
|
||||
.fl
|
||||
\f3jcmd\fP <\fIpid\fR | \fImain class\fR> PerfCounter.print
|
||||
.fl
|
||||
\f3jcmd\fP <\fIpid\fR | \fImain class\fR> \fIcommand\fR [\fIarguments\fR]
|
||||
.fl
|
||||
\f3jcmd\fP <\fIpid\fR | \fImain class\fR> -f \fIfile\fR
|
||||
.fl
|
||||
.fl
|
||||
.fi
|
||||
|
||||
.LP
|
||||
.SH "DESCRIPTION"
|
||||
.LP
|
||||
.LP
|
||||
\f3jcmd\fP is a utility to send diagnostic command requests to a Java
|
||||
Virtual Machine supporting this feature. Used without arguments or with the \-l option, jcmd prints the list of running Java processes with their process id, their main class and their command line arguments. When a process id is specified on the command line, jcmd sends the diagnostic command request to the process with this id. When a main class is specified on the command line, jcmd sends the diagnostic command request to all Java processes with this main class. With the PerfCounter.print argument, jcmd prints the performance counters available on the targeted Java process(es). With the \-f option, jcmd sends to the targeted Java process(es) the diagnostic commands stored in the file \fIfile\fR.
|
||||
.LP
|
||||
\fP
|
||||
.fi
|
||||
|
||||
.SH "OPTIONS"
|
||||
.LP
|
||||
.LP
|
||||
Options are mutually exclusive. Options, if used, should follow immediately after the command name.
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 3
|
||||
\-l
|
||||
prints the list of running Java processes with their process id, their
|
||||
main class and their command line arguments.
|
||||
.TP 3
|
||||
\-h
|
||||
prints a help message.
|
||||
.br
|
||||
.br
|
||||
.TP 3
|
||||
\-help
|
||||
prints a help message
|
||||
.br
|
||||
.RE
|
||||
|
||||
.LP
|
||||
.SH "PARAMETERS"
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fIpid\fR
|
||||
Identifies the process which will receive the diagnostic command requests. The process must be a Java process. To get a list of Java processes running on a machine, jps(1) or jcmd(1) may be used.
|
||||
.RE
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fImain class\fR
|
||||
Main class of the process which will receive the diagnostic command requests. If several running Java processes share this main class, the diagnostic command request will be sent to all these processes. To get a list of Java processes running on a machine, jps(1) or jcmd(1) may be used.
|
||||
.RE
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fIcommand\fR [\fIarguments\fR]
|
||||
Invoke the diagnostic command called \fIcommand\fR on the targeted Java
|
||||
process(es). The list of available diagnostic commands for a given
|
||||
process can be obtained by invoking the 'help' command on this process.
|
||||
Each diagnostic command has its own set of \fIarguments\fR which can be
|
||||
obtained by invoking the 'help' command followed by the command name.
|
||||
.RE
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fIPerfCounter.print\fR
|
||||
Print the performance counters available on the targeted Java
|
||||
process(es). The list of performance counters may vary with the Java
|
||||
process.
|
||||
.RE
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fI-f file\fR
|
||||
Read commands from \fIfile\fR and invoke them on the targeted Java
|
||||
process(es). In \fIfile\fR, each command must be written on a single line.
|
||||
Lines starting with # are ignored. Processing of \fIfile\fR ends when
|
||||
all lines have been invoked or when a line containing the 'stop' keyword
|
||||
is read.
|
||||
.LP
|
||||
.SH "SEE ALSO"
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 2
|
||||
o
|
||||
jps(1)
|
||||
.RE
|
||||
|
||||
|
@ -382,6 +382,11 @@ JavaMain(void * _args)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (showSettings != NULL) {
|
||||
ShowSettings(env, showSettings);
|
||||
CHECK_EXCEPTION_LEAVE(1);
|
||||
}
|
||||
|
||||
if (printVersion || showVersion) {
|
||||
PrintJavaVersion(env, showVersion);
|
||||
CHECK_EXCEPTION_LEAVE(0);
|
||||
@ -390,10 +395,6 @@ JavaMain(void * _args)
|
||||
}
|
||||
}
|
||||
|
||||
if (showSettings != NULL) {
|
||||
ShowSettings(env, showSettings);
|
||||
CHECK_EXCEPTION_LEAVE(1);
|
||||
}
|
||||
/* If the user specified neither a class name nor a JAR file */
|
||||
if (printXUsage || printUsage || what == 0 || mode == LM_UNKNOWN) {
|
||||
PrintUsage(env, printXUsage);
|
||||
|
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.management;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
/**
|
||||
* Diagnostic Command Argument information. It contains the description
|
||||
* of one parameter of the diagnostic command. A parameter can either be an
|
||||
* option or an argument. Options are identified by the option name while
|
||||
* arguments are identified by their position in the command line. The generic
|
||||
* syntax of a diagnostic command is:
|
||||
* <blockquote>
|
||||
* <command name> [<option>=<value>] [<argument_value>]
|
||||
* </blockquote>
|
||||
* Example:
|
||||
* <blockquote>
|
||||
* command_name option1=value1 option2=value argumentA argumentB argumentC
|
||||
* </blockquote>
|
||||
* In this command line, the diagnostic command receives five parameters, two
|
||||
* options named {@code option1} and {@code option2}, and three arguments.
|
||||
* argumentA's position is 0, argumentB's position is 1 and argumentC's
|
||||
* position is 2.
|
||||
*
|
||||
* @author Frederic Parain
|
||||
* @since 7u4
|
||||
*/
|
||||
|
||||
public class DiagnosticCommandArgumentInfo {
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String type;
|
||||
private final String defaultValue;
|
||||
private final boolean mandatory;
|
||||
private final boolean option;
|
||||
private final int position;
|
||||
|
||||
/**
|
||||
* Returns the argument name
|
||||
*
|
||||
* @return the argument name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the argument description
|
||||
*
|
||||
* @return the argument description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the argument type
|
||||
*
|
||||
* @return the argument type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default value as a String if a default value
|
||||
* is defined, null otherwise.
|
||||
*
|
||||
* @return the default value as a String if a default value
|
||||
* is defined, null otherwise.
|
||||
*/
|
||||
public String getDefault() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the argument is mandatory,
|
||||
* {@code false} otherwise
|
||||
*
|
||||
* @return {@code true} if the argument is mandatory,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
public boolean isMandatory() {
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the argument is an option,
|
||||
* {@code false} otherwise. Options have to be specified using the
|
||||
* <key>=<value> syntax on the command line, while other
|
||||
* arguments are specified with a single <value> field and are
|
||||
* identified by their position on command line.
|
||||
*
|
||||
* @return {@code true} if the argument is an option,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
public boolean isOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expected position of this argument if it is not an option,
|
||||
* -1 otherwise. Argument position if defined from left to right,
|
||||
* starting at zero and ignoring the diagnostic command name and
|
||||
* options.
|
||||
*
|
||||
* @return the expected position of this argument if it is not an option,
|
||||
* -1 otherwise.
|
||||
*/
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
@ConstructorProperties({"name","description","type","default",
|
||||
"mandatory","option","position"})
|
||||
public DiagnosticCommandArgumentInfo(String name, String description,
|
||||
String type, String defaultValue,
|
||||
boolean mandatory, boolean option,
|
||||
int position) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
this.defaultValue = defaultValue;
|
||||
this.mandatory = mandatory;
|
||||
this.option = option;
|
||||
this.position = position;
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.management;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Diagnostic command information. It contains the description of a
|
||||
* diagnostic command.
|
||||
*
|
||||
* @author Frederic Parain
|
||||
* @since 7u4
|
||||
*/
|
||||
|
||||
public class DiagnosticCommandInfo {
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final String impact;
|
||||
private final boolean enabled;
|
||||
private final List<DiagnosticCommandArgumentInfo> arguments;
|
||||
|
||||
/**
|
||||
* Returns the diagnostic command name
|
||||
*
|
||||
* @return the diagnostic command name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the diagnostic command description
|
||||
*
|
||||
* @return the diagnostic command description
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the potential impact of the diagnostic command execution
|
||||
* on the Java virtual machine behavior
|
||||
*
|
||||
* @return the potential impact of the diagnostic command execution
|
||||
* on the Java virtual machine behavior
|
||||
*/
|
||||
public String getImpact() {
|
||||
return impact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the diagnostic command is enabled,
|
||||
* {@code false} otherwise. The enabled/disabled
|
||||
* status of a diagnostic command can evolve during
|
||||
* the lifetime of the Java virtual machine.
|
||||
*
|
||||
* @return {@code true} if the diagnostic command is enabled,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of the diagnostic command arguments description.
|
||||
* If the diagnostic command has no arguments, it returns an empty list.
|
||||
*
|
||||
* @return a list of the diagnostic command arguments description
|
||||
*/
|
||||
public List<DiagnosticCommandArgumentInfo> getArgumentsInfo() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@ConstructorProperties({"name", "description","impact","enabled",
|
||||
"argumentsInfo"})
|
||||
public DiagnosticCommandInfo(String name, String description,
|
||||
String impact, boolean enabled,
|
||||
List<DiagnosticCommandArgumentInfo> arguments)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.impact = impact;
|
||||
this.enabled = enabled;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,18 @@
|
||||
|
||||
package com.sun.management;
|
||||
|
||||
import java.util.List;
|
||||
import java.lang.management.PlatformManagedObject;
|
||||
|
||||
/**
|
||||
* Diagnostic management interface for the HotSpot Virtual Machine.
|
||||
* The diagnostic MBean is registered to the platform MBeanServer
|
||||
*
|
||||
* <p>{@linkplain #getDiagnosticCommands Diagnostic commands}
|
||||
* are actions that can be invoked dynamically and
|
||||
* executed in a target Java virtual machine, mainly for troubleshooting
|
||||
* and diagnosis.
|
||||
*
|
||||
* <p>The diagnostic MBean is registered to the platform MBeanServer
|
||||
* as are other platform MBeans.
|
||||
*
|
||||
* <p>The <tt>ObjectName</tt> for uniquely identifying the diagnostic
|
||||
@ -41,6 +48,9 @@ import java.lang.management.PlatformManagedObject;
|
||||
* It can be obtained by calling the
|
||||
* {@link PlatformManagedObject#getObjectName} method.
|
||||
*
|
||||
* All methods throw a {@code NullPointerException} if any input argument is
|
||||
* {@code null} unless it's stated otherwise.
|
||||
*
|
||||
* @see ManagementFactory#getPlatformMXBeans(Class)
|
||||
*/
|
||||
public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
|
||||
@ -101,9 +111,113 @@ public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
|
||||
* @throws IllegalArgumentException if the VM option is not writeable.
|
||||
* @throws NullPointerException if name or value is <tt>null</tt>.
|
||||
*
|
||||
* @throws java.security.SecurityException
|
||||
* @throws java.lang.SecurityException
|
||||
* if a security manager exists and the caller does not have
|
||||
* ManagementPermission("control").
|
||||
*/
|
||||
public void setVMOption(String name, String value);
|
||||
|
||||
/**
|
||||
* Returns the {@linkplain DiagnosticCommandInfo#getName() names}
|
||||
* of all diagnostic commands.
|
||||
* A diagnostic command is an action that can be invoked dynamically
|
||||
* mainly for troubleshooting and diagnosis. The list of diagnostic
|
||||
* commands may change at runtime. A diagnostic command may be
|
||||
* {@linkplain DiagnosticCommandInfo#isEnabled disabled} but will
|
||||
* not be removed from a previously returned list.
|
||||
*
|
||||
* @return the names of all diagnostic commands.
|
||||
*
|
||||
* @since 7u4
|
||||
*/
|
||||
public List<String> getDiagnosticCommands();
|
||||
|
||||
/**
|
||||
* Returns a {@code DiagnosticCommandInfo} object describing the
|
||||
* diagnostic command of the specified name {@code command}
|
||||
*
|
||||
* @param command a diagnostic command name
|
||||
* @return a {@code DiagnosticCommandInfo} object
|
||||
* @throws java.lang.IllegalArgumentException if the {@code command}
|
||||
* doesn't match any diagnostic command registered in the
|
||||
* targeted Java virtual machine.
|
||||
*
|
||||
* @since 7u4
|
||||
*/
|
||||
public DiagnosticCommandInfo getDiagnosticCommandInfo(String command);
|
||||
|
||||
/**
|
||||
* Returns a list of {@code DiagnosticCommandInfo} object describing
|
||||
* all diagnostic commands available on the targeted Java virtual machine
|
||||
*
|
||||
* @return a list of {@code DiagnosticCommandInfo} objects
|
||||
*
|
||||
* @since 7u4
|
||||
*/
|
||||
public List<DiagnosticCommandInfo> getDiagnosticCommandInfo();
|
||||
|
||||
/**
|
||||
* Returns a list of {@code DiagnosticCommandInfo} object describing
|
||||
* all diagnostic commands specified in the {@code commands} list.
|
||||
*
|
||||
* @param commands {@code List} of {@code String} containing diagnostic
|
||||
* command names
|
||||
* @return a {@code List} of {@code DiagnosticCommandInfo} objects
|
||||
*
|
||||
* @throws java.lang.IllegalArgumentException if at least one
|
||||
* command specified in the {@code commands } list
|
||||
* doesn't match any diagnostic command registered in the
|
||||
* targeted Java virtual machine.
|
||||
*
|
||||
* @since 7u4
|
||||
*/
|
||||
public List<DiagnosticCommandInfo> getDiagnosticCommandInfo(List<String> commands);
|
||||
|
||||
/**
|
||||
* Executes the command line {@code commandLine}. The command line must
|
||||
* start with a diagnostic command name, optionally followed by parameters.
|
||||
* Each command has its own syntax but the generic syntax for a diagnostic
|
||||
* command line is:
|
||||
* <blockquote>
|
||||
* <command name> [<option>=<value>] [<argument_value>]
|
||||
* </blockquote>
|
||||
*
|
||||
* @param commandLine command line to execute
|
||||
* @return a {@code String} object containing the diagnostic command
|
||||
* output.
|
||||
*
|
||||
* @throws java.lang.IllegalArgumentException if the command line doesn't
|
||||
* match any diagnostic command registered in the virtual machine
|
||||
* of if the parameters don't match the diagnostic command syntax.
|
||||
* @throws java.lang.SecurityException
|
||||
* if a security manager exists and the caller does not have
|
||||
* ManagementPermission("control").
|
||||
*
|
||||
* @since 7u4
|
||||
*/
|
||||
public String execute(String commandLine);
|
||||
|
||||
/**
|
||||
* Invokes the diagnostic command named {@code cmd} with the parameters
|
||||
* specified in {@code args}. Each command has its own syntax but
|
||||
* the generic syntax for parameters is:
|
||||
* <blockquote>
|
||||
* [<option>=<value>] [<argument_value>]
|
||||
* </blockquote>
|
||||
*
|
||||
* @param cmd a diagnostic command name
|
||||
* @param args the command parameters
|
||||
* @return a {@code String} object containing the diagnostic command
|
||||
* output.
|
||||
*
|
||||
* @throws java.lang.IllegalArgumentException if the command line doesn't
|
||||
* match any diagnostic command registered in the virtual machine
|
||||
* of if the parameters don't match the diagnostic command syntax.
|
||||
* @throws java.lang.SecurityException
|
||||
* if a security manager exists and the caller does not have
|
||||
* ManagementPermission("control").
|
||||
*
|
||||
* @since 7u4
|
||||
*/
|
||||
public String execute(String cmd, String... args);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ abstract public class ContentHandler {
|
||||
* @exception IOException if an I/O error occurs while reading the object.
|
||||
* @since 1.3
|
||||
*/
|
||||
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
|
||||
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
|
||||
Object obj = getContent(urlc);
|
||||
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
|
@ -175,9 +175,15 @@ public final class AclEntry {
|
||||
* AclEntryPermission}
|
||||
*/
|
||||
public Builder setPermissions(Set<AclEntryPermission> perms) {
|
||||
// copy and check for erroneous elements
|
||||
perms = EnumSet.copyOf(perms);
|
||||
checkSet(perms, AclEntryPermission.class);
|
||||
if (perms.isEmpty()) {
|
||||
// EnumSet.copyOf does not allow empty set
|
||||
perms = Collections.emptySet();
|
||||
} else {
|
||||
// copy and check for erroneous elements
|
||||
perms = EnumSet.copyOf(perms);
|
||||
checkSet(perms, AclEntryPermission.class);
|
||||
}
|
||||
|
||||
this.perms = perms;
|
||||
return this;
|
||||
}
|
||||
@ -212,9 +218,15 @@ public final class AclEntry {
|
||||
* AclEntryFlag}
|
||||
*/
|
||||
public Builder setFlags(Set<AclEntryFlag> flags) {
|
||||
// copy and check for erroneous elements
|
||||
flags = EnumSet.copyOf(flags);
|
||||
checkSet(flags, AclEntryFlag.class);
|
||||
if (flags.isEmpty()) {
|
||||
// EnumSet.copyOf does not allow empty set
|
||||
flags = Collections.emptySet();
|
||||
} else {
|
||||
// copy and check for erroneous elements
|
||||
flags = EnumSet.copyOf(flags);
|
||||
checkSet(flags, AclEntryFlag.class);
|
||||
}
|
||||
|
||||
this.flags = flags;
|
||||
return this;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,9 +27,13 @@ package sun.management;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import com.sun.management.DiagnosticCommandInfo;
|
||||
import com.sun.management.DiagnosticCommandArgumentInfo;
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
import com.sun.management.VMOption;
|
||||
|
||||
@ -116,7 +120,54 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getDiagnosticCommands() {
|
||||
String[] commands = getDiagnosticCommands0();
|
||||
return commands == null ? Collections.<String>emptyList() :
|
||||
Arrays.asList(commands);
|
||||
}
|
||||
|
||||
public DiagnosticCommandInfo getDiagnosticCommandInfo(String command) {
|
||||
String[] array = new String[] { command };
|
||||
return getDiagnosticCommandInfo0(array)[0];
|
||||
}
|
||||
|
||||
public List<DiagnosticCommandInfo> getDiagnosticCommandInfo() {
|
||||
String[] commands = getDiagnosticCommands0();
|
||||
return Arrays.asList(getDiagnosticCommandInfo0(commands));
|
||||
}
|
||||
|
||||
public List<DiagnosticCommandInfo> getDiagnosticCommandInfo(
|
||||
List<String> commands) {
|
||||
return Arrays.asList(getDiagnosticCommandInfo0(
|
||||
commands.toArray(new String[commands.size()])));
|
||||
}
|
||||
|
||||
public String execute(String command) {
|
||||
Util.checkControlAccess();
|
||||
return executeDiagnosticCommand0(command);
|
||||
}
|
||||
|
||||
public String execute(String cmd, String... arguments) {
|
||||
if(cmd == null) {
|
||||
throw new NullPointerException("Missing command name");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(cmd);
|
||||
sb.append(" ");
|
||||
for(String arg : arguments) {
|
||||
sb.append(arg);
|
||||
sb.append(" ");
|
||||
}
|
||||
return execute(sb.toString());
|
||||
}
|
||||
|
||||
public ObjectName getObjectName() {
|
||||
return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
|
||||
}
|
||||
|
||||
private native String[] getDiagnosticCommands0();
|
||||
private native DiagnosticCommandInfo[] getDiagnosticCommandInfo0(
|
||||
String[] commands) throws IllegalArgumentException;
|
||||
private native String executeDiagnosticCommand0(String command)
|
||||
throws IllegalArgumentException;
|
||||
}
|
||||
|
@ -37,15 +37,16 @@ public class gif extends ContentHandler {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
|
||||
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].isAssignableFrom(URLImageSource.class)) {
|
||||
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
|
||||
Class<?>[] cls = classes;
|
||||
for (int i = 0; i < cls.length; i++) {
|
||||
if (cls[i].isAssignableFrom(URLImageSource.class)) {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
if (classes[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
if (cls[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -36,15 +36,16 @@ public class jpeg extends ContentHandler {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
|
||||
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].isAssignableFrom(URLImageSource.class)) {
|
||||
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
|
||||
Class<?>[] cls = classes;
|
||||
for (int i = 0; i < cls.length; i++) {
|
||||
if (cls[i].isAssignableFrom(URLImageSource.class)) {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
if (classes[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
if (cls[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -36,15 +36,16 @@ public class png extends ContentHandler {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
|
||||
public Object getContent(URLConnection urlc, Class<?>[] classes) throws IOException {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].isAssignableFrom(URLImageSource.class)) {
|
||||
public Object getContent(URLConnection urlc, Class[] classes) throws IOException {
|
||||
Class<?>[] cls = classes;
|
||||
for (int i = 0; i < cls.length; i++) {
|
||||
if (cls[i].isAssignableFrom(URLImageSource.class)) {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
if (classes[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
if (cls[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -35,15 +35,16 @@ public class x_xbitmap extends ContentHandler {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
|
||||
public Object getContent(URLConnection urlc, Class<?>[] classes) throws java.io.IOException {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].isAssignableFrom(URLImageSource.class)) {
|
||||
public Object getContent(URLConnection urlc, Class[] classes) throws java.io.IOException {
|
||||
Class<?>[] cls = classes;
|
||||
for (int i = 0; i < cls.length; i++) {
|
||||
if (cls[i].isAssignableFrom(URLImageSource.class)) {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
if (classes[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
if (cls[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -35,15 +35,16 @@ public class x_xpixmap extends ContentHandler {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
|
||||
public Object getContent(URLConnection urlc, Class<?>[] classes) throws java.io.IOException {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (classes[i].isAssignableFrom(URLImageSource.class)) {
|
||||
public Object getContent(URLConnection urlc, Class[] classes) throws java.io.IOException {
|
||||
Class<?>[] cls = classes;
|
||||
for (int i = 0; i < cls.length; i++) {
|
||||
if (cls[i].isAssignableFrom(URLImageSource.class)) {
|
||||
return new URLImageSource(urlc);
|
||||
}
|
||||
if (classes[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
if (cls[i].isAssignableFrom(Image.class)) {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
return tk.createImage(new URLImageSource(urlc));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -195,6 +195,10 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine {
|
||||
return executeCommand("printflag", name);
|
||||
}
|
||||
|
||||
public InputStream executeJCmd(String command) throws IOException {
|
||||
return executeCommand("jcmd", command);
|
||||
}
|
||||
|
||||
// -- Supporting methods
|
||||
|
||||
|
||||
|
129
jdk/src/share/classes/sun/tools/jcmd/Arguments.java
Normal file
129
jdk/src/share/classes/sun/tools/jcmd/Arguments.java
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.tools.jcmd;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
class Arguments {
|
||||
private boolean listProcesses = false;
|
||||
private boolean listCounters = false;
|
||||
private boolean showUsage = false;
|
||||
private int pid = -1;
|
||||
private String command = null;
|
||||
private String processSubstring;
|
||||
|
||||
public boolean isListProcesses() { return listProcesses; }
|
||||
public boolean isListCounters() { return listCounters; }
|
||||
public boolean isShowUsage() { return showUsage; }
|
||||
public int getPid() { return pid; }
|
||||
public String getCommand() { return command; }
|
||||
public String getProcessSubstring() { return processSubstring; }
|
||||
|
||||
public Arguments(String[] args) {
|
||||
if (args.length == 0 || args[0].equals("-l")) {
|
||||
listProcesses = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args[0].equals("-h") || args[0].equals("-help") ) {
|
||||
showUsage = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
pid = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ex) {
|
||||
// use as a partial class-name instead
|
||||
if (args[0].charAt(0) != '-') {
|
||||
// unless it starts with a '-'
|
||||
processSubstring = args[0];
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (args[i].equals("-f")) {
|
||||
if (args.length == i + 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"No file specified for parameter -f");
|
||||
} else if (args.length == i + 2) {
|
||||
try {
|
||||
readCommandFile(args[i + 1]);
|
||||
} catch(IOException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not read from file specified with -f option: "
|
||||
+ args[i + 1]);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"Options after -f are not allowed");
|
||||
}
|
||||
} else if (args[i].equals("PerfCounter.print")) {
|
||||
listCounters = true;
|
||||
} else {
|
||||
sb.append(args[i]).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
if (listCounters != true && sb.length() == 0) {
|
||||
throw new IllegalArgumentException("No command specified");
|
||||
}
|
||||
|
||||
command = sb.toString().trim();
|
||||
}
|
||||
|
||||
private void readCommandFile(String path) throws IOException {
|
||||
try (BufferedReader bf = new BufferedReader(new FileReader(path));) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String s;
|
||||
while ((s = bf.readLine()) != null) {
|
||||
sb.append(s).append("\n");
|
||||
}
|
||||
command = sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static void usage() {
|
||||
System.out.println("Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>");
|
||||
System.out.println(" or: jcmd -l ");
|
||||
System.out.println(" or: jcmd -h ");
|
||||
System.out.println(" ");
|
||||
System.out.println(" command must be a valid jcmd command for the selected jvm. ");
|
||||
System.out.println(" Use the command \"help\" to see which commands are available. ");
|
||||
System.out.println(" If the pid is 0, commands will be sent to all Java processes. ");
|
||||
System.out.println(" The main class argument will be used to match (either partially ");
|
||||
System.out.println(" or fully) the class used to start Java. ");
|
||||
System.out.println(" If no options are given, lists Java processes (same as -p). ");
|
||||
System.out.println(" ");
|
||||
System.out.println(" PerfCounter.print display the counters exposed by this process ");
|
||||
System.out.println(" -f read and execute commands from the file ");
|
||||
System.out.println(" -l list JVM processes on the local machine ");
|
||||
System.out.println(" -h this help ");
|
||||
}
|
||||
}
|
226
jdk/src/share/classes/sun/tools/jcmd/JCmd.java
Normal file
226
jdk/src/share/classes/sun/tools/jcmd/JCmd.java
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*com.sun.tools.attach.AttachNotSupportedException
|
||||
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.tools.jcmd;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import com.sun.tools.attach.VirtualMachine;
|
||||
import com.sun.tools.attach.VirtualMachineDescriptor;
|
||||
import com.sun.tools.attach.AgentLoadException;
|
||||
import com.sun.tools.attach.AttachNotSupportedException;
|
||||
import sun.tools.attach.HotSpotVirtualMachine;
|
||||
import sun.tools.jstat.JStatLogger;
|
||||
import sun.jvmstat.monitor.Monitor;
|
||||
import sun.jvmstat.monitor.MonitoredHost;
|
||||
import sun.jvmstat.monitor.MonitoredVm;
|
||||
import sun.jvmstat.monitor.MonitoredVmUtil;
|
||||
import sun.jvmstat.monitor.MonitorException;
|
||||
import sun.jvmstat.monitor.VmIdentifier;
|
||||
|
||||
public class JCmd {
|
||||
public static void main(String[] args) {
|
||||
Arguments arg = null;
|
||||
try {
|
||||
arg = new Arguments(args);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.err.println("Error parsing arguments: " + ex.getMessage()
|
||||
+ "\n");
|
||||
Arguments.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (arg.isShowUsage()) {
|
||||
Arguments.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (arg.isListProcesses()) {
|
||||
List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
|
||||
for (VirtualMachineDescriptor vmd : vmds) {
|
||||
System.out.println(vmd.id() + " " + vmd.displayName());
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
List<String> pids = new ArrayList<String>();
|
||||
if (arg.getPid() == 0) {
|
||||
// find all VMs
|
||||
List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
|
||||
for (VirtualMachineDescriptor vmd : vmds) {
|
||||
if (!isJCmdProcess(vmd)) {
|
||||
pids.add(vmd.id());
|
||||
}
|
||||
}
|
||||
} else if (arg.getProcessSubstring() != null) {
|
||||
// use the partial class-name match
|
||||
List<VirtualMachineDescriptor> vmds = VirtualMachine.list();
|
||||
for (VirtualMachineDescriptor vmd : vmds) {
|
||||
if (isJCmdProcess(vmd)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
String mainClass = getMainClass(vmd);
|
||||
if (mainClass != null
|
||||
&& mainClass.indexOf(arg.getProcessSubstring()) != -1) {
|
||||
pids.add(vmd.id());
|
||||
}
|
||||
} catch (MonitorException|URISyntaxException e) {
|
||||
if (e.getMessage() != null) {
|
||||
System.err.println(e.getMessage());
|
||||
} else {
|
||||
Throwable cause = e.getCause();
|
||||
if ((cause != null) && (cause.getMessage() != null)) {
|
||||
System.err.println(cause.getMessage());
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pids.isEmpty()) {
|
||||
System.err.println("Could not find any processes matching : '"
|
||||
+ arg.getProcessSubstring() + "'");
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (arg.getPid() == -1) {
|
||||
System.err.println("Invalid pid specified");
|
||||
System.exit(1);
|
||||
} else {
|
||||
// Use the found pid
|
||||
pids.add(arg.getPid() + "");
|
||||
}
|
||||
|
||||
for (String pid : pids) {
|
||||
System.out.println(pid + ":");
|
||||
if (arg.isListCounters()) {
|
||||
listCounters(pid);
|
||||
} else {
|
||||
try {
|
||||
executeCommandForPid(pid, arg.getCommand());
|
||||
} catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void executeCommandForPid(String pid, String command)
|
||||
throws AttachNotSupportedException, IOException,
|
||||
UnsupportedEncodingException {
|
||||
VirtualMachine vm = VirtualMachine.attach(pid);
|
||||
|
||||
// Cast to HotSpotVirtualMachine as this is an
|
||||
// implementation specific method.
|
||||
HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
|
||||
try (InputStream in = hvm.executeJCmd(command);) {
|
||||
// read to EOF and just print output
|
||||
byte b[] = new byte[256];
|
||||
int n;
|
||||
do {
|
||||
n = in.read(b);
|
||||
if (n > 0) {
|
||||
String s = new String(b, 0, n, "UTF-8");
|
||||
System.out.print(s);
|
||||
}
|
||||
} while (n > 0);
|
||||
}
|
||||
vm.detach();
|
||||
}
|
||||
|
||||
private static void listCounters(String pid) {
|
||||
// Code from JStat (can't call it directly since it does System.exit)
|
||||
VmIdentifier vmId = null;
|
||||
try {
|
||||
vmId = new VmIdentifier(pid);
|
||||
} catch (URISyntaxException e) {
|
||||
System.err.println("Malformed VM Identifier: " + pid);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
|
||||
MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
|
||||
JStatLogger logger = new JStatLogger(monitoredVm);
|
||||
logger.printSnapShot("\\w*", // all names
|
||||
new AscendingMonitorComparator(), // comparator
|
||||
false, // not verbose
|
||||
true, // show unsupported
|
||||
System.out);
|
||||
monitoredHost.detach(monitoredVm);
|
||||
} catch (MonitorException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isJCmdProcess(VirtualMachineDescriptor vmd) {
|
||||
try {
|
||||
String mainClass = getMainClass(vmd);
|
||||
return mainClass != null && mainClass.equals(JCmd.class.getName());
|
||||
} catch (URISyntaxException|MonitorException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getMainClass(VirtualMachineDescriptor vmd)
|
||||
throws URISyntaxException, MonitorException {
|
||||
try {
|
||||
String mainClass = null;
|
||||
VmIdentifier vmId = new VmIdentifier(vmd.id());
|
||||
MonitoredHost monitoredHost = MonitoredHost.getMonitoredHost(vmId);
|
||||
MonitoredVm monitoredVm = monitoredHost.getMonitoredVm(vmId, -1);
|
||||
mainClass = MonitoredVmUtil.mainClass(monitoredVm, true);
|
||||
monitoredHost.detach(monitoredVm);
|
||||
return mainClass;
|
||||
} catch(NullPointerException e) {
|
||||
// There is a potential race, where a running java app is being
|
||||
// queried, unfortunately the java app has shutdown after this
|
||||
// method is started but before getMonitoredVM is called.
|
||||
// If this is the case, then the /tmp/hsperfdata_xxx/pid file
|
||||
// will have disappeared and we will get a NullPointerException.
|
||||
// Handle this gracefully....
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to compare two Monitor objects by name in ascending order.
|
||||
* (from jstat)
|
||||
*/
|
||||
static class AscendingMonitorComparator implements Comparator<Monitor> {
|
||||
|
||||
public int compare(Monitor m1, Monitor m2) {
|
||||
String name1 = m1.getName();
|
||||
String name2 = m2.getName();
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
}
|
||||
}
|
@ -1164,6 +1164,7 @@ redefineClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classDefinitio
|
||||
jmethodID getDefinitionClassMethodID = NULL;
|
||||
jmethodID getDefinitionClassFileMethodID = NULL;
|
||||
jvmtiClassDefinition* classDefs = NULL;
|
||||
jbyteArray* targetFiles = NULL;
|
||||
jsize numDefs = 0;
|
||||
|
||||
jplis_assert(classDefinitions != NULL);
|
||||
@ -1207,61 +1208,112 @@ redefineClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classDefinitio
|
||||
if ( errorOccurred ) {
|
||||
createAndThrowThrowableFromJVMTIErrorCode(jnienv, JVMTI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
else {
|
||||
jint i;
|
||||
for (i = 0; i < numDefs; i++) {
|
||||
jclass classDef = NULL;
|
||||
jbyteArray targetFile = NULL;
|
||||
|
||||
classDef = (*jnienv)->GetObjectArrayElement(jnienv, classDefinitions, i);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
classDefs[i].klass = (*jnienv)->CallObjectMethod(jnienv, classDef, getDefinitionClassMethodID);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
targetFile = (*jnienv)->CallObjectMethod(jnienv, classDef, getDefinitionClassFileMethodID);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
classDefs[i].class_bytes = (unsigned char*)(*jnienv)->GetByteArrayElements(jnienv, targetFile, NULL);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
classDefs[i].class_byte_count = (*jnienv)->GetArrayLength(jnienv, targetFile);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!errorOccurred) {
|
||||
jvmtiError errorCode = JVMTI_ERROR_NONE;
|
||||
errorCode = (*jvmtienv)->RedefineClasses(jvmtienv, numDefs, classDefs);
|
||||
check_phase_blob_ret(errorCode, deallocate(jvmtienv, (void*)classDefs));
|
||||
errorOccurred = (errorCode != JVMTI_ERROR_NONE);
|
||||
if ( errorOccurred ) {
|
||||
createAndThrowThrowableFromJVMTIErrorCode(jnienv, errorCode);
|
||||
}
|
||||
}
|
||||
|
||||
/* Give back the buffer if we allocated it.
|
||||
/*
|
||||
* We have to save the targetFile values that we compute so
|
||||
* that we can release the class_bytes arrays that are
|
||||
* returned by GetByteArrayElements(). In case of a JNI
|
||||
* error, we can't (easily) recompute the targetFile values
|
||||
* and we still want to free any memory we allocated.
|
||||
*/
|
||||
deallocate(jvmtienv, (void*)classDefs);
|
||||
targetFiles = (jbyteArray *) allocate(jvmtienv,
|
||||
numDefs * sizeof(jbyteArray));
|
||||
errorOccurred = (targetFiles == NULL);
|
||||
jplis_assert(!errorOccurred);
|
||||
if ( errorOccurred ) {
|
||||
deallocate(jvmtienv, (void*)classDefs);
|
||||
createAndThrowThrowableFromJVMTIErrorCode(jnienv,
|
||||
JVMTI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else {
|
||||
jint i, j;
|
||||
|
||||
// clear classDefs so we can correctly free memory during errors
|
||||
memset(classDefs, 0, numDefs * sizeof(jvmtiClassDefinition));
|
||||
|
||||
for (i = 0; i < numDefs; i++) {
|
||||
jclass classDef = NULL;
|
||||
|
||||
classDef = (*jnienv)->GetObjectArrayElement(jnienv, classDefinitions, i);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
classDefs[i].klass = (*jnienv)->CallObjectMethod(jnienv, classDef, getDefinitionClassMethodID);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
targetFiles[i] = (*jnienv)->CallObjectMethod(jnienv, classDef, getDefinitionClassFileMethodID);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
classDefs[i].class_byte_count = (*jnienv)->GetArrayLength(jnienv, targetFiles[i]);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate class_bytes last so we don't have to free
|
||||
* memory on a partial row error.
|
||||
*/
|
||||
classDefs[i].class_bytes = (unsigned char*)(*jnienv)->GetByteArrayElements(jnienv, targetFiles[i], NULL);
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
if (errorOccurred) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!errorOccurred) {
|
||||
jvmtiError errorCode = JVMTI_ERROR_NONE;
|
||||
errorCode = (*jvmtienv)->RedefineClasses(jvmtienv, numDefs, classDefs);
|
||||
if (errorCode == JVMTI_ERROR_WRONG_PHASE) {
|
||||
/* insulate caller from the wrong phase error */
|
||||
errorCode = JVMTI_ERROR_NONE;
|
||||
} else {
|
||||
errorOccurred = (errorCode != JVMTI_ERROR_NONE);
|
||||
if ( errorOccurred ) {
|
||||
createAndThrowThrowableFromJVMTIErrorCode(jnienv, errorCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup memory that we allocated above. If we had a
|
||||
* JNI error, a JVM/TI error or no errors, index 'i'
|
||||
* tracks how far we got in processing the classDefs
|
||||
* array. Note: ReleaseByteArrayElements() is safe to
|
||||
* call with a JNI exception pending.
|
||||
*/
|
||||
for (j = 0; j < i; j++) {
|
||||
if ((jbyte *)classDefs[j].class_bytes != NULL) {
|
||||
(*jnienv)->ReleaseByteArrayElements(jnienv,
|
||||
targetFiles[j], (jbyte *)classDefs[j].class_bytes,
|
||||
0 /* copy back and free */);
|
||||
/*
|
||||
* Only check for error if we didn't already have one
|
||||
* so we don't overwrite errorOccurred.
|
||||
*/
|
||||
if (!errorOccurred) {
|
||||
errorOccurred = checkForThrowable(jnienv);
|
||||
jplis_assert(!errorOccurred);
|
||||
}
|
||||
}
|
||||
}
|
||||
deallocate(jvmtienv, (void*)targetFiles);
|
||||
deallocate(jvmtienv, (void*)classDefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,8 @@ enum {
|
||||
JMM_VERSION_1_0 = 0x20010000,
|
||||
JMM_VERSION_1_1 = 0x20010100, // JDK 6
|
||||
JMM_VERSION_1_2 = 0x20010200, // JDK 7
|
||||
JMM_VERSION = 0x20010201
|
||||
JMM_VERSION_1_2_1 = 0x20010201, // JDK 7 GA
|
||||
JMM_VERSION = 0x20010202
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -188,6 +189,24 @@ typedef struct {
|
||||
/* -1 indicates gc_ext_attribute_values is not big enough */
|
||||
} jmmGCStat;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
const char* description;
|
||||
const char* impact;
|
||||
int num_arguments;
|
||||
jboolean enabled;
|
||||
} dcmdInfo;
|
||||
|
||||
typedef struct {
|
||||
const char* name;
|
||||
const char* description;
|
||||
const char* type;
|
||||
const char* default_string;
|
||||
jboolean mandatory;
|
||||
jboolean option;
|
||||
int position;
|
||||
} dcmdArgInfo;
|
||||
|
||||
typedef struct jmmInterface_1_ {
|
||||
void* reserved1;
|
||||
void* reserved2;
|
||||
@ -293,9 +312,21 @@ typedef struct jmmInterface_1_ {
|
||||
jlongArray ids,
|
||||
jboolean lockedMonitors,
|
||||
jboolean lockedSynchronizers);
|
||||
void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
|
||||
jobject mgr,
|
||||
jboolean enabled);
|
||||
void (JNICALL *SetGCNotificationEnabled) (JNIEnv *env,
|
||||
jobject mgr,
|
||||
jboolean enabled);
|
||||
jobjectArray (JNICALL *GetDiagnosticCommands) (JNIEnv *env);
|
||||
void (JNICALL *GetDiagnosticCommandInfo)
|
||||
(JNIEnv *env,
|
||||
jobjectArray cmds,
|
||||
dcmdInfo *infoArray);
|
||||
void (JNICALL *GetDiagnosticCommandArgumentsInfo)
|
||||
(JNIEnv *env,
|
||||
jstring commandName,
|
||||
dcmdArgInfo *infoArray);
|
||||
jstring (JNICALL *ExecuteDiagnosticCommand)
|
||||
(JNIEnv *env,
|
||||
jstring command);
|
||||
} JmmInterface;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,3 +34,141 @@ Java_sun_management_HotSpotDiagnostic_dumpHeap
|
||||
{
|
||||
jmm_interface->DumpHeap0(env, outputfile, live);
|
||||
}
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0
|
||||
(JNIEnv *env, jobject dummy)
|
||||
{
|
||||
if ((jmm_version > JMM_VERSION_1_2_1)
|
||||
|| (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
|
||||
return jmm_interface->GetDiagnosticCommands(env);
|
||||
}
|
||||
JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
|
||||
"Diagnostic commands are not supported by this VM");
|
||||
}
|
||||
|
||||
jobject getDiagnosticCommandArgumentInfoArray(JNIEnv *env, jstring command,
|
||||
int num_arg) {
|
||||
int i;
|
||||
jobject obj;
|
||||
jobjectArray result;
|
||||
dcmdArgInfo* dcmd_arg_info_array;
|
||||
jclass dcmdArgInfoCls;
|
||||
jclass arraysCls;
|
||||
jmethodID mid;
|
||||
jobject resultList;
|
||||
|
||||
dcmd_arg_info_array = (dcmdArgInfo*) malloc(num_arg * sizeof(dcmdArgInfo));
|
||||
if (dcmd_arg_info_array == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
jmm_interface->GetDiagnosticCommandArgumentsInfo(env, command,
|
||||
dcmd_arg_info_array);
|
||||
dcmdArgInfoCls = (*env)->FindClass(env,
|
||||
"com/sun/management/DiagnosticCommandArgumentInfo");
|
||||
result = (*env)->NewObjectArray(env, num_arg, dcmdArgInfoCls, NULL);
|
||||
if (result == NULL) {
|
||||
free(dcmd_arg_info_array);
|
||||
return NULL;
|
||||
}
|
||||
for (i=0; i<num_arg; i++) {
|
||||
obj = JNU_NewObjectByName(env,
|
||||
"com/sun/management/DiagnosticCommandArgumentInfo",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZI)V",
|
||||
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].name),
|
||||
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].description),
|
||||
(*env)->NewStringUTF(env,dcmd_arg_info_array[i].type),
|
||||
dcmd_arg_info_array[i].default_string == NULL ? NULL:
|
||||
(*env)->NewStringUTF(env, dcmd_arg_info_array[i].default_string),
|
||||
dcmd_arg_info_array[i].mandatory,
|
||||
dcmd_arg_info_array[i].option,
|
||||
dcmd_arg_info_array[i].position);
|
||||
if (obj == NULL) {
|
||||
free(dcmd_arg_info_array);
|
||||
return NULL;
|
||||
}
|
||||
(*env)->SetObjectArrayElement(env, result, i, obj);
|
||||
}
|
||||
free(dcmd_arg_info_array);
|
||||
arraysCls = (*env)->FindClass(env, "java/util/Arrays");
|
||||
mid = (*env)->GetStaticMethodID(env, arraysCls,
|
||||
"asList", "([Ljava/lang/Object;)Ljava/util/List;");
|
||||
resultList = (*env)->CallStaticObjectMethod(env, arraysCls, mid, result);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/* Throws IllegalArgumentException if at least one the diagnostic command
|
||||
* passed in argument is not supported by the JVM
|
||||
*/
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0
|
||||
(JNIEnv *env, jobject dummy, jobjectArray commands)
|
||||
{
|
||||
int i;
|
||||
jclass dcmdInfoCls;
|
||||
jobject result;
|
||||
jobjectArray args;
|
||||
jobject obj;
|
||||
|
||||
if (commands == NULL) {
|
||||
JNU_ThrowNullPointerException(env, "Invalid String Array");
|
||||
return NULL;
|
||||
}
|
||||
if ((jmm_version > JMM_VERSION_1_2_1)
|
||||
|| (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
|
||||
jsize num_commands = (*env)->GetArrayLength(env, commands);
|
||||
dcmdInfo* dcmd_info_array = (dcmdInfo*) malloc(num_commands *
|
||||
sizeof(dcmdInfo));
|
||||
if (dcmd_info_array == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
}
|
||||
jmm_interface->GetDiagnosticCommandInfo(env, commands, dcmd_info_array);
|
||||
dcmdInfoCls = (*env)->FindClass(env,
|
||||
"com/sun/management/DiagnosticCommandInfo");
|
||||
result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL);
|
||||
if (result == NULL) {
|
||||
free(dcmd_info_array);
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
}
|
||||
for (i=0; i<num_commands; i++) {
|
||||
args = getDiagnosticCommandArgumentInfoArray(env,
|
||||
(*env)->GetObjectArrayElement(env,commands,i),
|
||||
dcmd_info_array[i].num_arguments);
|
||||
if (args == NULL) {
|
||||
free(dcmd_info_array);
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
}
|
||||
obj = JNU_NewObjectByName(env,
|
||||
"com/sun/management/DiagnosticCommandInfo",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/util/List;)V",
|
||||
(*env)->NewStringUTF(env,dcmd_info_array[i].name),
|
||||
(*env)->NewStringUTF(env,dcmd_info_array[i].description),
|
||||
(*env)->NewStringUTF(env,dcmd_info_array[i].impact),
|
||||
dcmd_info_array[i].enabled,
|
||||
args);
|
||||
if (obj == NULL) {
|
||||
free(dcmd_info_array);
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
}
|
||||
(*env)->SetObjectArrayElement(env, result, i, obj);
|
||||
}
|
||||
free(dcmd_info_array);
|
||||
return result;
|
||||
}
|
||||
JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
|
||||
"Diagnostic commands are not supported by this VM");
|
||||
}
|
||||
|
||||
/* Throws IllegalArgumentException if the diagnostic command
|
||||
* passed in argument is not supported by the JVM
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0
|
||||
(JNIEnv *env, jobject dummy, jstring command) {
|
||||
if((jmm_version > JMM_VERSION_1_2_1 )
|
||||
|| (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
|
||||
return jmm_interface->ExecuteDiagnosticCommand(env, command);
|
||||
}
|
||||
JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
|
||||
"Diagnostic commands are not supported by this VM");
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; (i < ckLength) && (i < 4) ; i++) {
|
||||
for (i = 0; (i < ckLength) && (i < 2) ; i++) {
|
||||
ckpDate->month[i] = jCharToCKChar(jTempChars[i]);
|
||||
}
|
||||
free(jTempChars);
|
||||
@ -398,7 +398,7 @@ CK_DATE * jDateObjectPtrToCKDatePtr(JNIEnv *env, jobject jDate)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; (i < ckLength) && (i < 4) ; i++) {
|
||||
for (i = 0; (i < ckLength) && (i < 2) ; i++) {
|
||||
ckpDate->day[i] = jCharToCKChar(jTempChars[i]);
|
||||
}
|
||||
free(jTempChars);
|
||||
|
124
jdk/src/solaris/doc/sun/man/man1/jcmd.1
Normal file
124
jdk/src/solaris/doc/sun/man/man1/jcmd.1
Normal file
@ -0,0 +1,124 @@
|
||||
." Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
."
|
||||
." This code is free software; you can redistribute it and/or modify it
|
||||
." under the terms of the GNU General Public License version 2 only, as
|
||||
." published by the Free Software Foundation.
|
||||
."
|
||||
." This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
." version 2 for more details (a copy is included in the LICENSE file that
|
||||
." accompanied this code).
|
||||
."
|
||||
." You should have received a copy of the GNU General Public License version
|
||||
." 2 along with this work; if not, write to the Free Software Foundation,
|
||||
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
."
|
||||
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
." or visit www.oracle.com if you need additional information or have any
|
||||
." questions.
|
||||
."
|
||||
.TH jcmd 1 "22 Novembre 2011"
|
||||
|
||||
.LP
|
||||
.SH "Name"
|
||||
jcmd \- Diagnostic Command
|
||||
.br
|
||||
|
||||
.LP
|
||||
.SH "SYNOPSIS"
|
||||
.LP
|
||||
.nf
|
||||
\f3
|
||||
.fl
|
||||
\fP\f3jcmd\fP [ option ]
|
||||
.fl
|
||||
\f3jcmd\fP <\fIpid\fR | \fImain class\fR> PerfCounter.print
|
||||
.fl
|
||||
\f3jcmd\fP <\fIpid\fR | \fImain class\fR> \fIcommand\fR [\fIarguments\fR]
|
||||
.fl
|
||||
\f3jcmd\fP <\fIpid\fR | \fImain class\fR> -f \fIfile\fR
|
||||
.fl
|
||||
.fl
|
||||
.fi
|
||||
|
||||
.LP
|
||||
.SH "DESCRIPTION"
|
||||
.LP
|
||||
.LP
|
||||
\f3jcmd\fP is a utility to send diagnostic command requests to a Java
|
||||
Virtual Machine supporting this feature. Used without arguments or with the \-l option, jcmd prints the list of running Java processes with their process id, their main class and their command line arguments. When a process id is specified on the command line, jcmd sends the diagnostic command request to the process with this id. When a main class is specified on the command line, jcmd sends the diagnostic command request to all Java processes with this main class. With the PerfCounter.print argument, jcmd prints the performance counters available on the targeted Java process(es). With the \-f option, jcmd sends to the targeted Java process(es) the diagnostic commands stored in the file \fIfile\fR.
|
||||
.LP
|
||||
\fP
|
||||
.fi
|
||||
|
||||
.SH "OPTIONS"
|
||||
.LP
|
||||
.LP
|
||||
Options are mutually exclusive. Options, if used, should follow immediately after the command name.
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 3
|
||||
\-l
|
||||
prints the list of running Java processes with their process id, their
|
||||
main class and their command line arguments.
|
||||
.TP 3
|
||||
\-h
|
||||
prints a help message.
|
||||
.br
|
||||
.br
|
||||
.TP 3
|
||||
\-help
|
||||
prints a help message
|
||||
.br
|
||||
.RE
|
||||
|
||||
.LP
|
||||
.SH "PARAMETERS"
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fIpid\fR
|
||||
Identifies the process which will receive the diagnostic command requests. The process must be a Java process. To get a list of Java processes running on a machine, jps(1) or jcmd(1) may be used.
|
||||
.RE
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fImain class\fR
|
||||
Main class of the process which will receive the diagnostic command requests. If several running Java processes share this main class, the diagnostic command request will be sent to all these processes. To get a list of Java processes running on a machine, jps(1) or jcmd(1) may be used.
|
||||
.RE
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fIcommand\fR [\fIarguments\fR]
|
||||
Invoke the diagnostic command called \fIcommand\fR on the targeted Java
|
||||
process(es). The list of available diagnostic commands for a given
|
||||
process can be obtained by invoking the 'help' command on this process.
|
||||
Each diagnostic command has its own set of \fIarguments\fR which can be
|
||||
obtained by invoking the 'help' command followed by the command name.
|
||||
.RE
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fIPerfCounter.print\fR
|
||||
Print the performance counters available on the targeted Java
|
||||
process(es). The list of performance counters may vary with the Java
|
||||
process.
|
||||
.RE
|
||||
.RS 3
|
||||
.TP 3
|
||||
\fI-f file\fR
|
||||
Read commands from \fIfile\fR and invoke them on the targeted Java
|
||||
process(es). In \fIfile\fR, each command must be written on a single line.
|
||||
Lines starting with # are ignored. Processing of \fIfile\fR ends when
|
||||
all lines have been invoked or when a line containing the 'stop' keyword
|
||||
is read.
|
||||
.LP
|
||||
.SH "SEE ALSO"
|
||||
.LP
|
||||
.RS 3
|
||||
.TP 2
|
||||
o
|
||||
jps(1)
|
||||
.RE
|
||||
|
||||
|
@ -1109,7 +1109,7 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
|
||||
uint8_t ipv6addr[16];
|
||||
|
||||
if ((f = fopen(_PATH_PROCNET_IFINET6, "r")) != NULL) {
|
||||
while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n",
|
||||
while (fscanf(f, "%4s%4s%4s%4s%4s%4s%4s%4s %08x %02x %02x %02x %20s\n",
|
||||
addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[4], addr6p[5], addr6p[6], addr6p[7],
|
||||
&if_idx, &plen, &scope, &dad_status, devname) != EOF) {
|
||||
|
||||
|
@ -191,5 +191,6 @@ Venezuela Standard Time:923,923::America/Caracas:
|
||||
Magadan Standard Time:924,924::Asia/Magadan:
|
||||
Kaliningrad Standard Time:925,925:RU:Europe/Kaliningrad:
|
||||
Turkey Standard Time:926,926::Asia/Istanbul:
|
||||
Western Brazilian Standard Time:927,927:BR:America/Rio_Branco:
|
||||
Armenian Standard Time:928,928:AM:Asia/Yerevan:
|
||||
Bahia Standard Time:927,927::America/Bahia:
|
||||
Western Brazilian Standard Time:928,928:BR:America/Rio_Branco:
|
||||
Armenian Standard Time:929,929:AM:Asia/Yerevan:
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7104647
|
||||
* @summary Basic Test for HotSpotDiagnosticMXBean.execute()
|
||||
* @author Frederic Parain
|
||||
*
|
||||
* @run main ExecuteDiagnosticCommand
|
||||
*/
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
import com.sun.management.VMOption;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
public class ExecuteDiagnosticCommand {
|
||||
private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
|
||||
"com.sun.management:type=HotSpotDiagnostic";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
HotSpotDiagnosticMXBean mbean =
|
||||
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
|
||||
executeDiagnosticCommand(mbean);
|
||||
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
|
||||
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
|
||||
HotSpotDiagnosticMXBean.class);
|
||||
executeDiagnosticCommand(mbean);
|
||||
}
|
||||
|
||||
private static void executeDiagnosticCommand(HotSpotDiagnosticMXBean mbean) {
|
||||
String s = mbean.execute("help help");
|
||||
System.out.println(s);
|
||||
s = mbean.execute("help", "help");
|
||||
System.out.println(s);
|
||||
String tab[] = { "help"};
|
||||
s = mbean.execute("help", tab);
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7104647
|
||||
* @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommandInfo()
|
||||
* @author Frederic Parain
|
||||
*
|
||||
* @run main GetDiagnosticCommandInfo
|
||||
*/
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
import com.sun.management.DiagnosticCommandInfo;
|
||||
import com.sun.management.DiagnosticCommandArgumentInfo;
|
||||
import com.sun.management.VMOption;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
public class GetDiagnosticCommandInfo {
|
||||
private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
|
||||
"com.sun.management:type=HotSpotDiagnostic";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
HotSpotDiagnosticMXBean mbean =
|
||||
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
|
||||
checkDiagnosticCommandArguments(mbean);
|
||||
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
|
||||
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
|
||||
HotSpotDiagnosticMXBean.class);
|
||||
checkDiagnosticCommandArguments(mbean);
|
||||
}
|
||||
|
||||
private static void checkDiagnosticCommandArguments(HotSpotDiagnosticMXBean mbean) {
|
||||
// check getDiagnosticCommandInfo()
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<DiagnosticCommandInfo> infoList = mbean.getDiagnosticCommandInfo();
|
||||
for(DiagnosticCommandInfo info : infoList) {
|
||||
printCommandInfo(info,sb);
|
||||
}
|
||||
// check getDiagnosticCommandInfo(List<String>)
|
||||
List<String> commands = mbean.getDiagnosticCommands();
|
||||
List<DiagnosticCommandInfo> list2 =
|
||||
mbean.getDiagnosticCommandInfo(commands);
|
||||
for(DiagnosticCommandInfo info : list2) {
|
||||
printCommandInfo(info,sb);
|
||||
}
|
||||
// check getDiagnosticCommandInfo(String)
|
||||
for(String cmd : commands) {
|
||||
DiagnosticCommandInfo info2 = mbean.getDiagnosticCommandInfo(cmd);
|
||||
printCommandInfo(info2,sb);
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
|
||||
private static void printCommandInfo(DiagnosticCommandInfo info,
|
||||
StringBuilder sb) {
|
||||
sb.append("\t").append(info.getName()).append(":\n");
|
||||
sb.append("\t\tDescription=").append(info.getDescription()).append("\n");
|
||||
sb.append("\t\tImpact=").append(info.getImpact()).append("\n");
|
||||
sb.append("\t\tStatus=");
|
||||
if (info.isEnabled()) {
|
||||
sb.append("Enabled\n");
|
||||
} else {
|
||||
sb.append("Disbled\n");
|
||||
}
|
||||
sb.append("\t\tArguments=");
|
||||
for(DiagnosticCommandArgumentInfo arg : info.getArgumentsInfo()) {
|
||||
printArgumentInfo(arg,sb);
|
||||
}
|
||||
}
|
||||
|
||||
private static void printArgumentInfo(DiagnosticCommandArgumentInfo info,
|
||||
StringBuilder sb) {
|
||||
sb.append("\t\t\t").append(info.getName()).append(":\n");
|
||||
sb.append("\t\t\t\tType=").append(info.getType()).append("\n");
|
||||
sb.append("\t\t\t\tDescription=").append(info.getDescription()).append("\n");
|
||||
if(info.getDefault() != null) {
|
||||
sb.append("\t\t\t\tDefault=").append(info.getDefault()).append("\n");
|
||||
}
|
||||
if(info.isMandatory()) {
|
||||
sb.append("\t\t\t\tMandatory\n");
|
||||
} else {
|
||||
sb.append("\t\t\t\tOptional\n");
|
||||
}
|
||||
if(info.isOption()) {
|
||||
sb.append("\t\t\t\tIs an option\n");
|
||||
} else {
|
||||
sb.append("\t\t\t\tIs an argument expected at position");
|
||||
sb.append(info.getPosition());
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7104647
|
||||
* @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommands()
|
||||
* @author Frederic Parain
|
||||
*
|
||||
* @run main GetDiagnosticCommands
|
||||
*/
|
||||
|
||||
import com.sun.management.HotSpotDiagnosticMXBean;
|
||||
import com.sun.management.VMOption;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.List;
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
public class GetDiagnosticCommands {
|
||||
private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
|
||||
"com.sun.management:type=HotSpotDiagnostic";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
HotSpotDiagnosticMXBean mbean =
|
||||
ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
|
||||
checkDiagnosticCommands(mbean);
|
||||
|
||||
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
|
||||
mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
|
||||
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
|
||||
HotSpotDiagnosticMXBean.class);
|
||||
checkDiagnosticCommands(mbean);
|
||||
}
|
||||
|
||||
private static void checkDiagnosticCommands(HotSpotDiagnosticMXBean mbean) {
|
||||
List<String> commands = mbean.getDiagnosticCommands();
|
||||
System.out.println("Commands:");
|
||||
for (String cmd : commands) {
|
||||
System.out.println(cmd);
|
||||
}
|
||||
}
|
||||
}
|
10105
jdk/test/java/lang/instrument/BigClass.java
Normal file
10105
jdk/test/java/lang/instrument/BigClass.java
Normal file
File diff suppressed because it is too large
Load Diff
40
jdk/test/java/lang/instrument/MakeJAR4.sh
Normal file
40
jdk/test/java/lang/instrument/MakeJAR4.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
AGENT="$1"
|
||||
OTHER="$2"
|
||||
shift 2
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
echo "TESTJAVA=${TESTJAVA}"
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JAVAC="${TESTJAVA}/bin/javac -g"
|
||||
JAR="${TESTJAVA}/bin/jar"
|
||||
|
||||
cp ${TESTSRC}/${AGENT}.java ${TESTSRC}/${OTHER}.java .
|
||||
${JAVAC} ${AGENT}.java ${OTHER}.java
|
||||
|
||||
echo "Manifest-Version: 1.0" > ${AGENT}.mf
|
||||
echo Premain-Class: ${AGENT} >> ${AGENT}.mf
|
||||
while [ $# != 0 ] ; do
|
||||
echo $1 >> ${AGENT}.mf
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
${JAR} cvfm ${AGENT}.jar ${AGENT}.mf ${AGENT}*.class ${OTHER}*.java
|
82
jdk/test/java/lang/instrument/RedefineBigClass.sh
Normal file
82
jdk/test/java/lang/instrument/RedefineBigClass.sh
Normal file
@ -0,0 +1,82 @@
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 7121600
|
||||
# @summary Redefine a big class.
|
||||
# @author Daniel D. Daugherty
|
||||
#
|
||||
# @run shell MakeJAR3.sh RedefineBigClassAgent 'Can-Redefine-Classes: true'
|
||||
# @run build BigClass RedefineBigClassApp
|
||||
# @run shell/timeout=600 RedefineBigClass.sh
|
||||
#
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JAVAC="${TESTJAVA}"/bin/javac
|
||||
JAVA="${TESTJAVA}"/bin/java
|
||||
|
||||
"${JAVA}" ${TESTVMOPTS} \
|
||||
-XX:TraceRedefineClasses=3 \
|
||||
-javaagent:RedefineBigClassAgent.jar=BigClass.class \
|
||||
-classpath "${TESTCLASSES}" RedefineBigClassApp \
|
||||
> output.log 2>&1
|
||||
result=$?
|
||||
|
||||
cat output.log
|
||||
|
||||
if [ "$result" = 0 ]; then
|
||||
echo "PASS: RedefineBigClassApp exited with status of 0."
|
||||
else
|
||||
echo "FAIL: RedefineBigClassApp exited with status of $result"
|
||||
exit "$result"
|
||||
fi
|
||||
|
||||
MESG="Exception"
|
||||
grep "$MESG" output.log
|
||||
result=$?
|
||||
if [ "$result" = 0 ]; then
|
||||
echo "FAIL: found '$MESG' in the test output"
|
||||
result=1
|
||||
else
|
||||
echo "PASS: did NOT find '$MESG' in the test output"
|
||||
result=0
|
||||
fi
|
||||
|
||||
exit $result
|
85
jdk/test/java/lang/instrument/RedefineBigClassAgent.java
Normal file
85
jdk/test/java/lang/instrument/RedefineBigClassAgent.java
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.instrument.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
public class RedefineBigClassAgent {
|
||||
// N_REDEFINES = 2000 made my Solaris X86 box crawl on its knees
|
||||
// with the Server VM. The timeout is 600 seconds, but the test
|
||||
// ran for 675 seconds so it took the harness 75 seconds to kill
|
||||
// the test.
|
||||
private static int N_REDEFINES = 1000;
|
||||
public static Class clz;
|
||||
public static volatile boolean doneRedefining = false;
|
||||
|
||||
// just read the original class and redefine in a loop via a Timer
|
||||
public static void premain(String agentArgs, final Instrumentation inst) throws Exception {
|
||||
String s = agentArgs.substring(0, agentArgs.indexOf(".class"));
|
||||
clz = Class.forName(s.replace('/', '.'));
|
||||
ClassLoader loader =
|
||||
RedefineBigClassAgent.class.getClassLoader();
|
||||
URL classURL = loader.getResource(agentArgs);
|
||||
if (classURL == null) {
|
||||
throw new Exception("Cannot find class: " + agentArgs);
|
||||
}
|
||||
|
||||
int redefineLength;
|
||||
InputStream redefineStream;
|
||||
|
||||
System.out.println("Reading test class from " + classURL);
|
||||
if (classURL.getProtocol().equals("file")) {
|
||||
File f = new File(classURL.getFile());
|
||||
redefineStream = new FileInputStream(f);
|
||||
redefineLength = (int) f.length();
|
||||
} else {
|
||||
URLConnection conn = classURL.openConnection();
|
||||
redefineStream = conn.getInputStream();
|
||||
redefineLength = conn.getContentLength();
|
||||
}
|
||||
|
||||
final byte[] buffer = new byte[redefineLength];
|
||||
new BufferedInputStream(redefineStream).read(buffer);
|
||||
|
||||
System.gc(); // throw away anything we can before we start testing
|
||||
|
||||
new Timer(true).schedule(new TimerTask() {
|
||||
public void run() {
|
||||
try {
|
||||
int i;
|
||||
System.out.println("Redefining");
|
||||
ClassDefinition cld = new ClassDefinition(clz, buffer);
|
||||
for (i = 0; i < N_REDEFINES; i++) {
|
||||
inst.redefineClasses(new ClassDefinition[] { cld });
|
||||
System.gc(); // throw away anything we can
|
||||
}
|
||||
System.out.println("Redefined " + i + " times.");
|
||||
RedefineBigClassAgent.doneRedefining = true;
|
||||
}
|
||||
catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
42
jdk/test/java/lang/instrument/RedefineBigClassApp.java
Normal file
42
jdk/test/java/lang/instrument/RedefineBigClassApp.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
public class RedefineBigClassApp {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Creating instance of " +
|
||||
RedefineBigClassAgent.clz);
|
||||
RedefineBigClassAgent.clz.newInstance();
|
||||
|
||||
int count = 0;
|
||||
while (!RedefineBigClassAgent.doneRedefining) {
|
||||
System.out.println("App loop count: " + ++count);
|
||||
try {
|
||||
Thread.sleep(10 * 1000);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
System.out.println("App looped " + count + " times.");
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
83
jdk/test/java/lang/instrument/RetransformBigClass.sh
Normal file
83
jdk/test/java/lang/instrument/RetransformBigClass.sh
Normal file
@ -0,0 +1,83 @@
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 7122253
|
||||
# @ignore until the fix for 7122253 (from HotSpot) is in a promoted build
|
||||
# @summary Retransform a big class.
|
||||
# @author Daniel D. Daugherty
|
||||
#
|
||||
# @run shell MakeJAR4.sh RetransformBigClassAgent SimpleIdentityTransformer 'Can-Retransform-Classes: true'
|
||||
# @run build BigClass RetransformBigClassApp
|
||||
# @run shell/timeout=600 RetransformBigClass.sh
|
||||
#
|
||||
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTCLASSES}" = "" ]
|
||||
then
|
||||
echo "TESTCLASSES not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JAVAC="${TESTJAVA}"/bin/javac
|
||||
JAVA="${TESTJAVA}"/bin/java
|
||||
|
||||
"${JAVA}" ${TESTVMOPTS} \
|
||||
-XX:TraceRedefineClasses=3 \
|
||||
-javaagent:RetransformBigClassAgent.jar=BigClass.class \
|
||||
-classpath "${TESTCLASSES}" RetransformBigClassApp \
|
||||
> output.log 2>&1
|
||||
result=$?
|
||||
|
||||
cat output.log
|
||||
|
||||
if [ "$result" = 0 ]; then
|
||||
echo "PASS: RetransformBigClassApp exited with status of 0."
|
||||
else
|
||||
echo "FAIL: RetransformBigClassApp exited with status of $result"
|
||||
exit "$result"
|
||||
fi
|
||||
|
||||
MESG="Exception"
|
||||
grep "$MESG" output.log
|
||||
result=$?
|
||||
if [ "$result" = 0 ]; then
|
||||
echo "FAIL: found '$MESG' in the test output"
|
||||
result=1
|
||||
else
|
||||
echo "PASS: did NOT find '$MESG' in the test output"
|
||||
result=0
|
||||
fi
|
||||
|
||||
exit $result
|
58
jdk/test/java/lang/instrument/RetransformBigClassAgent.java
Normal file
58
jdk/test/java/lang/instrument/RetransformBigClassAgent.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.lang.instrument.*;
|
||||
import java.util.*;
|
||||
|
||||
public class RetransformBigClassAgent {
|
||||
private static int N_RETRANSFORMS = 1000;
|
||||
public static Class clz;
|
||||
public static volatile boolean doneRetransforming = false;
|
||||
|
||||
// just retransform the class in a loop via a Timer
|
||||
public static void premain(String agentArgs, final Instrumentation inst) throws Exception {
|
||||
String s = agentArgs.substring(0, agentArgs.indexOf(".class"));
|
||||
clz = Class.forName(s.replace('/', '.'));
|
||||
|
||||
ClassFileTransformer trans = new SimpleIdentityTransformer();
|
||||
inst.addTransformer(trans, true /* canRetransform */);
|
||||
|
||||
System.gc(); // throw away anything we can before we start testing
|
||||
|
||||
new Timer(true).schedule(new TimerTask() {
|
||||
public void run() {
|
||||
try {
|
||||
int i;
|
||||
System.out.println("Retransforming");
|
||||
for (i = 0; i < N_RETRANSFORMS; i++) {
|
||||
inst.retransformClasses(clz);
|
||||
System.gc(); // throw away anything we can
|
||||
}
|
||||
System.out.println("Retransformed " + i + " times.");
|
||||
RetransformBigClassAgent.doneRetransforming = true;
|
||||
}
|
||||
catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
42
jdk/test/java/lang/instrument/RetransformBigClassApp.java
Normal file
42
jdk/test/java/lang/instrument/RetransformBigClassApp.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
public class RetransformBigClassApp {
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println("Creating instance of " +
|
||||
RetransformBigClassAgent.clz);
|
||||
RetransformBigClassAgent.clz.newInstance();
|
||||
|
||||
int count = 0;
|
||||
while (!RetransformBigClassAgent.doneRetransforming) {
|
||||
System.out.println("App loop count: " + ++count);
|
||||
try {
|
||||
Thread.sleep(10 * 1000);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
System.out.println("App looped " + count + " times.");
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
47
jdk/test/java/nio/file/attribute/AclEntry/EmptySet.java
Normal file
47
jdk/test/java/nio/file/attribute/AclEntry/EmptySet.java
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 7076310
|
||||
* @summary Test AclEntry.Builder setFlags and setPermissions with empty sets
|
||||
*/
|
||||
|
||||
import java.nio.file.attribute.*;
|
||||
import java.util.*;
|
||||
|
||||
/*
|
||||
* Test for bug 7076310 "(file) AclEntry.Builder setFlags throws
|
||||
* IllegalArgumentException if set argument is empty"
|
||||
* The bug is only applies when the given Set is NOT an instance of EnumSet.
|
||||
*
|
||||
* The setPermissions method also has the same problem.
|
||||
*/
|
||||
public class EmptySet {
|
||||
public static void main(String[] args) {
|
||||
Set<AclEntryFlag> flags = new HashSet<>();
|
||||
AclEntry.newBuilder().setFlags(flags);
|
||||
|
||||
Set<AclEntryPermission> perms = new HashSet<>();
|
||||
AclEntry.newBuilder().setPermissions(perms);
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 6952519
|
||||
* @run main/timeout=40/othervm TcpTimeout
|
||||
* @run main/othervm TcpTimeout
|
||||
* @summary kdc_timeout is not being honoured when using TCP
|
||||
*/
|
||||
|
||||
@ -36,30 +36,19 @@ public class TcpTimeout {
|
||||
public static void main(String[] args)
|
||||
throws Exception {
|
||||
|
||||
// Set debug to grab debug output like ">>> KDCCommunication"
|
||||
System.setProperty("sun.security.krb5.debug", "true");
|
||||
final int p1 = 10000 + new java.util.Random().nextInt(10000);
|
||||
final int p2 = 20000 + new java.util.Random().nextInt(10000);
|
||||
final int p3 = 30000 + new java.util.Random().nextInt(10000);
|
||||
|
||||
KDC k = new KDC(OneKDC.REALM, OneKDC.KDCHOST, p3, true);
|
||||
// Called before new ServerSocket on p1 and p2 to make sure
|
||||
// customized nameservice is used
|
||||
KDC k = new KDC(OneKDC.REALM, OneKDC.KDCHOST, 0, true);
|
||||
int p3 = k.getPort();
|
||||
k.addPrincipal(OneKDC.USER, OneKDC.PASS);
|
||||
k.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
|
||||
|
||||
// Start two listener that does not communicate, simulate timeout
|
||||
new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
new ServerSocket(p1).accept();
|
||||
} catch (Exception e) {
|
||||
}}
|
||||
}.start();
|
||||
new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
new ServerSocket(p2).accept();
|
||||
} catch (Exception e) {
|
||||
}}
|
||||
}.start();
|
||||
int p1 = new ServerSocket(0).getLocalPort();
|
||||
int p2 = new ServerSocket(0).getLocalPort();
|
||||
|
||||
FileWriter fw = new FileWriter("alternative-krb5.conf");
|
||||
|
||||
@ -78,13 +67,15 @@ public class TcpTimeout {
|
||||
System.setProperty("java.security.krb5.conf", "alternative-krb5.conf");
|
||||
Config.refresh();
|
||||
|
||||
System.out.println("Ports opened on " + p1 + ", " + p2 + ", " + p3);
|
||||
|
||||
// The correct behavior should be:
|
||||
// 5 sec on p1, 5 sec on p1, fail
|
||||
// 5 sec on p2, 5 sec on p2, fail
|
||||
// p3 ok, p3 ok again for preauth.
|
||||
// The total time should be 20sec + 2x. x is processing time for AS-REQ.
|
||||
int count = 6;
|
||||
long start = System.nanoTime();
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
||||
PrintStream oldout = System.out;
|
||||
@ -103,36 +94,9 @@ public class TcpTimeout {
|
||||
throw new Exception("Retry count is " + count + " less");
|
||||
}
|
||||
|
||||
long end = System.nanoTime();
|
||||
if ((end - start)/1000000000L < 20) {
|
||||
throw new Exception("Too fast? " + (end - start)/1000000000L);
|
||||
long end = System.currentTimeMillis();
|
||||
if ((end - start)/1000L < 20) {
|
||||
throw new Exception("Too fast? " + (end - start)/1000L);
|
||||
}
|
||||
}
|
||||
|
||||
private static KDC on(int p) throws Exception {
|
||||
KDC k = new KDC(OneKDC.REALM, OneKDC.KDCHOST, p, true);
|
||||
k.addPrincipal(OneKDC.USER, OneKDC.PASS);
|
||||
k.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
|
||||
return k;
|
||||
}
|
||||
|
||||
private static void addFakeKDCs()
|
||||
throws Exception {
|
||||
BufferedReader fr = new BufferedReader(new FileReader(OneKDC.KRB5_CONF));
|
||||
FileWriter fw = new FileWriter("alternative-krb5.conf");
|
||||
while (true) {
|
||||
String s = fr.readLine();
|
||||
if (s == null) {
|
||||
break;
|
||||
}
|
||||
if (s.trim().startsWith("kdc = ")) {
|
||||
fw.write(" kdc = localhost:33333\n");
|
||||
fw.write(" kdc = localhost:22222\n");
|
||||
}
|
||||
fw.write(s + "\n");
|
||||
}
|
||||
fr.close();
|
||||
fw.close();
|
||||
sun.security.krb5.Config.refresh();
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
# JMAP - jmap utility
|
||||
# JPS - jps utility
|
||||
# JSTACK - jstack utility
|
||||
# JCMD - jcmd utility
|
||||
# OS - operating system name
|
||||
# PATTERN_EOL - grep or sed end-of-line pattern
|
||||
# PATTERN_WS - grep or sed whitespace pattern
|
||||
@ -72,6 +73,7 @@ JINFO="${TESTJAVA}/bin/jinfo"
|
||||
JMAP="${TESTJAVA}/bin/jmap"
|
||||
JPS="${TESTJAVA}/bin/jps"
|
||||
JSTACK="${TESTJAVA}/bin/jstack"
|
||||
JCMD="${TESTJAVA}/bin/jcmd"
|
||||
|
||||
isCygwin=false
|
||||
isMKS=false
|
||||
|
2
jdk/test/sun/tools/jcmd/dcmd-script.txt
Normal file
2
jdk/test/sun/tools/jcmd/dcmd-script.txt
Normal file
@ -0,0 +1,2 @@
|
||||
help help
|
||||
stop
|
12
jdk/test/sun/tools/jcmd/help_help.out
Normal file
12
jdk/test/sun/tools/jcmd/help_help.out
Normal file
@ -0,0 +1,12 @@
|
||||
help
|
||||
For more information about a specific command use 'help <command>'. With no argument this will show a list of available commands. 'help all' will show help for all commands.
|
||||
|
||||
Impact: Low:
|
||||
|
||||
Syntax : help [options] [<command name>]
|
||||
|
||||
Arguments:
|
||||
command name : [optional] The name of the command for which we want help (STRING, no default value)
|
||||
|
||||
Options: (options must be specified using the <key> or <key>=<value> syntax)
|
||||
-all : [optional] Show help for all commands (BOOLEAN, false)
|
33
jdk/test/sun/tools/jcmd/jcmd-Defaults.sh
Normal file
33
jdk/test/sun/tools/jcmd/jcmd-Defaults.sh
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 7104647
|
||||
# @run shell jcmd-Defaults.sh
|
||||
# @summary Test that output of 'jcmd' and 'jcmd -l' match a specific pattern
|
||||
|
||||
JCMD="${TESTJAVA}/bin/jcmd"
|
||||
|
||||
${JCMD} 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
|
||||
|
||||
${JCMD} -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
|
63
jdk/test/sun/tools/jcmd/jcmd-f.sh
Normal file
63
jdk/test/sun/tools/jcmd/jcmd-f.sh
Normal file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
|
||||
# @test
|
||||
# @bug 7104647
|
||||
# @summary Unit test for jcmd utility
|
||||
#
|
||||
# @library ../common
|
||||
# @build SimpleApplication ShutdownSimpleApplication
|
||||
# @run shell jcmd-f.sh
|
||||
|
||||
. ${TESTSRC}/../common/CommonSetup.sh
|
||||
. ${TESTSRC}/../common/ApplicationSetup.sh
|
||||
|
||||
# Start application and use PORTFILE for coordination
|
||||
PORTFILE="${TESTCLASSES}"/shutdown.port
|
||||
startApplication SimpleApplication "${PORTFILE}"
|
||||
|
||||
# all return statuses are checked in this test
|
||||
set +e
|
||||
|
||||
failed=0
|
||||
|
||||
# -f <script>
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
${JCMD} $appJavaPid -f ${TESTSRC}/dcmd-script.txt | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
|
||||
echo jcmd.out
|
||||
diff -w jcmd.out ${TESTSRC}/help_help.out
|
||||
if [ $? != 0 ]; then
|
||||
echo "Output of jcmd [pid] -f dcmd-script.txt differ from expected output. Failed."
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
failed=1;
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
stopApplication "${PORTFILE}"
|
||||
waitForApplication
|
||||
|
||||
exit $failed
|
63
jdk/test/sun/tools/jcmd/jcmd-help-help.sh
Normal file
63
jdk/test/sun/tools/jcmd/jcmd-help-help.sh
Normal file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
|
||||
# @test
|
||||
# @bug 7104647
|
||||
# @summary Unit test for jcmd utility
|
||||
#
|
||||
# @library ../common
|
||||
# @build SimpleApplication ShutdownSimpleApplication
|
||||
# @run shell jcmd-help-help.sh
|
||||
|
||||
. ${TESTSRC}/../common/CommonSetup.sh
|
||||
. ${TESTSRC}/../common/ApplicationSetup.sh
|
||||
|
||||
# Start application and use PORTFILE for coordination
|
||||
PORTFILE="${TESTCLASSES}"/shutdown.port
|
||||
startApplication SimpleApplication "${PORTFILE}"
|
||||
|
||||
# all return statuses are checked in this test
|
||||
set +e
|
||||
|
||||
failed=0
|
||||
|
||||
# help help
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
${JCMD} $appJavaPid help help | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
|
||||
echo jcmd.out
|
||||
diff -w jcmd.out ${TESTSRC}/help_help.out
|
||||
if [ $? != 0 ]; then
|
||||
echo "Output of jcmd [pid] help help differ from expected output. Failed."
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
failed=1;
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
stopApplication "${PORTFILE}"
|
||||
waitForApplication
|
||||
|
||||
exit $failed
|
54
jdk/test/sun/tools/jcmd/jcmd-help.sh
Normal file
54
jdk/test/sun/tools/jcmd/jcmd-help.sh
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 7104647
|
||||
# @run shell jcmd-help.sh
|
||||
# @summary Test that output of 'jcmd -h' matches the usage.out file
|
||||
|
||||
JCMD="${TESTJAVA}/bin/jcmd"
|
||||
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
${JCMD} -h > jcmd.out 2>&1
|
||||
|
||||
diff -w jcmd.out ${TESTSRC}/usage.out
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo "Output of jcmd -h differ from expected output. Failed."
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
${JCMD} -help > jcmd.out 2>&1
|
||||
|
||||
diff -w jcmd.out ${TESTSRC}/usage.out
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo "Output of jcmd -help differ from expected output. Failed."
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f jcmd.out 2>/dev/null
|
||||
exit 0
|
60
jdk/test/sun/tools/jcmd/jcmd-pid.sh
Normal file
60
jdk/test/sun/tools/jcmd/jcmd-pid.sh
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
|
||||
# @test
|
||||
# @bug 7104647
|
||||
# @summary Unit test for jcmd utility
|
||||
#
|
||||
# @library ../common
|
||||
# @build SimpleApplication ShutdownSimpleApplication
|
||||
# @run shell jcmd-pid.sh
|
||||
|
||||
. ${TESTSRC}/../common/CommonSetup.sh
|
||||
. ${TESTSRC}/../common/ApplicationSetup.sh
|
||||
|
||||
# Start application and use PORTFILE for coordination
|
||||
PORTFILE="${TESTCLASSES}"/shutdown.port
|
||||
startApplication SimpleApplication "${PORTFILE}"
|
||||
|
||||
# all return statuses are checked in this test
|
||||
set +e
|
||||
|
||||
failed=0
|
||||
|
||||
# help command
|
||||
${JCMD} $appJavaPid help 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output1.awk
|
||||
if [ $? != 0 ]; then failed=1; fi
|
||||
|
||||
# PerfCounter.list option
|
||||
${JCMD} $appJavaPid PerfCounter.print 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output2.awk
|
||||
if [ $? != 0 ]; then failed=1; fi
|
||||
|
||||
set -e
|
||||
|
||||
stopApplication "${PORTFILE}"
|
||||
waitForApplication
|
||||
|
||||
exit $failed
|
32
jdk/test/sun/tools/jcmd/jcmd_Output1.awk
Normal file
32
jdk/test/sun/tools/jcmd/jcmd_Output1.awk
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
BEGIN {
|
||||
totallines=0; matched=0
|
||||
}
|
||||
|
||||
# match on a main class name followed by arbitrary arguments
|
||||
/^[0-9]+ [a-z|A-Z][a-z|A-Z|0-9|\.]*($| .*$)/ {
|
||||
matched++;
|
||||
}
|
||||
|
||||
# or match on a path name to a jar file followed by arbitraty arguments
|
||||
# - note, jar files ending with ".jar" is only a convention, not a requirement.
|
||||
#Theoretically, any valid file name could occur here.
|
||||
/^[0-9]+ .*\.jar($| .*$)/ {
|
||||
matched++;
|
||||
}
|
||||
|
||||
# or match on the condition that the class name is not available
|
||||
/^[0-9]+ -- process information unavailable$/ {
|
||||
matched++;
|
||||
}
|
||||
|
||||
{ totallines++; print $0 }
|
||||
|
||||
END {
|
||||
if ((totallines > 0) && (matched == totallines)) {
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
exit 1
|
||||
}
|
||||
}
|
58
jdk/test/sun/tools/jcmd/jcmd_pid_Output1.awk
Normal file
58
jdk/test/sun/tools/jcmd/jcmd_pid_Output1.awk
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
|
||||
# section 0 = [PID]:
|
||||
# section 1 = "The following commands are available:"
|
||||
# section 2 = <list of commands, one command per line>
|
||||
# section 3 = blank line
|
||||
# section 4 = "For more information about a specific command use 'help <command>'."
|
||||
|
||||
BEGIN {
|
||||
totallines=0; matched=0; section=0;
|
||||
}
|
||||
|
||||
# match the first line (PID of the JVM followed by ':')
|
||||
/^[0-9]+:/{
|
||||
if(section==0) {
|
||||
matched++;
|
||||
section=1;
|
||||
}
|
||||
}
|
||||
|
||||
/^The following commands are available:$/{
|
||||
if(section==1) {
|
||||
matched++;
|
||||
section=2;
|
||||
}
|
||||
}
|
||||
|
||||
# match a command name
|
||||
/^[a-z|A-Z][a-z|A-Z|0-9|\.|_]*$/{
|
||||
if(section==2) {
|
||||
matched++;
|
||||
}
|
||||
}
|
||||
|
||||
/^$/{
|
||||
if(section==2) {
|
||||
matched++;
|
||||
section=4;
|
||||
}
|
||||
}
|
||||
|
||||
/^For more information about a specific command use 'help <command>'\.$/{
|
||||
if(section==4) {
|
||||
matched++;
|
||||
section=5;
|
||||
}
|
||||
}
|
||||
|
||||
{ totallines++; print $0 }
|
||||
|
||||
END {
|
||||
if ((totallines > 0) && (matched == totallines)) {
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
exit 1
|
||||
}
|
||||
}
|
25
jdk/test/sun/tools/jcmd/jcmd_pid_Output2.awk
Normal file
25
jdk/test/sun/tools/jcmd/jcmd_pid_Output2.awk
Normal file
@ -0,0 +1,25 @@
|
||||
#
|
||||
BEGIN {
|
||||
totallines=0; matched=0
|
||||
}
|
||||
|
||||
# match on counter name followed '=' and an arbitrary value
|
||||
/^[a-z|A-Z][a-z|A-Z|0-9|\.|_]*=.*$/ {
|
||||
matched++;
|
||||
}
|
||||
|
||||
# or match the first line (PID of the JVM followed by ':')
|
||||
/^[0-9]+:/ {
|
||||
matched++;
|
||||
}
|
||||
|
||||
{ totallines++; print $0 }
|
||||
|
||||
END {
|
||||
if ((totallines > 0) && (matched == totallines)) {
|
||||
exit 0
|
||||
}
|
||||
else {
|
||||
exit 1
|
||||
}
|
||||
}
|
15
jdk/test/sun/tools/jcmd/usage.out
Normal file
15
jdk/test/sun/tools/jcmd/usage.out
Normal file
@ -0,0 +1,15 @@
|
||||
Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>
|
||||
or: jcmd -l
|
||||
or: jcmd -h
|
||||
|
||||
command must be a valid jcmd command for the selected jvm.
|
||||
Use the command "help" to see which commands are available.
|
||||
If the pid is 0, commands will be sent to all Java processes.
|
||||
The main class argument will be used to match (either partially
|
||||
or fully) the class used to start Java.
|
||||
If no options are given, lists Java processes (same as -p).
|
||||
|
||||
PerfCounter.print display the counters exposed by this process
|
||||
-f read and execute commands from the file
|
||||
-l list JVM processes on the local machine
|
||||
-h this help
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,22 +21,55 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.util.Properties;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import static java.nio.file.Files.*;
|
||||
import static java.nio.file.StandardOpenOption.*;
|
||||
|
||||
public class DefaultLocaleTest {
|
||||
public static void main(String[] args) {
|
||||
String setting =
|
||||
|
||||
static final String setting =
|
||||
"language:" + System.getProperty("user.language") + "_" +
|
||||
"country:" + System.getProperty("user.country") + "_" +
|
||||
"encoding:" + System.getProperty("file.encoding") + "_" +
|
||||
"jnuEncoding:"+ System.getProperty("sun.jnu.encoding");
|
||||
if (args.length != 0) {
|
||||
if (!setting.equals(args[0])) {
|
||||
System.exit(1);
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
if (args != null && args.length > 1) {
|
||||
File f = new File(args[1]);
|
||||
switch (args[0]) {
|
||||
case "-r":
|
||||
System.out.println("reading file: " + args[1]);
|
||||
String str = null;
|
||||
try (BufferedReader in = newBufferedReader(f.toPath(),
|
||||
Charset.defaultCharset())) {
|
||||
str = in.readLine().trim();
|
||||
}
|
||||
if (setting.equals(str)) {
|
||||
System.out.println("Compared ok");
|
||||
} else {
|
||||
System.out.println("Compare fails");
|
||||
System.out.println("EXPECTED: " + setting);
|
||||
System.out.println("OBTAINED: " + str);
|
||||
throw new RuntimeException("Test fails: compare failed");
|
||||
}
|
||||
break;
|
||||
case "-w":
|
||||
System.out.println("writing file: " + args[1]);
|
||||
try (BufferedWriter out = newBufferedWriter(f.toPath(),
|
||||
Charset.defaultCharset(), CREATE_NEW)) {
|
||||
out.write(setting);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("ERROR: invalid arguments");
|
||||
}
|
||||
} else {
|
||||
System.out.println(setting);
|
||||
throw new RuntimeException("ERROR: invalid arguments");
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,90 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 4958170 4891531 4989534
|
||||
# @summary Test to see if default java locale settings are identical
|
||||
# when launch jvm from java and javaw respectively. Test
|
||||
# should be run on Windows with different user locale and
|
||||
# system locale setting in ControlPanel's RegionSetting.
|
||||
# Following 2 testing scenarios are recommended
|
||||
# (1)systemLocale=Japanese, userLocale=English
|
||||
# (2)systemLocale=English, userLocale=Japanese
|
||||
# @run shell DefaultLocaleTest.sh
|
||||
#
|
||||
# Verify directory context variables are set
|
||||
if [ "${TESTJAVA}" = "" ]
|
||||
then
|
||||
echo "TESTJAVA not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
echo "TESTSRC not set. Test cannot execute. Failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OS=`uname`
|
||||
|
||||
case "$OS" in
|
||||
Windows* )
|
||||
JAVAC="${TESTJAVA}/bin/javac -d . "
|
||||
JAVA="${TESTJAVA}/bin/java -classpath . "
|
||||
JAVAW="${TESTJAVA}/bin/javaw -classpath . "
|
||||
|
||||
${JAVAC} ${TESTSRC}/DefaultLocaleTest.java
|
||||
props=`${JAVA} DefaultLocaleTest`
|
||||
${JAVAW} DefaultLocaleTest $props
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Test fails"
|
||||
exit 1
|
||||
fi
|
||||
echo "Test passes"
|
||||
exit 0
|
||||
;;
|
||||
CYGWIN* )
|
||||
JAVAC="${TESTJAVA}/bin/javac -d . "
|
||||
JAVA="${TESTJAVA}/bin/java -classpath . "
|
||||
JAVAW="${TESTJAVA}/bin/javaw -classpath . "
|
||||
|
||||
${JAVAC} ${TESTSRC}/DefaultLocaleTest.java
|
||||
${JAVA} DefaultLocaleTest | sed -e s@\\r@@g > x.out
|
||||
${JAVAW} DefaultLocaleTest `cat x.out`
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Test fails"
|
||||
exit 1
|
||||
fi
|
||||
echo "Test passes"
|
||||
exit 0
|
||||
;;
|
||||
* )
|
||||
echo "Non-windows environment; test vacuously succeeds."
|
||||
exit 0;
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
|
56
jdk/test/tools/launcher/DefaultLocaleTestRun.java
Normal file
56
jdk/test/tools/launcher/DefaultLocaleTestRun.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4958170 4891531 4989534
|
||||
* @summary Test to see if default java locale settings are identical
|
||||
when launch jvm from java and javaw respectively. Test
|
||||
should be run on Windows with different user locale and
|
||||
system locale setting in ControlPanel's RegionSetting.
|
||||
Following 2 testing scenarios are recommended
|
||||
(1)systemLocale=Japanese, userLocale=English
|
||||
(2)systemLocale=English, userLocale=Japanese
|
||||
* @compile -XDignore.symbol.file DefaultLocaleTest.java TestHelper.java
|
||||
* @run main DefaultLocaleTestRun
|
||||
*/
|
||||
import java.io.File;
|
||||
|
||||
public class DefaultLocaleTestRun {
|
||||
public static void main(String... args) {
|
||||
if (!TestHelper.isWindows) {
|
||||
System.out.println("Test passes vacuously on non-windows");
|
||||
return;
|
||||
}
|
||||
TestHelper.TestResult tr = null;
|
||||
tr = TestHelper.doExec(TestHelper.javaCmd, "DefaultLocaleTest", "-w",
|
||||
"x.out");
|
||||
System.out.println(tr.testOutput);
|
||||
tr = TestHelper.doExec(TestHelper.javawCmd, "DefaultLocaleTest", "-r",
|
||||
"x.out");
|
||||
System.out.println(tr.testOutput);
|
||||
if (!tr.isOK()) {
|
||||
throw new RuntimeException("Test failed");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,7 @@ import java.io.IOException;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6994753
|
||||
* @bug 6994753 7123582
|
||||
* @summary tests -XshowSettings options
|
||||
* @compile -XDignore.symbol.file Settings.java TestHelper.java
|
||||
* @run main Settings
|
||||
@ -129,6 +129,17 @@ public class Settings {
|
||||
checkNoContains(tr, LOCALE_SETTINGS);
|
||||
checkContains(tr, "Unrecognized option: -XshowSettingsBadOption");
|
||||
}
|
||||
|
||||
static void runTest7123582() throws IOException {
|
||||
TestHelper.TestResult tr = null;
|
||||
tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings", "-version");
|
||||
if (!tr.isOK()) {
|
||||
System.out.println(tr.status);
|
||||
throw new RuntimeException("test fails");
|
||||
}
|
||||
containsAllOptions(tr);
|
||||
}
|
||||
|
||||
public static void main(String... args) {
|
||||
try {
|
||||
runTestOptionAll();
|
||||
@ -137,6 +148,7 @@ public class Settings {
|
||||
runTestOptionProperty();
|
||||
runTestOptionLocale();
|
||||
runTestBadOptions();
|
||||
runTest7123582();
|
||||
} catch (IOException ioe) {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ public enum TestHelper {
|
||||
static final String JAVAHOME = System.getProperty("java.home");
|
||||
static final boolean isSDK = JAVAHOME.endsWith("jre");
|
||||
static final String javaCmd;
|
||||
static final String javawCmd;
|
||||
static final String java64Cmd;
|
||||
static final String javacCmd;
|
||||
static final JavaCompiler compiler;
|
||||
@ -84,15 +85,29 @@ public enum TestHelper {
|
||||
: new File(binDir, "java");
|
||||
javaCmd = javaCmdFile.getAbsolutePath();
|
||||
if (!javaCmdFile.canExecute()) {
|
||||
throw new RuntimeException("java <" + TestHelper.javaCmd + "> must exist");
|
||||
throw new RuntimeException("java <" + TestHelper.javaCmd +
|
||||
"> must exist and should be executable");
|
||||
}
|
||||
|
||||
File javacCmdFile = (isWindows)
|
||||
? new File(binDir, "javac.exe")
|
||||
: new File(binDir, "javac");
|
||||
javacCmd = javacCmdFile.getAbsolutePath();
|
||||
|
||||
if (isWindows) {
|
||||
File javawCmdFile = new File(binDir, "javaw.exe");
|
||||
javawCmd = javawCmdFile.getAbsolutePath();
|
||||
if (!javawCmdFile.canExecute()) {
|
||||
throw new RuntimeException("java <" + javawCmd +
|
||||
"> must exist and should be executable");
|
||||
}
|
||||
} else {
|
||||
javawCmd = null;
|
||||
}
|
||||
|
||||
if (!javacCmdFile.canExecute()) {
|
||||
throw new RuntimeException("java <" + javacCmd + "> must exist");
|
||||
throw new RuntimeException("java <" + javacCmd +
|
||||
"> must exist and should be executable");
|
||||
}
|
||||
if (isSolaris) {
|
||||
File sparc64BinDir = new File(binDir,isSparc ? "sparcv9" : "amd64");
|
||||
|
Loading…
x
Reference in New Issue
Block a user