diff --git a/jdk/make/CompileDemos.gmk b/jdk/make/CompileDemos.gmk
index 123711d102c..35bf0b4a691 100644
--- a/jdk/make/CompileDemos.gmk
+++ b/jdk/make/CompileDemos.gmk
@@ -314,19 +314,6 @@ $(eval $(call SetupJVMTIDemo,compiledMethodLoad, agent_util))
$(eval $(call SetupJVMTIDemo,gctest, agent_util))
$(eval $(call SetupJVMTIDemo,heapTracker, agent_util java_crw_demo))
$(eval $(call SetupJVMTIDemo,heapViewer, agent_util))
-
-# On AIX, hprof requires 'dladdr' from src/aix/porting/porting_aix.cpp
-BUILD_LIBHPROF_AIX_EXTRA_SRC :=
-BUILD_LIBHPROF_AIX_EXTRA_CFLAGS :=
-ifeq ($(OPENJDK_TARGET_OS), aix)
- BUILD_LIBHPROF_AIX_EXTRA_SRC += $(JDK_TOPDIR)/src/aix/porting
- BUILD_LIBHPROF_AIX_EXTRA_CFLAGS += -I$(JDK_TOPDIR)/src/aix/porting
-endif
-
-$(eval $(call SetupJVMTIDemo,hprof, java_crw_demo, \
- $(BUILD_LIBHPROF_AIX_EXTRA_CFLAGS), C, \
- -ldl, ws2_32.lib winmm.lib, -lsocket -lnsl, -lpthread, $(BUILD_LIBHPROF_AIX_EXTRA_SRC)))
-
$(eval $(call SetupJVMTIDemo,minst, agent_util java_crw_demo))
$(eval $(call SetupJVMTIDemo,mtrace, agent_util java_crw_demo))
$(eval $(call SetupJVMTIDemo,waiters, agent_util, , C++))
@@ -334,34 +321,6 @@ $(eval $(call SetupJVMTIDemo,versionCheck, agent_util))
##################################################################################################
-$(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README: \
- $(JDK_TOPDIR)/src/demo/share/jpda/com/sun/tools/example/README
- $(call install-file)
- $(CHMOD) -f ug+w $@
-
-$(eval $(call SetupArchive,JPDA_JAR, \
- $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example/README, \
- SRCS := $(JDK_TOPDIR)/src/demo/share/jpda \
- $(JDK_TOPDIR)/src/jdk.jdi/share/classes \
- $(JDK_OUTPUTDIR)/demo/jpda/com/sun/tools/example, \
- INCLUDES := com/sun/tools/example README, \
- SUFFIXES := .java .html .jj README, \
- JAR := $(JDK_OUTPUTDIR)/demo/jpda/examples.jar, \
- MANIFEST := $(JDK_TOPDIR)/make/data/mainmanifest/manifest.mf, \
- EXTRA_MANIFEST_ATTR := Main-Class:$$(SPACE), \
- SKIP_METAINF := true))
-
-$(eval $(call SetupZipArchive,JPDA_ZIP, \
- SRC := $(JDK_TOPDIR)/src/demo/share/jpda \
- $(JDK_TOPDIR)/src/jdk.jdi/share/classes, \
- INCLUDES := com/sun/tools/example, \
- SUFFIXES := .java .html .jj README, \
- ZIP := $(JDK_OUTPUTDIR)/demo/jpda/src.zip))
-
-BUILD_DEMOS += $(JPDA_JAR) $(JPDA_ZIP)
-
-##################################################################################################
-
$(JDK_OUTPUTDIR)/demo/management/index.html: $(DEMO_SHARE_SRC)/management/index.html
$(call install-file)
$(CHMOD) -f ug+w $@
diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk
index 4cfa33fc9f8..b68d19c3d34 100644
--- a/jdk/make/Tools.gmk
+++ b/jdk/make/Tools.gmk
@@ -134,7 +134,7 @@ TOOL_CHECKDEPS = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
-cp "$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)" \
- build.tools.module.GenerateModulesXml
+ build.tools.module.GenJdepsModulesXml
##########################################################################################
diff --git a/jdk/make/copy/Copy-jdk.hprof.agent.gmk b/jdk/make/copy/Copy-jdk.hprof.agent.gmk
index 738af52b20d..069e915514f 100644
--- a/jdk/make/copy/Copy-jdk.hprof.agent.gmk
+++ b/jdk/make/copy/Copy-jdk.hprof.agent.gmk
@@ -27,7 +27,7 @@ include CopyCommon.gmk
################################################################################
-HPROF_SRC := $(JDK_TOPDIR)/src/demo/share/jvmti/hprof/jvm.hprof.txt
+HPROF_SRC := $(JDK_TOPDIR)/src/jdk.hprof.agent/share/native/libhprof/jvm.hprof.txt
$(LIB_DST_DIR)/jvm.hprof.txt: $(HPROF_SRC)
$(call install-file)
diff --git a/jdk/make/data/fontconfig/aix.fontconfig.properties b/jdk/make/data/fontconfig/aix.fontconfig.properties
index 29e7c7d9510..f203f759894 100644
--- a/jdk/make/data/fontconfig/aix.fontconfig.properties
+++ b/jdk/make/data/fontconfig/aix.fontconfig.properties
@@ -24,9 +24,14 @@
# questions.
#
-# Minimal version for AIX using the standard Latin Type1 Fonts from the
-# package X11.fnt.iso_T1. These fonts are installed by default into
-# "/usr/lpp/X11/lib/X11/fonts/Type1" and sym-linked to "/usr/lib/X11/fonts/Type1"
+#
+# Portions Copyright (c) 2014 IBM Corporation
+#
+
+# This file references the standard Latin Type1 fonts from the AIX package
+# X11.fnt.iso_T1 and the Unicode TrueType fonts from X11.fnt.ucs.ttf. They
+# are located by default under "/usr/lpp/X11/lib/X11/fonts/{Type1,TrueType}"
+# and sym-linked to "/usr/lib/X11/fonts/".
# Version
@@ -34,44 +39,381 @@ version=1
# Component Font Mappings
-dialog.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso10646-1
-dialog.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso10646-1
-dialog.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso10646-1
-dialog.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso10646-1
+allfonts.iso10646-extB=-monotype-sansmonowtextb-medium-r-normal--*-%d-75-75-m-*-unicode-2
-dialoginput.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso10646-1
-dialoginput.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso10646-1
-dialoginput.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso10646-1
-dialoginput.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso10646-1
-sansserif.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso10646-1
-sansserif.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso10646-1
-sansserif.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso10646-1
-sansserif.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso10646-1
+dialog.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso8859-1
+dialog.plain.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+dialog.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+dialog.plain.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialog.plain.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialog.plain.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialog.plain.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialog.plain.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialog.plain.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialog.plain.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialog.plain.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialog.plain.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
-serif.plain.latin-1=-*-times new roman-medium-r-normal--*-%d-100-100-p-*-iso10646-1
-serif.bold.latin-1=-*-times new roman-bold-r-normal--*-%d-100-100-p-*-iso10646-1
-serif.italic.latin-1=-*-times new roman-medium-i-normal--*-%d-100-100-p-*-iso10646-1
-serif.bolditalic.latin-1=-*-times new roman-bold-i-normal--*-%d-100-100-p-*-iso10646-1
+dialog.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso8859-1
+dialog.bold.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+dialog.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+dialog.bold.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialog.bold.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialog.bold.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialog.bold.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialog.bold.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialog.bold.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialog.bold.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialog.bold.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialog.bold.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
-monospaced.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso10646-1
-monospaced.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso10646-1
-monospaced.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso10646-1
-monospaced.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso10646-1
+dialog.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso8859-1
+dialog.italic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+dialog.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0
+dialog.italic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialog.italic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialog.italic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialog.italic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialog.italic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialog.italic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialog.italic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialog.italic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialog.italic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+dialog.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso8859-1
+dialog.bolditalic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+dialog.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+dialog.bolditalic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialog.bolditalic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialog.bolditalic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialog.bolditalic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialog.bolditalic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialog.bolditalic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialog.bolditalic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialog.bolditalic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialog.bolditalic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+dialoginput.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso8859-1
+dialoginput.plain.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+dialoginput.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0
+dialoginput.plain.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialoginput.plain.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialoginput.plain.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialoginput.plain.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialoginput.plain.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialoginput.plain.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialoginput.plain.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialoginput.plain.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialoginput.plain.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+dialoginput.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso8859-1
+dialoginput.bold.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+dialoginput.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-m-*-ucs2.i18n-0
+dialoginput.bold.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialoginput.bold.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialoginput.bold.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialoginput.bold.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialoginput.bold.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialoginput.bold.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialoginput.bold.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialoginput.bold.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialoginput.bold.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+dialoginput.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso8859-1
+dialoginput.italic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+dialoginput.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-m-*-ucs2.i18n-0
+dialoginput.italic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialoginput.italic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialoginput.italic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialoginput.italic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialoginput.italic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialoginput.italic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialoginput.italic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialoginput.italic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialoginput.italic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+dialoginput.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso8859-1
+dialoginput.bolditalic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+dialoginput.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0
+dialoginput.bolditalic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+dialoginput.bolditalic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+dialoginput.bolditalic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+dialoginput.bolditalic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+dialoginput.bolditalic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+dialoginput.bolditalic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+dialoginput.bolditalic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+dialoginput.bolditalic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+dialoginput.bolditalic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+sansserif.plain.latin-1=-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso8859-1
+sansserif.plain.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+sansserif.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+sansserif.plain.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+sansserif.plain.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+sansserif.plain.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+sansserif.plain.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+sansserif.plain.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+sansserif.plain.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+sansserif.plain.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+sansserif.plain.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+sansserif.plain.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+sansserif.bold.latin-1=-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso8859-1
+sansserif.bold.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+sansserif.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+sansserif.bold.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+sansserif.bold.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+sansserif.bold.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+sansserif.bold.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+sansserif.bold.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+sansserif.bold.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+sansserif.bold.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+sansserif.bold.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+sansserif.bold.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+sansserif.italic.latin-1=-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso8859-1
+sansserif.italic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+sansserif.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0
+sansserif.italic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+sansserif.italic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+sansserif.italic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+sansserif.italic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+sansserif.italic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+sansserif.italic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+sansserif.italic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+sansserif.italic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+sansserif.italic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+sansserif.bolditalic.latin-1=-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso8859-1
+sansserif.bolditalic.thai=-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+sansserif.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+sansserif.bolditalic.japanese-x0208=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+sansserif.bolditalic.japanese-x0201=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+sansserif.bolditalic.japanese-udc=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+sansserif.bolditalic.japanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+sansserif.bolditalic.korean=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+sansserif.bolditalic.korean-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+sansserif.bolditalic.chinese=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+sansserif.bolditalic.chinese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+sansserif.bolditalic.taiwanese-iso10646=-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+serif.plain.latin-1=-*-times new roman-medium-r-normal--*-%d-100-100-p-*-iso8859-1
+serif.plain.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+serif.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+serif.plain.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+serif.plain.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+serif.plain.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+serif.plain.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+serif.plain.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+serif.plain.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+serif.plain.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+serif.plain.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+serif.plain.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+serif.bold.latin-1=-*-times new roman-bold-r-normal--*-%d-100-100-p-*-iso8859-1
+serif.bold.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+serif.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+serif.bold.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+serif.bold.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+serif.bold.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+serif.bold.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+serif.bold.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+serif.bold.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+serif.bold.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+serif.bold.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+serif.bold.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+
+serif.italic.latin-1=-*-times new roman-medium-i-normal--*-%d-100-100-p-*-iso8859-1
+serif.italic.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+serif.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0
+serif.italic.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+serif.italic.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+serif.italic.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+serif.italic.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+serif.italic.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+serif.italic.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+serif.italic.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+serif.italic.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+serif.italic.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+serif.bolditalic.latin-1=-*-times new roman-bold-i-normal--*-%d-100-100-p-*-iso8859-1
+serif.bolditalic.thai=-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0
+serif.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0
+serif.bolditalic.japanese-x0208=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+serif.bolditalic.japanese-x0201=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+serif.bolditalic.japanese-udc=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+serif.bolditalic.japanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+serif.bolditalic.korean=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+serif.bolditalic.korean-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+serif.bolditalic.chinese=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+serif.bolditalic.chinese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+serif.bolditalic.taiwanese-iso10646=-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+monospaced.plain.latin-1=-*-courier-medium-r-normal--*-%d-100-100-m-*-iso8859-1
+monospaced.plain.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+monospaced.plain.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0
+monospaced.plain.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+monospaced.plain.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+monospaced.plain.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+monospaced.plain.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+monospaced.plain.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+monospaced.plain.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+monospaced.plain.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+monospaced.plain.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+monospaced.plain.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+monospaced.bold.latin-1=-*-courier-bold-r-normal--*-%d-100-100-m-*-iso8859-1
+monospaced.bold.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+monospaced.bold.ukranian-ibm1124=-*-*-bold-r-normal--*-%d-75-75-m-*-ucs2.i18n-0
+monospaced.bold.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+monospaced.bold.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+monospaced.bold.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+monospaced.bold.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+monospaced.bold.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+monospaced.bold.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+monospaced.bold.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+monospaced.bold.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+monospaced.bold.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+monospaced.italic.latin-1=-*-courier-medium-o-normal--*-%d-100-100-m-*-iso8859-1
+monospaced.italic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+monospaced.italic.ukranian-ibm1124=-*-*-medium-i-normal--*-%d-75-75-m-*-ucs2.i18n-0
+monospaced.italic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+monospaced.italic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+monospaced.italic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+monospaced.italic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+monospaced.italic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+monospaced.italic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+monospaced.italic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+monospaced.italic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+monospaced.italic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
+
+monospaced.bolditalic.latin-1=-*-courier-bold-o-normal--*-%d-100-100-m-*-iso8859-1
+monospaced.bolditalic.thai=-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0
+monospaced.bolditalic.ukranian-ibm1124=-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0
+monospaced.bolditalic.japanese-x0208=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0
+monospaced.bolditalic.japanese-x0201=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0
+monospaced.bolditalic.japanese-udc=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp
+monospaced.bolditalic.japanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0
+monospaced.bolditalic.korean=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0
+monospaced.bolditalic.korean-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0
+monospaced.bolditalic.chinese=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0
+monospaced.bolditalic.chinese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0
+monospaced.bolditalic.taiwanese-iso10646=-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0
# Search Sequences
sequence.allfonts=latin-1
+sequence.allfonts.UTF-8=latin-1,japanese-iso10646
+# Uk_UA
+sequence.allfonts.x-IBM1124=latin-1,ukranian-ibm1124
+# Japanese
+sequence.allfonts.x-IBM943C=latin-1,japanese-x0201,japanese-x0208,japanese-udc
+sequence.allfonts.x-IBM29626C=latin-1,japanese-x0201,japanese-x0208,japanese-udc
+sequence.allfonts.UTF-8.ja=japanese-iso10646,latin-1,iso10646-extB
+# Chinese
+sequence.allfonts.x-EUC_CN=latin-1,chinese
+sequence.allfonts.GB18030=latin-1,chinese-iso10646,iso10646-extB
+sequence.allfonts.UTF-8.zh.CN=latin-1,chinese-iso10646,iso10646-extB
+# Taiwanese
+sequence.allfonts.x-IBM964=latin-1,taiwanese-iso10646
+sequence.allfonts.Big5=latin-1,taiwanese-iso10646
+sequence.allfonts.UTF-8.zh.TW=latin-1,taiwanese-iso10646
+# Korean
+sequence.allfonts.x-IBM970=latin-1,korean
+sequence.allfonts.UTF-8.ko=latin-1,korean-iso10646
+# Thai
+sequence.allfonts.TIS-620=latin-1,thai
+sequence.allfonts.UTF-8.th=latin-1,thai
+# fallback
+sequence.fallback=thai,chinese-iso10646,taiwanese-iso10646,japanese-iso10646,korean-iso10646,iso10646-extB
+
+# Exclusion Ranges
+exclusion.japanese-iso10646=0000-00ff
+
+# Font File Names
+filename.-*-courier-medium-r-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/cour.pfa
+filename.-*-courier-bold-r-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/courb.pfa
+filename.-*-courier-medium-o-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/couri.pfa
+filename.-*-courier-bold-o-normal--*-%d-100-100-m-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/courbi.pfa
+filename.-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helv.pfa
+filename.-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvb.pfa
+filename.-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvi.pfa
+filename.-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvbi.pfa
+filename.-*-times_new_roman-medium-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnr.pfa
+filename.-*-times_new_roman-bold-r-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrb.pfa
+filename.-*-times_new_roman-medium-i-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnri.pfa
+filename.-*-times_new_roman-bold-i-normal--*-%d-100-100-p-*-iso8859-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrbi.pfa
+
+
+filename.-monotype-sansmonowtextb-medium-r-normal--*-%d-75-75-m-*-unicode-2=/usr/lpp/X11/lib/X11/fonts/TrueType/MTSanXBA.ttf
+
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_k.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_k.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_s.ttf
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_t.ttf
+
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdk.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdk.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansds.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansds.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdt.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0208.1983-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-jisx0201.1976-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ibm-udcjp=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_japan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_j.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ksc5601.1987-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_k.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_korea-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_k.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-gb2312.1980-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_s.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_china-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_s.ttf
+filename.-monotype-sanswt-medium-r-normal--*-%d-75-75-*-*-ucs2.cjk_taiwan-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsans_t.ttf
+
+filename.-monotype-timesnewromanwt-medium-r-normal--*-%d-75-75-*-*-iso8859-15=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-monotype-sansmonowt-medium-r-normal--*-%d-75-75-*-*-iso8859-15=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+
+filename.-ibm-thaicourier-medium-r-normal--*-%d-75-75-m-*-ucs2.thai-0=/usr/lpp/X11/lib/X11/fonts/TrueType/courth.ttf
+filename.-ibm-thaihelvetica-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0=/usr/lpp/X11/lib/X11/fonts/TrueType/helvth.ttf
+filename.-ibm-thaitimes-medium-r-normal--*-%d-75-75-p-*-ucs2.thai-0=/usr/lpp/X11/lib/X11/fonts/TrueType/timeth.ttf
+
+filename.-*-*-medium-r-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-bold-r-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-medium-i-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-bold-i-normal--*-%d-*-*-p-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-medium-r-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-*-*-bold-r-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-*-*-medium-i-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-*-*-bold-i-normal--*-%d-*-*-m-*-ibm-1046=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+
+filename.-*-*-medium-r-normal--*-%d-75-75-p-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-bold-r-normal--*-%d-75-75-p-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-medium-i-normal--*-%d-75-75-p-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/tnrwt_j.ttf
+filename.-*-*-medium-r-normal--*-%d-75-75-m-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-*-*-bold-r-normal--*-%d-75-75-m-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+filename.-*-*-medium-i-normal--*-%d-75-75-m-*-ucs2.i18n-0=/usr/lpp/X11/lib/X11/fonts/TrueType/mtsansdj.ttf
+
+# AWT font path
+awtfontpath.japanese-x0201=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.japanese-x0208=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.japanese-udc=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.japanese-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.korean=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.korean-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.chinese=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.chinese-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.taiwanese-iso10646=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.thai=/usr/lpp/X11/lib/X11/fonts/TrueType
+awtfontpath.iso10646-extB=/usr/lpp/X11/lib/X11/fonts/TrueType
-filename.-*-courier-medium-r-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/cour.pfa
-filename.-*-courier-bold-r-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/courb.pfa
-filename.-*-courier-medium-o-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/couri.pfa
-filename.-*-courier-bold-o-normal--*-%d-100-100-m-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/courbi.pfa
-filename.-*-helvetica-medium-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helv.pfa
-filename.-*-helvetica-bold-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvb.pfa
-filename.-*-helvetica-medium-o-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvi.pfa
-filename.-*-helvetica-bold-o-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/helvbi.pfa
-filename.-*-times_new_roman-medium-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnr.pfa
-filename.-*-times_new_roman-bold-r-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrb.pfa
-filename.-*-times_new_roman-medium-i-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnri.pfa
-filename.-*-times_new_roman-bold-i-normal--*-%d-100-100-p-*-iso10646-1=/usr/lpp/X11/lib/X11/fonts/Type1/tnrbi.pfa
diff --git a/jdk/make/ModulesXml.gmk b/jdk/make/gendata/Gendata-jdk.dev.gmk
similarity index 57%
rename from jdk/make/ModulesXml.gmk
rename to jdk/make/gendata/Gendata-jdk.dev.gmk
index 1399e46bace..3c24cf4b703 100644
--- a/jdk/make/ModulesXml.gmk
+++ b/jdk/make/gendata/Gendata-jdk.dev.gmk
@@ -23,47 +23,24 @@
# questions.
#
-# Default target declared first
-default: all
+include GendataCommon.gmk
-include $(SPEC)
-include MakeBase.gmk
-include Tools.gmk
+$(eval $(call IncludeCustomExtension, jdk, gendata/Gendata-jdk.dev.gmk))
+
+GENDATA := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/jdeps-modules.xml
+METADATA_FILES += $(TOPDIR)/modules.xml
#
# Generate modules.xml for jdeps to use
# It augments $(TOPDIR)/modules.xml to include module membership
#
-JDEPS_MODULES_XML := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/modules.xml
-
-METADATA := $(JDK_OUTPUTDIR)/btclasses/build/tools/module/modules.xml
-$(METADATA): $(TOPDIR)/modules.xml
- $(call install-file)
-
-METADATA_FILES := $(METADATA)
-
-ifndef OPENJDK
- CLOSED_METADATA := $(JDK_OUTPUTDIR)/btclasses/build/tools/module/closed/modules.xml
- $(CLOSED_METADATA): $(TOPDIR)/closed/modules.xml
- $(call install-file)
-
- METADATA_FILES += $(CLOSED_METADATA)
-endif
-
-$(JDEPS_MODULES_XML): $(BUILD_TOOLS_JDK) $(METADATA_FILES)
+$(GENDATA): $(BUILD_TOOLS_JDK) $(METADATA_FILES)
$(MKDIR) -p $(@D)
$(RM) $@
- $(TOOL_GENMODULESXML) $@ $(JDK_OUTPUTDIR)/modules
+ $(TOOL_GENMODULESXML) -o $@ -mp $(JDK_OUTPUTDIR)/modules $(METADATA_FILES)
-#
-# Verify access across module boundaries
-#
-checkdeps: $(JDEPS_MODULES_XML)
- $(ECHO) "Checking dependencies across JDK modules"
- $(FIXPATH) $(JDK_OUTPUTDIR)/bin/jdeps -verify:access -mp $(JDK_OUTPUTDIR)/modules
+jdk.dev: $(GENDATA)
-gen-modules-xml: $(JDEPS_MODULES_XML)
+all: $(GENDATA)
-all: checkdeps
-
-.PHONY: all
+.PHONY: all jdk.dev
diff --git a/jdk/make/gensrc/GensrcProviders.gmk b/jdk/make/gensrc/GensrcProviders.gmk
index 985f032169e..dca14083054 100644
--- a/jdk/make/gensrc/GensrcProviders.gmk
+++ b/jdk/make/gensrc/GensrcProviders.gmk
@@ -32,15 +32,6 @@ endef
################################################################################
-# Filter com.sun.tools.attach.spi.AttachProvider
-$(JDK_OUTPUTDIR)/gensrc/jdk.attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider: \
- $(JDK_TOPDIR)/src/jdk.attach/share/classes/META-INF/services/com.sun.tools.attach.spi.AttachProvider
- $(process-provider)
-
-GENSRC_JDK_ATTACH += $(JDK_OUTPUTDIR)/gensrc/jdk.attach/META-INF/services/com.sun.tools.attach.spi.AttachProvider
-
-################################################################################
-
# Filter com.sun.jdi.connect.Connector
$(JDK_OUTPUTDIR)/gensrc/jdk.jdi/META-INF/services/com.sun.jdi.connect.Connector: \
$(JDK_TOPDIR)/src/jdk.jdi/share/classes/META-INF/services/com.sun.jdi.connect.Connector
diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk
index c071b3f093d..e5161a35552 100644
--- a/jdk/make/lib/Awt2dLibraries.gmk
+++ b/jdk/make/lib/Awt2dLibraries.gmk
@@ -149,13 +149,17 @@ LIBAWT_DIRS := $(JDK_TOPDIR)/src/java.desktop/share/native/libawt \
$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/sun/awt \
#
+ifeq ($(OPENJDK_TARGET_OS), aix)
+ LIBAWT_DIRS += $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS)/native/libawt
+endif
+
ifeq ($(OPENJDK_TARGET_OS), windows)
LIBAWT_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/native/common/sun/awt/utility
else
LIBAWT_EXFILES := sun/java2d/ShaderList.c
endif
-ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx), )
+ifneq ($(filter $(OPENJDK_TARGET_OS), solaris linux macosx aix), )
LIBAWT_EXFILES += awt_Font.c CUPSfuncs.c fontpath.c X11Color.c
endif
@@ -165,14 +169,11 @@ endif
LIBAWT_CFLAGS += -I$(JDK_OUTPUTDIR)/gensrc_headers/java.desktop \
$(addprefix -I, $(shell find $(LIBAWT_DIRS) -type d)) \
- -I$(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_API_DIR)/native/common/sun/awt \
$(LIBJAVA_HEADER_FLAGS) \
$(addprefix -I, $(BUILD_LIBMLIB_IMAGE_SRC)) \
#
-LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES \
- $(X_CFLAGS) \
- $(foreach dir, $(LIBAWT_DIRS), -I$(dir))
+LIBAWT_CFLAGS += -D__MEDIALIB_OLD_NAMES -D__USE_J2D_NAMES $(X_CFLAGS)
ifeq ($(OPENJDK_TARGET_OS), macosx)
endif
diff --git a/jdk/make/lib/Lib-jdk.attach.gmk b/jdk/make/lib/Lib-jdk.attach.gmk
index 65b7b1397d7..2b58e173efb 100644
--- a/jdk/make/lib/Lib-jdk.attach.gmk
+++ b/jdk/make/lib/Lib-jdk.attach.gmk
@@ -27,33 +27,11 @@ include LibCommon.gmk
################################################################################
-ifeq ($(OPENJDK_TARGET_OS), aix)
- LIBATTACH_OS_API_DIR := aix
-else
- LIBATTACH_OS_API_DIR := $(OPENJDK_TARGET_OS_API_DIR)
-endif
-
-LIBATTACH_SRC := $(JDK_TOPDIR)/src/jdk.attach/$(LIBATTACH_OS_API_DIR)/native/libattach
-
-LIBATTACH_EXCLUDE_FILES :=
-ifneq ($(OPENJDK_TARGET_OS), solaris)
- LIBATTACH_EXCLUDE_FILES += SolarisVirtualMachine.c
-endif
-ifneq ($(OPENJDK_TARGET_OS), linux)
- LIBATTACH_EXCLUDE_FILES += LinuxVirtualMachine.c
-endif
-ifneq ($(OPENJDK_TARGET_OS), macosx)
- LIBATTACH_EXCLUDE_FILES += BsdVirtualMachine.c
-endif
-ifneq ($(OPENJDK_TARGET_OS),aix)
- LIBATTACH_EXCLUDE_FILES += AixVirtualMachine.c
-endif
$(eval $(call SetupNativeCompilation,BUILD_LIBATTACH, \
LIBRARY := attach, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
- SRC := $(LIBATTACH_SRC), \
- EXCLUDE_FILES := $(LIBATTACH_EXCLUDE_FILES), \
+ SRC := $(JDK_TOPDIR)/src/jdk.attach/$(OPENJDK_TARGET_OS)/native/libattach, \
LANG := C, \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) \
diff --git a/jdk/make/lib/Lib-jdk.hprof.agent.gmk b/jdk/make/lib/Lib-jdk.hprof.agent.gmk
index 7b7ef69b2e0..a58687da251 100644
--- a/jdk/make/lib/Lib-jdk.hprof.agent.gmk
+++ b/jdk/make/lib/Lib-jdk.hprof.agent.gmk
@@ -27,11 +27,11 @@ include LibCommon.gmk
################################################################################
-BUILD_LIBHPROF_SRC := $(JDK_TOPDIR)/src/demo/share/jvmti/hprof \
- $(JDK_TOPDIR)/src/demo/$(OPENJDK_TARGET_OS_API_DIR)/jvmti/hprof
+BUILD_LIBHPROF_SRC := $(call FindSrcDirsForLib, jdk.hprof.agent, hprof)
+
BUILD_LIBHPROF_CFLAGS := $(addprefix -I, $(BUILD_LIBHPROF_SRC)) \
-I$(JDK_TOPDIR)/src/demo/share/jvmti/java_crw_demo
-
+
BUILD_LIBHPROF_LDFLAGS :=
LIBHPROF_OPTIMIZATION := HIGHEST
diff --git a/jdk/make/lib/NetworkingLibraries.gmk b/jdk/make/lib/NetworkingLibraries.gmk
index e61f80be925..a0825b06ce2 100644
--- a/jdk/make/lib/NetworkingLibraries.gmk
+++ b/jdk/make/lib/NetworkingLibraries.gmk
@@ -44,7 +44,7 @@ ifneq ($(OPENJDK_TARGET_OS), macosx)
endif
ifeq ($(OPENJDK_TARGET_OS), aix)
- LIBNET_SRC_DIRS += $(JDK_TOPDIR)/src/aix/native/java/net/
+ LIBNET_SRC_DIRS += $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/native/libnet/java/net/
endif
$(eval $(call SetupNativeCompilation,BUILD_LIBNET, \
diff --git a/jdk/make/lib/NioLibraries.gmk b/jdk/make/lib/NioLibraries.gmk
index 259517c2aad..722115fdee5 100644
--- a/jdk/make/lib/NioLibraries.gmk
+++ b/jdk/make/lib/NioLibraries.gmk
@@ -56,17 +56,8 @@ endif
ifeq ($(OPENJDK_TARGET_OS), aix)
BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
- BUILD_LIBNIO_FILES += \
- AixPollPort.c \
- InheritedChannel.c \
- AixNativeThread.c \
- PollArrayWrapper.c \
- UnixAsynchronousServerSocketChannelImpl.c \
- UnixAsynchronousSocketChannelImpl.c \
- GnomeFileTypeDetector.c \
- UnixCopyFile.c \
- AixNativeDispatcher.c \
- UnixNativeDispatcher.c
+ BUILD_LIBNIO_EXFILES += \
+ NativeThread.c
endif
$(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \
diff --git a/jdk/make/mapfiles/libattach/mapfile-aix b/jdk/make/mapfiles/libattach/mapfile-aix
index 4c02da01fce..10ca49534ba 100644
--- a/jdk/make/mapfiles/libattach/mapfile-aix
+++ b/jdk/make/mapfiles/libattach/mapfile-aix
@@ -27,13 +27,13 @@
SUNWprivate_1.1 {
global:
- Java_sun_tools_attach_AixVirtualMachine_socket
- Java_sun_tools_attach_AixVirtualMachine_connect
- Java_sun_tools_attach_AixVirtualMachine_sendQuitTo
- Java_sun_tools_attach_AixVirtualMachine_checkPermissions
- Java_sun_tools_attach_AixVirtualMachine_close
- Java_sun_tools_attach_AixVirtualMachine_read
- Java_sun_tools_attach_AixVirtualMachine_write
+ Java_sun_tools_attach_VirtualMachineImpl_socket
+ Java_sun_tools_attach_VirtualMachineImpl_connect
+ Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo
+ Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
+ Java_sun_tools_attach_VirtualMachineImpl_close
+ Java_sun_tools_attach_VirtualMachineImpl_read
+ Java_sun_tools_attach_VirtualMachineImpl_write
local:
*;
};
diff --git a/jdk/make/mapfiles/libattach/mapfile-linux b/jdk/make/mapfiles/libattach/mapfile-linux
index fbfdedfdad9..b569ae5e637 100644
--- a/jdk/make/mapfiles/libattach/mapfile-linux
+++ b/jdk/make/mapfiles/libattach/mapfile-linux
@@ -27,17 +27,17 @@
SUNWprivate_1.1 {
global:
- Java_sun_tools_attach_LinuxVirtualMachine_checkPermissions;
- Java_sun_tools_attach_LinuxVirtualMachine_close;
- Java_sun_tools_attach_LinuxVirtualMachine_connect;
- Java_sun_tools_attach_LinuxVirtualMachine_getLinuxThreadsManager;
- Java_sun_tools_attach_LinuxVirtualMachine_isLinuxThreads;
- Java_sun_tools_attach_LinuxVirtualMachine_open;
- Java_sun_tools_attach_LinuxVirtualMachine_sendQuitTo;
- Java_sun_tools_attach_LinuxVirtualMachine_sendQuitToChildrenOf;
- Java_sun_tools_attach_LinuxVirtualMachine_socket;
- Java_sun_tools_attach_LinuxVirtualMachine_read;
- Java_sun_tools_attach_LinuxVirtualMachine_write;
+ Java_sun_tools_attach_VirtualMachineImpl_checkPermissions;
+ Java_sun_tools_attach_VirtualMachineImpl_close;
+ Java_sun_tools_attach_VirtualMachineImpl_connect;
+ Java_sun_tools_attach_VirtualMachineImpl_getLinuxThreadsManager;
+ Java_sun_tools_attach_VirtualMachineImpl_isLinuxThreads;
+ Java_sun_tools_attach_VirtualMachineImpl_open;
+ Java_sun_tools_attach_VirtualMachineImpl_sendQuitTo;
+ Java_sun_tools_attach_VirtualMachineImpl_sendQuitToChildrenOf;
+ Java_sun_tools_attach_VirtualMachineImpl_socket;
+ Java_sun_tools_attach_VirtualMachineImpl_read;
+ Java_sun_tools_attach_VirtualMachineImpl_write;
local:
*;
};
diff --git a/jdk/make/mapfiles/libattach/mapfile-solaris b/jdk/make/mapfiles/libattach/mapfile-solaris
index 6e61f754b99..df71490fdb8 100644
--- a/jdk/make/mapfiles/libattach/mapfile-solaris
+++ b/jdk/make/mapfiles/libattach/mapfile-solaris
@@ -27,12 +27,12 @@
SUNWprivate_1.1 {
global:
- Java_sun_tools_attach_SolarisVirtualMachine_checkPermissions;
- Java_sun_tools_attach_SolarisVirtualMachine_enqueue;
- Java_sun_tools_attach_SolarisVirtualMachine_open;
- Java_sun_tools_attach_SolarisVirtualMachine_close;
- Java_sun_tools_attach_SolarisVirtualMachine_read;
- Java_sun_tools_attach_SolarisVirtualMachine_sigquit;
+ Java_sun_tools_attach_VirtualMachineImpl_checkPermissions;
+ Java_sun_tools_attach_VirtualMachineImpl_enqueue;
+ Java_sun_tools_attach_VirtualMachineImpl_open;
+ Java_sun_tools_attach_VirtualMachineImpl_close;
+ Java_sun_tools_attach_VirtualMachineImpl_read;
+ Java_sun_tools_attach_VirtualMachineImpl_sigquit;
local:
*;
};
diff --git a/jdk/make/mapfiles/libnio/mapfile-linux b/jdk/make/mapfiles/libnio/mapfile-linux
index 16f72e43cfa..53555c4763f 100644
--- a/jdk/make/mapfiles/libnio/mapfile-linux
+++ b/jdk/make/mapfiles/libnio/mapfile-linux
@@ -79,6 +79,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_InheritedChannel_close0;
Java_sun_nio_ch_InheritedChannel_dup;
Java_sun_nio_ch_InheritedChannel_dup2;
+ Java_sun_nio_ch_InheritedChannel_initIDs;
Java_sun_nio_ch_InheritedChannel_open0;
Java_sun_nio_ch_InheritedChannel_peerAddress0;
Java_sun_nio_ch_InheritedChannel_peerPort0;
diff --git a/jdk/make/mapfiles/libnio/mapfile-macosx b/jdk/make/mapfiles/libnio/mapfile-macosx
index 4dd0dc513e4..d4b6dc5a219 100644
--- a/jdk/make/mapfiles/libnio/mapfile-macosx
+++ b/jdk/make/mapfiles/libnio/mapfile-macosx
@@ -62,6 +62,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_InheritedChannel_close0;
Java_sun_nio_ch_InheritedChannel_dup;
Java_sun_nio_ch_InheritedChannel_dup2;
+ Java_sun_nio_ch_InheritedChannel_initIDs;
Java_sun_nio_ch_InheritedChannel_open0;
Java_sun_nio_ch_InheritedChannel_peerAddress0;
Java_sun_nio_ch_InheritedChannel_peerPort0;
diff --git a/jdk/make/mapfiles/libnio/mapfile-solaris b/jdk/make/mapfiles/libnio/mapfile-solaris
index 3933cef7ada..cdbb851bcad 100644
--- a/jdk/make/mapfiles/libnio/mapfile-solaris
+++ b/jdk/make/mapfiles/libnio/mapfile-solaris
@@ -67,6 +67,7 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_InheritedChannel_close0;
Java_sun_nio_ch_InheritedChannel_dup;
Java_sun_nio_ch_InheritedChannel_dup2;
+ Java_sun_nio_ch_InheritedChannel_initIDs;
Java_sun_nio_ch_InheritedChannel_open0;
Java_sun_nio_ch_InheritedChannel_peerAddress0;
Java_sun_nio_ch_InheritedChannel_peerPort0;
diff --git a/jdk/make/src/classes/build/tools/module/GenerateModulesXml.java b/jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java
similarity index 90%
rename from jdk/make/src/classes/build/tools/module/GenerateModulesXml.java
rename to jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java
index c2fdf4ae9d1..43ba458f326 100644
--- a/jdk/make/src/classes/build/tools/module/GenerateModulesXml.java
+++ b/jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java
@@ -25,6 +25,7 @@
package build.tools.module;
+import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -49,47 +50,56 @@ import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.XMLEvent;
/**
- * This tool is used to generate com/sun/tools/jdeps/resources/modules.xml
- * for jdeps to analyze dependencies and enforce module boundaries.
+ * GenJdepsModulesXml augments the input modules.xml file(s)
+ * to include the module membership from the given path to
+ * the JDK exploded image. The output file is used by jdeps
+ * to analyze dependencies and enforce module boundaries.
*
- * $ java build.tools.module.GenerateModulesXml \
- * com/sun/tools/jdeps/resources/modules.xml $OUTPUTDIR/modules
+ * The input modules.xml file defines the modular structure of
+ * the JDK as described in JEP 200: The Modular JDK
+ * (http://openjdk.java.net/jeps/200).
*
- * This will generate modules.xml as jdeps resources that extend
- * the metadata to include module membership (jdeps needs the
- * membership information to determine which module a type belongs to.)
+ * $ java build.tools.module.GenJdepsModulesXml \
+ * -o com/sun/tools/jdeps/resources/modules.xml \
+ * -mp $OUTPUTDIR/modules \
+ * top/modules.xml
*/
-public final class GenerateModulesXml {
+public final class GenJdepsModulesXml {
private final static String USAGE =
- "Usage: GenerateModulesXml build/modules";
+ "Usage: GenJdepsModulesXml -o -mp build/modules path-to-modules-xml";
public static void main(String[] args) throws Exception {
- if (args.length < 2) {
+ Path outfile = null;
+ Path modulepath = null;
+ int i = 0;
+ while (i < args.length) {
+ String arg = args[i];
+ if (arg.equals("-o")) {
+ outfile = Paths.get(args[i+1]);
+ i = i+2;
+ } else if (arg.equals("-mp")) {
+ modulepath = Paths.get(args[i+1]);
+ i = i+2;
+ if (!Files.isDirectory(modulepath)) {
+ System.err.println(modulepath + " is not a directory");
+ System.exit(1);
+ }
+ } else {
+ break;
+ }
+ }
+ if (outfile == null || modulepath == null || i >= args.length) {
System.err.println(USAGE);
System.exit(-1);
}
- Path outfile = Paths.get(args[0]);
- Path modulepath = Paths.get(args[1]);
-
- if (!Files.isDirectory(modulepath)) {
- System.err.println(modulepath + " is not a directory");
- System.exit(1);
- }
- GenerateModulesXml gentool =
- new GenerateModulesXml(modulepath);
- Set modules;
- try (InputStream in = GenerateModulesXml.class.getResourceAsStream("modules.xml")) {
- modules = gentool.load(in);
- }
-
- InputStream in = GenerateModulesXml.class.getResourceAsStream("closed/modules.xml");
- if (in != null) {
- try {
+ GenJdepsModulesXml gentool = new GenJdepsModulesXml(modulepath);
+ Set modules = new HashSet<>();
+ for (; i < args.length; i++) {
+ Path p = Paths.get(args[i]);
+ try (InputStream in = new BufferedInputStream(Files.newInputStream(p))) {
Set mods = gentool.load(in);
modules.addAll(mods);
- } finally {
- in.close();
}
}
@@ -98,7 +108,7 @@ public final class GenerateModulesXml {
}
final Path modulepath;
- public GenerateModulesXml(Path modulepath) {
+ public GenJdepsModulesXml(Path modulepath) {
this.modulepath = modulepath;
}
@@ -275,7 +285,7 @@ public final class GenerateModulesXml {
m.exports().keySet().stream()
.filter(pn -> m.exports().get(pn).isEmpty())
.sorted()
- .forEach(pn -> GenerateModulesXml.this.writeExportElement(xtw, pn, depth+1));
+ .forEach(pn -> writeExportElement(xtw, pn, depth+1));
m.exports().entrySet().stream()
.filter(e -> !e.getValue().isEmpty())
.sorted(Map.Entry.comparingByKey())
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/README b/jdk/src/demo/share/jpda/com/sun/tools/example/README
deleted file mode 100644
index 13e1540f14c..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/README
+++ /dev/null
@@ -1,3 +0,0 @@
-Please refer to the documentation in:
-
- doc/index.html
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java
deleted file mode 100644
index 0d9fe21a7d3..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AccessWatchpointSpec.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-
-public class AccessWatchpointSpec extends WatchpointSpec {
-
- AccessWatchpointSpec(EventRequestSpecList specs,
- ReferenceTypeSpec refSpec, String fieldId) {
- super(specs, refSpec, fieldId);
- }
-
- /**
- * The 'refType' is known to match.
- */
- @Override
- void resolve(ReferenceType refType) throws InvalidTypeException,
- NoSuchFieldException {
- if (!(refType instanceof ClassType)) {
- throw new InvalidTypeException();
- }
- Field field = refType.fieldByName(fieldId);
- if (field == null) {
- throw new NoSuchFieldException(fieldId);
- }
- setRequest(refType.virtualMachine().eventRequestManager()
- .createAccessWatchpointRequest(field));
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj instanceof AccessWatchpointSpec) && super.equals(obj);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java
deleted file mode 100644
index 97d54dd32c8..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/AmbiguousMethodException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class AmbiguousMethodException extends Exception
-{
-
- private static final long serialVersionUID = 7793370943251707514L;
-
- public AmbiguousMethodException()
- {
- super();
- }
-
- public AmbiguousMethodException(String s)
- {
- super(s);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java
deleted file mode 100644
index 50059c1ff49..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/BreakpointSpec.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public abstract class BreakpointSpec extends EventRequestSpec {
-
- BreakpointSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) {
- super(specs, refSpec);
- }
-
- @Override
- void notifySet(SpecListener listener, SpecEvent evt) {
- listener.breakpointSet(evt);
- }
-
- @Override
- void notifyDeferred(SpecListener listener, SpecEvent evt) {
- listener.breakpointDeferred(evt);
- }
-
- @Override
- void notifyResolved(SpecListener listener, SpecEvent evt) {
- listener.breakpointResolved(evt);
- }
-
- @Override
- void notifyDeleted(SpecListener listener, SpecEvent evt) {
- listener.breakpointDeleted(evt);
- }
-
- @Override
- void notifyError(SpecListener listener, SpecErrorEvent evt) {
- listener.breakpointError(evt);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java
deleted file mode 100644
index b6042a6e845..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ChildSession.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import com.sun.jdi.connect.LaunchingConnector;
-import com.sun.jdi.connect.Connector;
-import com.sun.jdi.connect.VMStartException;
-import com.sun.jdi.connect.IllegalConnectorArgumentsException;
-import java.io.*;
-import java.util.Map;
-import javax.swing.SwingUtilities;
-
-
-class ChildSession extends Session {
-
- private Process process;
-
- private PrintWriter in;
- private BufferedReader out;
- private BufferedReader err;
-
- private InputListener input;
- private OutputListener output;
- private OutputListener error;
-
- public ChildSession(ExecutionManager runtime,
- String userVMArgs, String cmdLine,
- InputListener input,
- OutputListener output,
- OutputListener error,
- OutputListener diagnostics) {
- this(runtime, getVM(diagnostics, userVMArgs, cmdLine),
- input, output, error, diagnostics);
- }
-
- public ChildSession(ExecutionManager runtime,
- LaunchingConnector connector,
- Map arguments,
- InputListener input,
- OutputListener output,
- OutputListener error,
- OutputListener diagnostics) {
- this(runtime, generalGetVM(diagnostics, connector, arguments),
- input, output, error, diagnostics);
- }
-
- private ChildSession(ExecutionManager runtime,
- VirtualMachine vm,
- InputListener input,
- OutputListener output,
- OutputListener error,
- OutputListener diagnostics) {
- super(vm, runtime, diagnostics);
- this.input = input;
- this.output = output;
- this.error = error;
- }
-
- @Override
- public boolean attach() {
-
- if (!connectToVMProcess()) {
- diagnostics.putString("Could not launch VM");
- return false;
- }
-
- /*
- * Create a Thread that will retrieve and display any output.
- * Needs to be high priority, else debugger may exit before
- * it can be displayed.
- */
-
- //### Rename InputWriter and OutputReader classes
- //### Thread priorities cribbed from ttydebug. Think about them.
-
- OutputReader outputReader =
- new OutputReader("output reader", "output",
- out, output, diagnostics);
- outputReader.setPriority(Thread.MAX_PRIORITY-1);
- outputReader.start();
-
- OutputReader errorReader =
- new OutputReader("error reader", "error",
- err, error, diagnostics);
- errorReader.setPriority(Thread.MAX_PRIORITY-1);
- errorReader.start();
-
- InputWriter inputWriter =
- new InputWriter("input writer", in, input);
- inputWriter.setPriority(Thread.MAX_PRIORITY-1);
- inputWriter.start();
-
- if (!super.attach()) {
- if (process != null) {
- process.destroy();
- process = null;
- }
- return false;
- }
-
- //### debug
- //System.out.println("IO after attach: "+ inputWriter + " " + outputReader + " "+ errorReader);
-
- return true;
- }
-
- @Override
- public void detach() {
-
- //### debug
- //System.out.println("IO before detach: "+ inputWriter + " " + outputReader + " "+ errorReader);
-
- super.detach();
-
- /*
- inputWriter.quit();
- outputReader.quit();
- errorReader.quit();
- */
-
- if (process != null) {
- process.destroy();
- process = null;
- }
-
- }
-
- /**
- * Launch child java interpreter, return host:port
- */
-
- static private void dumpStream(OutputListener diagnostics,
- InputStream stream) throws IOException {
- BufferedReader in =
- new BufferedReader(new InputStreamReader(stream));
- String line;
- while ((line = in.readLine()) != null) {
- diagnostics.putString(line);
- }
- }
-
- static private void dumpFailedLaunchInfo(OutputListener diagnostics,
- Process process) {
- try {
- dumpStream(diagnostics, process.getErrorStream());
- dumpStream(diagnostics, process.getInputStream());
- } catch (IOException e) {
- diagnostics.putString("Unable to display process output: " +
- e.getMessage());
- }
- }
-
- static private VirtualMachine getVM(OutputListener diagnostics,
- String userVMArgs,
- String cmdLine) {
- VirtualMachineManager manager = Bootstrap.virtualMachineManager();
- LaunchingConnector connector = manager.defaultConnector();
- Map arguments = connector.defaultArguments();
- arguments.get("options").setValue(userVMArgs);
- arguments.get("main").setValue(cmdLine);
- return generalGetVM(diagnostics, connector, arguments);
- }
-
- static private VirtualMachine generalGetVM(OutputListener diagnostics,
- LaunchingConnector connector,
- Map arguments) {
- VirtualMachine vm = null;
- try {
- diagnostics.putString("Starting child.");
- vm = connector.launch(arguments);
- } catch (IOException ioe) {
- diagnostics.putString("Unable to start child: " + ioe.getMessage());
- } catch (IllegalConnectorArgumentsException icae) {
- diagnostics.putString("Unable to start child: " + icae.getMessage());
- } catch (VMStartException vmse) {
- diagnostics.putString("Unable to start child: " + vmse.getMessage() + '\n');
- dumpFailedLaunchInfo(diagnostics, vmse.process());
- }
- return vm;
- }
-
- private boolean connectToVMProcess() {
- if (vm == null) {
- return false;
- }
- process = vm.process();
- in = new PrintWriter(new OutputStreamWriter(process.getOutputStream()));
- //### Note small buffer sizes!
- out = new BufferedReader(new InputStreamReader(process.getInputStream()), 1);
- err = new BufferedReader(new InputStreamReader(process.getErrorStream()), 1);
- return true;
- }
-
- /**
- * Threads to handle application input/output.
- */
-
- private static class OutputReader extends Thread {
-
- private String streamName;
- private BufferedReader stream;
- private OutputListener output;
- private OutputListener diagnostics;
- private boolean running = true;
- private char[] buffer = new char[512];
-
- OutputReader(String threadName,
- String streamName,
- BufferedReader stream,
- OutputListener output,
- OutputListener diagnostics) {
- super(threadName);
- this.streamName = streamName;
- this.stream = stream;
- this.output = output;
- this.diagnostics = diagnostics;
- }
-
- @Override
- public void run() {
- try {
- int count;
- while (running && (count = stream.read(buffer, 0, 512)) != -1) {
- if (count > 0) {
- // Run in Swing event dispatcher thread.
- final String chars = new String(buffer, 0, count);
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- output.putString(chars);
- }
- });
- }
- //### Should we sleep briefly here?
- }
- } catch (IOException e) {
- // Run in Swing event dispatcher thread.
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- diagnostics.putString("IO error reading " +
- streamName +
- " stream of child java interpreter");
- }
- });
- }
- }
- }
-
- private static class InputWriter extends Thread {
-
- private PrintWriter stream;
- private InputListener input;
- private boolean running = true;
-
- InputWriter(String threadName,
- PrintWriter stream,
- InputListener input) {
- super(threadName);
- this.stream = stream;
- this.input = input;
- }
-
- @Override
- public void run() {
- String line;
- while (running) {
- line = input.getLine();
- stream.println(line);
- // Should not be needed for println above!
- stream.flush();
- }
- }
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EvaluationException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EvaluationException.java
deleted file mode 100644
index b9a02c37117..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EvaluationException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class EvaluationException extends Exception {
-
- private static final long serialVersionUID = 4947109680354951694L;
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java
deleted file mode 100644
index 0ea58fb3ebd..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpec.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import com.sun.jdi.request.EventRequest;
-
-abstract public class EventRequestSpec {
-
- static final int STATUS_UNRESOLVED = 1;
- static final int STATUS_RESOLVED = 2;
- static final int STATUS_ERROR = 3;
-
- static final Object specPropertyKey = "spec";
-
- final EventRequestSpecList specs;
- final ReferenceTypeSpec refSpec;
- EventRequest request = null;
-
- int status = STATUS_UNRESOLVED;
-
- EventRequestSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec) {
- this.specs = specs;
- this.refSpec = refSpec;
- }
-
- void setRequest(EventRequest request) {
- this.request = request;
- request.putProperty(specPropertyKey, this);
- request.enable();
- }
-
- /**
- * The 'refType' is known to match.
- */
- abstract void resolve(ReferenceType refType) throws Exception;
-
- abstract void notifySet(SpecListener listener, SpecEvent evt);
- abstract void notifyDeferred(SpecListener listener, SpecEvent evt);
- abstract void notifyResolved(SpecListener listener, SpecEvent evt);
- abstract void notifyDeleted(SpecListener listener, SpecEvent evt);
- abstract void notifyError(SpecListener listener, SpecErrorEvent evt);
-
- /**
- * The 'refType' is known to match.
- */
- void resolveNotify(ReferenceType refType) {
- try {
- resolve(refType);
- status = STATUS_RESOLVED;
- specs.notifyResolved(this);
- } catch(Exception exc) {
- status = STATUS_ERROR;
- specs.notifyError(this, exc);
- }
- }
-
- /**
- * See if 'refType' matches and resolve.
- */
- void attemptResolve(ReferenceType refType) {
- if (!isResolved() && refSpec.matches(refType)) {
- resolveNotify(refType);
- }
- }
-
- void attemptImmediateResolve(VirtualMachine vm) {
- // try to resolve immediately
- for (ReferenceType refType : vm.allClasses()) {
- if (refSpec.matches(refType)) {
- try {
- resolve(refType);
- status = STATUS_RESOLVED;
- specs.notifySet(this);
- } catch(Exception exc) {
- status = STATUS_ERROR;
- specs.notifyError(this, exc);
- }
- return;
- }
- }
- specs.notifyDeferred(this);
- }
-
- public EventRequest getEventRequest() {
- return request;
- }
-
- /**
- * @return true if this spec has been resolved.
- */
- public boolean isResolved() {
- return status == STATUS_RESOLVED;
- }
-
- /**
- * @return true if this spec has not yet been resolved.
- */
- public boolean isUnresolved() {
- return status == STATUS_UNRESOLVED;
- }
-
- /**
- * @return true if this spec is unresolvable due to error.
- */
- public boolean isErroneous() {
- return status == STATUS_ERROR;
- }
-
- public String getStatusString() {
- switch (status) {
- case STATUS_RESOLVED:
- return "resolved";
- case STATUS_UNRESOLVED:
- return "deferred";
- case STATUS_ERROR:
- return "erroneous";
- }
- return "unknown";
- }
-
- boolean isJavaIdentifier(String s) {
- return Utils.isJavaIdentifier(s);
- }
-
- public String errorMessageFor(Exception e) {
- if (e instanceof IllegalArgumentException) {
- return ("Invalid command syntax");
- } else if (e instanceof RuntimeException) {
- // A runtime exception that we were not expecting
- throw (RuntimeException)e;
- } else {
- return ("Internal error; unable to set" + this);
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java
deleted file mode 100644
index 17c001483c7..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/EventRequestSpecList.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import com.sun.jdi.request.*;
-
-import java.util.*;
-
-class EventRequestSpecList {
-
- // all specs
- private List eventRequestSpecs = Collections.synchronizedList(
- new ArrayList());
-
- final ExecutionManager runtime;
-
- EventRequestSpecList(ExecutionManager runtime) {
- this.runtime = runtime;
- }
-
- /**
- * Resolve all deferred eventRequests waiting for 'refType'.
- */
- void resolve(ReferenceType refType) {
- synchronized(eventRequestSpecs) {
- for (EventRequestSpec spec : eventRequestSpecs) {
- spec.attemptResolve(refType);
- }
- }
- }
-
- void install(EventRequestSpec ers, VirtualMachine vm) {
- synchronized (eventRequestSpecs) {
- eventRequestSpecs.add(ers);
- }
- if (vm != null) {
- ers.attemptImmediateResolve(vm);
- }
- }
-
- BreakpointSpec
- createClassLineBreakpoint(String classPattern, int line) {
- ReferenceTypeSpec refSpec =
- new PatternReferenceTypeSpec(classPattern);
- return new LineBreakpointSpec(this, refSpec, line);
- }
-
- BreakpointSpec
- createSourceLineBreakpoint(String sourceName, int line) {
- ReferenceTypeSpec refSpec =
- new SourceNameReferenceTypeSpec(sourceName, line);
- return new LineBreakpointSpec(this, refSpec, line);
- }
-
- BreakpointSpec
- createMethodBreakpoint(String classPattern,
- String methodId, List methodArgs) {
- ReferenceTypeSpec refSpec =
- new PatternReferenceTypeSpec(classPattern);
- return new MethodBreakpointSpec(this, refSpec,
- methodId, methodArgs);
- }
-
- ExceptionSpec
- createExceptionIntercept(String classPattern,
- boolean notifyCaught,
- boolean notifyUncaught) {
- ReferenceTypeSpec refSpec =
- new PatternReferenceTypeSpec(classPattern);
- return new ExceptionSpec(this, refSpec,
- notifyCaught, notifyUncaught);
- }
-
- AccessWatchpointSpec
- createAccessWatchpoint(String classPattern, String fieldId) {
- ReferenceTypeSpec refSpec =
- new PatternReferenceTypeSpec(classPattern);
- return new AccessWatchpointSpec(this, refSpec, fieldId);
- }
-
- ModificationWatchpointSpec
- createModificationWatchpoint(String classPattern, String fieldId) {
- ReferenceTypeSpec refSpec =
- new PatternReferenceTypeSpec(classPattern);
- return new ModificationWatchpointSpec(this, refSpec, fieldId);
- }
-
- void delete(EventRequestSpec ers) {
- EventRequest request = ers.getEventRequest();
- synchronized (eventRequestSpecs) {
- eventRequestSpecs.remove(ers);
- }
- if (request != null) {
- request.virtualMachine().eventRequestManager()
- .deleteEventRequest(request);
- }
- notifyDeleted(ers);
- //### notify delete - here?
- }
-
- List eventRequestSpecs() {
- // We need to make a copy to avoid synchronization problems
- synchronized (eventRequestSpecs) {
- return new ArrayList(eventRequestSpecs);
- }
- }
-
- // -------- notify routines --------------------
-
- @SuppressWarnings("unchecked")
- private Vector specListeners() {
- return (Vector)runtime.specListeners.clone();
- }
-
- void notifySet(EventRequestSpec spec) {
- Vector l = specListeners();
- SpecEvent evt = new SpecEvent(spec);
- for (int i = 0; i < l.size(); i++) {
- spec.notifySet(l.elementAt(i), evt);
- }
- }
-
- void notifyDeferred(EventRequestSpec spec) {
- Vector l = specListeners();
- SpecEvent evt = new SpecEvent(spec);
- for (int i = 0; i < l.size(); i++) {
- spec.notifyDeferred(l.elementAt(i), evt);
- }
- }
-
- void notifyDeleted(EventRequestSpec spec) {
- Vector l = specListeners();
- SpecEvent evt = new SpecEvent(spec);
- for (int i = 0; i < l.size(); i++) {
- spec.notifyDeleted(l.elementAt(i), evt);
- }
- }
-
- void notifyResolved(EventRequestSpec spec) {
- Vector l = specListeners();
- SpecEvent evt = new SpecEvent(spec);
- for (int i = 0; i < l.size(); i++) {
- spec.notifyResolved(l.elementAt(i), evt);
- }
- }
-
- void notifyError(EventRequestSpec spec, Exception exc) {
- Vector l = specListeners();
- SpecErrorEvent evt = new SpecErrorEvent(spec, exc);
- for (int i = 0; i < l.size(); i++) {
- spec.notifyError(l.elementAt(i), evt);
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java
deleted file mode 100644
index df87688152c..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExceptionSpec.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.ReferenceType;
-
-public class ExceptionSpec extends EventRequestSpec {
-
- boolean notifyCaught;
- boolean notifyUncaught;
-
- ExceptionSpec(EventRequestSpecList specs, ReferenceTypeSpec refSpec,
- boolean notifyCaught, boolean notifyUncaught)
- {
- super(specs, refSpec);
- this.notifyCaught = notifyCaught;
- this.notifyUncaught = notifyUncaught;
- }
-
- @Override
- void notifySet(SpecListener listener, SpecEvent evt) {
- listener.exceptionInterceptSet(evt);
- }
-
- @Override
- void notifyDeferred(SpecListener listener, SpecEvent evt) {
- listener.exceptionInterceptDeferred(evt);
- }
-
- @Override
- void notifyResolved(SpecListener listener, SpecEvent evt) {
- listener.exceptionInterceptResolved(evt);
- }
-
- @Override
- void notifyDeleted(SpecListener listener, SpecEvent evt) {
- listener.exceptionInterceptDeleted(evt);
- }
-
- @Override
- void notifyError(SpecListener listener, SpecErrorEvent evt) {
- listener.exceptionInterceptError(evt);
- }
-
- /**
- * The 'refType' is known to match.
- */
- @Override
- void resolve(ReferenceType refType) {
- setRequest(refType.virtualMachine().eventRequestManager()
- .createExceptionRequest(refType,
- notifyCaught, notifyUncaught));
- }
-
- @Override
- public int hashCode() {
- return refSpec.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ExceptionSpec) {
- ExceptionSpec es = (ExceptionSpec)obj;
-
- return refSpec.equals(es.refSpec);
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("exception catch ");
- sb.append(refSpec.toString());
- return sb.toString();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java
deleted file mode 100644
index b5bc053a3c3..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ExecutionManager.java
+++ /dev/null
@@ -1,824 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import com.sun.jdi.request.*;
-import com.sun.jdi.connect.*;
-import com.sun.tools.example.debug.expr.ExpressionParser;
-import com.sun.tools.example.debug.expr.ParseException;
-
-import java.io.*;
-import java.util.*;
-
-import com.sun.tools.example.debug.event.*;
-
-import javax.swing.SwingUtilities;
-
-/**
- * Move this towards being only state and functionality
- * that spans across Sessions (and thus VMs).
- */
-public class ExecutionManager {
-
- private Session session;
-
- /**
- * Get/set JDI trace mode.
- */
- int traceMode = VirtualMachine.TRACE_NONE;
-
- ////////////////// Listener registration //////////////////
-
- // Session Listeners
-
- ArrayList sessionListeners = new ArrayList();
-
- public void addSessionListener(SessionListener listener) {
- sessionListeners.add(listener);
- }
-
- public void removeSessionListener(SessionListener listener) {
- sessionListeners.remove(listener);
- }
-
- // Spec Listeners
-
- ArrayList specListeners = new ArrayList();
-
- public void addSpecListener(SpecListener cl) {
- specListeners.add(cl);
- }
-
- public void removeSpecListener(SpecListener cl) {
- specListeners.remove(cl);
- }
-
- // JDI Listeners
-
- ArrayList jdiListeners = new ArrayList();
-
- /**
- * Adds a JDIListener
- */
- public void addJDIListener(JDIListener jl) {
- jdiListeners.add(jl);
- }
-
- /**
- * Adds a JDIListener - at the specified position
- */
- public void addJDIListener(int index, JDIListener jl) {
- jdiListeners.add(index, jl);
- }
-
- /**
- * Removes a JDIListener
- */
- public void removeJDIListener(JDIListener jl) {
- jdiListeners.remove(jl);
- }
-
- // App Echo Listeners
-
- private ArrayList appEchoListeners = new ArrayList();
-
- public void addApplicationEchoListener(OutputListener l) {
- appEchoListeners.add(l);
- }
-
- public void removeApplicationEchoListener(OutputListener l) {
- appEchoListeners.remove(l);
- }
-
- // App Output Listeners
-
- private ArrayList appOutputListeners = new ArrayList();
-
- public void addApplicationOutputListener(OutputListener l) {
- appOutputListeners.add(l);
- }
-
- public void removeApplicationOutputListener(OutputListener l) {
- appOutputListeners.remove(l);
- }
-
- // App Error Listeners
-
- private ArrayList appErrorListeners = new ArrayList();
-
- public void addApplicationErrorListener(OutputListener l) {
- appErrorListeners.add(l);
- }
-
- public void removeApplicationErrorListener(OutputListener l) {
- appErrorListeners.remove(l);
- }
-
- // Diagnostic Listeners
-
- private ArrayList diagnosticsListeners = new ArrayList();
-
- public void addDiagnosticsListener(OutputListener l) {
- diagnosticsListeners.add(l);
- }
-
- public void removeDiagnosticsListener(OutputListener l) {
- diagnosticsListeners.remove(l);
- }
-
- /////////// End Listener Registration //////////////
-
- //### We probably don't want this public
- public VirtualMachine vm() {
- return session == null ? null : session.vm;
- }
-
- void ensureActiveSession() throws NoSessionException {
- if (session == null) {
- throw new NoSessionException();
- }
- }
-
- public EventRequestManager eventRequestManager() {
- return vm() == null ? null : vm().eventRequestManager();
- }
-
- /**
- * Get JDI trace mode.
- */
- public int getTraceMode(int mode) {
- return traceMode;
- }
-
- /**
- * Set JDI trace mode.
- */
- public void setTraceMode(int mode) {
- traceMode = mode;
- if (session != null) {
- session.setTraceMode(mode);
- }
- }
-
- /**
- * Determine if VM is interrupted, i.e, present and not running.
- */
- public boolean isInterrupted() /* should: throws NoSessionException */ {
-// ensureActiveSession();
- return session.interrupted;
- }
-
- /**
- * Return a list of ReferenceType objects for all
- * currently loaded classes and interfaces.
- * Array types are not returned.
- */
- public List allClasses() throws NoSessionException {
- ensureActiveSession();
- return vm().allClasses();
- }
-
- /**
- * Return a ReferenceType object for the currently
- * loaded class or interface whose fully-qualified
- * class name is specified, else return null if there
- * is none.
- *
- * In general, we must return a list of types, because
- * multiple class loaders could have loaded a class
- * with the same fully-qualified name.
- */
- public List findClassesByName(String name) throws NoSessionException {
- ensureActiveSession();
- return vm().classesByName(name);
- }
-
- /**
- * Return a list of ReferenceType objects for all
- * currently loaded classes and interfaces whose name
- * matches the given pattern. The pattern syntax is
- * open to some future revision, but currently consists
- * of a fully-qualified class name in which the first
- * component may optionally be a "*" character, designating
- * an arbitrary prefix.
- */
- public List findClassesMatchingPattern(String pattern)
- throws NoSessionException {
- ensureActiveSession();
- List result = new ArrayList(); //### Is default size OK?
- if (pattern.startsWith("*.")) {
- // Wildcard matches any leading package name.
- pattern = pattern.substring(1);
- for (ReferenceType type : vm().allClasses()) {
- if (type.name().endsWith(pattern)) {
- result.add(type);
- }
- }
- return result;
- } else {
- // It's a class name.
- return vm().classesByName(pattern);
- }
- }
-
- /*
- * Return a list of ThreadReference objects corresponding
- * to the threads that are currently active in the VM.
- * A thread is removed from the list just before the
- * thread terminates.
- */
-
- public List allThreads() throws NoSessionException {
- ensureActiveSession();
- return vm().allThreads();
- }
-
- /*
- * Return a list of ThreadGroupReference objects corresponding
- * to the top-level threadgroups that are currently active in the VM.
- * Note that a thread group may be empty, or contain no threads as
- * descendents.
- */
-
- public List topLevelThreadGroups() throws NoSessionException {
- ensureActiveSession();
- return vm().topLevelThreadGroups();
- }
-
- /*
- * Return the system threadgroup.
- */
-
- public ThreadGroupReference systemThreadGroup()
- throws NoSessionException {
- ensureActiveSession();
- return vm().topLevelThreadGroups().get(0);
- }
-
- /*
- * Evaluate an expression.
- */
-
- public Value evaluate(final StackFrame f, String expr)
- throws ParseException,
- InvocationException,
- InvalidTypeException,
- ClassNotLoadedException,
- NoSessionException,
- IncompatibleThreadStateException {
- ExpressionParser.GetFrame frameGetter = null;
- ensureActiveSession();
- if (f != null) {
- frameGetter = new ExpressionParser.GetFrame() {
- @Override
- public StackFrame get() /* throws IncompatibleThreadStateException */ {
- return f;
- }
- };
- }
- return ExpressionParser.evaluate(expr, vm(), frameGetter);
- }
-
-
- /*
- * Start a new VM.
- */
-
- public void run(boolean suspended,
- String vmArgs,
- String className,
- String args) throws VMLaunchFailureException {
-
- endSession();
-
- //### Set a breakpoint on 'main' method.
- //### Would be cleaner if we could just bring up VM already suspended.
- if (suspended) {
- //### Set breakpoint at 'main(java.lang.String[])'.
- List argList = new ArrayList(1);
- argList.add("java.lang.String[]");
- createMethodBreakpoint(className, "main", argList);
- }
-
- String cmdLine = className + " " + args;
-
- startSession(new ChildSession(this, vmArgs, cmdLine,
- appInput, appOutput, appError,
- diagnostics));
- }
-
- /*
- * Attach to an existing VM.
- */
- public void attach(String portName) throws VMLaunchFailureException {
- endSession();
-
- //### Changes made here for connectors have broken the
- //### the 'Session' abstraction. The 'Session.attach()'
- //### method is intended to encapsulate all of the various
- //### ways in which session start-up can fail. (maddox 12/18/98)
-
- /*
- * Now that attaches and launches both go through Connectors,
- * it may be worth creating a new subclass of Session for
- * attach sessions.
- */
- VirtualMachineManager mgr = Bootstrap.virtualMachineManager();
- AttachingConnector connector = mgr.attachingConnectors().get(0);
- Map arguments = connector.defaultArguments();
- arguments.get("port").setValue(portName);
-
- Session newSession = internalAttach(connector, arguments);
- if (newSession != null) {
- startSession(newSession);
- }
- }
-
- private Session internalAttach(AttachingConnector connector,
- Map arguments) {
- try {
- VirtualMachine vm = connector.attach(arguments);
- return new Session(vm, this, diagnostics);
- } catch (IOException ioe) {
- diagnostics.putString("\n Unable to attach to target VM: " +
- ioe.getMessage());
- } catch (IllegalConnectorArgumentsException icae) {
- diagnostics.putString("\n Invalid connector arguments: " +
- icae.getMessage());
- }
- return null;
- }
-
- private Session internalListen(ListeningConnector connector,
- Map arguments) {
- try {
- VirtualMachine vm = connector.accept(arguments);
- return new Session(vm, this, diagnostics);
- } catch (IOException ioe) {
- diagnostics.putString(
- "\n Unable to accept connection to target VM: " +
- ioe.getMessage());
- } catch (IllegalConnectorArgumentsException icae) {
- diagnostics.putString("\n Invalid connector arguments: " +
- icae.getMessage());
- }
- return null;
- }
-
- /*
- * Connect via user specified arguments
- * @return true on success
- */
- public boolean explictStart(Connector connector, Map arguments)
- throws VMLaunchFailureException {
- Session newSession = null;
-
- endSession();
-
- if (connector instanceof LaunchingConnector) {
- // we were launched, use ChildSession
- newSession = new ChildSession(this, (LaunchingConnector)connector,
- arguments,
- appInput, appOutput, appError,
- diagnostics);
- } else if (connector instanceof AttachingConnector) {
- newSession = internalAttach((AttachingConnector)connector,
- arguments);
- } else if (connector instanceof ListeningConnector) {
- newSession = internalListen((ListeningConnector)connector,
- arguments);
- } else {
- diagnostics.putString("\n Unknown connector: " + connector);
- }
- if (newSession != null) {
- startSession(newSession);
- }
- return newSession != null;
- }
-
- /*
- * Detach from VM. If VM was started by debugger, terminate it.
- */
- public void detach() throws NoSessionException {
- ensureActiveSession();
- endSession();
- }
-
- private void startSession(Session s) throws VMLaunchFailureException {
- if (!s.attach()) {
- throw new VMLaunchFailureException();
- }
- session = s;
- EventRequestManager em = vm().eventRequestManager();
- ClassPrepareRequest classPrepareRequest = em.createClassPrepareRequest();
- //### We must allow the deferred breakpoints to be resolved before
- //### we continue executing the class. We could optimize if there
- //### were no deferred breakpoints outstanding for a particular class.
- //### Can we do this with JDI?
- classPrepareRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
- classPrepareRequest.enable();
- ClassUnloadRequest classUnloadRequest = em.createClassUnloadRequest();
- classUnloadRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
- classUnloadRequest.enable();
- ThreadStartRequest threadStartRequest = em.createThreadStartRequest();
- threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
- threadStartRequest.enable();
- ThreadDeathRequest threadDeathRequest = em.createThreadDeathRequest();
- threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
- threadDeathRequest.enable();
- ExceptionRequest exceptionRequest =
- em.createExceptionRequest(null, false, true);
- exceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
- exceptionRequest.enable();
- validateThreadInfo();
- session.interrupted = true;
- notifySessionStart();
- }
-
- void endSession() {
- if (session != null) {
- session.detach();
- session = null;
- invalidateThreadInfo();
- notifySessionDeath();
- }
- }
-
- /*
- * Suspend all VM activity.
- */
-
- public void interrupt() throws NoSessionException {
- ensureActiveSession();
- vm().suspend();
- //### Is it guaranteed that the interrupt has happened?
- validateThreadInfo();
- session.interrupted = true;
- notifyInterrupted();
- }
-
- /*
- * Resume interrupted VM.
- */
-
- public void go() throws NoSessionException, VMNotInterruptedException {
- ensureActiveSession();
- invalidateThreadInfo();
- session.interrupted = false;
- notifyContinued();
- vm().resume();
- }
-
- /*
- * Stepping.
- */
- void clearPreviousStep(ThreadReference thread) {
- /*
- * A previous step may not have completed on this thread;
- * if so, it gets removed here.
- */
- EventRequestManager mgr = vm().eventRequestManager();
- for (StepRequest request : mgr.stepRequests()) {
- if (request.thread().equals(thread)) {
- mgr.deleteEventRequest(request);
- break;
- }
- }
- }
-
- private void generalStep(ThreadReference thread, int size, int depth)
- throws NoSessionException {
- ensureActiveSession();
- invalidateThreadInfo();
- session.interrupted = false;
- notifyContinued();
-
- clearPreviousStep(thread);
- EventRequestManager reqMgr = vm().eventRequestManager();
- StepRequest request = reqMgr.createStepRequest(thread,
- size, depth);
- // We want just the next step event and no others
- request.addCountFilter(1);
- request.enable();
- vm().resume();
- }
-
- public void stepIntoInstruction(ThreadReference thread)
- throws NoSessionException {
- generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO);
- }
-
- public void stepOverInstruction(ThreadReference thread)
- throws NoSessionException {
- generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER);
- }
-
- public void stepIntoLine(ThreadReference thread)
- throws NoSessionException,
- AbsentInformationException {
- generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO);
- }
-
- public void stepOverLine(ThreadReference thread)
- throws NoSessionException,
- AbsentInformationException {
- generalStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER);
- }
-
- public void stepOut(ThreadReference thread)
- throws NoSessionException {
- generalStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OUT);
- }
-
- /*
- * Thread control.
- */
-
- public void suspendThread(ThreadReference thread) throws NoSessionException {
- ensureActiveSession();
- thread.suspend();
- }
-
- public void resumeThread(ThreadReference thread) throws NoSessionException {
- ensureActiveSession();
- thread.resume();
- }
-
- public void stopThread(ThreadReference thread) throws NoSessionException {
- ensureActiveSession();
- //### Need an exception now. Which one to use?
- //thread.stop();
- }
-
- /*
- * ThreadInfo objects -- Allow query of thread status and stack.
- */
-
- private List threadInfoList = new LinkedList();
- //### Should be weak! (in the value, not the key)
- private HashMap threadInfoMap = new HashMap();
-
- public ThreadInfo threadInfo(ThreadReference thread) {
- if (session == null || thread == null) {
- return null;
- }
- ThreadInfo info = threadInfoMap.get(thread);
- if (info == null) {
- //### Should not hardcode initial frame count and prefetch here!
- //info = new ThreadInfo(thread, 10, 10);
- info = new ThreadInfo(thread);
- if (session.interrupted) {
- info.validate();
- }
- threadInfoList.add(info);
- threadInfoMap.put(thread, info);
- }
- return info;
- }
-
- void validateThreadInfo() {
- session.interrupted = true;
- for (ThreadInfo threadInfo : threadInfoList) {
- threadInfo.validate();
- }
- }
-
- private void invalidateThreadInfo() {
- if (session != null) {
- session.interrupted = false;
- for (ThreadInfo threadInfo : threadInfoList) {
- threadInfo.invalidate();
- }
- }
- }
-
- void removeThreadInfo(ThreadReference thread) {
- ThreadInfo info = threadInfoMap.get(thread);
- if (info != null) {
- info.invalidate();
- threadInfoMap.remove(thread);
- threadInfoList.remove(info);
- }
- }
-
- /*
- * Listen for Session control events.
- */
-
- private void notifyInterrupted() {
- ArrayList l = new ArrayList(sessionListeners);
- EventObject evt = new EventObject(this);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).sessionInterrupt(evt);
- }
- }
-
- private void notifyContinued() {
- ArrayList l = new ArrayList(sessionListeners);
- EventObject evt = new EventObject(this);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).sessionContinue(evt);
- }
- }
-
- private void notifySessionStart() {
- ArrayList l = new ArrayList(sessionListeners);
- EventObject evt = new EventObject(this);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).sessionStart(evt);
- }
- }
-
- private void notifySessionDeath() {
-/*** noop for now
- ArrayList l = new ArrayList(sessionListeners);
- EventObject evt = new EventObject(this);
- for (int i = 0; i < l.size(); i++) {
- ((SessionListener)l.get(i)).sessionDeath(evt);
- }
-****/
- }
-
- /*
- * Listen for input and output requests from the application
- * being debugged. These are generated only when the debuggee
- * is spawned as a child of the debugger.
- */
-
- private Object inputLock = new Object();
- private LinkedList inputBuffer = new LinkedList();
-
- private void resetInputBuffer() {
- synchronized (inputLock) {
- inputBuffer = new LinkedList();
- }
- }
-
- public void sendLineToApplication(String line) {
- synchronized (inputLock) {
- inputBuffer.addFirst(line);
- inputLock.notifyAll();
- }
- }
-
- private InputListener appInput = new InputListener() {
- @Override
- public String getLine() {
- // Don't allow reader to be interrupted -- catch and retry.
- String line = null;
- while (line == null) {
- synchronized (inputLock) {
- try {
- while (inputBuffer.size() < 1) {
- inputLock.wait();
- }
- line = inputBuffer.removeLast();
- } catch (InterruptedException e) {}
- }
- }
- // We must not be holding inputLock here, as the listener
- // that we call to echo a line might call us re-entrantly
- // to provide another line of input.
- // Run in Swing event dispatcher thread.
- final String input = line;
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- echoInputLine(input);
- }
- });
- return line;
- }
- };
-
- private static String newline = System.getProperty("line.separator");
-
- private void echoInputLine(String line) {
- ArrayList l = new ArrayList(appEchoListeners);
- for (int i = 0; i < l.size(); i++) {
- OutputListener ol = l.get(i);
- ol.putString(line);
- ol.putString(newline);
- }
- }
-
- private OutputListener appOutput = new OutputListener() {
- @Override
- public void putString(String string) {
- ArrayList l = new ArrayList(appEchoListeners);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).putString(string);
- }
- }
- };
-
- private OutputListener appError = new OutputListener() {
- @Override
- public void putString(String string) {
- ArrayList l = new ArrayList(appEchoListeners);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).putString(string);
- }
- }
- };
-
- private OutputListener diagnostics = new OutputListener() {
- @Override
- public void putString(String string) {
- ArrayList l = new ArrayList(diagnosticsListeners);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).putString(string);
- }
- }
- };
-
- ///////////// Spec Request Creation/Deletion/Query ///////////
-
- private EventRequestSpecList specList = new EventRequestSpecList(this);
-
- public BreakpointSpec
- createSourceLineBreakpoint(String sourceName, int line) {
- return specList.createSourceLineBreakpoint(sourceName, line);
- }
-
- public BreakpointSpec
- createClassLineBreakpoint(String classPattern, int line) {
- return specList.createClassLineBreakpoint(classPattern, line);
- }
-
- public BreakpointSpec
- createMethodBreakpoint(String classPattern,
- String methodId, List methodArgs) {
- return specList.createMethodBreakpoint(classPattern,
- methodId, methodArgs);
- }
-
- public ExceptionSpec
- createExceptionIntercept(String classPattern,
- boolean notifyCaught,
- boolean notifyUncaught) {
- return specList.createExceptionIntercept(classPattern,
- notifyCaught,
- notifyUncaught);
- }
-
- public AccessWatchpointSpec
- createAccessWatchpoint(String classPattern, String fieldId) {
- return specList.createAccessWatchpoint(classPattern, fieldId);
- }
-
- public ModificationWatchpointSpec
- createModificationWatchpoint(String classPattern, String fieldId) {
- return specList.createModificationWatchpoint(classPattern,
- fieldId);
- }
-
- public void delete(EventRequestSpec spec) {
- specList.delete(spec);
- }
-
- void resolve(ReferenceType refType) {
- specList.resolve(refType);
- }
-
- public void install(EventRequestSpec spec) {
- specList.install(spec, vm());
- }
-
- public List eventRequestSpecs() {
- return specList.eventRequestSpecs();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java
deleted file mode 100644
index 57d4e2a6d9c..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/FrameIndexOutOfBoundsException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class FrameIndexOutOfBoundsException extends IndexOutOfBoundsException {
-
- private static final long serialVersionUID = -4870148107027371437L;
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/InputListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/InputListener.java
deleted file mode 100644
index 99a37c2e9f2..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/InputListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public interface InputListener {
- String getLine();
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java
deleted file mode 100644
index 2d92094d0d5..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/JDIEventSource.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-import com.sun.tools.example.debug.event.*;
-
-import javax.swing.SwingUtilities;
-
-/**
- */
-class JDIEventSource extends Thread {
-
- private /*final*/ EventQueue queue;
- private /*final*/ Session session;
- private /*final*/ ExecutionManager runtime;
- private final JDIListener firstListener = new FirstListener();
-
- private boolean wantInterrupt; //### Hack
-
- /**
- * Create event source.
- */
- JDIEventSource(Session session) {
- super("JDI Event Set Dispatcher");
- this.session = session;
- this.runtime = session.runtime;
- this.queue = session.vm.eventQueue();
- }
-
- @Override
- public void run() {
- try {
- runLoop();
- } catch (Exception exc) {
- //### Do something different for InterruptedException???
- // just exit
- }
- session.running = false;
- }
-
- private void runLoop() throws InterruptedException {
- AbstractEventSet es;
- do {
- EventSet jdiEventSet = queue.remove();
- es = AbstractEventSet.toSpecificEventSet(jdiEventSet);
- session.interrupted = es.suspendedAll();
- dispatchEventSet(es);
- } while(!(es instanceof VMDisconnectEventSet));
- }
-
- //### Gross foul hackery!
- private void dispatchEventSet(final AbstractEventSet es) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- boolean interrupted = es.suspendedAll();
- es.notify(firstListener);
- boolean wantInterrupt = JDIEventSource.this.wantInterrupt;
- for (JDIListener jl : session.runtime.jdiListeners) {
- es.notify(jl);
- }
- if (interrupted && !wantInterrupt) {
- session.interrupted = false;
- //### Catch here is a hack
- try {
- session.vm.resume();
- } catch (VMDisconnectedException ee) {}
- }
- if (es instanceof ThreadDeathEventSet) {
- ThreadReference t = ((ThreadDeathEventSet)es).getThread();
- session.runtime.removeThreadInfo(t);
- }
- }
- });
- }
-
- private void finalizeEventSet(AbstractEventSet es) {
- if (session.interrupted && !wantInterrupt) {
- session.interrupted = false;
- //### Catch here is a hack
- try {
- session.vm.resume();
- } catch (VMDisconnectedException ee) {}
- }
- if (es instanceof ThreadDeathEventSet) {
- ThreadReference t = ((ThreadDeathEventSet)es).getThread();
- session.runtime.removeThreadInfo(t);
- }
- }
-
- //### This is a Hack, deal with it
- private class FirstListener implements JDIListener {
-
- @Override
- public void accessWatchpoint(AccessWatchpointEventSet e) {
- session.runtime.validateThreadInfo();
- wantInterrupt = true;
- }
-
- @Override
- public void classPrepare(ClassPrepareEventSet e) {
- wantInterrupt = false;
- runtime.resolve(e.getReferenceType());
- }
-
- @Override
- public void classUnload(ClassUnloadEventSet e) {
- wantInterrupt = false;
- }
-
- @Override
- public void exception(ExceptionEventSet e) {
- wantInterrupt = true;
- }
-
- @Override
- public void locationTrigger(LocationTriggerEventSet e) {
- session.runtime.validateThreadInfo();
- wantInterrupt = true;
- }
-
- @Override
- public void modificationWatchpoint(ModificationWatchpointEventSet e) {
- session.runtime.validateThreadInfo();
- wantInterrupt = true;
- }
-
- @Override
- public void threadDeath(ThreadDeathEventSet e) {
- wantInterrupt = false;
- }
-
- @Override
- public void threadStart(ThreadStartEventSet e) {
- wantInterrupt = false;
- }
-
- @Override
- public void vmDeath(VMDeathEventSet e) {
- //### Should have some way to notify user
- //### that VM died before the session ended.
- wantInterrupt = false;
- }
-
- @Override
- public void vmDisconnect(VMDisconnectEventSet e) {
- //### Notify user?
- wantInterrupt = false;
- session.runtime.endSession();
- }
-
- @Override
- public void vmStart(VMStartEventSet e) {
- //### Do we need to do anything with it?
- wantInterrupt = false;
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java
deleted file mode 100644
index f7d66ce2d52..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineBreakpointSpec.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import java.util.List;
-
-public class LineBreakpointSpec extends BreakpointSpec {
- int lineNumber;
-
- LineBreakpointSpec(EventRequestSpecList specs,
- ReferenceTypeSpec refSpec, int lineNumber) {
- super(specs, refSpec);
- this.lineNumber = lineNumber;
- }
-
- /**
- * The 'refType' is known to match.
- */
- @Override
- void resolve(ReferenceType refType) throws InvalidTypeException,
- LineNotFoundException {
- if (!(refType instanceof ClassType)) {
- throw new InvalidTypeException();
- }
- Location location = location((ClassType)refType);
- setRequest(refType.virtualMachine().eventRequestManager()
- .createBreakpointRequest(location));
- }
-
- private Location location(ClassType clazz) throws
- LineNotFoundException {
- Location location = null;
- try {
- List locs = clazz.locationsOfLine(lineNumber());
- if (locs.size() == 0) {
- throw new LineNotFoundException();
- }
- // TODO handle multiple locations
- location = locs.get(0);
- if (location.method() == null) {
- throw new LineNotFoundException();
- }
- } catch (AbsentInformationException e) {
- /*
- * TO DO: throw something more specific, or allow
- * AbsentInfo exception to pass through.
- */
- throw new LineNotFoundException();
- }
- return location;
- }
-
- public int lineNumber() {
- return lineNumber;
- }
-
- @Override
- public int hashCode() {
- return refSpec.hashCode() + lineNumber;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LineBreakpointSpec) {
- LineBreakpointSpec breakpoint = (LineBreakpointSpec)obj;
-
- return refSpec.equals(breakpoint.refSpec) &&
- (lineNumber == breakpoint.lineNumber);
- } else {
- return false;
- }
- }
-
- @Override
- public String errorMessageFor(Exception e) {
- if (e instanceof LineNotFoundException) {
- return ("No code at line " + lineNumber() + " in " + refSpec);
- } else if (e instanceof InvalidTypeException) {
- return ("Breakpoints can be located only in classes. " +
- refSpec + " is an interface or array");
- } else {
- return super.errorMessageFor( e);
- }
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("breakpoint ");
- sb.append(refSpec.toString());
- sb.append(':');
- sb.append(lineNumber);
- sb.append(" (");
- sb.append(getStatusString());
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineNotFoundException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineNotFoundException.java
deleted file mode 100644
index 56b4ba3fa39..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/LineNotFoundException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class LineNotFoundException extends Exception
-{
-
- private static final long serialVersionUID = -5630418117861587582L;
-
- public LineNotFoundException()
- {
- super();
- }
-
- public LineNotFoundException(String s)
- {
- super(s);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java
deleted file mode 100644
index 1980893a361..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MalformedMemberNameException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-class MalformedMemberNameException extends Exception {
-
- private static final long serialVersionUID = -7726664097374844485L;
-
- public MalformedMemberNameException() {
- super();
- }
-
- public MalformedMemberNameException(String s) {
- super(s);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java
deleted file mode 100644
index b414443faf7..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodBreakpointSpec.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import java.util.ArrayList;
-import java.util.List;
-
-public class MethodBreakpointSpec extends BreakpointSpec {
- String methodId;
- List methodArgs;
-
- MethodBreakpointSpec(EventRequestSpecList specs,
- ReferenceTypeSpec refSpec,
- String methodId, List methodArgs) {
- super(specs, refSpec);
- this.methodId = methodId;
- this.methodArgs = methodArgs;
- }
-
- /**
- * The 'refType' is known to match.
- */
- @Override
- void resolve(ReferenceType refType) throws MalformedMemberNameException,
- AmbiguousMethodException,
- InvalidTypeException,
- NoSuchMethodException,
- NoSessionException {
- if (!isValidMethodName(methodId)) {
- throw new MalformedMemberNameException(methodId);
- }
- if (!(refType instanceof ClassType)) {
- throw new InvalidTypeException();
- }
- Location location = location((ClassType)refType);
- setRequest(refType.virtualMachine().eventRequestManager()
- .createBreakpointRequest(location));
- }
-
- private Location location(ClassType clazz) throws
- AmbiguousMethodException,
- NoSuchMethodException,
- NoSessionException {
- Method method = findMatchingMethod(clazz);
- Location location = method.location();
- return location;
- }
-
- public String methodName() {
- return methodId;
- }
-
- public List methodArgs() {
- return methodArgs;
- }
-
- @Override
- public int hashCode() {
- return refSpec.hashCode() +
- ((methodId != null) ? methodId.hashCode() : 0) +
- ((methodArgs != null) ? methodArgs.hashCode() : 0);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MethodBreakpointSpec) {
- MethodBreakpointSpec breakpoint = (MethodBreakpointSpec)obj;
-
- return methodId.equals(breakpoint.methodId) &&
- methodArgs.equals(breakpoint.methodArgs) &&
- refSpec.equals(breakpoint.refSpec);
- } else {
- return false;
- }
- }
-
- @Override
- public String errorMessageFor(Exception e) {
- if (e instanceof AmbiguousMethodException) {
- return ("Method " + methodName() + " is overloaded; specify arguments");
- /*
- * TO DO: list the methods here
- */
- } else if (e instanceof NoSuchMethodException) {
- return ("No method " + methodName() + " in " + refSpec);
- } else if (e instanceof InvalidTypeException) {
- return ("Breakpoints can be located only in classes. " +
- refSpec + " is an interface or array");
- } else {
- return super.errorMessageFor( e);
- }
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder("breakpoint ");
- sb.append(refSpec.toString());
- sb.append('.');
- sb.append(methodId);
- if (methodArgs != null) {
- boolean first = true;
- sb.append('(');
- for (String name : methodArgs) {
- if (!first) {
- sb.append(',');
- }
- sb.append(name);
- first = false;
- }
- sb.append(")");
- }
- sb.append(" (");
- sb.append(getStatusString());
- sb.append(')');
- return sb.toString();
- }
-
- private boolean isValidMethodName(String s) {
- return isJavaIdentifier(s) ||
- s.equals("") ||
- s.equals("");
- }
-
- /*
- * Compare a method's argument types with a Vector of type names.
- * Return true if each argument type has a name identical to the
- * corresponding string in the vector (allowing for varargs)
- * and if the number of arguments in the method matches the
- * number of names passed
- */
- private boolean compareArgTypes(Method method, List nameList) {
- List argTypeNames = method.argumentTypeNames();
-
- // If argument counts differ, we can stop here
- if (argTypeNames.size() != nameList.size()) {
- return false;
- }
-
- // Compare each argument type's name
- int nTypes = argTypeNames.size();
- for (int i = 0; i < nTypes; ++i) {
- String comp1 = argTypeNames.get(i);
- String comp2 = nameList.get(i);
- if (! comp1.equals(comp2)) {
- /*
- * We have to handle varargs. EG, the
- * method's last arg type is xxx[]
- * while the nameList contains xxx...
- * Note that the nameList can also contain
- * xxx[] in which case we don't get here.
- */
- if (i != nTypes - 1 ||
- !method.isVarArgs() ||
- !comp2.endsWith("...")) {
- return false;
- }
- /*
- * The last types differ, it is a varargs
- * method and the nameList item is varargs.
- * We just have to compare the type names, eg,
- * make sure we don't have xxx[] for the method
- * arg type and yyy... for the nameList item.
- */
- int comp1Length = comp1.length();
- if (comp1Length + 1 != comp2.length()) {
- // The type names are different lengths
- return false;
- }
- // We know the two type names are the same length
- if (!comp1.regionMatches(0, comp2, 0, comp1Length - 2)) {
- return false;
- }
- // We do have xxx[] and xxx... as the last param type
- return true;
- }
- }
-
- return true;
- }
-
- private VirtualMachine vm() {
- return request.virtualMachine();
- }
-
- /**
- * Remove unneeded spaces and expand class names to fully
- * qualified names, if necessary and possible.
- */
- private String normalizeArgTypeName(String name) throws NoSessionException {
- /*
- * Separate the type name from any array modifiers,
- * stripping whitespace after the name ends.
- */
- int i = 0;
- StringBuilder typePart = new StringBuilder();
- StringBuilder arrayPart = new StringBuilder();
- name = name.trim();
- int nameLength = name.length();
- /*
- * For varargs, there can be spaces before the ... but not
- * within the ... So, we will just ignore the ...
- * while stripping blanks.
- */
- boolean isVarArgs = name.endsWith("...");
- if (isVarArgs) {
- nameLength -= 3;
- }
-
- while (i < nameLength) {
- char c = name.charAt(i);
- if (Character.isWhitespace(c) || c == '[') {
- break; // name is complete
- }
- typePart.append(c);
- i++;
- }
- while (i < nameLength) {
- char c = name.charAt(i);
- if ( (c == '[') || (c == ']')) {
- arrayPart.append(c);
- } else if (!Character.isWhitespace(c)) {
- throw new IllegalArgumentException(
- "Invalid argument type name");
-
- }
- i++;
- }
-
- name = typePart.toString();
-
- /*
- * When there's no sign of a package name already,
- * try to expand the
- * the name to a fully qualified class name
- */
- if ((name.indexOf('.') == -1) || name.startsWith("*.")) {
- try {
- List> refs = specs.runtime.findClassesMatchingPattern(name);
- if (refs.size() > 0) { //### ambiguity???
- name = ((ReferenceType)(refs.get(0))).name();
- }
- } catch (IllegalArgumentException e) {
- // We'll try the name as is
- }
- }
- name += arrayPart.toString();
- if (isVarArgs) {
- name += "...";
- }
- return name;
- }
-
- /*
- * Attempt an unambiguous match of the method name and
- * argument specification to a method. If no arguments
- * are specified, the method must not be overloaded.
- * Otherwise, the argument types much match exactly
- */
- private Method findMatchingMethod(ClassType clazz)
- throws AmbiguousMethodException,
- NoSuchMethodException,
- NoSessionException {
-
- // Normalize the argument string once before looping below.
- List argTypeNames = null;
- if (methodArgs() != null) {
- argTypeNames = new ArrayList(methodArgs().size());
- for (String name : methodArgs()) {
- name = normalizeArgTypeName(name);
- argTypeNames.add(name);
- }
- }
-
- // Check each method in the class for matches
- Method firstMatch = null; // first method with matching name
- Method exactMatch = null; // (only) method with same name & sig
- int matchCount = 0; // > 1 implies overload
- for (Method candidate : clazz.methods()) {
- if (candidate.name().equals(methodName())) {
- matchCount++;
-
- // Remember the first match in case it is the only one
- if (matchCount == 1) {
- firstMatch = candidate;
- }
-
- // If argument types were specified, check against candidate
- if ((argTypeNames != null)
- && compareArgTypes(candidate, argTypeNames) == true) {
- exactMatch = candidate;
- break;
- }
- }
- }
-
- // Determine method for breakpoint
- Method method = null;
- if (exactMatch != null) {
- // Name and signature match
- method = exactMatch;
- } else if ((argTypeNames == null) && (matchCount > 0)) {
- // At least one name matched and no arg types were specified
- if (matchCount == 1) {
- method = firstMatch; // Only one match; safe to use it
- } else {
- throw new AmbiguousMethodException();
- }
- } else {
- throw new NoSuchMethodException(methodName());
- }
- return method;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java
deleted file mode 100644
index 820c35cc61b..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/MethodNotFoundException.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class MethodNotFoundException extends Exception
-{
- private static final long serialVersionUID = -2064968107599632609L;
-
- public MethodNotFoundException()
- {
- super();
- }
-
- public MethodNotFoundException(String s)
- {
- super(s);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java
deleted file mode 100644
index b8f2b86e65a..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ModificationWatchpointSpec.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-
-public class ModificationWatchpointSpec extends WatchpointSpec {
-
- ModificationWatchpointSpec(EventRequestSpecList specs,
- ReferenceTypeSpec refSpec, String fieldId) {
- super(specs, refSpec, fieldId);
- }
-
- /**
- * The 'refType' is known to match.
- */
- @Override
- void resolve(ReferenceType refType) throws InvalidTypeException,
- NoSuchFieldException {
- if (!(refType instanceof ClassType)) {
- throw new InvalidTypeException();
- }
- Field field = refType.fieldByName(fieldId);
- if (field == null) {
- throw new NoSuchFieldException(fieldId);
- }
- setRequest(refType.virtualMachine().eventRequestManager()
- .createModificationWatchpointRequest(field));
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj instanceof ModificationWatchpointSpec) &&
- super.equals(obj);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java
deleted file mode 100644
index 3e92e2eb167..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoSessionException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class NoSessionException extends Exception {
-
- private static final long serialVersionUID = -7324357828115128603L;
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoThreadException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoThreadException.java
deleted file mode 100644
index 12512094f4d..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/NoThreadException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class NoThreadException extends Exception {
-
- private static final long serialVersionUID = 1846613539928921998L;
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java
deleted file mode 100644
index 8bb6701595e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/OutputListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public interface OutputListener {
- void putString(String str);
- //void putLine(String line);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java
deleted file mode 100644
index 3d407985635..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ParseException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-// dummy placeholder for javaCC-generated code.
-
-public class ParseException extends Exception {}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java
deleted file mode 100644
index fa034aea3b4..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/PatternReferenceTypeSpec.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-import java.util.StringTokenizer;
-
-class PatternReferenceTypeSpec implements ReferenceTypeSpec {
- final boolean isWild;
- final String classId;
-
- PatternReferenceTypeSpec(String classId)
-// throws ClassNotFoundException
- {
-// checkClassName(classId);
- isWild = classId.startsWith("*.");
- if (isWild) {
- this.classId = classId.substring(1);
- } else {
- this.classId = classId;
- }
- }
-
- /**
- * Does the specified ReferenceType match this spec.
- */
- @Override
- public boolean matches(ReferenceType refType) {
- if (isWild) {
- return refType.name().endsWith(classId);
- } else {
- return refType.name().equals(classId);
- }
- }
-
- @Override
- public int hashCode() {
- return classId.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof PatternReferenceTypeSpec) {
- PatternReferenceTypeSpec spec = (PatternReferenceTypeSpec)obj;
-
- return classId.equals(spec.classId) && (isWild == spec.isWild);
- } else {
- return false;
- }
- }
-
- private void checkClassName(String className) throws ClassNotFoundException {
- // Do stricter checking of class name validity on deferred
- // because if the name is invalid, it will
- // never match a future loaded class, and we'll be silent
- // about it.
- StringTokenizer tokenizer = new StringTokenizer(className, ".");
- boolean first = true;
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- // Each dot-separated piece must be a valid identifier
- // and the first token can also be "*". (Note that
- // numeric class ids are not permitted. They must
- // match a loaded class.)
- if (!Utils.isJavaIdentifier(token) && !(first && token.equals("*"))) {
- throw new ClassNotFoundException();
- }
- first = false;
- }
- }
-
- @Override
- public String toString() {
- return isWild? "*" + classId : classId;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java
deleted file mode 100644
index 7ad277e341f..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ReferenceTypeSpec.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-
-interface ReferenceTypeSpec {
- /**
- * Does the specified ReferenceType match this spec.
- */
- boolean matches(ReferenceType refType);
-
- @Override
- int hashCode();
-
- @Override
- boolean equals(Object obj);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java
deleted file mode 100644
index 883834a07a1..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Session.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.VMDisconnectedException;
-
-/**
- * Our repository of what we know about the state of one
- * running VM.
- */
-class Session {
-
- final VirtualMachine vm;
- final ExecutionManager runtime;
- final OutputListener diagnostics;
-
- boolean running = true; // Set false by JDIEventSource
- boolean interrupted = false; // Set false by JDIEventSource
-
- private JDIEventSource eventSourceThread = null;
- private int traceFlags;
- private boolean dead = false;
-
- public Session(VirtualMachine vm, ExecutionManager runtime,
- OutputListener diagnostics) {
- this.vm = vm;
- this.runtime = runtime;
- this.diagnostics = diagnostics;
- this.traceFlags = VirtualMachine.TRACE_NONE;
- }
-
- /**
- * Determine if VM is interrupted, i.e, present and not running.
- */
- public boolean isInterrupted() {
- return interrupted;
- }
-
- public void setTraceMode(int traceFlags) {
- this.traceFlags = traceFlags;
- if (!dead) {
- vm.setDebugTraceMode(traceFlags);
- }
- }
-
- public boolean attach() {
- vm.setDebugTraceMode(traceFlags);
- diagnostics.putString("Connected to VM");
- eventSourceThread = new JDIEventSource(this);
- eventSourceThread.start();
- return true;
- }
-
- public void detach() {
- if (!dead) {
- eventSourceThread.interrupt();
- eventSourceThread = null;
- //### The VM may already be disconnected
- //### if the debuggee did a System.exit().
- //### Exception handler here is a kludge,
- //### Rather, there are many other places
- //### where we need to handle this exception,
- //### and initiate a detach due to an error
- //### condition, e.g., connection failure.
- try {
- vm.dispose();
- } catch (VMDisconnectedException ee) {}
- dead = true;
- diagnostics.putString("Disconnected from VM");
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java
deleted file mode 100644
index e13c4d70e72..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SessionListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import java.util.EventObject;
-import java.util.EventListener;
-
-public interface SessionListener extends EventListener {
-
- void sessionStart(EventObject e);
-
- void sessionInterrupt(EventObject e);
- void sessionContinue(EventObject e);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java
deleted file mode 100644
index 36061bfc487..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SourceNameReferenceTypeSpec.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-
-class SourceNameReferenceTypeSpec implements ReferenceTypeSpec {
- final String sourceName;
- final int linenumber;
-
- SourceNameReferenceTypeSpec(String sourceName, int linenumber) {
- this.sourceName = sourceName;
- this.linenumber = linenumber;
- }
-
- /**
- * Does the specified ReferenceType match this spec.
- */
- @Override
- public boolean matches(ReferenceType refType) {
- try {
- if (refType.sourceName().equals(sourceName)) {
- try {
- refType.locationsOfLine(linenumber);
- // if we don't throw an exception then it was found
- return true;
- } catch(AbsentInformationException exc) {
- } catch(ObjectCollectedException exc) {
- }
- }
- } catch(AbsentInformationException exc) {
- // for sourceName(), fall through
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return sourceName.hashCode() + linenumber;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof SourceNameReferenceTypeSpec) {
- SourceNameReferenceTypeSpec spec = (SourceNameReferenceTypeSpec)obj;
-
- return sourceName.equals(spec.sourceName) &&
- (linenumber == spec.linenumber);
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return sourceName + "@" + linenumber;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java
deleted file mode 100644
index baab1291d2d..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecErrorEvent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class SpecErrorEvent extends SpecEvent {
-
- private static final long serialVersionUID = 8162634387866409578L;
- private Exception reason;
-
- public SpecErrorEvent(EventRequestSpec eventRequestSpec,
- Exception reason) {
- super(eventRequestSpec);
- this.reason = reason;
- }
-
- public Exception getReason() {
- return reason;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java
deleted file mode 100644
index 7a321ef4aaa..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecEvent.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import java.util.EventObject;
-
-import com.sun.jdi.request.EventRequest;
-
-public class SpecEvent extends EventObject {
-
- private static final long serialVersionUID = 4820735456787276230L;
- private EventRequestSpec eventRequestSpec;
-
- public SpecEvent(EventRequestSpec eventRequestSpec) {
- super(eventRequestSpec.specs);
- this.eventRequestSpec = eventRequestSpec;
- }
-
- public EventRequestSpec getEventRequestSpec() {
- return eventRequestSpec;
- }
-
- public EventRequest getEventRequest() {
- return eventRequestSpec.getEventRequest();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java
deleted file mode 100644
index 2e5df596ea4..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/SpecListener.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import java.util.EventListener;
-
-public interface SpecListener extends EventListener {
-
- void breakpointSet(SpecEvent e);
- void breakpointDeferred(SpecEvent e);
- void breakpointDeleted(SpecEvent e);
- void breakpointResolved(SpecEvent e);
- void breakpointError(SpecErrorEvent e);
-
- void watchpointSet(SpecEvent e);
- void watchpointDeferred(SpecEvent e);
- void watchpointDeleted(SpecEvent e);
- void watchpointResolved(SpecEvent e);
- void watchpointError(SpecErrorEvent e);
-
- void exceptionInterceptSet(SpecEvent e);
- void exceptionInterceptDeferred(SpecEvent e);
- void exceptionInterceptDeleted(SpecEvent e);
- void exceptionInterceptResolved(SpecEvent e);
- void exceptionInterceptError(SpecErrorEvent e);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java
deleted file mode 100644
index dd8b0cb3f7e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadGroupIterator.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.ThreadGroupReference;
-import java.util.List;
-import java.util.Stack;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-/**
- * Descend the tree of thread groups.
- * @author Robert G. Field
- */
-public class ThreadGroupIterator implements Iterator {
- private final Stack> stack
- = new Stack>();
-
- public ThreadGroupIterator(List tgl) {
- push(tgl);
- }
-
- public ThreadGroupIterator(ThreadGroupReference tg) {
- List tgl = new ArrayList();
- tgl.add(tg);
- push(tgl);
- }
-
-/*
- ThreadGroupIterator() {
- this(Env.vm().topLevelThreadGroups());
- }
-*/
-
- private Iterator top() {
- return stack.peek();
- }
-
- /**
- * The invariant in this class is that the top iterator
- * on the stack has more elements. If the stack is
- * empty, there is no top. This method assures
- * this invariant.
- */
- private void push(List tgl) {
- stack.push(tgl.iterator());
- while (!stack.isEmpty() && !top().hasNext()) {
- stack.pop();
- }
- }
-
- @Override
- public boolean hasNext() {
- return !stack.isEmpty();
- }
-
- @Override
- public ThreadGroupReference next() {
- return nextThreadGroup();
- }
-
- public ThreadGroupReference nextThreadGroup() {
- ThreadGroupReference tg = top().next();
- push(tg.threadGroups());
- return tg;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
-/*
- static ThreadGroupReference find(String name) {
- ThreadGroupIterator tgi = new ThreadGroupIterator();
- while (tgi.hasNext()) {
- ThreadGroupReference tg = tgi.nextThreadGroup();
- if (tg.name().equals(name)) {
- return tg;
- }
- }
- return null;
- }
-*/
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java
deleted file mode 100644
index 02626ac324f..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadInfo.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.*;
-
-//### Should handle target VM death or connection failure cleanly.
-
-public class ThreadInfo {
-
- private ThreadReference thread;
- private int status;
-
- private int frameCount;
-
- Object userObject; // User-supplied annotation.
-
- private boolean interrupted = false;
-
- private void assureInterrupted() throws VMNotInterruptedException {
- if (!interrupted) {
- throw new VMNotInterruptedException();
- }
- }
-
- ThreadInfo (ThreadReference thread) {
- this.thread = thread;
- this.frameCount = -1;
- }
-
- public ThreadReference thread() {
- return thread;
- }
-
- public int getStatus() throws VMNotInterruptedException {
- assureInterrupted();
- update();
- return status;
- }
-
- public int getFrameCount() throws VMNotInterruptedException {
- assureInterrupted();
- update();
- return frameCount;
- }
-
- public StackFrame getFrame(int index) throws VMNotInterruptedException {
- assureInterrupted();
- update();
- try {
- return thread.frame(index);
- } catch (IncompatibleThreadStateException e) {
- // Should not happen
- interrupted = false;
- throw new VMNotInterruptedException();
- }
- }
-
- public Object getUserObject() {
- return userObject;
- }
-
- public void setUserObject(Object obj) {
- userObject = obj;
- }
-
- // Refresh upon first access after cache is cleared.
-
- void update() throws VMNotInterruptedException {
- if (frameCount == -1) {
- try {
- status = thread.status();
- frameCount = thread.frameCount();
- } catch (IncompatibleThreadStateException e) {
- // Should not happen
- interrupted = false;
- throw new VMNotInterruptedException();
- }
- }
- }
-
- // Called from 'ExecutionManager'.
-
- void validate() {
- interrupted = true;
- }
-
- void invalidate() {
- interrupted = false;
- frameCount = -1;
- status = ThreadReference.THREAD_STATUS_UNKNOWN;
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java
deleted file mode 100644
index b82d88e6e1e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/ThreadIterator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-import com.sun.jdi.ThreadGroupReference;
-import com.sun.jdi.ThreadReference;
-import java.util.List;
-import java.util.Iterator;
-
-public class ThreadIterator implements Iterator {
- Iterator it = null;
- ThreadGroupIterator tgi;
-
- public ThreadIterator(ThreadGroupReference tg) {
- tgi = new ThreadGroupIterator(tg);
- }
-
- //### make this package access only?
- public ThreadIterator(List tgl) {
- tgi = new ThreadGroupIterator(tgl);
- }
-
- @Override
- public boolean hasNext() {
- while (it == null || !it.hasNext()) {
- if (!tgi.hasNext()) {
- return false; // no more
- }
- it = tgi.nextThreadGroup().threads().iterator();
- }
- return true;
- }
-
- @Override
- public ThreadReference next() {
- return it.next();
- }
-
- public ThreadReference nextThread() {
- return next();
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java
deleted file mode 100644
index 34f1d724929..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/Utils.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi; //### does it belong here?
-
-import com.sun.jdi.*;
-
-public class Utils {
-
- /**
- * Return the thread status description.
- */
- public static String getStatus(ThreadReference thr) {
- int status = thr.status();
- String result;
- switch (status) {
- case ThreadReference.THREAD_STATUS_UNKNOWN:
- result = "unknown status";
- break;
- case ThreadReference.THREAD_STATUS_ZOMBIE:
- result = "zombie";
- break;
- case ThreadReference.THREAD_STATUS_RUNNING:
- result = "running";
- break;
- case ThreadReference.THREAD_STATUS_SLEEPING:
- result = "sleeping";
- break;
- case ThreadReference.THREAD_STATUS_MONITOR:
- result = "waiting to acquire a monitor lock";
- break;
- case ThreadReference.THREAD_STATUS_WAIT:
- result = "waiting on a condition";
- break;
- default:
- result = "";
- }
- if (thr.isSuspended()) {
- result += " (suspended)";
- }
- return result;
- }
-
- /**
- * Return a description of an object.
- */
- public static String description(ObjectReference ref) {
- ReferenceType clazz = ref.referenceType();
- long id = ref.uniqueID(); //### TODO use real id
- if (clazz == null) {
- return toHex(id);
- } else {
- return "(" + clazz.name() + ")" + toHex(id);
- }
- }
-
- /**
- * Convert a long to a hexadecimal string.
- */
- public static String toHex(long n) {
- char s1[] = new char[16];
- char s2[] = new char[18];
-
- // Store digits in reverse order.
- int i = 0;
- do {
- long d = n & 0xf;
- s1[i++] = (char)((d < 10) ? ('0' + d) : ('a' + d - 10));
- } while ((n >>>= 4) > 0);
-
- // Now reverse the array.
- s2[0] = '0';
- s2[1] = 'x';
- int j = 2;
- while (--i >= 0) {
- s2[j++] = s1[i];
- }
- return new String(s2, 0, j);
- }
-
- /**
- * Convert hexadecimal strings to longs.
- */
- public static long fromHex(String hexStr) {
- String str = hexStr.startsWith("0x") ?
- hexStr.substring(2).toLowerCase() : hexStr.toLowerCase();
- if (hexStr.length() == 0) {
- throw new NumberFormatException();
- }
-
- long ret = 0;
- for (int i = 0; i < str.length(); i++) {
- int c = str.charAt(i);
- if (c >= '0' && c <= '9') {
- ret = (ret * 16) + (c - '0');
- } else if (c >= 'a' && c <= 'f') {
- ret = (ret * 16) + (c - 'a' + 10);
- } else {
- throw new NumberFormatException();
- }
- }
- return ret;
- }
-
-
- /*
- * The next two methods are used by this class and by EventHandler
- * to print consistent locations and error messages.
- */
- public static String locationString(Location loc) {
- return loc.declaringType().name() +
- "." + loc.method().name() + "(), line=" +
- loc.lineNumber();
- }
-
-//### UNUSED.
-/************************
- private String typedName(Method method) {
- // TO DO: Use method.signature() instead of method.arguments() so that
- // we get sensible results for classes without debugging info
- StringBuffer buf = new StringBuffer();
- buf.append(method.name());
- buf.append("(");
- Iterator it = method.arguments().iterator();
- while (it.hasNext()) {
- buf.append(((LocalVariable)it.next()).typeName());
- if (it.hasNext()) {
- buf.append(",");
- }
- }
- buf.append(")");
- return buf.toString();
- }
-************************/
-
- public static boolean isValidMethodName(String s) {
- return isJavaIdentifier(s) ||
- s.equals("") ||
- s.equals("");
- }
-
- public static boolean isJavaIdentifier(String s) {
- if (s.length() == 0) {
- return false;
- }
- int cp = s.codePointAt(0);
- if (! Character.isJavaIdentifierStart(cp)) {
- return false;
- }
- for (int i = Character.charCount(cp); i < s.length(); i += Character.charCount(cp)) {
- cp = s.codePointAt(i);
- if (! Character.isJavaIdentifierPart(cp)) {
- return false;
- }
- }
- return true;
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java
deleted file mode 100644
index c2429684d29..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMLaunchFailureException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class VMLaunchFailureException extends Exception {
-
- private static final long serialVersionUID = -2439646729274310108L;
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java
deleted file mode 100644
index 489d88086cb..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/VMNotInterruptedException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public class VMNotInterruptedException extends Exception {
-
- private static final long serialVersionUID = 8111074582188765600L;
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java
deleted file mode 100644
index 367e38c7490..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/bdi/WatchpointSpec.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.bdi;
-
-public abstract class WatchpointSpec extends EventRequestSpec {
- final String fieldId;
-
- WatchpointSpec(EventRequestSpecList specs,
- ReferenceTypeSpec refSpec, String fieldId) {
- super(specs, refSpec);
- this.fieldId = fieldId;
-// if (!isJavaIdentifier(fieldId)) {
-// throw new MalformedMemberNameException(fieldId);
-// }
- }
-
- @Override
- void notifySet(SpecListener listener, SpecEvent evt) {
- listener.watchpointSet(evt);
- }
-
- @Override
- void notifyDeferred(SpecListener listener, SpecEvent evt) {
- listener.watchpointDeferred(evt);
- }
-
- @Override
- void notifyResolved(SpecListener listener, SpecEvent evt) {
- listener.watchpointResolved(evt);
- }
-
- @Override
- void notifyDeleted(SpecListener listener, SpecEvent evt) {
- listener.watchpointDeleted(evt);
- }
-
- @Override
- void notifyError(SpecListener listener, SpecErrorEvent evt) {
- listener.watchpointError(evt);
- }
-
- @Override
- public int hashCode() {
- return refSpec.hashCode() + fieldId.hashCode() +
- getClass().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof WatchpointSpec) {
- WatchpointSpec watchpoint = (WatchpointSpec)obj;
-
- return fieldId.equals(watchpoint.fieldId) &&
- refSpec.equals(watchpoint.refSpec) &&
- getClass().equals(watchpoint.getClass());
- } else {
- return false;
- }
- }
-
- @Override
- public String errorMessageFor(Exception e) {
- if (e instanceof NoSuchFieldException) {
- return ("No field " + fieldId + " in " + refSpec);
- } else {
- return super.errorMessageFor(e);
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java
deleted file mode 100644
index 0a82f15ee0a..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AbstractEventSet.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-import com.sun.jdi.request.*;
-
-import java.util.*;
-
-public abstract class AbstractEventSet extends EventObject implements EventSet {
-
- private static final long serialVersionUID = 2772717574222076977L;
- private final EventSet jdiEventSet;
- final Event oneEvent;
-
- /**
- */
- AbstractEventSet(EventSet jdiEventSet) {
- super(jdiEventSet.virtualMachine());
- this.jdiEventSet = jdiEventSet;
- this.oneEvent = eventIterator().nextEvent();
- }
-
- public static AbstractEventSet toSpecificEventSet(EventSet jdiEventSet) {
- Event evt = jdiEventSet.eventIterator().nextEvent();
- if (evt instanceof LocatableEvent) {
- if (evt instanceof ExceptionEvent) {
- return new ExceptionEventSet(jdiEventSet);
- } else if (evt instanceof WatchpointEvent) {
- if (evt instanceof AccessWatchpointEvent) {
- return new AccessWatchpointEventSet(jdiEventSet);
- } else {
- return new ModificationWatchpointEventSet(jdiEventSet);
- }
- } else {
- return new LocationTriggerEventSet(jdiEventSet);
- }
- } else if (evt instanceof ClassPrepareEvent) {
- return new ClassPrepareEventSet(jdiEventSet);
- } else if (evt instanceof ClassUnloadEvent) {
- return new ClassUnloadEventSet(jdiEventSet);
- } else if (evt instanceof ThreadDeathEvent) {
- return new ThreadDeathEventSet(jdiEventSet);
- } else if (evt instanceof ThreadStartEvent) {
- return new ThreadStartEventSet(jdiEventSet);
- } else if (evt instanceof VMDeathEvent) {
- return new VMDeathEventSet(jdiEventSet);
- } else if (evt instanceof VMDisconnectEvent) {
- return new VMDisconnectEventSet(jdiEventSet);
- } else if (evt instanceof VMStartEvent) {
- return new VMStartEventSet(jdiEventSet);
- } else {
- throw new IllegalArgumentException("Unknown event " + evt);
- }
- }
-
- public abstract void notify(JDIListener listener);
-
- // Implement Mirror
-
- @Override
- public VirtualMachine virtualMachine() {
- return jdiEventSet.virtualMachine();
- }
-
- public VirtualMachine getVirtualMachine() {
- return jdiEventSet.virtualMachine();
- }
-
- // Implement EventSet
-
- /**
- * Returns the policy used to suspend threads in the target VM
- * for this event set. This policy is selected from the suspend
- * policies for each event's request. The one that suspends the
- * most threads is chosen when the event occurs in the target VM
- * and that policy is returned here. See
- * com.sun.jdi.request.EventRequest for the possible policy values.
- *
- * @return the integer suspendPolicy
- */
- public int getSuspendPolicy() {
- return jdiEventSet.suspendPolicy();
- }
-
- @Override
- public void resume() {
- jdiEventSet.resume();
- }
-
- @Override
- public int suspendPolicy() {
- return jdiEventSet.suspendPolicy();
- }
-
- public boolean suspendedAll() {
- return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_ALL;
- }
-
- public boolean suspendedEventThread() {
- return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD;
- }
-
- public boolean suspendedNone() {
- return jdiEventSet.suspendPolicy() == EventRequest.SUSPEND_NONE;
- }
-
- /**
- * Return an iterator specific to {@link Event} objects.
- */
- @Override
- public EventIterator eventIterator() {
- return jdiEventSet.eventIterator();
- }
-
-
- // Implement java.util.Set (by pass through)
-
- /**
- * Returns the number of elements in this set (its cardinality). If this
- * set contains more than Integer.MAX_VALUE elements, returns
- * Integer.MAX_VALUE .
- *
- * @return the number of elements in this set (its cardinality).
- */
- @Override
- public int size() {
- return jdiEventSet.size();
- }
-
- /**
- * Returns true if this set contains no elements.
- *
- * @return true if this set contains no elements.
- */
- @Override
- public boolean isEmpty() {
- return jdiEventSet.isEmpty();
- }
-
- /**
- * Returns true if this set contains the specified element. More
- * formally, returns true if and only if this set contains an
- * element e
such that (o==null ? e==null :
- * o.equals(e))
.
- *
- * @return true if this set contains the specified element.
- */
- @Override
- public boolean contains(Object o) {
- return jdiEventSet.contains(o);
- }
-
- /**
- * Returns an iterator over the elements in this set. The elements are
- * returned in no particular order (unless this set is an instance of some
- * class that provides a guarantee).
- *
- * @return an iterator over the elements in this set.
- */
- @Override
- public Iterator iterator() {
- return jdiEventSet.iterator();
- }
-
- /**
- * Returns an array containing all of the elements in this set.
- * Obeys the general contract of the Collection.toArray method.
- *
- * @return an array containing all of the elements in this set.
- */
- @Override
- public Object[] toArray() {
- return jdiEventSet.toArray();
- }
-
- /**
- * Returns an array containing all of the elements in this set whose
- * runtime type is that of the specified array. Obeys the general
- * contract of the Collection.toArray(Object[]) method.
- *
- * @param a the array into which the elements of this set are to
- * be stored, if it is big enough {
- return jdiEventSet.XXX();
- } otherwise, a new array of the
- * same runtime type is allocated for this purpose.
- * @return an array containing the elements of this set.
- * @throws ArrayStoreException the runtime type of a is not a supertype
- * of the runtime type of every element in this set.
- */
- @Override
- public T[] toArray(T a[]) {
- return jdiEventSet.toArray(a);
- }
-
- // Bulk Operations
-
- /**
- * Returns true if this set contains all of the elements of the
- * specified collection. If the specified collection is also a set, this
- * method returns true if it is a subset of this set.
- *
- * @param c collection to be checked for containment in this set.
- * @return true if this set contains all of the elements of the
- * specified collection.
- */
- @Override
- public boolean containsAll(Collection> c) {
- return jdiEventSet.containsAll(c);
- }
-
-
- // Make the rest of Set unmodifiable
-
- @Override
- public boolean add(Event e){
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean remove(Object o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean addAll(Collection extends Event> coll) {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean removeAll(Collection> coll) {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean retainAll(Collection> coll) {
- throw new UnsupportedOperationException();
- }
- @Override
- public void clear() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java
deleted file mode 100644
index 10462e3bbb4..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/AccessWatchpointEventSet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.event.*;
-
-public class AccessWatchpointEventSet extends WatchpointEventSet {
-
- private static final long serialVersionUID = -2620394219156607673L;
-
- AccessWatchpointEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.accessWatchpoint(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java
deleted file mode 100644
index 9010415e362..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassPrepareEventSet.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public class ClassPrepareEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = 5958493423581010491L;
-
- ClassPrepareEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the thread in which this event has occurred.
- *
- * @return a {@link ThreadReference} which mirrors the event's thread in
- * the target VM.
- */
- public ThreadReference getThread() {
- return ((ClassPrepareEvent)oneEvent).thread();
- }
-
-
- /**
- * Returns the reference type for which this event was generated.
- *
- * @return a {@link ReferenceType} which mirrors the class, interface, or
- * array which has been linked.
- */
- public ReferenceType getReferenceType() {
- return ((ClassPrepareEvent)oneEvent).referenceType();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.classPrepare(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java
deleted file mode 100644
index ad57b70d059..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ClassUnloadEventSet.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.event.*;
-
-public class ClassUnloadEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = 8370341450345835866L;
-
- ClassUnloadEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the name of the class that has been unloaded.
- */
- public String getClassName() {
- return ((ClassUnloadEvent)oneEvent).className();
- }
-
- /**
- * Returns the JNI-style signature of the class that has been unloaded.
- */
- public String getClassSignature() {
- return ((ClassUnloadEvent)oneEvent).classSignature();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.classUnload(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java
deleted file mode 100644
index d59cce74d49..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ExceptionEventSet.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public class ExceptionEventSet extends LocatableEventSet {
-
- private static final long serialVersionUID = 5328140167954640711L;
-
- ExceptionEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Gets the thrown exception object. The exception object is
- * an instance of java.lang.Throwable or a subclass in the
- * target VM.
- *
- * @return an {@link ObjectReference} which mirrors the thrown object in
- * the target VM.
- */
- public ObjectReference getException() {
- return ((ExceptionEvent)oneEvent).exception();
- }
-
- /**
- * Gets the location where the exception will be caught. An exception
- * is considered to be caught if, at the point of the throw, the
- * current location is dynamically enclosed in a try statement that
- * handles the exception. (See the JVM specification for details).
- * If there is such a try statement, the catch location is the
- * first code index of the appropriate catch clause.
- *
- * If there are native methods in the call stack at the time of the
- * exception, there are important restrictions to note about the
- * returned catch location. In such cases,
- * it is not possible to predict whether an exception will be handled
- * by some native method on the call stack.
- * Thus, it is possible that exceptions considered uncaught
- * here will, in fact, be handled by a native method and not cause
- * termination of the target VM. Also, it cannot be assumed that the
- * catch location returned here will ever be reached by the throwing
- * thread. If there is
- * a native frame between the current location and the catch location,
- * the exception might be handled and cleared in that native method
- * instead.
- *
- * @return the {@link Location} where the exception will be caught or null if
- * the exception is uncaught.
- */
- public Location getCatchLocation() {
- return ((ExceptionEvent)oneEvent).catchLocation();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.exception(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java
deleted file mode 100644
index 056cd0933b5..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIAdapter.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-/**
- * The adapter which receives JDI event sets. The methods in this
- * class are empty; this class is provided as a convenience for
- * easily creating listeners by extending this class and overriding
- * only the methods of interest.
- */
-public class JDIAdapter implements JDIListener {
-
- @Override
- public void accessWatchpoint(AccessWatchpointEventSet e) {
- }
-
- @Override
- public void classPrepare(ClassPrepareEventSet e) {
- }
-
- @Override
- public void classUnload(ClassUnloadEventSet e) {
- }
-
- @Override
- public void exception(ExceptionEventSet e) {
- }
-
- @Override
- public void locationTrigger(LocationTriggerEventSet e) {
- }
-
- @Override
- public void modificationWatchpoint(ModificationWatchpointEventSet e) {
- }
-
- @Override
- public void threadDeath(ThreadDeathEventSet e) {
- }
-
- @Override
- public void threadStart(ThreadStartEventSet e) {
- }
-
- @Override
- public void vmDeath(VMDeathEventSet e) {
- }
-
- @Override
- public void vmDisconnect(VMDisconnectEventSet e) {
- }
-
- @Override
- public void vmStart(VMStartEventSet e) {
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java
deleted file mode 100644
index 18a37261ee4..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/JDIListener.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import java.util.EventListener;
-
-public interface JDIListener extends EventListener {
- void accessWatchpoint(AccessWatchpointEventSet e);
- void classPrepare(ClassPrepareEventSet e);
- void classUnload(ClassUnloadEventSet e);
- void exception(ExceptionEventSet e);
- void locationTrigger(LocationTriggerEventSet e);
- void modificationWatchpoint(ModificationWatchpointEventSet e);
- void threadDeath(ThreadDeathEventSet e);
- void threadStart(ThreadStartEventSet e);
- void vmDeath(VMDeathEventSet e);
- void vmDisconnect(VMDisconnectEventSet e);
- void vmStart(VMStartEventSet e);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java
deleted file mode 100644
index 6b4f607009c..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocatableEventSet.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-/**
- * Abstract event set for events with location and thread.
- */
-public abstract class LocatableEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = 1027131209997915620L;
-
- LocatableEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the {@link Location} of this mirror. Depending on context
- * and on available debug information, this location will have
- * varying precision.
- *
- * @return the {@link Location} of this mirror.
- */
- public Location getLocation() {
- return ((LocatableEvent)oneEvent).location();
- }
-
- /**
- * Returns the thread in which this event has occurred.
- *
- * @return a {@link ThreadReference} which mirrors the event's thread in
- * the target VM.
- */
- public ThreadReference getThread() {
- return ((LocatableEvent)oneEvent).thread();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java
deleted file mode 100644
index 3d25a573883..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/LocationTriggerEventSet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.event.*;
-
-public class LocationTriggerEventSet extends LocatableEventSet {
-
- private static final long serialVersionUID = -3674631710485872487L;
-
- LocationTriggerEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.locationTrigger(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java
deleted file mode 100644
index 41749efa705..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ModificationWatchpointEventSet.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public class ModificationWatchpointEventSet extends WatchpointEventSet {
-
- private static final long serialVersionUID = -680889300856154719L;
-
- ModificationWatchpointEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Value that will be assigned to the field when the instruction
- * completes.
- */
- public Value getValueToBe() {
- return ((ModificationWatchpointEvent)oneEvent).valueToBe();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.modificationWatchpoint(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java
deleted file mode 100644
index 893ec73fa97..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadDeathEventSet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public class ThreadDeathEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = -8801604712308151331L;
-
- ThreadDeathEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the thread which is terminating.
- *
- * @return a {@link ThreadReference} which mirrors the event's thread in
- * the target VM.
- */
- public ThreadReference getThread() {
- return ((ThreadDeathEvent)oneEvent).thread();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.threadDeath(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java
deleted file mode 100644
index 657e9633c9c..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/ThreadStartEventSet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public class ThreadStartEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = -3802096132294933502L;
-
- ThreadStartEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the thread which has started.
- *
- * @return a {@link ThreadReference} which mirrors the event's thread in
- * the target VM.
- */
- public ThreadReference getThread() {
- return ((ThreadStartEvent)oneEvent).thread();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.threadStart(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java
deleted file mode 100644
index b6f7eb31843..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDeathEventSet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.event.*;
-
-public class VMDeathEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = 1163097303940092229L;
-
- VMDeathEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.vmDeath(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java
deleted file mode 100644
index 5b7dc7953ac..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMDisconnectEventSet.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.event.*;
-
-public class VMDisconnectEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = 7968123152344675342L;
-
- VMDisconnectEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.vmDisconnect(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java
deleted file mode 100644
index f9381239fc8..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/VMStartEventSet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public class VMStartEventSet extends AbstractEventSet {
-
- private static final long serialVersionUID = -3384957227835478191L;
-
- VMStartEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the initial thread of the VM which has started.
- *
- * @return a {@link ThreadReference} which mirrors the event's
- * thread in the target VM.
- */
- public ThreadReference getThread() {
- return ((VMStartEvent)oneEvent).thread();
- }
-
- @Override
- public void notify(JDIListener listener) {
- listener.vmStart(this);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java
deleted file mode 100644
index 76be4acf1da..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/event/WatchpointEventSet.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.event;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-public abstract class WatchpointEventSet extends LocatableEventSet {
-
- private static final long serialVersionUID = 5606285209703845409L;
-
- WatchpointEventSet(EventSet jdiEventSet) {
- super(jdiEventSet);
- }
-
- /**
- * Returns the field that is about to be accessed/modified.
- *
- * @return a {@link Field} which mirrors the field
- * in the target VM.
- */
- public Field getField() {
- return ((WatchpointEvent)oneEvent).field();
- }
-
- /**
- * Returns the object whose field is about to be accessed/modified.
- * Return null is the access is to a static field.
- *
- * @return a {@link ObjectReference} which mirrors the event's
- * object in the target VM.
- */
- public ObjectReference getObject() {
- return ((WatchpointEvent)oneEvent).object();
- }
-
- /**
- * Current value of the field.
- */
- public Value getValueCurrent() {
- return ((WatchpointEvent)oneEvent).valueCurrent();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java
deleted file mode 100644
index 717a5b9390e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ApplicationTool.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import com.sun.tools.example.debug.bdi.*;
-
-public class ApplicationTool extends JPanel {
-
- private static final long serialVersionUID = 310966063293205714L;
-
- private ExecutionManager runtime;
-
- private TypeScript script;
-
- private static final String PROMPT = "Input:";
-
- public ApplicationTool(Environment env) {
-
- super(new BorderLayout());
-
- this.runtime = env.getExecutionManager();
-
- this.script = new TypeScript(PROMPT, false); // No implicit echo.
- this.add(script);
-
- script.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- runtime.sendLineToApplication(script.readln());
- }
- });
-
- runtime.addApplicationEchoListener(new TypeScriptOutputListener(script));
- runtime.addApplicationOutputListener(new TypeScriptOutputListener(script));
- runtime.addApplicationErrorListener(new TypeScriptOutputListener(script));
-
- //### should clean up on exit!
-
- }
-
- /******
- public void setFont(Font f) {
- script.setFont(f);
- }
- ******/
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java
deleted file mode 100644
index 6e347376769..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassManager.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-public class ClassManager {
-
- // This class is provided primarily for symmetry with
- // SourceManager. Currently, it does very little.
- // If we add facilities in the future that require that
- // class files be read outside of the VM, for example, to
- // provide a disassembled view of a class for bytecode-level
- // debugging, the required class file management will be done
- // here.
-
- private SearchPath classPath;
-
- public ClassManager(Environment env) {
- this.classPath = new SearchPath("");
- }
-
- public ClassManager(SearchPath classPath) {
- this.classPath = classPath;
- }
-
- /*
- * Set path for access to class files.
- */
-
- public void setClassPath(SearchPath sp) {
- classPath = sp;
- }
-
- /*
- * Get path for access to class files.
- */
-
- public SearchPath getClassPath() {
- return classPath;
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java
deleted file mode 100644
index 995c414854c..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ClassTreeTool.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.tree.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.event.*;
-import com.sun.tools.example.debug.bdi.*;
-
-public class ClassTreeTool extends JPanel {
-
- private static final long serialVersionUID = 526178912591739259L;
-
- private Environment env;
-
- private ExecutionManager runtime;
- private SourceManager sourceManager;
- private ClassManager classManager;
-
- private JTree tree;
- private DefaultTreeModel treeModel;
- private ClassTreeNode root;
-// private SearchPath sourcePath;
-
- private CommandInterpreter interpreter;
-
- private static String HEADING = "CLASSES";
-
- public ClassTreeTool(Environment env) {
-
- super(new BorderLayout());
-
- this.env = env;
- this.runtime = env.getExecutionManager();
- this.sourceManager = env.getSourceManager();
-
- this.interpreter = new CommandInterpreter(env);
-
- root = createClassTree(HEADING);
- treeModel = new DefaultTreeModel(root);
-
- // Create a tree that allows one selection at a time.
-
- tree = new JTree(treeModel);
- tree.setSelectionModel(new SingleLeafTreeSelectionModel());
-
- /******
- // Listen for when the selection changes.
- tree.addTreeSelectionListener(new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- ClassTreeNode node = (ClassTreeNode)
- (e.getPath().getLastPathComponent());
- if (node != null) {
- interpreter.executeCommand("view " + node.getReferenceTypeName());
- }
- }
- });
- ******/
-
- MouseListener ml = new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- int selRow = tree.getRowForLocation(e.getX(), e.getY());
- TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
- if(selRow != -1) {
- if(e.getClickCount() == 1) {
- ClassTreeNode node =
- (ClassTreeNode)selPath.getLastPathComponent();
- // If user clicks on leaf, select it, and issue 'view' command.
- if (node.isLeaf()) {
- tree.setSelectionPath(selPath);
- interpreter.executeCommand("view " + node.getReferenceTypeName());
- }
- }
- }
- }
- };
- tree.addMouseListener(ml);
-
- JScrollPane treeView = new JScrollPane(tree);
- add(treeView);
-
- // Create listener.
- ClassTreeToolListener listener = new ClassTreeToolListener();
- runtime.addJDIListener(listener);
- runtime.addSessionListener(listener);
-
- //### remove listeners on exit!
- }
-
- private class ClassTreeToolListener extends JDIAdapter
- implements JDIListener, SessionListener {
-
- // SessionListener
-
- @Override
- public void sessionStart(EventObject e) {
- // Get system classes and any others loaded before attaching.
- try {
- for (ReferenceType type : runtime.allClasses()) {
- root.addClass(type);
- }
- } catch (VMDisconnectedException ee) {
- // VM terminated unexpectedly.
- } catch (NoSessionException ee) {
- // Ignore. Should not happen.
- }
- }
-
- @Override
- public void sessionInterrupt(EventObject e) {}
- @Override
- public void sessionContinue(EventObject e) {}
-
- // JDIListener
-
- @Override
- public void classPrepare(ClassPrepareEventSet e) {
- root.addClass(e.getReferenceType());
- }
-
- @Override
- public void classUnload(ClassUnloadEventSet e) {
- root.removeClass(e.getClassName());
- }
-
- @Override
- public void vmDisconnect(VMDisconnectEventSet e) {
- // Clear contents of this view.
- root = createClassTree(HEADING);
- treeModel = new DefaultTreeModel(root);
- tree.setModel(treeModel);
- }
- }
-
- ClassTreeNode createClassTree(String label) {
- return new ClassTreeNode(label, null);
- }
-
- class ClassTreeNode extends DefaultMutableTreeNode {
-
- private String name;
- private ReferenceType refTy; // null for package
-
- ClassTreeNode(String name, ReferenceType refTy) {
- this.name = name;
- this.refTy = refTy;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public ReferenceType getReferenceType() {
- return refTy;
- }
-
- public String getReferenceTypeName() {
- return refTy.name();
- }
-
- private boolean isPackage() {
- return (refTy == null);
- }
-
- @Override
- public boolean isLeaf() {
- return !isPackage();
- }
-
- public void addClass(ReferenceType refTy) {
- addClass(refTy.name(), refTy);
- }
-
- private void addClass(String className, ReferenceType refTy) {
- if (className.equals("")) {
- return;
- }
- int pos = className.indexOf('.');
- if (pos < 0) {
- insertNode(className, refTy);
- } else {
- String head = className.substring(0, pos);
- String tail = className.substring(pos + 1);
- ClassTreeNode child = insertNode(head, null);
- child.addClass(tail, refTy);
- }
- }
-
- private ClassTreeNode insertNode(String name, ReferenceType refTy) {
- for (int i = 0; i < getChildCount(); i++) {
- ClassTreeNode child = (ClassTreeNode)getChildAt(i);
- int cmp = name.compareTo(child.toString());
- if (cmp == 0) {
- // like-named node already exists
- return child;
- } else if (cmp < 0) {
- // insert new node before the child
- ClassTreeNode newChild = new ClassTreeNode(name, refTy);
- treeModel.insertNodeInto(newChild, this, i);
- return newChild;
- }
- }
- // insert new node after last child
- ClassTreeNode newChild = new ClassTreeNode(name, refTy);
- treeModel.insertNodeInto(newChild, this, getChildCount());
- return newChild;
- }
-
- public void removeClass(String className) {
- if (className.equals("")) {
- return;
- }
- int pos = className.indexOf('.');
- if (pos < 0) {
- ClassTreeNode child = findNode(className);
- if (!isPackage()) {
- treeModel.removeNodeFromParent(child);
- }
- } else {
- String head = className.substring(0, pos);
- String tail = className.substring(pos + 1);
- ClassTreeNode child = findNode(head);
- child.removeClass(tail);
- if (isPackage() && child.getChildCount() < 1) {
- // Prune non-leaf nodes with no children.
- treeModel.removeNodeFromParent(child);
- }
- }
- }
-
- private ClassTreeNode findNode(String name) {
- for (int i = 0; i < getChildCount(); i++) {
- ClassTreeNode child = (ClassTreeNode)getChildAt(i);
- int cmp = name.compareTo(child.toString());
- if (cmp == 0) {
- return child;
- } else if (cmp > 0) {
- // not found, since children are sorted
- return null;
- }
- }
- return null;
- }
-
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java
deleted file mode 100644
index fbff95b2703..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandInterpreter.java
+++ /dev/null
@@ -1,1468 +0,0 @@
-/*
- * Copyright (c) 1998, 2013, 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.bdi.*;
-
-public class CommandInterpreter {
-
- boolean echo;
-
- Environment env;
-
- private ContextManager context;
- private ExecutionManager runtime;
- private ClassManager classManager;
- private SourceManager sourceManager;
-
- private OutputSink out; //### Hack! Should be local in each method used.
- private String lastCommand = "help";
-
- public CommandInterpreter(Environment env) {
- this(env, true);
- }
-
- public CommandInterpreter(Environment env, boolean echo) {
- this.env = env;
- this.echo = echo;
- this.runtime = env.getExecutionManager();
- this.context = env.getContextManager();
- this.classManager = env.getClassManager();
- this.sourceManager = env.getSourceManager();
- }
-
- private ThreadReference[] threads = null;
-
- /*
- * The numbering of threads is relative to the current set of threads,
- * and may be affected by the creation and termination of new threads.
- * Commands issued using such thread ids will only give reliable behavior
- * relative to what was shown earlier in 'list' commands if the VM is interrupted.
- * We need a better scheme.
- */
-
- private ThreadReference[] threads() throws NoSessionException {
- if (threads == null) {
- ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup());
- List tlist = new ArrayList();
- while (ti.hasNext()) {
- tlist.add(ti.nextThread());
- }
- threads = tlist.toArray(new ThreadReference[tlist.size()]);
- }
- return threads;
- }
-
- private ThreadReference findThread(String idToken) throws NoSessionException {
- String id;
- ThreadReference thread = null;
- if (idToken.startsWith("t@")) {
- id = idToken.substring(2);
- } else {
- id = idToken;
- }
- try {
- ThreadReference[] threads = threads();
- long threadID = Long.parseLong(id, 16);
- for (ThreadReference thread2 : threads) {
- if (thread2.uniqueID() == threadID) {
- thread = thread2;
- break;
- }
- }
- if (thread == null) {
- //env.failure("No thread for id \"" + idToken + "\"");
- env.failure("\"" + idToken + "\" is not a valid thread id.");
- }
- } catch (NumberFormatException e) {
- env.error("Thread id \"" + idToken + "\" is ill-formed.");
- thread = null;
- }
- return thread;
- }
-
- private ThreadIterator allThreads() throws NoSessionException {
- threads = null;
- //### Why not use runtime.allThreads().iterator() ?
- return new ThreadIterator(runtime.topLevelThreadGroups());
- }
-
- private ThreadIterator currentThreadGroupThreads() throws NoSessionException {
- threads = null;
- return new ThreadIterator(getDefaultThreadGroup());
- }
-
- private ThreadGroupIterator allThreadGroups() throws NoSessionException {
- threads = null;
- return new ThreadGroupIterator(runtime.topLevelThreadGroups());
- }
-
- private ThreadGroupReference defaultThreadGroup;
-
- private ThreadGroupReference getDefaultThreadGroup() throws NoSessionException {
- if (defaultThreadGroup == null) {
- defaultThreadGroup = runtime.systemThreadGroup();
- }
- return defaultThreadGroup;
- }
-
- private void setDefaultThreadGroup(ThreadGroupReference tg) {
- defaultThreadGroup = tg;
- }
-
- /*
- * Command handlers.
- */
-
- // Command: classes
-
- private void commandClasses() throws NoSessionException {
- OutputSink out = env.getOutputSink();
- //out.println("** classes list **");
- for (ReferenceType refType : runtime.allClasses()) {
- out.println(refType.name());
- }
- out.show();
- }
-
-
- // Command: methods
-
- private void commandMethods(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- env.error("No class specified.");
- return;
- }
- String idClass = t.nextToken();
- ReferenceType cls = findClass(idClass);
- if (cls != null) {
- List methods = cls.allMethods();
- OutputSink out = env.getOutputSink();
- for (int i = 0; i < methods.size(); i++) {
- Method method = methods.get(i);
- out.print(method.declaringType().name() + " " +
- method.name() + "(");
- Iterator it = method.argumentTypeNames().iterator();
- if (it.hasNext()) {
- while (true) {
- out.print(it.next());
- if (!it.hasNext()) {
- break;
- }
- out.print(", ");
- }
- }
- out.println(")");
- }
- out.show();
- } else {
- //### Should validate class name syntax.
- env.failure("\"" + idClass + "\" is not a valid id or class name.");
- }
- }
-
- private ReferenceType findClass(String pattern) throws NoSessionException {
- List results = runtime.findClassesMatchingPattern(pattern);
- if (results.size() > 0) {
- //### Should handle multiple results sensibly.
- return results.get(0);
- }
- return null;
- }
-
- // Command: threads
-
- private void commandThreads(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- OutputSink out = env.getOutputSink();
- printThreadGroup(out, getDefaultThreadGroup(), 0);
- out.show();
- return;
- }
- String name = t.nextToken();
- ThreadGroupReference tg = findThreadGroup(name);
- if (tg == null) {
- env.failure(name + " is not a valid threadgroup name.");
- } else {
- OutputSink out = env.getOutputSink();
- printThreadGroup(out, tg, 0);
- out.show();
- }
- }
-
- private ThreadGroupReference findThreadGroup(String name) throws NoSessionException {
- //### Issue: Uniqueness of thread group names is not enforced.
- ThreadGroupIterator tgi = allThreadGroups();
- while (tgi.hasNext()) {
- ThreadGroupReference tg = tgi.nextThreadGroup();
- if (tg.name().equals(name)) {
- return tg;
- }
- }
- return null;
- }
-
- private int printThreadGroup(OutputSink out, ThreadGroupReference tg, int iThread) {
- out.println("Group " + tg.name() + ":");
- List tlist = tg.threads();
- int maxId = 0;
- int maxName = 0;
- for (int i = 0 ; i < tlist.size() ; i++) {
- ThreadReference thr = tlist.get(i);
- int len = Utils.description(thr).length();
- if (len > maxId) {
- maxId = len;
- }
- String name = thr.name();
- int iDot = name.lastIndexOf('.');
- if (iDot >= 0 && name.length() > iDot) {
- name = name.substring(iDot + 1);
- }
- if (name.length() > maxName) {
- maxName = name.length();
- }
- }
- String maxNumString = String.valueOf(iThread + tlist.size());
- int maxNumDigits = maxNumString.length();
- for (int i = 0 ; i < tlist.size() ; i++) {
- ThreadReference thr = tlist.get(i);
- char buf[] = new char[80];
- for (int j = 0; j < 79; j++) {
- buf[j] = ' ';
- }
- buf[79] = '\0';
- StringBuilder sbOut = new StringBuilder();
- sbOut.append(buf);
-
- // Right-justify the thread number at start of output string
- String numString = String.valueOf(iThread + i + 1);
- sbOut.insert(maxNumDigits - numString.length(),
- numString);
- sbOut.insert(maxNumDigits, ".");
-
- int iBuf = maxNumDigits + 2;
- sbOut.insert(iBuf, Utils.description(thr));
- iBuf += maxId + 1;
- String name = thr.name();
- int iDot = name.lastIndexOf('.');
- if (iDot >= 0 && name.length() > iDot) {
- name = name.substring(iDot + 1);
- }
- sbOut.insert(iBuf, name);
- iBuf += maxName + 1;
- sbOut.insert(iBuf, Utils.getStatus(thr));
- sbOut.setLength(79);
- out.println(sbOut.toString());
- }
- for (ThreadGroupReference tg0 : tg.threadGroups()) {
- if (!tg.equals(tg0)) { // TODO ref mgt
- iThread += printThreadGroup(out, tg0, iThread + tlist.size());
- }
- }
- return tlist.size();
- }
-
- // Command: threadgroups
-
- private void commandThreadGroups() throws NoSessionException {
- ThreadGroupIterator it = allThreadGroups();
- int cnt = 0;
- OutputSink out = env.getOutputSink();
- while (it.hasNext()) {
- ThreadGroupReference tg = it.nextThreadGroup();
- ++cnt;
- out.println("" + cnt + ". " + Utils.description(tg) + " " + tg.name());
- }
- out.show();
- }
-
- // Command: thread
-
- private void commandThread(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- env.error("Thread number not specified.");
- return;
- }
- ThreadReference thread = findThread(t.nextToken());
- if (thread != null) {
- //### Should notify user.
- context.setCurrentThread(thread);
- }
- }
-
- // Command: threadgroup
-
- private void commandThreadGroup(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- env.error("Threadgroup name not specified.");
- return;
- }
- String name = t.nextToken();
- ThreadGroupReference tg = findThreadGroup(name);
- if (tg == null) {
- env.failure(name + " is not a valid threadgroup name.");
- } else {
- //### Should notify user.
- setDefaultThreadGroup(tg);
- }
- }
-
- // Command: run
-
- private void commandRun(StringTokenizer t) throws NoSessionException {
- if (doLoad(false, t)) {
- env.notice("Running ...");
- }
- }
-
- // Command: load
-
- private void commandLoad(StringTokenizer t) throws NoSessionException {
- if (doLoad(true, t)) {}
- }
-
- private boolean doLoad(boolean suspended,
- StringTokenizer t) throws NoSessionException {
-
- String clname;
-
- if (!t.hasMoreTokens()) {
- clname = context.getMainClassName();
- if (!clname.equals("")) {
- // Run from prevously-set class name.
- try {
- String vmArgs = context.getVmArguments();
- runtime.run(suspended,
- vmArgs,
- clname,
- context.getProgramArguments());
- return true;
- } catch (VMLaunchFailureException e) {
- env.failure("Attempt to launch main class \"" + clname + "\" failed.");
- }
- } else {
- env.failure("No main class specified and no current default defined.");
- }
- } else {
- clname = t.nextToken();
- StringBuilder str = new StringBuilder();
- // Allow VM arguments to be specified here?
- while (t.hasMoreTokens()) {
- String tok = t.nextToken();
- str.append(tok);
- if (t.hasMoreTokens()) {
- str.append(' ');
- }
- }
- String args = str.toString();
- try {
- String vmArgs = context.getVmArguments();
- runtime.run(suspended, vmArgs, clname, args);
- context.setMainClassName(clname);
- //context.setVmArguments(vmArgs);
- context.setProgramArguments(args);
- return true;
- } catch (VMLaunchFailureException e) {
- env.failure("Attempt to launch main class \"" + clname + "\" failed.");
- }
- }
- return false;
- }
-
- // Command: connect
-
- private void commandConnect(StringTokenizer t) {
- try {
- LaunchTool.queryAndLaunchVM(runtime);
- } catch (VMLaunchFailureException e) {
- env.failure("Attempt to connect failed.");
- }
- }
-
- // Command: attach
-
- private void commandAttach(StringTokenizer t) {
- String portName;
- if (!t.hasMoreTokens()) {
- portName = context.getRemotePort();
- if (!portName.equals("")) {
- try {
- runtime.attach(portName);
- } catch (VMLaunchFailureException e) {
- env.failure("Attempt to attach to port \"" + portName + "\" failed.");
- }
- } else {
- env.failure("No port specified and no current default defined.");
- }
- } else {
- portName = t.nextToken();
- try {
- runtime.attach(portName);
- } catch (VMLaunchFailureException e) {
- env.failure("Attempt to attach to port \"" + portName + "\" failed.");
- }
- context.setRemotePort(portName);
- }
- }
-
- // Command: detach
-
- private void commandDetach(StringTokenizer t) throws NoSessionException {
- runtime.detach();
- }
-
- // Command: interrupt
-
- private void commandInterrupt(StringTokenizer t) throws NoSessionException {
- runtime.interrupt();
- }
-
- // Command: suspend
-
- private void commandSuspend(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- // Suspend all threads in the current thread group.
- //### Issue: help message says default is all threads.
- //### Behavior here agrees with 'jdb', however.
- ThreadIterator ti = currentThreadGroupThreads();
- while (ti.hasNext()) {
- // TODO - don't suspend debugger threads
- ti.nextThread().suspend();
- }
- env.notice("All (non-system) threads suspended.");
- } else {
- while (t.hasMoreTokens()) {
- ThreadReference thread = findThread(t.nextToken());
- if (thread != null) {
- //thread.suspend();
- runtime.suspendThread(thread);
- }
- }
- }
- }
-
- // Command: resume
-
- private void commandResume(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- // Suspend all threads in the current thread group.
- //### Issue: help message says default is all threads.
- //### Behavior here agrees with 'jdb', however.
- ThreadIterator ti = currentThreadGroupThreads();
- while (ti.hasNext()) {
- // TODO - don't suspend debugger threads
- ti.nextThread().resume();
- }
- env.notice("All threads resumed.");
- } else {
- while (t.hasMoreTokens()) {
- ThreadReference thread = findThread(t.nextToken());
- if (thread != null) {
- //thread.resume();
- runtime.resumeThread(thread);
- }
- }
- }
- }
-
- // Command: cont
-
- private void commandCont() throws NoSessionException {
- try {
- runtime.go();
- } catch (VMNotInterruptedException e) {
- //### failure?
- env.notice("Target VM is already running.");
- }
- }
-
- // Command: step
-
- private void commandStep(StringTokenizer t) throws NoSessionException{
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- try {
- if (t.hasMoreTokens() &&
- t.nextToken().toLowerCase().equals("up")) {
- runtime.stepOut(current);
- } else {
- runtime.stepIntoLine(current);
- }
- } catch (AbsentInformationException e) {
- env.failure("No linenumber information available -- " +
- "Try \"stepi\" to step by instructions.");
- }
- }
-
- // Command: stepi
-
- private void commandStepi() throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- runtime.stepIntoInstruction(current);
- }
-
- // Command: next
-
- private void commandNext() throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- try {
- runtime.stepOverLine(current);
- } catch (AbsentInformationException e) {
- env.failure("No linenumber information available -- " +
- "Try \"nexti\" to step by instructions.");
- }
- }
-
- // Command: nexti (NEW)
-
- private void commandNexti() throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- runtime.stepOverInstruction(current);
- }
-
- // Command: kill
-
- private void commandKill(StringTokenizer t) throws NoSessionException {
- //### Should change the way in which thread ids and threadgroup names
- //### are distinguished.
- if (!t.hasMoreTokens()) {
- env.error("Usage: kill or ");
- return;
- }
- while (t.hasMoreTokens()) {
- String idToken = t.nextToken();
- ThreadReference thread = findThread(idToken);
- if (thread != null) {
- runtime.stopThread(thread);
- env.notice("Thread " + thread.name() + " killed.");
- return;
- } else {
- /* Check for threadgroup name, NOT skipping "system". */
- //### Should skip "system"? Classic 'jdb' does this.
- //### Should deal with possible non-uniqueness of threadgroup names.
- ThreadGroupIterator itg = allThreadGroups();
- while (itg.hasNext()) {
- ThreadGroupReference tg = itg.nextThreadGroup();
- if (tg.name().equals(idToken)) {
- ThreadIterator it = new ThreadIterator(tg);
- while (it.hasNext()) {
- runtime.stopThread(it.nextThread());
- }
- env.notice("Threadgroup " + tg.name() + "killed.");
- return;
- }
- }
- env.failure("\"" + idToken +
- "\" is not a valid threadgroup or id.");
- }
- }
- }
-
-
- /*************
- // TODO
- private void commandCatchException(StringTokenizer t) throws NoSessionException {}
- // TODO
- private void commandIgnoreException(StringTokenizer t) throws NoSessionException {}
- *************/
-
- // Command: up
-
- //### Print current frame after command?
-
- int readCount(StringTokenizer t) {
- int cnt = 1;
- if (t.hasMoreTokens()) {
- String idToken = t.nextToken();
- try {
- cnt = Integer.valueOf(idToken).intValue();
- } catch (NumberFormatException e) {
- cnt = -1;
- }
- }
- return cnt;
- }
-
- void commandUp(StringTokenizer t) throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- int nLevels = readCount(t);
- if (nLevels <= 0) {
- env.error("usage: up [n frames]");
- return;
- }
- try {
- int delta = context.moveCurrentFrameIndex(current, -nLevels);
- if (delta == 0) {
- env.notice("Already at top of stack.");
- } else if (-delta < nLevels) {
- env.notice("Moved up " + delta + " frames to top of stack.");
- }
- } catch (VMNotInterruptedException e) {
- env.failure("Target VM must be in interrupted state.");
- }
- }
-
- private void commandDown(StringTokenizer t) throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- int nLevels = readCount(t);
- if (nLevels <= 0) {
- env.error("usage: down [n frames]");
- return;
- }
- try {
- int delta = context.moveCurrentFrameIndex(current, nLevels);
- if (delta == 0) {
- env.notice("Already at bottom of stack.");
- } else if (delta < nLevels) {
- env.notice("Moved down " + delta + " frames to bottom of stack.");
- }
- } catch (VMNotInterruptedException e) {
- env.failure("Target VM must be in interrupted state.");
- }
- }
-
- // Command: frame
-
- private void commandFrame(StringTokenizer t) throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No current thread.");
- return;
- }
- if (!t.hasMoreTokens()) {
- env.error("usage: frame ");
- return;
- }
- String idToken = t.nextToken();
- int n;
- try {
- n = Integer.valueOf(idToken).intValue();
- } catch (NumberFormatException e) {
- n = 0;
- }
- if (n <= 0) {
- env.error("use positive frame index");
- return;
- }
- try {
- int delta = context.setCurrentFrameIndex(current, n);
- if (delta == 0) {
- env.notice("Frame unchanged.");
- } else if (delta < 0) {
- env.notice("Moved up " + -delta + " frames.");
- } else {
- env.notice("Moved down " + delta + " frames.");
- }
- } catch (VMNotInterruptedException e) {
- env.failure("Target VM must be in interrupted state.");
- }
- }
-
- // Command: where
-
- //### Should we insist that VM be interrupted here?
- //### There is an inconsistency between the 'where' command
- //### and 'up' and 'down' in this respect.
-
- private void commandWhere(StringTokenizer t, boolean showPC)
- throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (!t.hasMoreTokens()) {
- if (current == null) {
- env.error("No thread specified.");
- return;
- }
- dumpStack(current, showPC);
- } else {
- String token = t.nextToken();
- if (token.toLowerCase().equals("all")) {
- ThreadIterator it = allThreads();
- while (it.hasNext()) {
- ThreadReference thread = it.next();
- out.println(thread.name() + ": ");
- dumpStack(thread, showPC);
- }
- } else {
- ThreadReference thread = findThread(t.nextToken());
- //### Do we want to set current thread here?
- //### Should notify user of change.
- if (thread != null) {
- context.setCurrentThread(thread);
- }
- dumpStack(thread, showPC);
- }
- }
- }
-
- private void dumpStack(ThreadReference thread, boolean showPC) {
- //### Check for these.
- //env.failure("Thread no longer exists.");
- //env.failure("Target VM must be in interrupted state.");
- //env.failure("Current thread isn't suspended.");
- //### Should handle extremely long stack traces sensibly for user.
- List stack = null;
- try {
- stack = thread.frames();
- } catch (IncompatibleThreadStateException e) {
- env.failure("Thread is not suspended.");
- }
- //### Fix this!
- //### Previously mishandled cases where thread was not current.
- //### Now, prints all of the stack regardless of current frame.
- int frameIndex = 0;
- //int frameIndex = context.getCurrentFrameIndex();
- if (stack == null) {
- env.failure("Thread is not running (no stack).");
- } else {
- OutputSink out = env.getOutputSink();
- int nFrames = stack.size();
- for (int i = frameIndex; i < nFrames; i++) {
- StackFrame frame = stack.get(i);
- Location loc = frame.location();
- Method meth = loc.method();
- out.print(" [" + (i + 1) + "] ");
- out.print(meth.declaringType().name());
- out.print('.');
- out.print(meth.name());
- out.print(" (");
- if (meth.isNative()) {
- out.print("native method");
- } else if (loc.lineNumber() != -1) {
- try {
- out.print(loc.sourceName());
- } catch (AbsentInformationException e) {
- out.print("");
- }
- out.print(':');
- out.print(loc.lineNumber());
- }
- out.print(')');
- if (showPC) {
- long pc = loc.codeIndex();
- if (pc != -1) {
- out.print(", pc = " + pc);
- }
- }
- out.println();
- }
- out.show();
- }
- }
-
- private void listEventRequests() throws NoSessionException {
- // Print set breakpoints
- List specs = runtime.eventRequestSpecs();
- if (specs.isEmpty()) {
- env.notice("No breakpoints/watchpoints/exceptions set.");
- } else {
- OutputSink out = env.getOutputSink();
- out.println("Current breakpoints/watchpoints/exceptions set:");
- for (EventRequestSpec bp : specs) {
- out.println("\t" + bp);
- }
- out.show();
- }
- }
-
- private BreakpointSpec parseBreakpointSpec(String bptSpec) {
- StringTokenizer t = new StringTokenizer(bptSpec);
- BreakpointSpec bpSpec = null;
-// try {
- String token = t.nextToken("@:( \t\n\r");
- // We can't use hasMoreTokens here because it will cause any leading
- // paren to be lost.
- String rest;
- try {
- rest = t.nextToken("").trim();
- } catch (NoSuchElementException e) {
- rest = null;
- }
- if ((rest != null) && rest.startsWith("@")) {
- t = new StringTokenizer(rest.substring(1));
- String sourceName = token;
- String lineToken = t.nextToken();
- int lineNumber = Integer.valueOf(lineToken).intValue();
- if (t.hasMoreTokens()) {
- return null;
- }
- bpSpec = runtime.createSourceLineBreakpoint(sourceName,
- lineNumber);
- } else if ((rest != null) && rest.startsWith(":")) {
- t = new StringTokenizer(rest.substring(1));
- String classId = token;
- String lineToken = t.nextToken();
- int lineNumber = Integer.valueOf(lineToken).intValue();
- if (t.hasMoreTokens()) {
- return null;
- }
- bpSpec = runtime.createClassLineBreakpoint(classId, lineNumber);
- } else {
- // Try stripping method from class.method token.
- int idot = token.lastIndexOf('.');
- if ( (idot <= 0) || /* No dot or dot in first char */
- (idot >= token.length() - 1) ) { /* dot in last char */
- return null;
- }
- String methodName = token.substring(idot + 1);
- String classId = token.substring(0, idot);
- List argumentList = null;
- if (rest != null) {
- if (!rest.startsWith("(") || !rest.endsWith(")")) {
- //### Should throw exception with error message
- //out.println("Invalid method specification: "
- // + methodName + rest);
- return null;
- }
- // Trim the parens
- //### What about spaces in arglist?
- rest = rest.substring(1, rest.length() - 1);
- argumentList = new ArrayList();
- t = new StringTokenizer(rest, ",");
- while (t.hasMoreTokens()) {
- argumentList.add(t.nextToken());
- }
- }
- bpSpec = runtime.createMethodBreakpoint(classId,
- methodName,
- argumentList);
- }
-// } catch (Exception e) {
-// env.error("Exception attempting to create breakpoint: " + e);
-// return null;
-// }
- return bpSpec;
- }
-
- private void commandStop(StringTokenizer t) throws NoSessionException {
- String token;
-
- if (!t.hasMoreTokens()) {
- listEventRequests();
- } else {
- token = t.nextToken();
- // Ignore optional "at" or "in" token.
- // Allowed for backward compatibility.
- if (token.equals("at") || token.equals("in")) {
- if (t.hasMoreTokens()) {
- token = t.nextToken();
- } else {
- env.error("Missing breakpoint specification.");
- return;
- }
- }
- BreakpointSpec bpSpec = parseBreakpointSpec(token);
- if (bpSpec != null) {
- //### Add sanity-checks for deferred breakpoint.
- runtime.install(bpSpec);
- } else {
- env.error("Ill-formed breakpoint specification.");
- }
- }
- }
-
- private void commandClear(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- // Print set breakpoints
- listEventRequests();
- return;
- }
- //### need 'clear all'
- BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
- if (bpSpec != null) {
- List specs = runtime.eventRequestSpecs();
-
- if (specs.isEmpty()) {
- env.notice("No breakpoints set.");
- } else {
- List toDelete = new ArrayList();
- for (EventRequestSpec spec : specs) {
- if (spec.equals(bpSpec)) {
- toDelete.add(spec);
- }
- }
- // The request used for matching should be found
- if (toDelete.size() <= 1) {
- env.notice("No matching breakpoint set.");
- }
- for (EventRequestSpec spec : toDelete) {
- runtime.delete(spec);
- }
- }
- } else {
- env.error("Ill-formed breakpoint specification.");
- }
- }
-
- // Command: list
-
- private void commandList(StringTokenizer t) throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.error("No thread specified.");
- return;
- }
- Location loc;
- try {
- StackFrame frame = context.getCurrentFrame(current);
- if (frame == null) {
- env.failure("Thread has not yet begun execution.");
- return;
- }
- loc = frame.location();
- } catch (VMNotInterruptedException e) {
- env.failure("Target VM must be in interrupted state.");
- return;
- }
- SourceModel source = sourceManager.sourceForLocation(loc);
- if (source == null) {
- if (loc.method().isNative()) {
- env.failure("Current method is native.");
- return;
- }
- env.failure("No source available for " + Utils.locationString(loc) + ".");
- return;
- }
- ReferenceType refType = loc.declaringType();
- int lineno = loc.lineNumber();
- if (t.hasMoreTokens()) {
- String id = t.nextToken();
- // See if token is a line number.
- try {
- lineno = Integer.valueOf(id).intValue();
- } catch (NumberFormatException nfe) {
- // It isn't -- see if it's a method name.
- List meths = refType.methodsByName(id);
- if (meths == null || meths.size() == 0) {
- env.failure(id +
- " is not a valid line number or " +
- "method name for class " +
- refType.name());
- return;
- } else if (meths.size() > 1) {
- env.failure(id +
- " is an ambiguous method name in" +
- refType.name());
- return;
- }
- loc = meths.get(0).location();
- lineno = loc.lineNumber();
- }
- }
- int startLine = (lineno > 4) ? lineno - 4 : 1;
- int endLine = startLine + 9;
- String sourceLine = source.sourceLine(lineno);
- if (sourceLine == null) {
- env.failure("" +
- lineno +
- " is an invalid line number for " +
- refType.name());
- } else {
- OutputSink out = env.getOutputSink();
- for (int i = startLine; i <= endLine; i++) {
- sourceLine = source.sourceLine(i);
- if (sourceLine == null) {
- break;
- }
- out.print(i);
- out.print("\t");
- if (i == lineno) {
- out.print("=> ");
- } else {
- out.print(" ");
- }
- out.println(sourceLine);
- }
- out.show();
- }
- }
-
- // Command: use
- // Get or set the source file path list.
-
- private void commandUse(StringTokenizer t) {
- if (!t.hasMoreTokens()) {
- out.println(sourceManager.getSourcePath().asString());
- } else {
- //### Should throw exception for invalid path.
- //### E.g., vetoable property change.
- sourceManager.setSourcePath(new SearchPath(t.nextToken()));
- }
- }
-
- // Command: sourcepath
- // Get or set the source file path list. (Alternate to 'use'.)
-
- private void commandSourcepath(StringTokenizer t) {
- if (!t.hasMoreTokens()) {
- out.println(sourceManager.getSourcePath().asString());
- } else {
- //### Should throw exception for invalid path.
- //### E.g., vetoable property change.
- sourceManager.setSourcePath(new SearchPath(t.nextToken()));
- }
- }
-
- // Command: classpath
- // Get or set the class file path list.
-
- private void commandClasspath(StringTokenizer t) {
- if (!t.hasMoreTokens()) {
- out.println(classManager.getClassPath().asString());
- } else {
- //### Should throw exception for invalid path.
- //### E.g., vetoable property change.
- classManager.setClassPath(new SearchPath(t.nextToken()));
- }
- }
-
- // Command: view
- // Display source for source file or class.
-
- private void commandView(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- env.error("Argument required");
- } else {
- String name = t.nextToken();
- if (name.endsWith(".java") ||
- name.indexOf(File.separatorChar) >= 0) {
- env.viewSource(name);
- } else {
- //### JDI crashes taking line number for class.
- /*****
- ReferenceType cls = findClass(name);
- if (cls != null) {
- env.viewLocation(cls.location());
- } else {
- env.failure("No such class");
- }
- *****/
- String fileName = name.replace('.', File.separatorChar) + ".java";
- env.viewSource(fileName);
- }
- }
- }
-
- // Command: locals
- // Print all local variables in current stack frame.
-
- private void commandLocals() throws NoSessionException {
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No default thread specified: " +
- "use the \"thread\" command first.");
- return;
- }
- StackFrame frame;
- try {
- frame = context.getCurrentFrame(current);
- if (frame == null) {
- env.failure("Thread has not yet created any stack frames.");
- return;
- }
- } catch (VMNotInterruptedException e) {
- env.failure("Target VM must be in interrupted state.");
- return;
- }
-
- List vars;
- try {
- vars = frame.visibleVariables();
- if (vars == null || vars.size() == 0) {
- env.failure("No local variables");
- return;
- }
- } catch (AbsentInformationException e) {
- env.failure("Local variable information not available." +
- " Compile with -g to generate variable information");
- return;
- }
-
- OutputSink out = env.getOutputSink();
- out.println("Method arguments:");
- for (LocalVariable var : vars) {
- if (var.isArgument()) {
- printVar(out, var, frame);
- }
- }
- out.println("Local variables:");
- for (LocalVariable var : vars) {
- if (!var.isArgument()) {
- printVar(out, var, frame);
- }
- }
- out.show();
- return;
- }
-
- /**
- * Command: monitor
- * Monitor an expression
- */
- private void commandMonitor(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- env.error("Argument required");
- } else {
- env.getMonitorListModel().add(t.nextToken(""));
- }
- }
-
- /**
- * Command: unmonitor
- * Unmonitor an expression
- */
- private void commandUnmonitor(StringTokenizer t) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- env.error("Argument required");
- } else {
- env.getMonitorListModel().remove(t.nextToken(""));
- }
- }
-
- // Print a stack variable.
-
- private void printVar(OutputSink out, LocalVariable var, StackFrame frame) {
- out.print(" " + var.name());
- if (var.isVisible(frame)) {
- Value val = frame.getValue(var);
- out.println(" = " + val.toString());
- } else {
- out.println(" is not in scope");
- }
- }
-
- // Command: print
- // Evaluate an expression.
-
- private void commandPrint(StringTokenizer t, boolean dumpObject) throws NoSessionException {
- if (!t.hasMoreTokens()) {
- //### Probably confused if expresion contains whitespace.
- env.error("No expression specified.");
- return;
- }
- ThreadReference current = context.getCurrentThread();
- if (current == null) {
- env.failure("No default thread specified: " +
- "use the \"thread\" command first.");
- return;
- }
- StackFrame frame;
- try {
- frame = context.getCurrentFrame(current);
- if (frame == null) {
- env.failure("Thread has not yet created any stack frames.");
- return;
- }
- } catch (VMNotInterruptedException e) {
- env.failure("Target VM must be in interrupted state.");
- return;
- }
- while (t.hasMoreTokens()) {
- String expr = t.nextToken("");
- Value val = null;
- try {
- val = runtime.evaluate(frame, expr);
- } catch(Exception e) {
- env.error("Exception: " + e);
- //### Fix this!
- }
- if (val == null) {
- return; // Error message already printed
- }
- OutputSink out = env.getOutputSink();
- if (dumpObject && (val instanceof ObjectReference) &&
- !(val instanceof StringReference)) {
- ObjectReference obj = (ObjectReference)val;
- ReferenceType refType = obj.referenceType();
- out.println(expr + " = " + val.toString() + " {");
- dump(out, obj, refType, refType);
- out.println("}");
- } else {
- out.println(expr + " = " + val.toString());
- }
- out.show();
- }
- }
-
- private void dump(OutputSink out,
- ObjectReference obj, ReferenceType refType,
- ReferenceType refTypeBase) {
- for (Field field : refType.fields()) {
- out.print(" ");
- if (!refType.equals(refTypeBase)) {
- out.print(refType.name() + ".");
- }
- out.print(field.name() + ": ");
- Object o = obj.getValue(field);
- out.println((o == null) ? "null" : o.toString()); // Bug ID 4374471
- }
- if (refType instanceof ClassType) {
- ClassType sup = ((ClassType)refType).superclass();
- if (sup != null) {
- dump(out, obj, sup, refTypeBase);
- }
- } else if (refType instanceof InterfaceType) {
- for (InterfaceType sup : ((InterfaceType)refType).superinterfaces()) {
- dump(out, obj, sup, refTypeBase);
- }
- }
- }
-
- /*
- * Display help message.
- */
-
- private void help() {
- out.println("** command list **");
- out.println("threads [threadgroup] -- list threads");
- out.println("thread -- set default thread");
- out.println("suspend [thread id(s)] -- suspend threads (default: all)");
- out.println("resume [thread id(s)] -- resume threads (default: all)");
- out.println("where [thread id] | all -- dump a thread's stack");
- out.println("wherei [thread id] | all -- dump a thread's stack, with pc info");
- out.println("threadgroups -- list threadgroups");
- out.println("threadgroup -- set current threadgroup\n");
-// out.println("print -- print value of expression");
- out.println("dump -- print all object information\n");
-// out.println("eval -- evaluate expression (same as print)");
- out.println("locals -- print all local variables in current stack frame\n");
- out.println("classes -- list currently known classes");
- out.println("methods -- list a class's methods\n");
- out.println("stop [in] .[(argument_type,...)] -- set a breakpoint in a method");
- out.println("stop [at] : -- set a breakpoint at a line");
- out.println("up [n frames] -- move up a thread's stack");
- out.println("down [n frames] -- move down a thread's stack");
- out.println("frame -- to a frame");
- out.println("clear .[(argument_type,...)] -- clear a breakpoint in a method");
- out.println("clear : -- clear a breakpoint at a line");
- out.println("clear -- list breakpoints");
- out.println("step -- execute current line");
- out.println("step up -- execute until the current method returns to its caller");
- out.println("stepi -- execute current instruction");
- out.println("next -- step one line (step OVER calls)");
- out.println("nexti -- step one instruction (step OVER calls)");
- out.println("cont -- continue execution from breakpoint\n");
-// out.println("catch -- break for the specified exception");
-// out.println("ignore -- ignore when the specified exception\n");
- out.println("view classname|filename -- display source file");
- out.println("list [line number|method] -- print source code context at line or method");
- out.println("use -- display or change the source path\n");
-//### new
- out.println("sourcepath -- display or change the source path\n");
-//### new
- out.println("classpath -- display or change the class path\n");
- out.println("monitor -- evaluate an expression each time the program stops\n");
- out.println("unmonitor -- delete a monitor\n");
- out.println("read -- read and execute a command file\n");
-// out.println("memory -- report memory usage");
-// out.println("gc -- free unused objects\n");
- out.println("run [args] -- start execution of a Java class");
- out.println("run -- re-execute last class run");
- out.println("load [args] -- start execution of a Java class, initially suspended");
- out.println("load -- re-execute last class run, initially suspended");
- out.println("attach -- debug existing process\n");
- out.println("detach -- detach from debuggee process\n");
- out.println("kill -- kill a thread or threadgroup\n");
- out.println("!! -- repeat last command");
- out.println("help (or ?) -- list commands");
- out.println("exit (or quit) -- exit debugger");
- }
-
- /*
- * Execute a command.
- */
-
- public void executeCommand(String command) {
- //### Treatment of 'out' here is dirty...
- out = env.getOutputSink();
- if (echo) {
- out.println(">>> " + command);
- }
- StringTokenizer t = new StringTokenizer(command);
- try {
- String cmd;
- if (t.hasMoreTokens()) {
- cmd = t.nextToken().toLowerCase();
- lastCommand = cmd;
- } else {
- cmd = lastCommand;
- }
- if (cmd.equals("print")) {
- commandPrint(t, false);
- } else if (cmd.equals("eval")) {
- commandPrint(t, false);
- } else if (cmd.equals("dump")) {
- commandPrint(t, true);
- } else if (cmd.equals("locals")) {
- commandLocals();
- } else if (cmd.equals("classes")) {
- commandClasses();
- } else if (cmd.equals("methods")) {
- commandMethods(t);
- } else if (cmd.equals("threads")) {
- commandThreads(t);
- } else if (cmd.equals("thread")) {
- commandThread(t);
- } else if (cmd.equals("suspend")) {
- commandSuspend(t);
- } else if (cmd.equals("resume")) {
- commandResume(t);
- } else if (cmd.equals("cont")) {
- commandCont();
- } else if (cmd.equals("threadgroups")) {
- commandThreadGroups();
- } else if (cmd.equals("threadgroup")) {
- commandThreadGroup(t);
- } else if (cmd.equals("run")) {
- commandRun(t);
- } else if (cmd.equals("load")) {
- commandLoad(t);
- } else if (cmd.equals("connect")) {
- commandConnect(t);
- } else if (cmd.equals("attach")) {
- commandAttach(t);
- } else if (cmd.equals("detach")) {
- commandDetach(t);
- } else if (cmd.equals("interrupt")) {
- commandInterrupt(t);
-//### Not implemented.
-// } else if (cmd.equals("catch")) {
-// commandCatchException(t);
-//### Not implemented.
-// } else if (cmd.equals("ignore")) {
-// commandIgnoreException(t);
- } else if (cmd.equals("step")) {
- commandStep(t);
- } else if (cmd.equals("stepi")) {
- commandStepi();
- } else if (cmd.equals("next")) {
- commandNext();
- } else if (cmd.equals("nexti")) {
- commandNexti();
- } else if (cmd.equals("kill")) {
- commandKill(t);
- } else if (cmd.equals("where")) {
- commandWhere(t, false);
- } else if (cmd.equals("wherei")) {
- commandWhere(t, true);
- } else if (cmd.equals("up")) {
- commandUp(t);
- } else if (cmd.equals("down")) {
- commandDown(t);
- } else if (cmd.equals("frame")) {
- commandFrame(t);
- } else if (cmd.equals("stop")) {
- commandStop(t);
- } else if (cmd.equals("clear")) {
- commandClear(t);
- } else if (cmd.equals("list")) {
- commandList(t);
- } else if (cmd.equals("use")) {
- commandUse(t);
- } else if (cmd.equals("sourcepath")) {
- commandSourcepath(t);
- } else if (cmd.equals("classpath")) {
- commandClasspath(t);
- } else if (cmd.equals("monitor")) {
- commandMonitor(t);
- } else if (cmd.equals("unmonitor")) {
- commandUnmonitor(t);
- } else if (cmd.equals("view")) {
- commandView(t);
-// } else if (cmd.equals("read")) {
-// readCommand(t);
- } else if (cmd.equals("help") || cmd.equals("?")) {
- help();
- } else if (cmd.equals("quit") || cmd.equals("exit")) {
- try {
- runtime.detach();
- } catch (NoSessionException e) {
- // ignore
- }
- env.terminate();
- } else {
- //### Dubious repeat-count feature inherited from 'jdb'
- if (t.hasMoreTokens()) {
- try {
- int repeat = Integer.parseInt(cmd);
- String subcom = t.nextToken("");
- while (repeat-- > 0) {
- executeCommand(subcom);
- }
- return;
- } catch (NumberFormatException exc) {
- }
- }
- out.println("huh? Try help...");
- out.flush();
- }
- } catch (NoSessionException e) {
- out.println("There is no currently attached VM session.");
- out.flush();
- } catch (Exception e) {
- out.println("Internal exception: " + e.toString());
- out.flush();
- System.out.println("JDB internal exception: " + e.toString());
- e.printStackTrace();
- }
- out.show();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java
deleted file mode 100644
index d010ec2f56b..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CommandTool.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-import javax.swing.*;
-import java.awt.BorderLayout;
-import java.awt.event.*;
-
-import com.sun.jdi.*;
-import com.sun.jdi.event.*;
-
-import com.sun.tools.example.debug.bdi.*;
-import com.sun.tools.example.debug.event.*;
-
-public class CommandTool extends JPanel {
-
- private static final long serialVersionUID = 8613516856378346415L;
-
- private Environment env;
-
- private ContextManager context;
- private ExecutionManager runtime;
- private SourceManager sourceManager;
-
- private TypeScript script;
-
- private static final String DEFAULT_CMD_PROMPT = "Command:";
-
- public CommandTool(Environment env) {
-
- super(new BorderLayout());
-
- this.env = env;
- this.context = env.getContextManager();
- this.runtime = env.getExecutionManager();
- this.sourceManager = env.getSourceManager();
-
- script = new TypeScript(DEFAULT_CMD_PROMPT, false); //no echo
- this.add(script);
-
- final CommandInterpreter interpreter =
- new CommandInterpreter(env);
-
- // Establish handler for incoming commands.
-
- script.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- interpreter.executeCommand(script.readln());
- }
- });
-
- // Establish ourselves as the listener for VM diagnostics.
-
- OutputListener diagnosticsListener =
- new TypeScriptOutputListener(script, true);
- runtime.addDiagnosticsListener(diagnosticsListener);
-
- // Establish ourselves as the shared debugger typescript.
-
- env.setTypeScript(new PrintWriter(new TypeScriptWriter(script)));
-
- // Handle VM events.
-
- TTYDebugListener listener = new TTYDebugListener(diagnosticsListener);
-
- runtime.addJDIListener(listener);
- runtime.addSessionListener(listener);
- runtime.addSpecListener(listener);
- context.addContextListener(listener);
-
- //### remove listeners on exit!
-
- }
-
- private class TTYDebugListener implements
- JDIListener, SessionListener, SpecListener, ContextListener {
-
- private OutputListener diagnostics;
-
- TTYDebugListener(OutputListener diagnostics) {
- this.diagnostics = diagnostics;
- }
-
- // JDIListener
-
- @Override
- public void accessWatchpoint(AccessWatchpointEventSet e) {
- setThread(e);
- for (EventIterator it = e.eventIterator(); it.hasNext(); ) {
- it.nextEvent();
- diagnostics.putString("Watchpoint hit: " +
- locationString(e));
- }
- }
-
- @Override
- public void classPrepare(ClassPrepareEventSet e) {
- if (context.getVerboseFlag()) {
- String name = e.getReferenceType().name();
- diagnostics.putString("Class " + name + " loaded");
- }
- }
-
- @Override
- public void classUnload(ClassUnloadEventSet e) {
- if (context.getVerboseFlag()) {
- diagnostics.putString("Class " + e.getClassName() +
- " unloaded.");
- }
- }
-
- @Override
- public void exception(ExceptionEventSet e) {
- setThread(e);
- String name = e.getException().referenceType().name();
- diagnostics.putString("Exception: " + name);
- }
-
- @Override
- public void locationTrigger(LocationTriggerEventSet e) {
- String locString = locationString(e);
- setThread(e);
- for (EventIterator it = e.eventIterator(); it.hasNext(); ) {
- Event evt = it.nextEvent();
- if (evt instanceof BreakpointEvent) {
- diagnostics.putString("Breakpoint hit: " + locString);
- } else if (evt instanceof StepEvent) {
- diagnostics.putString("Step completed: " + locString);
- } else if (evt instanceof MethodEntryEvent) {
- diagnostics.putString("Method entered: " + locString);
- } else if (evt instanceof MethodExitEvent) {
- diagnostics.putString("Method exited: " + locString);
- } else {
- diagnostics.putString("UNKNOWN event: " + e);
- }
- }
- }
-
- @Override
- public void modificationWatchpoint(ModificationWatchpointEventSet e) {
- setThread(e);
- for (EventIterator it = e.eventIterator(); it.hasNext(); ) {
- it.nextEvent();
- diagnostics.putString("Watchpoint hit: " +
- locationString(e));
- }
- }
-
- @Override
- public void threadDeath(ThreadDeathEventSet e) {
- if (context.getVerboseFlag()) {
- diagnostics.putString("Thread " + e.getThread() +
- " ended.");
- }
- }
-
- @Override
- public void threadStart(ThreadStartEventSet e) {
- if (context.getVerboseFlag()) {
- diagnostics.putString("Thread " + e.getThread() +
- " started.");
- }
- }
-
- @Override
- public void vmDeath(VMDeathEventSet e) {
- script.setPrompt(DEFAULT_CMD_PROMPT);
- diagnostics.putString("VM exited");
- }
-
- @Override
- public void vmDisconnect(VMDisconnectEventSet e) {
- script.setPrompt(DEFAULT_CMD_PROMPT);
- diagnostics.putString("Disconnected from VM");
- }
-
- @Override
- public void vmStart(VMStartEventSet e) {
- script.setPrompt(DEFAULT_CMD_PROMPT);
- diagnostics.putString("VM started");
- }
-
- // SessionListener
-
- @Override
- public void sessionStart(EventObject e) {}
-
- @Override
- public void sessionInterrupt(EventObject e) {
- Thread.yield(); // fetch output
- diagnostics.putString("VM interrupted by user.");
- script.setPrompt(DEFAULT_CMD_PROMPT);
- }
-
- @Override
- public void sessionContinue(EventObject e) {
- diagnostics.putString("Execution resumed.");
- script.setPrompt(DEFAULT_CMD_PROMPT);
- }
-
- // SpecListener
-
- @Override
- public void breakpointSet(SpecEvent e) {
- EventRequestSpec spec = e.getEventRequestSpec();
- diagnostics.putString("Breakpoint set at " + spec + ".");
- }
- @Override
- public void breakpointDeferred(SpecEvent e) {
- EventRequestSpec spec = e.getEventRequestSpec();
- diagnostics.putString("Breakpoint will be set at " +
- spec + " when its class is loaded.");
- }
- @Override
- public void breakpointDeleted(SpecEvent e) {
- EventRequestSpec spec = e.getEventRequestSpec();
- diagnostics.putString("Breakpoint at " + spec.toString() + " deleted.");
- }
- @Override
- public void breakpointResolved(SpecEvent e) {
- EventRequestSpec spec = e.getEventRequestSpec();
- diagnostics.putString("Breakpoint resolved to " + spec.toString() + ".");
- }
- @Override
- public void breakpointError(SpecErrorEvent e) {
- EventRequestSpec spec = e.getEventRequestSpec();
- diagnostics.putString("Deferred breakpoint at " +
- spec + " could not be resolved:" +
- e.getReason());
- }
-
-//### Add info for watchpoints and exceptions
-
- @Override
- public void watchpointSet(SpecEvent e) {
- }
- @Override
- public void watchpointDeferred(SpecEvent e) {
- }
- @Override
- public void watchpointDeleted(SpecEvent e) {
- }
- @Override
- public void watchpointResolved(SpecEvent e) {
- }
- @Override
- public void watchpointError(SpecErrorEvent e) {
- }
-
- @Override
- public void exceptionInterceptSet(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptDeferred(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptDeleted(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptResolved(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptError(SpecErrorEvent e) {
- }
-
-
- // ContextListener.
-
- // If the user selects a new current thread or frame, update prompt.
-
- @Override
- public void currentFrameChanged(CurrentFrameChangedEvent e) {
- // Update prompt only if affect thread is current.
- ThreadReference thread = e.getThread();
- if (thread == context.getCurrentThread()) {
- script.setPrompt(promptString(thread, e.getIndex()));
- }
- }
-
- }
-
- private String locationString(LocatableEventSet e) {
- Location loc = e.getLocation();
- return "thread=\"" + e.getThread().name() +
- "\", " + Utils.locationString(loc);
- }
-
- private void setThread(LocatableEventSet e) {
- if (!e.suspendedNone()) {
- Thread.yield(); // fetch output
- script.setPrompt(promptString(e.getThread(), 0));
- //### Current thread should be set elsewhere, e.g.,
- //### in ContextManager
- //### context.setCurrentThread(thread);
- }
- }
-
- private String promptString(ThreadReference thread, int frameIndex) {
- if (thread == null) {
- return DEFAULT_CMD_PROMPT;
- } else {
- // Frame indices are presented to user as indexed from 1.
- return (thread.name() + "[" + (frameIndex + 1) + "]:");
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextListener.java
deleted file mode 100644
index 27143fac83a..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-public interface ContextListener {
- void currentFrameChanged(CurrentFrameChangedEvent e);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java
deleted file mode 100644
index fb2416789e8..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ContextManager.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.event.*;
-import com.sun.tools.example.debug.bdi.*;
-
-public class ContextManager {
-
- private ClassManager classManager;
- private ExecutionManager runtime;
-
- private String mainClassName;
- private String vmArguments;
- private String commandArguments;
- private String remotePort;
-
- private ThreadReference currentThread;
-
- private boolean verbose;
-
- private ArrayList contextListeners = new ArrayList();
-
- public ContextManager(Environment env) {
- classManager = env.getClassManager();
- runtime = env.getExecutionManager();
- mainClassName = "";
- vmArguments = "";
- commandArguments = "";
- currentThread = null;
-
- ContextManagerListener listener = new ContextManagerListener();
- runtime.addJDIListener(listener);
- runtime.addSessionListener(listener);
- }
-
- // Program execution defaults.
-
- //### Should there be change listeners for these?
- //### They would be needed if we expected a dialog to be
- //### synchronized with command input while it was open.
-
- public String getMainClassName() {
- return mainClassName;
- }
-
- public void setMainClassName(String mainClassName) {
- this.mainClassName = mainClassName;
- }
-
- public String getVmArguments() {
- return processClasspathDefaults(vmArguments);
- }
-
- public void setVmArguments(String vmArguments) {
- this.vmArguments = vmArguments;
- }
-
- public String getProgramArguments() {
- return commandArguments;
- }
-
- public void setProgramArguments(String commandArguments) {
- this.commandArguments = commandArguments;
- }
-
- public String getRemotePort() {
- return remotePort;
- }
-
- public void setRemotePort(String remotePort) {
- this.remotePort = remotePort;
-
- }
-
-
- // Miscellaneous debugger session preferences.
-
- public boolean getVerboseFlag() {
- return verbose;
- }
-
- public void setVerboseFlag(boolean verbose) {
- this.verbose = verbose;
- }
-
-
- // Thread focus.
-
- public ThreadReference getCurrentThread() {
- return currentThread;
- }
-
- public void setCurrentThread(ThreadReference t) {
- if (t != currentThread) {
- currentThread = t;
- notifyCurrentThreadChanged(t);
- }
- }
-
- public void setCurrentThreadInvalidate(ThreadReference t) {
- currentThread = t;
- notifyCurrentFrameChanged(runtime.threadInfo(t),
- 0, true);
- }
-
- public void invalidateCurrentThread() {
- notifyCurrentFrameChanged(null, 0, true);
- }
-
-
- // If a view is displaying the current thread, it may
- // choose to indicate which frame is current in the
- // sense of the command-line UI. It may also "warp" the
- // selection to that frame when changed by an 'up' or 'down'
- // command. Hence, a notifier is provided.
-
- /******
- public int getCurrentFrameIndex() {
- return getCurrentFrameIndex(currentThreadInfo);
- }
- ******/
-
- public int getCurrentFrameIndex(ThreadReference t) {
- return getCurrentFrameIndex(runtime.threadInfo(t));
- }
-
- //### Used in StackTraceTool.
- public int getCurrentFrameIndex(ThreadInfo tinfo) {
- if (tinfo == null) {
- return 0;
- }
- Integer currentFrame = (Integer)tinfo.getUserObject();
- if (currentFrame == null) {
- return 0;
- } else {
- return currentFrame.intValue();
- }
- }
-
- public int moveCurrentFrameIndex(ThreadReference t, int count) throws VMNotInterruptedException {
- return setCurrentFrameIndex(t,count, true);
- }
-
- public int setCurrentFrameIndex(ThreadReference t, int newIndex) throws VMNotInterruptedException {
- return setCurrentFrameIndex(t, newIndex, false);
- }
-
- public int setCurrentFrameIndex(int newIndex) throws VMNotInterruptedException {
- if (currentThread == null) {
- return 0;
- } else {
- return setCurrentFrameIndex(currentThread, newIndex, false);
- }
- }
-
- private int setCurrentFrameIndex(ThreadReference t, int x, boolean relative) throws VMNotInterruptedException {
- boolean sameThread = t.equals(currentThread);
- ThreadInfo tinfo = runtime.threadInfo(t);
- if (tinfo == null) {
- return 0;
- }
- int maxIndex = tinfo.getFrameCount()-1;
- int oldIndex = getCurrentFrameIndex(tinfo);
- int newIndex = relative? oldIndex + x : x;
- if (newIndex > maxIndex) {
- newIndex = maxIndex;
- } else if (newIndex < 0) {
- newIndex = 0;
- }
- if (!sameThread || newIndex != oldIndex) { // don't recurse
- setCurrentFrameIndex(tinfo, newIndex);
- }
- return newIndex - oldIndex;
- }
-
- private void setCurrentFrameIndex(ThreadInfo tinfo, int index) {
- tinfo.setUserObject(index);
- //### In fact, the value may not have changed at this point.
- //### We need to signal that the user attempted to change it,
- //### however, so that the selection can be "warped" to the
- //### current location.
- notifyCurrentFrameChanged(tinfo.thread(), index);
- }
-
- public StackFrame getCurrentFrame() throws VMNotInterruptedException {
- return getCurrentFrame(runtime.threadInfo(currentThread));
- }
-
- public StackFrame getCurrentFrame(ThreadReference t) throws VMNotInterruptedException {
- return getCurrentFrame(runtime.threadInfo(t));
- }
-
- public StackFrame getCurrentFrame(ThreadInfo tinfo) throws VMNotInterruptedException {
- int index = getCurrentFrameIndex(tinfo);
- try {
- // It is possible, though unlikely, that the VM was interrupted
- // before the thread created its Java stack.
- return tinfo.getFrame(index);
- } catch (FrameIndexOutOfBoundsException e) {
- return null;
- }
- }
-
- public void addContextListener(ContextListener cl) {
- contextListeners.add(cl);
- }
-
- public void removeContextListener(ContextListener cl) {
- contextListeners.remove(cl);
- }
-
- //### These notifiers are fired only in response to USER-INITIATED changes
- //### to the current thread and current frame. When the current thread is set automatically
- //### after a breakpoint hit or step completion, no event is generated. Instead,
- //### interested parties are expected to listen for the BreakpointHit and StepCompleted
- //### events. This convention is unclean, and I believe that it reflects a defect in
- //### in the current architecture. Unfortunately, however, we cannot guarantee the
- //### order in which various listeners receive a given event, and the handlers for
- //### the very same events that cause automatic changes to the current thread may also
- //### need to know the current thread.
-
- private void notifyCurrentThreadChanged(ThreadReference t) {
- ThreadInfo tinfo = null;
- int index = 0;
- if (t != null) {
- tinfo = runtime.threadInfo(t);
- index = getCurrentFrameIndex(tinfo);
- }
- notifyCurrentFrameChanged(tinfo, index, false);
- }
-
- private void notifyCurrentFrameChanged(ThreadReference t, int index) {
- notifyCurrentFrameChanged(runtime.threadInfo(t),
- index, false);
- }
-
- private void notifyCurrentFrameChanged(ThreadInfo tinfo, int index,
- boolean invalidate) {
- ArrayList l = new ArrayList(contextListeners);
- CurrentFrameChangedEvent evt =
- new CurrentFrameChangedEvent(this, tinfo, index, invalidate);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).currentFrameChanged(evt);
- }
- }
-
- private class ContextManagerListener extends JDIAdapter
- implements SessionListener, JDIListener {
-
- // SessionListener
-
- @Override
- public void sessionStart(EventObject e) {
- invalidateCurrentThread();
- }
-
- @Override
- public void sessionInterrupt(EventObject e) {
- setCurrentThreadInvalidate(currentThread);
- }
-
- @Override
- public void sessionContinue(EventObject e) {
- invalidateCurrentThread();
- }
-
- // JDIListener
-
- @Override
- public void locationTrigger(LocationTriggerEventSet e) {
- setCurrentThreadInvalidate(e.getThread());
- }
-
- @Override
- public void exception(ExceptionEventSet e) {
- setCurrentThreadInvalidate(e.getThread());
- }
-
- @Override
- public void vmDisconnect(VMDisconnectEventSet e) {
- invalidateCurrentThread();
- }
-
- }
-
-
- /**
- * Add a -classpath argument to the arguments passed to the exec'ed
- * VM with the contents of CLASSPATH environment variable,
- * if -classpath was not already specified.
- *
- * @param javaArgs the arguments to the VM being exec'd that
- * potentially has a user specified -classpath argument.
- * @return a javaArgs whose -classpath option has been added
- */
-
- private String processClasspathDefaults(String javaArgs) {
- if (javaArgs.indexOf("-classpath ") == -1) {
- StringBuilder munged = new StringBuilder(javaArgs);
- SearchPath classpath = classManager.getClassPath();
- if (classpath.isEmpty()) {
- String envcp = System.getProperty("env.class.path");
- if ((envcp != null) && (envcp.length() > 0)) {
- munged.append(" -classpath " + envcp);
- }
- } else {
- munged.append(" -classpath " + classpath.asString());
- }
- return munged.toString();
- } else {
- return javaArgs;
- }
- }
-
- private String appendPath(String path1, String path2) {
- if (path1 == null || path1.length() == 0) {
- return path2 == null ? "." : path2;
- } else if (path2 == null || path2.length() == 0) {
- return path1;
- } else {
- return path1 + File.pathSeparator + path2;
- }
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java
deleted file mode 100644
index b933e758f38..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/CurrentFrameChangedEvent.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.bdi.*;
-import java.util.EventObject;
-
-public class CurrentFrameChangedEvent extends EventObject {
-
- private static final long serialVersionUID = 4214479486546762179L;
- private ThreadInfo tinfo;
- private int index;
- private boolean invalidate;
-
- public CurrentFrameChangedEvent(Object source, ThreadInfo tinfo,
- int index, boolean invalidate) {
- super(source);
- this.tinfo = tinfo;
- this.index = index;
- this.invalidate = invalidate;
- }
-
- public ThreadReference getThread() {
- return tinfo == null? null : tinfo.thread();
- }
-
- public ThreadInfo getThreadInfo() {
- return tinfo;
- }
-
- public int getIndex() {
- return index;
- }
-
- public boolean getInvalidate() {
- return invalidate;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java
deleted file mode 100644
index b06ae4d6c79..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Environment.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.bdi.*;
-
-public class Environment {
-
- private SourceManager sourceManager;
- private ClassManager classManager;
- private ContextManager contextManager;
- private MonitorListModel monitorListModel;
- private ExecutionManager runtime;
-
- private PrintWriter typeScript;
-
- private boolean verbose;
-
- public Environment() {
- this.classManager = new ClassManager(this);
- //### Order of the next three lines is important! (FIX THIS)
- this.runtime = new ExecutionManager();
- this.sourceManager = new SourceManager(this);
- this.contextManager = new ContextManager(this);
- this.monitorListModel = new MonitorListModel(this);
- }
-
- // Services used by debugging tools.
-
- public SourceManager getSourceManager() {
- return sourceManager;
- }
-
- public ClassManager getClassManager() {
- return classManager;
- }
-
- public ContextManager getContextManager() {
- return contextManager;
- }
-
- public MonitorListModel getMonitorListModel() {
- return monitorListModel;
- }
-
- public ExecutionManager getExecutionManager() {
- return runtime;
- }
-
- //### TODO:
- //### Tools should attach/detach from environment
- //### via a property, which should call an 'addTool'
- //### method when set to maintain a registry of
- //### tools for exit-time cleanup, etc. Tool
- //### class constructors should be argument-free, so
- //### that they may be instantiated by bean builders.
- //### Will also need 'removeTool' in case property
- //### value is changed.
- //
- // public void addTool(Tool t);
- // public void removeTool(Tool t);
-
- public void terminate() {
- System.exit(0);
- }
-
- // public void refresh(); // notify all tools to refresh their views
-
-
- // public void addStatusListener(StatusListener l);
- // public void removeStatusListener(StatusListener l);
-
- // public void addOutputListener(OutputListener l);
- // public void removeOutputListener(OutputListener l);
-
- public void setTypeScript(PrintWriter writer) {
- typeScript = writer;
- }
-
- public void error(String message) {
- if (typeScript != null) {
- typeScript.println(message);
- } else {
- System.out.println(message);
- }
- }
-
- public void failure(String message) {
- if (typeScript != null) {
- typeScript.println(message);
- } else {
- System.out.println(message);
- }
- }
-
- public void notice(String message) {
- if (typeScript != null) {
- typeScript.println(message);
- } else {
- System.out.println(message);
- }
- }
-
- public OutputSink getOutputSink() {
- return new OutputSink(typeScript);
- }
-
- public void viewSource(String fileName) {
- //### HACK ###
- //### Should use listener here.
- com.sun.tools.example.debug.gui.GUI.srcTool.showSourceFile(fileName);
- }
-
- public void viewLocation(Location locn) {
- //### HACK ###
- //### Should use listener here.
- //### Should we use sourceForLocation here?
- com.sun.tools.example.debug.gui.GUI.srcTool.showSourceForLocation(locn);
- }
-
- //### Also in 'ContextManager'. Do we need both?
-
- public boolean getVerboseFlag() {
- return verbose;
- }
-
- public void setVerboseFlag(boolean verbose) {
- this.verbose = verbose;
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java
deleted file mode 100644
index eefbcfa7b61..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/GUI.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.bdi.*;
-
-public class GUI extends JPanel {
-
- private static final long serialVersionUID = 3292463234530679091L;
- private CommandTool cmdTool;
- private ApplicationTool appTool;
- //###HACK##
- //### There is currently dirty code in Environment that
- //### accesses this directly.
- //private SourceTool srcTool;
- public static SourceTool srcTool;
-
- private SourceTreeTool sourceTreeTool;
- private ClassTreeTool classTreeTool;
- private ThreadTreeTool threadTreeTool;
- private StackTraceTool stackTool;
- private MonitorTool monitorTool;
-
- public static final String progname = "javadt";
- public static final String version = "1.0Beta"; //### FIX ME.
- public static final String windowBanner = "Java(tm) platform Debug Tool";
-
- private Font fixedFont = new Font("monospaced", Font.PLAIN, 10);
-
- private GUI(Environment env) {
- setLayout(new BorderLayout());
-
- setBorder(new EmptyBorder(5, 5, 5, 5));
-
- add(new JDBToolBar(env), BorderLayout.NORTH);
-
- srcTool = new SourceTool(env);
- srcTool.setPreferredSize(new java.awt.Dimension(500, 300));
- srcTool.setTextFont(fixedFont);
-
- stackTool = new StackTraceTool(env);
- stackTool.setPreferredSize(new java.awt.Dimension(500, 100));
-
- monitorTool = new MonitorTool(env);
- monitorTool.setPreferredSize(new java.awt.Dimension(500, 50));
-
- JSplitPane right = new JSplitPane(JSplitPane.VERTICAL_SPLIT, srcTool,
- new JSplitPane(JSplitPane.VERTICAL_SPLIT, stackTool, monitorTool));
-
- sourceTreeTool = new SourceTreeTool(env);
- sourceTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
-
- classTreeTool = new ClassTreeTool(env);
- classTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
-
- threadTreeTool = new ThreadTreeTool(env);
- threadTreeTool.setPreferredSize(new java.awt.Dimension(200, 450));
-
- JTabbedPane treePane = new JTabbedPane(SwingConstants.BOTTOM);
- treePane.addTab("Source", null, sourceTreeTool);
- treePane.addTab("Classes", null, classTreeTool);
- treePane.addTab("Threads", null, threadTreeTool);
-
- JSplitPane centerTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, right);
-
- cmdTool = new CommandTool(env);
- cmdTool.setPreferredSize(new java.awt.Dimension(700, 150));
-
- appTool = new ApplicationTool(env);
- appTool.setPreferredSize(new java.awt.Dimension(700, 200));
-
- JSplitPane centerBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cmdTool, appTool);
- // centerBottom.setPreferredSize(new java.awt.Dimension(700, 350));
-
- JSplitPane center = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerTop, centerBottom);
-
- add(center, BorderLayout.CENTER);
-
-
- }
-
- private static void usage() {
- String separator = File.pathSeparator;
- System.out.println("Usage: " + progname + " ");
- System.out.println();
- System.out.println("where options include:");
- System.out.println(" -help print out this message and exit");
- System.out.println(" -sourcepath ");
- System.out.println(" list directories in which to look for source files");
- System.out.println(" -remote :");
- System.out.println(" host machine and port number of interpreter to attach to");
- System.out.println(" -dbgtrace [flags] print info for debugging " + progname);
- System.out.println();
- System.out.println("options forwarded to debuggee process:");
- System.out.println(" -v -verbose[:class|gc|jni]");
- System.out.println(" turn on verbose mode");
- System.out.println(" -D= set a system property");
- System.out.println(" -classpath ");
- System.out.println(" list directories in which to look for classes");
- System.out.println(" -X non-standard debuggee VM option");
- System.out.println();
- System.out.println(" is the name of the class to begin debugging");
- System.out.println(" are the arguments passed to the main() method of ");
- System.out.println();
- System.out.println("For command help type 'help' at " + progname + " prompt");
- }
-
- public static void main(String argv[]) {
- String clsName = "";
- String progArgs = "";
- String javaArgs = "";
- final Environment env = new Environment();
-
- JPanel mainPanel = new GUI(env);
-
- ContextManager context = env.getContextManager();
- ExecutionManager runtime = env.getExecutionManager();
-
- for (int i = 0; i < argv.length; i++) {
- String token = argv[i];
- if (token.equals("-dbgtrace")) {
- if ((i == argv.length - 1) ||
- ! Character.isDigit(argv[i+1].charAt(0))) {
- runtime.setTraceMode(VirtualMachine.TRACE_ALL);
- } else {
- String flagStr = argv[++i];
- runtime.setTraceMode(Integer.decode(flagStr).intValue());
- }
- } else if (token.equals("-X")) {
- System.out.println(
- "Use 'java -X' to see the available non-standard options");
- System.out.println();
- usage();
- System.exit(1);
- } else if (
- // Standard VM options passed on
- token.equals("-v") || token.startsWith("-v:") || // -v[:...]
- token.startsWith("-verbose") || // -verbose[:...]
- token.startsWith("-D") ||
- // NonStandard options passed on
- token.startsWith("-X") ||
- // Old-style options
- // (These should remain in place as long as the standard VM accepts them)
- token.equals("-noasyncgc") || token.equals("-prof") ||
- token.equals("-verify") || token.equals("-noverify") ||
- token.equals("-verifyremote") ||
- token.equals("-verbosegc") ||
- token.startsWith("-ms") || token.startsWith("-mx") ||
- token.startsWith("-ss") || token.startsWith("-oss") ) {
- javaArgs += token + " ";
- } else if (token.equals("-sourcepath")) {
- if (i == (argv.length - 1)) {
- System.out.println("No sourcepath specified.");
- usage();
- System.exit(1);
- }
- env.getSourceManager().setSourcePath(new SearchPath(argv[++i]));
- } else if (token.equals("-classpath")) {
- if (i == (argv.length - 1)) {
- System.out.println("No classpath specified.");
- usage();
- System.exit(1);
- }
- env.getClassManager().setClassPath(new SearchPath(argv[++i]));
- } else if (token.equals("-remote")) {
- if (i == (argv.length - 1)) {
- System.out.println("No remote specified.");
- usage();
- System.exit(1);
- }
- env.getContextManager().setRemotePort(argv[++i]);
- } else if (token.equals("-help")) {
- usage();
- System.exit(0);
- } else if (token.equals("-version")) {
- System.out.println(progname + " version " + version);
- System.exit(0);
- } else if (token.startsWith("-")) {
- System.out.println("invalid option: " + token);
- usage();
- System.exit(1);
- } else {
- // Everything from here is part of the command line
- clsName = token;
- for (i++; i < argv.length; i++) {
- progArgs += argv[i] + " ";
- }
- break;
- }
- }
-
- context.setMainClassName(clsName);
- context.setProgramArguments(progArgs);
- context.setVmArguments(javaArgs);
-
- // Force Cross Platform L&F
- try {
- UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
- // If you want the System L&F instead, comment out the above line and
- // uncomment the following:
- // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception exc) {
- System.err.println("Error loading L&F: " + exc);
- }
-
- JFrame frame = new JFrame();
- frame.setBackground(Color.lightGray);
- frame.setTitle(windowBanner);
- frame.setJMenuBar(new JDBMenuBar(env));
- frame.setContentPane(mainPanel);
-
- frame.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- env.terminate();
- }
- });
-
- frame.pack();
- frame.setVisible(true);
-
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Icons.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Icons.java
deleted file mode 100644
index 2f5076b96db..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/Icons.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-
-class Icons {
-
- private static int[] exec = {
- 0xffd8ffe0, 0x00104a46, 0x49460001, 0x01020000
-, 0x00000000, 0xffdb0043, 0x00020101, 0x01010102
-, 0x01010102, 0x02020202, 0x04030202, 0x02020504
-, 0x04030406, 0x05060606, 0x05060606, 0x07090806
-, 0x07090706, 0x06080b08, 0x090a0a0a, 0x0a0a0608
-, 0x0b0c0b0a, 0x0c090a0a, 0x0affdb00, 0x43010202
-, 0x02020202, 0x05030305, 0x0a070607, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0affc0
-, 0x00110800, 0x0c000c03, 0x01220002, 0x11010311
-, 0x01ffc400, 0x1f000001, 0x05010101, 0x01010100
-, 0x00000000, 0x00000001, 0x02030405, 0x06070809
-, 0x0a0bffc4, 0x00b51000, 0x02010303, 0x02040305
-, 0x05040400, 0x00017d01, 0x02030004, 0x11051221
-, 0x31410613, 0x51610722, 0x71143281, 0x91a10823
-, 0x42b1c115, 0x52d1f024, 0x33627282, 0x090a1617
-, 0x18191a25, 0x26272829, 0x2a343536, 0x3738393a
-, 0x43444546, 0x4748494a, 0x53545556, 0x5758595a
-, 0x63646566, 0x6768696a, 0x73747576, 0x7778797a
-, 0x83848586, 0x8788898a, 0x92939495, 0x96979899
-, 0x9aa2a3a4, 0xa5a6a7a8, 0xa9aab2b3, 0xb4b5b6b7
-, 0xb8b9bac2, 0xc3c4c5c6, 0xc7c8c9ca, 0xd2d3d4d5
-, 0xd6d7d8d9, 0xdae1e2e3, 0xe4e5e6e7, 0xe8e9eaf1
-, 0xf2f3f4f5, 0xf6f7f8f9, 0xfaffc400, 0x1f010003
-, 0x01010101, 0x01010101, 0x01000000, 0x00000001
-, 0x02030405, 0x06070809, 0x0a0bffc4, 0x00b51100
-, 0x02010204, 0x04030407, 0x05040400, 0x01027700
-, 0x01020311, 0x04052131, 0x06124151, 0x07617113
-, 0x22328108, 0x144291a1, 0xb1c10923, 0x3352f015
-, 0x6272d10a, 0x162434e1, 0x25f11718, 0x191a2627
-, 0x28292a35, 0x36373839, 0x3a434445, 0x46474849
-, 0x4a535455, 0x56575859, 0x5a636465, 0x66676869
-, 0x6a737475, 0x76777879, 0x7a828384, 0x85868788
-, 0x898a9293, 0x94959697, 0x98999aa2, 0xa3a4a5a6
-, 0xa7a8a9aa, 0xb2b3b4b5, 0xb6b7b8b9, 0xbac2c3c4
-, 0xc5c6c7c8, 0xc9cad2d3, 0xd4d5d6d7, 0xd8d9dae2
-, 0xe3e4e5e6, 0xe7e8e9ea, 0xf2f3f4f5, 0xf6f7f8f9
-, 0xfaffda00, 0x0c030100, 0x02110311, 0x003f00fd
-, 0xbafda27e, 0x35ea1f03, 0x346f0ef8, 0x86cfc2d3
-, 0x6b31ea9e, 0x2ab7d2ee, 0xf4fb38cb, 0x5cc91cb0
-, 0xce4790a0, 0xfcd2ef44, 0xc29e1f95, 0xf94b065f
-, 0x42a86eb4, 0xed3ef67b, 0x7b9bcb18, 0x6692ce63
-, 0x35a492c4, 0x19a090a3, 0x465d09fb, 0xadb1dd72
-, 0x39daec3a, 0x13535706, 0x1f0f8ca7, 0x8dad56a5
-, 0x5e6a72e5, 0xe485be0b, 0x2b49df77, 0xcceda6ca
-, 0xda6ece3a, 0x147150c5, 0xd5a93a97, 0x84b97963
-, 0x6f86cbde, 0x77ddf33b, 0x69b2b69b, 0xb3ffd900
-
- };
- private static int[] blank = {
- 0xffd8ffe0, 0x00104a46, 0x49460001, 0x01020000
-, 0x00000000, 0xffdb0043, 0x00020101, 0x01010102
-, 0x01010102, 0x02020202, 0x04030202, 0x02020504
-, 0x04030406, 0x05060606, 0x05060606, 0x07090806
-, 0x07090706, 0x06080b08, 0x090a0a0a, 0x0a0a0608
-, 0x0b0c0b0a, 0x0c090a0a, 0x0affdb00, 0x43010202
-, 0x02020202, 0x05030305, 0x0a070607, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0affc0
-, 0x00110800, 0x0c000c03, 0x01220002, 0x11010311
-, 0x01ffc400, 0x1f000001, 0x05010101, 0x01010100
-, 0x00000000, 0x00000001, 0x02030405, 0x06070809
-, 0x0a0bffc4, 0x00b51000, 0x02010303, 0x02040305
-, 0x05040400, 0x00017d01, 0x02030004, 0x11051221
-, 0x31410613, 0x51610722, 0x71143281, 0x91a10823
-, 0x42b1c115, 0x52d1f024, 0x33627282, 0x090a1617
-, 0x18191a25, 0x26272829, 0x2a343536, 0x3738393a
-, 0x43444546, 0x4748494a, 0x53545556, 0x5758595a
-, 0x63646566, 0x6768696a, 0x73747576, 0x7778797a
-, 0x83848586, 0x8788898a, 0x92939495, 0x96979899
-, 0x9aa2a3a4, 0xa5a6a7a8, 0xa9aab2b3, 0xb4b5b6b7
-, 0xb8b9bac2, 0xc3c4c5c6, 0xc7c8c9ca, 0xd2d3d4d5
-, 0xd6d7d8d9, 0xdae1e2e3, 0xe4e5e6e7, 0xe8e9eaf1
-, 0xf2f3f4f5, 0xf6f7f8f9, 0xfaffc400, 0x1f010003
-, 0x01010101, 0x01010101, 0x01000000, 0x00000001
-, 0x02030405, 0x06070809, 0x0a0bffc4, 0x00b51100
-, 0x02010204, 0x04030407, 0x05040400, 0x01027700
-, 0x01020311, 0x04052131, 0x06124151, 0x07617113
-, 0x22328108, 0x144291a1, 0xb1c10923, 0x3352f015
-, 0x6272d10a, 0x162434e1, 0x25f11718, 0x191a2627
-, 0x28292a35, 0x36373839, 0x3a434445, 0x46474849
-, 0x4a535455, 0x56575859, 0x5a636465, 0x66676869
-, 0x6a737475, 0x76777879, 0x7a828384, 0x85868788
-, 0x898a9293, 0x94959697, 0x98999aa2, 0xa3a4a5a6
-, 0xa7a8a9aa, 0xb2b3b4b5, 0xb6b7b8b9, 0xbac2c3c4
-, 0xc5c6c7c8, 0xc9cad2d3, 0xd4d5d6d7, 0xd8d9dae2
-, 0xe3e4e5e6, 0xe7e8e9ea, 0xf2f3f4f5, 0xf6f7f8f9
-, 0xfaffda00, 0x0c030100, 0x02110311, 0x003f00fd
-, 0xfca28a28, 0x03ffd900
-
- };
-
- private static int[] stopSignWords = {
- 0xffd8ffe0, 0x00104a46, 0x49460001, 0x01020000
-, 0x00000000, 0xffdb0043, 0x00020101, 0x01010102
-, 0x01010102, 0x02020202, 0x04030202, 0x02020504
-, 0x04030406, 0x05060606, 0x05060606, 0x07090806
-, 0x07090706, 0x06080b08, 0x090a0a0a, 0x0a0a0608
-, 0x0b0c0b0a, 0x0c090a0a, 0x0affdb00, 0x43010202
-, 0x02020202, 0x05030305, 0x0a070607, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a
-, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0affc0
-, 0x00110800, 0x0c000c03, 0x01220002, 0x11010311
-, 0x01ffc400, 0x1f000001, 0x05010101, 0x01010100
-, 0x00000000, 0x00000001, 0x02030405, 0x06070809
-, 0x0a0bffc4, 0x00b51000, 0x02010303, 0x02040305
-, 0x05040400, 0x00017d01, 0x02030004, 0x11051221
-, 0x31410613, 0x51610722, 0x71143281, 0x91a10823
-, 0x42b1c115, 0x52d1f024, 0x33627282, 0x090a1617
-, 0x18191a25, 0x26272829, 0x2a343536, 0x3738393a
-, 0x43444546, 0x4748494a, 0x53545556, 0x5758595a
-, 0x63646566, 0x6768696a, 0x73747576, 0x7778797a
-, 0x83848586, 0x8788898a, 0x92939495, 0x96979899
-, 0x9aa2a3a4, 0xa5a6a7a8, 0xa9aab2b3, 0xb4b5b6b7
-, 0xb8b9bac2, 0xc3c4c5c6, 0xc7c8c9ca, 0xd2d3d4d5
-, 0xd6d7d8d9, 0xdae1e2e3, 0xe4e5e6e7, 0xe8e9eaf1
-, 0xf2f3f4f5, 0xf6f7f8f9, 0xfaffc400, 0x1f010003
-, 0x01010101, 0x01010101, 0x01000000, 0x00000001
-, 0x02030405, 0x06070809, 0x0a0bffc4, 0x00b51100
-, 0x02010204, 0x04030407, 0x05040400, 0x01027700
-, 0x01020311, 0x04052131, 0x06124151, 0x07617113
-, 0x22328108, 0x144291a1, 0xb1c10923, 0x3352f015
-, 0x6272d10a, 0x162434e1, 0x25f11718, 0x191a2627
-, 0x28292a35, 0x36373839, 0x3a434445, 0x46474849
-, 0x4a535455, 0x56575859, 0x5a636465, 0x66676869
-, 0x6a737475, 0x76777879, 0x7a828384, 0x85868788
-, 0x898a9293, 0x94959697, 0x98999aa2, 0xa3a4a5a6
-, 0xa7a8a9aa, 0xb2b3b4b5, 0xb6b7b8b9, 0xbac2c3c4
-, 0xc5c6c7c8, 0xc9cad2d3, 0xd4d5d6d7, 0xd8d9dae2
-, 0xe3e4e5e6, 0xe7e8e9ea, 0xf2f3f4f5, 0xf6f7f8f9
-, 0xfaffda00, 0x0c030100, 0x02110311, 0x003f00f8
-, 0xe7e37fc6, 0xff00197f, 0xc142fc65, 0x17ed5bfb
-, 0x56db699e, 0x27f14f89, 0xf4cb7b85, 0x5bcd3924
-, 0xb5d1ed5d, 0x3cc8b4db, 0x08a4ddf6, 0x6b387cc6
-, 0x09182599, 0x99e595e5, 0x9e69a693, 0xbaf0dffc
-, 0x1c9dff00, 0x050aff00, 0x82637837, 0x44fd94be
-, 0x11e89f0f, 0xfc61e16d, 0x334c5b8f, 0x0f37c45d
-, 0x26fef2eb, 0x46b56778, 0xd34db796, 0xd6fadbfd
-, 0x0e2f2898, 0xa3903b42, 0xb21891d6, 0x08e08623
-, 0xfe0e4ef0, 0xdf837fe0, 0x98dff050, 0xbb2f847f
-, 0xb2978274, 0xcd33c2de, 0x30f87f69, 0xe2e6f0f5
-, 0xe44ef6ba, 0x35d5c5fe, 0xa16b2dad, 0x8246d1f9
-, 0x167fe84b, 0x2a40772c, 0x2d33c717, 0x9702c304
-, 0x5fb0dff0, 0x4abff825, 0x5ffc13d7, 0xc55ff04f
-, 0x5f845f17, 0x3e2e7ec8, 0xbf0ffe21, 0xf8a7e21f
-, 0xc3fd1fc5, 0xde21f10f, 0xc45f0758, 0x6b774b75
-, 0xa9584174, 0xf6b6ef75, 0x0b7d9ace, 0x1f304514
-, 0x11ed50a8, 0x647f3279, 0x679e5fcf, 0x720cbb37
-, 0xc3f1257a, 0x95eb7343, 0xdebabc9d, 0xeef4d1ab
-, 0x2b7e1b2d, 0x0fec0f16, 0xb8c7c3cc, 0xdbc15caf
-, 0x0795e59e, 0xc710fd97, 0x2cfd9d38, 0xf2f241aa
-, 0x9efc64e5, 0x2e67dd7b, 0xdf14acd1, 0xffd90000
-
-};
-
- static private byte[] wordsToBytes(int[] wordArray) {
- byte[] bytes = new byte[wordArray.length * 4];
- int inx = bytes.length;
- for (int i = wordArray.length-1; i >= 0; --i) {
- int word = wordArray[i];
- for (int j = 0; j < 4; ++j) {
- bytes[--inx] = (byte)(word & 0xff);
- word = word >>> 8;
- }
- }
- return bytes;
- }
-
- static Icon stopSignIcon = new ImageIcon(wordsToBytes(stopSignWords));
- static Icon blankIcon = new ImageIcon(wordsToBytes(blank));
-
- static Icon execIcon = new ImageIcon(wordsToBytes(exec));
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBFileFilter.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBFileFilter.java
deleted file mode 100644
index 8b8240ef39f..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBFileFilter.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.File;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import javax.swing.filechooser.*;
-
-//### Renamed from 'ExampleFileFilter.java' provided with Swing demos.
-
-/**
- * A convenience implementation of FileFilter that filters out
- * all files except for those type extensions that it knows about.
- *
- * Extensions are of the type ".foo", which is typically found on
- * Windows and Unix boxes, but not on Macinthosh. Case is ignored.
- *
- * Example - create a new filter that filerts out all files
- * but gif and jpg image files:
- *
- * JFileChooser chooser = new JFileChooser();
- * ExampleFileFilter filter = new ExampleFileFilter(
- * new String{"gif", "jpg"}, "JPEG & GIF Images")
- * chooser.addChoosableFileFilter(filter);
- * chooser.showOpenDialog(this);
- *
- * @author Jeff Dinkins
- */
-
-public class JDBFileFilter extends FileFilter {
-
- private static String TYPE_UNKNOWN = "Type Unknown";
- private static String HIDDEN_FILE = "Hidden File";
-
- private Hashtable filters = null;
- private String description = null;
- private String fullDescription = null;
- private boolean useExtensionsInDescription = true;
-
- /**
- * Creates a file filter. If no filters are added, then all
- * files are accepted.
- *
- * @see #addExtension
- */
- public JDBFileFilter() {
- this.filters = new Hashtable();
- }
-
- /**
- * Creates a file filter that accepts files with the given extension.
- * Example: new JDBFileFilter("jpg");
- *
- * @see #addExtension
- */
- public JDBFileFilter(String extension) {
- this(extension,null);
- }
-
- /**
- * Creates a file filter that accepts the given file type.
- * Example: new JDBFileFilter("jpg", "JPEG Image Images");
- *
- * Note that the "." before the extension is not needed. If
- * provided, it will be ignored.
- *
- * @see #addExtension
- */
- public JDBFileFilter(String extension, String description) {
- this();
- if(extension!=null) {
- addExtension(extension);
- }
- if(description!=null) {
- setDescription(description);
- }
- }
-
- /**
- * Creates a file filter from the given string array.
- * Example: new JDBFileFilter(String {"gif", "jpg"});
- *
- * Note that the "." before the extension is not needed adn
- * will be ignored.
- *
- * @see #addExtension
- */
- public JDBFileFilter(String[] filters) {
- this(filters, null);
- }
-
- /**
- * Creates a file filter from the given string array and description.
- * Example: new JDBFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
- *
- * Note that the "." before the extension is not needed and will be ignored.
- *
- * @see #addExtension
- */
- public JDBFileFilter(String[] filters, String description) {
- this();
- for (String filter : filters) {
- // add filters one by one
- addExtension(filter);
- }
- if(description!=null) {
- setDescription(description);
- }
- }
-
- /**
- * Return true if this file should be shown in the directory pane,
- * false if it shouldn't.
- *
- * Files that begin with "." are ignored.
- *
- * @see #getExtension
- * @see FileFilter#accepts
- */
- @Override
- public boolean accept(File f) {
- if(f != null) {
- if(f.isDirectory()) {
- return true;
- }
- String extension = getExtension(f);
- if(extension != null && filters.get(getExtension(f)) != null) {
- return true;
- };
- }
- return false;
- }
-
- /**
- * Return the extension portion of the file's name .
- *
- * @see #getExtension
- * @see FileFilter#accept
- */
- public String getExtension(File f) {
- if(f != null) {
- String filename = f.getName();
- int i = filename.lastIndexOf('.');
- if(i>0 && i(5);
- }
- filters.put(extension.toLowerCase(), this);
- fullDescription = null;
- }
-
-
- /**
- * Returns the human readable description of this filter. For
- * example: "JPEG and GIF Image Files (*.jpg, *.gif)"
- *
- * @see setDescription
- * @see setExtensionListInDescription
- * @see isExtensionListInDescription
- * @see FileFilter#getDescription
- */
- @Override
- public String getDescription() {
- if(fullDescription == null) {
- if(description == null || isExtensionListInDescription()) {
- fullDescription = description==null ? "(" : description + " (";
- // build the description from the extension list
- Enumeration extensions = filters.keys();
- if(extensions != null) {
- fullDescription += "." + extensions.nextElement();
- while (extensions.hasMoreElements()) {
- fullDescription += ", " + extensions.nextElement();
- }
- }
- fullDescription += ")";
- } else {
- fullDescription = description;
- }
- }
- return fullDescription;
- }
-
- /**
- * Sets the human readable description of this filter. For
- * example: filter.setDescription("Gif and JPG Images");
- *
- * @see setDescription
- * @see setExtensionListInDescription
- * @see isExtensionListInDescription
- */
- public void setDescription(String description) {
- this.description = description;
- fullDescription = null;
- }
-
- /**
- * Determines whether the extension list (.jpg, .gif, etc) should
- * show up in the human readable description.
- *
- * Only relevent if a description was provided in the constructor
- * or using setDescription();
- *
- * @see getDescription
- * @see setDescription
- * @see isExtensionListInDescription
- */
- public void setExtensionListInDescription(boolean b) {
- useExtensionsInDescription = b;
- fullDescription = null;
- }
-
- /**
- * Returns whether the extension list (.jpg, .gif, etc) should
- * show up in the human readable description.
- *
- * Only relevent if a description was provided in the constructor
- * or using setDescription();
- *
- * @see getDescription
- * @see setDescription
- * @see setExtensionListInDescription
- */
- public boolean isExtensionListInDescription() {
- return useExtensionsInDescription;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBMenuBar.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBMenuBar.java
deleted file mode 100644
index f8340456adb..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBMenuBar.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.util.Vector;
-import java.util.List;
-
-import com.sun.tools.example.debug.bdi.*;
-
-//### This is currently just a placeholder!
-
-class JDBMenuBar extends JMenuBar {
-
- Environment env;
-
- ExecutionManager runtime;
- ClassManager classManager;
- SourceManager sourceManager;
-
- CommandInterpreter interpreter;
-
- JDBMenuBar(Environment env) {
- this.env = env;
- this.runtime = env.getExecutionManager();
- this.classManager = env.getClassManager();
- this.sourceManager = env.getSourceManager();
- this.interpreter = new CommandInterpreter(env, true);
-
- JMenu fileMenu = new JMenu("File");
-
- JMenuItem openItem = new JMenuItem("Open...", 'O');
- openItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- openCommand();
- }
- });
- fileMenu.add(openItem);
- addTool(fileMenu, "Exit debugger", "Exit", "exit");
-
- JMenu cmdMenu = new JMenu("Commands");
-
- addTool(cmdMenu, "Step into next line", "Step", "step");
- addTool(cmdMenu, "Step over next line", "Next", "next");
- cmdMenu.addSeparator();
-
- addTool(cmdMenu, "Step into next instruction",
- "Step Instruction", "stepi");
- addTool(cmdMenu, "Step over next instruction",
- "Next Instruction", "nexti");
- cmdMenu.addSeparator();
-
- addTool(cmdMenu, "Step out of current method call",
- "Step Up", "step up");
- cmdMenu.addSeparator();
-
- addTool(cmdMenu, "Suspend execution", "Interrupt", "interrupt");
- addTool(cmdMenu, "Continue execution", "Continue", "cont");
- cmdMenu.addSeparator();
-
- addTool(cmdMenu, "Display current stack", "Where", "where");
- cmdMenu.addSeparator();
-
- addTool(cmdMenu, "Move up one stack frame", "Up", "up");
- addTool(cmdMenu, "Move down one stack frame", "Down", "down");
- cmdMenu.addSeparator();
-
- JMenuItem monitorItem = new JMenuItem("Monitor Expression...", 'M');
- monitorItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- monitorCommand();
- }
- });
- cmdMenu.add(monitorItem);
-
- JMenuItem unmonitorItem = new JMenuItem("Unmonitor Expression...");
- unmonitorItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- unmonitorCommand();
- }
- });
- cmdMenu.add(unmonitorItem);
-
- JMenu breakpointMenu = new JMenu("Breakpoint");
- JMenuItem stopItem = new JMenuItem("Stop in...", 'S');
- stopItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- buildBreakpoint();
- }
- });
- breakpointMenu.add(stopItem);
-
- JMenu helpMenu = new JMenu("Help");
- addTool(helpMenu, "Display command list", "Help", "help");
-
- this.add(fileMenu);
- this.add(cmdMenu);
-// this.add(breakpointMenu);
- this.add(helpMenu);
- }
-
- private void buildBreakpoint() {
- Frame frame = JOptionPane.getRootFrame();
- JDialog dialog = new JDialog(frame, "Specify Breakpoint");
- Container contents = dialog.getContentPane();
- Vector classes = new Vector();
- classes.add("Foo");
- classes.add("Bar");
- JList list = new JList(classes);
- JScrollPane scrollPane = new JScrollPane(list);
- contents.add(scrollPane);
- dialog.show();
-
- }
-
- private void monitorCommand() {
- String expr = (String)JOptionPane.showInputDialog(null,
- "Expression to monitor:", "Add Monitor",
- JOptionPane.QUESTION_MESSAGE, null, null, null);
- if (expr != null) {
- interpreter.executeCommand("monitor " + expr);
- }
- }
-
- private void unmonitorCommand() {
- List monitors = env.getMonitorListModel().monitors();
- String expr = (String)JOptionPane.showInputDialog(null,
- "Expression to unmonitor:", "Remove Monitor",
- JOptionPane.QUESTION_MESSAGE, null,
- monitors.toArray(),
- monitors.get(monitors.size()-1));
- if (expr != null) {
- interpreter.executeCommand("unmonitor " + expr);
- }
- }
-
- private void openCommand() {
- JFileChooser chooser = new JFileChooser();
- JDBFileFilter filter = new JDBFileFilter("java", "Java source code");
- chooser.setFileFilter(filter);
- int result = chooser.showOpenDialog(this);
- if (result == JFileChooser.APPROVE_OPTION) {
- System.out.println("Chose file: " + chooser.getSelectedFile().getName());
- }
- }
-
- private void addTool(JMenu menu, String toolTip, String labelText,
- String command) {
- JMenuItem mi = new JMenuItem(labelText);
- mi.setToolTipText(toolTip);
- final String cmd = command;
- mi.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- interpreter.executeCommand(cmd);
- }
- });
- menu.add(mi);
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBToolBar.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBToolBar.java
deleted file mode 100644
index ad82cb3780f..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/JDBToolBar.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.*;
-import java.awt.event.*;
-
-import com.sun.tools.example.debug.bdi.*;
-
-class JDBToolBar extends JToolBar {
-
- Environment env;
-
- ExecutionManager runtime;
- ClassManager classManager;
- SourceManager sourceManager;
-
- CommandInterpreter interpreter;
-
- JDBToolBar(Environment env) {
-
- this.env = env;
- this.runtime = env.getExecutionManager();
- this.classManager = env.getClassManager();
- this.sourceManager = env.getSourceManager();
- this.interpreter = new CommandInterpreter(env, true);
-
- //===== Configure toolbar here =====
-
- addTool("Run application", "run", "run");
- addTool("Connect to application", "connect", "connect");
- addSeparator();
-
- addTool("Step into next line", "step", "step");
- addTool("Step over next line", "next", "next");
-// addSeparator();
-
-// addTool("Step into next instruction", "stepi", "stepi");
-// addTool("Step over next instruction", "nexti", "nexti");
-// addSeparator();
-
- addTool("Step out of current method call", "step up", "step up");
- addSeparator();
-
- addTool("Suspend execution", "interrupt", "interrupt");
- addTool("Continue execution", "cont", "cont");
- addSeparator();
-
-// addTool("Display current stack", "where", "where");
-// addSeparator();
-
- addTool("Move up one stack frame", "up", "up");
- addTool("Move down one stack frame", "down", "down");
-// addSeparator();
-
-// addTool("Display command list", "help", "help");
-// addSeparator();
-
-// addTool("Exit debugger", "exit", "exit");
-
- //==================================
-
- }
-
- private void addTool(String toolTip, String labelText, String command) {
- JButton button = new JButton(labelText);
- button.setToolTipText(toolTip);
- final String cmd = command;
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- interpreter.executeCommand(cmd);
- }
- });
- this.add(button);
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/LaunchTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/LaunchTool.java
deleted file mode 100644
index 6ee9493be3a..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/LaunchTool.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import javax.swing.*;
-import javax.swing.border.Border;
-import javax.swing.border.TitledBorder;
-
-import com.sun.jdi.*;
-import com.sun.jdi.connect.*;
-
-import com.sun.tools.example.debug.bdi.*;
-
-class LaunchTool {
-
- private final ExecutionManager runtime;
-
- private abstract class ArgRep {
- final Connector.Argument arg;
- final JPanel panel;
-
- ArgRep(Connector.Argument arg) {
- this.arg = arg;
- panel = new JPanel();
- Border etched = BorderFactory.createEtchedBorder();
- Border titled = BorderFactory.createTitledBorder(etched,
- arg.description(),
- TitledBorder.LEFT, TitledBorder.TOP);
- panel.setBorder(titled);
- }
-
- abstract String getText();
-
- boolean isValid() {
- return arg.isValid(getText());
- }
-
- boolean isSpecified() {
- String value = getText();
- return (value != null && value.length() > 0) ||
- !arg.mustSpecify();
- }
-
- void install() {
- arg.setValue(getText());
- }
- }
-
- private class StringArgRep extends ArgRep {
- final JTextField textField;
-
- StringArgRep(Connector.Argument arg, JPanel comp) {
- super(arg);
- textField = new JTextField(arg.value(), 50 );
- textField.setBorder(BorderFactory.createLoweredBevelBorder());
-
- panel.add(new JLabel(arg.label(), SwingConstants.RIGHT));
- panel.add(textField); // , BorderLayout.CENTER);
- comp.add(panel);
- }
-
- @Override
- String getText() {
- return textField.getText();
- }
- }
-
- private class BooleanArgRep extends ArgRep {
- final JCheckBox check;
-
- BooleanArgRep(Connector.BooleanArgument barg, JPanel comp) {
- super(barg);
- check = new JCheckBox(barg.label());
- check.setSelected(barg.booleanValue());
- panel.add(check);
- comp.add(panel);
- }
-
- @Override
- String getText() {
- return ((Connector.BooleanArgument)arg)
- .stringValueOf(check.getModel().isSelected());
- }
- }
-
-
- private LaunchTool(ExecutionManager runtime) {
- this.runtime = runtime;
- }
-
- private Connector selectConnector() {
- final JDialog dialog = new JDialog();
- Container content = dialog.getContentPane();
- final JPanel radioPanel = new JPanel();
- final ButtonGroup radioGroup = new ButtonGroup();
- VirtualMachineManager manager = Bootstrap.virtualMachineManager();
- List all = manager.allConnectors();
- Map modelToConnector = new HashMap(all.size(), 0.5f);
-
- dialog.setModal(true);
- dialog.setTitle("Select Connector Type");
- radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
- for (Connector connector : all) {
- JRadioButton radio = new JRadioButton(connector.description());
- modelToConnector.put(radio.getModel(), connector);
- radioPanel.add(radio);
- radioGroup.add(radio);
- }
- content.add(radioPanel);
-
- final boolean[] oked = {false};
- JPanel buttonPanel = okCancel( dialog, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (radioGroup.getSelection() == null) {
- JOptionPane.showMessageDialog(dialog,
- "Please select a connector type",
- "No Selection",
- JOptionPane.ERROR_MESSAGE);
- } else {
- oked[0] = true;
- dialog.setVisible(false);
- dialog.dispose();
- }
- }
- } );
- content.add(BorderLayout.SOUTH, buttonPanel);
- dialog.pack();
- dialog.setVisible(true);
-
- return oked[0] ?
- modelToConnector.get(radioGroup.getSelection()) :
- null;
- }
-
- private void configureAndConnect(final Connector connector) {
- final JDialog dialog = new JDialog();
- final Map args = connector.defaultArguments();
-
- dialog.setModal(true);
- dialog.setTitle("Connector Arguments");
- Container content = dialog.getContentPane();
- JPanel guts = new JPanel();
- Border etched = BorderFactory.createEtchedBorder();
- BorderFactory.createTitledBorder(etched,
- connector.description(),
- TitledBorder.LEFT, TitledBorder.TOP);
- guts.setBorder(etched);
- guts.setLayout(new BoxLayout(guts, BoxLayout.Y_AXIS));
-
- // guts.add(new JLabel(connector.description()));
-
- final List argReps = new ArrayList(args.size());
- for (Connector.Argument arg : args.values()) {
- ArgRep ar;
- if (arg instanceof Connector.BooleanArgument) {
- ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts);
- } else {
- ar = new StringArgRep(arg, guts);
- }
- argReps.add(ar);
- }
- content.add(guts);
-
- JPanel buttonPanel = okCancel( dialog, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- for (ArgRep ar : argReps) {
- if (!ar.isSpecified()) {
- JOptionPane.showMessageDialog(dialog,
- ar.arg.label() +
- ": Argument must be specified",
- "No argument", JOptionPane.ERROR_MESSAGE);
- return;
- }
- if (!ar.isValid()) {
- JOptionPane.showMessageDialog(dialog,
- ar.arg.label() +
- ": Bad argument value: " +
- ar.getText(),
- "Bad argument", JOptionPane.ERROR_MESSAGE);
- return;
- }
- ar.install();
- }
- try {
- if (runtime.explictStart(connector, args)) {
- dialog.setVisible(false);
- dialog.dispose();
- } else {
- JOptionPane.showMessageDialog(dialog,
- "Bad arguments values: See diagnostics window.",
- "Bad arguments", JOptionPane.ERROR_MESSAGE);
- }
- } catch (VMLaunchFailureException exc) {
- JOptionPane.showMessageDialog(dialog,
- "Launch Failure: " + exc,
- "Launch Failed",JOptionPane.ERROR_MESSAGE);
- }
- }
- } );
- content.add(BorderLayout.SOUTH, buttonPanel);
- dialog.pack();
- dialog.setVisible(true);
- }
-
- private JPanel okCancel(final JDialog dialog, ActionListener okListener) {
- JPanel buttonPanel = new JPanel();
- JButton ok = new JButton("OK");
- JButton cancel = new JButton("Cancel");
- buttonPanel.add(ok);
- buttonPanel.add(cancel);
- ok.addActionListener(okListener);
- cancel.addActionListener( new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent event) {
- dialog.setVisible(false);
- dialog.dispose();
- }
- } );
- return buttonPanel;
- }
-
- static void queryAndLaunchVM(ExecutionManager runtime)
- throws VMLaunchFailureException {
- LaunchTool lt = new LaunchTool(runtime);
- Connector connector = lt.selectConnector();
- if (connector != null) {
- lt.configureAndConnect(connector);
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/MonitorListModel.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/MonitorListModel.java
deleted file mode 100644
index 6757735ec34..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/MonitorListModel.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.util.*;
-
-import javax.swing.AbstractListModel;
-
-public class MonitorListModel extends AbstractListModel {
-
- private final List monitors = new ArrayList();
-
- MonitorListModel(Environment env) {
-
- // Create listener.
- MonitorListListener listener = new MonitorListListener();
- env.getContextManager().addContextListener(listener);
-
- //### remove listeners on exit!
- }
-
- @Override
- public Object getElementAt(int index) {
- return monitors.get(index);
- }
-
- @Override
- public int getSize() {
- return monitors.size();
- }
-
- public void add(String expr) {
- monitors.add(expr);
- int newIndex = monitors.size()-1; // order important
- fireIntervalAdded(this, newIndex, newIndex);
- }
-
- public void remove(String expr) {
- int index = monitors.indexOf(expr);
- remove(index);
- }
-
- public void remove(int index) {
- monitors.remove(index);
- fireIntervalRemoved(this, index, index);
- }
-
- public List monitors() {
- return Collections.unmodifiableList(monitors);
- }
-
- public Iterator> iterator() {
- return monitors().iterator();
- }
-
- private void invalidate() {
- fireContentsChanged(this, 0, monitors.size()-1);
- }
-
- private class MonitorListListener implements ContextListener {
-
- @Override
- public void currentFrameChanged(final CurrentFrameChangedEvent e) {
- invalidate();
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/MonitorTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/MonitorTool.java
deleted file mode 100644
index 6eab85f5c5e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/MonitorTool.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.*;
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.bdi.*;
-import com.sun.tools.example.debug.expr.ExpressionParser;
-import com.sun.tools.example.debug.expr.ParseException;
-
-public class MonitorTool extends JPanel {
-
- private static final long serialVersionUID = -645235951031726647L;
- private ExecutionManager runtime;
- private ContextManager context;
-
- private JList list;
-
- public MonitorTool(Environment env) {
- super(new BorderLayout());
- this.runtime = env.getExecutionManager();
- this.context = env.getContextManager();
-
- list = new JList(env.getMonitorListModel());
- list.setCellRenderer(new MonitorRenderer());
-
- JScrollPane listView = new JScrollPane(list);
- add(listView);
-
- // Create listener.
- MonitorToolListener listener = new MonitorToolListener();
- list.addListSelectionListener(listener);
- //### remove listeners on exit!
- }
-
- private class MonitorToolListener implements ListSelectionListener {
- @Override
- public void valueChanged(ListSelectionEvent e) {
- int index = list.getSelectedIndex();
- if (index != -1) {
- }
- }
- }
-
- private Value evaluate(String expr) throws ParseException,
- InvocationException,
- InvalidTypeException,
- ClassNotLoadedException,
- IncompatibleThreadStateException {
- ExpressionParser.GetFrame frameGetter =
- new ExpressionParser.GetFrame() {
- @Override
- public StackFrame get()
- throws IncompatibleThreadStateException
- {
- try {
- return context.getCurrentFrame();
- } catch (VMNotInterruptedException exc) {
- throw new IncompatibleThreadStateException();
- }
- }
- };
- return ExpressionParser.evaluate(expr, runtime.vm(), frameGetter);
- }
-
- private class MonitorRenderer extends DefaultListCellRenderer {
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
-
- //### We should indicate the current thread independently of the
- //### selection, e.g., with an icon, because the user may change
- //### the selection graphically without affecting the current
- //### thread.
-
- super.getListCellRendererComponent(list, value, index,
- isSelected, cellHasFocus);
- if (value == null) {
- this.setText("");
- } else {
- String expr = (String)value;
- try {
- Value result = evaluate(expr);
- this.setText(expr + " = " + result);
- } catch (ParseException exc) {
- this.setText(expr + " ? " + exc.getMessage());
- } catch (IncompatibleThreadStateException exc) {
- this.setText(expr + " ...");
- } catch (Exception exc) {
- this.setText(expr + " ? " + exc);
- }
- }
- return this;
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/OutputSink.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/OutputSink.java
deleted file mode 100644
index 820a2c04bca..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/OutputSink.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-
-// This class is used in 'CommandInterpreter' as a hook to
-// allow messagebox style command output as an alternative
-// to a typescript. It should be an interface, not a class.
-
-public class OutputSink extends PrintWriter {
-
- // Currently, we do no buffering,
- // so 'show' is a no-op.
-
- OutputSink(Writer writer) {
- super(writer);
- }
-
- public void show() {
- // ignore
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SearchPath.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SearchPath.java
deleted file mode 100644
index 497584a3f8f..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SearchPath.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-public class SearchPath {
-
- private String pathString;
-
- private String[] pathArray;
-
- public SearchPath(String searchPath) {
- //### Should check searchpath for well-formedness.
- StringTokenizer st = new StringTokenizer(searchPath, File.pathSeparator);
- List dlist = new ArrayList();
- while (st.hasMoreTokens()) {
- dlist.add(st.nextToken());
- }
- pathString = searchPath;
- pathArray = dlist.toArray(new String[dlist.size()]);
- }
-
- public boolean isEmpty() {
- return (pathArray.length == 0);
- }
-
- public String asString() {
- return pathString;
- }
-
- public String[] asArray() {
- return pathArray.clone();
- }
-
- public File resolve(String relativeFileName) {
- for (String element : pathArray) {
- File path = new File(element, relativeFileName);
- if (path.exists()) {
- return path;
- }
- }
- return null;
- }
-
- //### return List?
-
- public String[] children(String relativeDirName, FilenameFilter filter) {
- // If a file appears at the same relative path
- // with respect to multiple entries on the classpath,
- // the one corresponding to the earliest entry on the
- // classpath is retained. This is the one that will be
- // found if we later do a 'resolve'.
- SortedSet s = new TreeSet(); // sorted, no duplicates
- for (String element : pathArray) {
- File path = new File(element, relativeDirName);
- if (path.exists()) {
- String[] childArray = path.list(filter);
- if (childArray != null) {
- for (int j = 0; j < childArray.length; j++) {
- if (!s.contains(childArray[j])) {
- s.add(childArray[j]);
- }
- }
- }
- }
- }
- return s.toArray(new String[s.size()]);
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SingleLeafTreeSelectionModel.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SingleLeafTreeSelectionModel.java
deleted file mode 100644
index 38688cb09a1..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SingleLeafTreeSelectionModel.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.tree.*;
-
-public class SingleLeafTreeSelectionModel extends DefaultTreeSelectionModel {
-
- private static final long serialVersionUID = -7849105107888117679L;
-
- SingleLeafTreeSelectionModel() {
- super();
- selectionMode = SINGLE_TREE_SELECTION;
- }
-
- @Override
- public void setSelectionPath(TreePath path) {
- if(((TreeNode)(path.getLastPathComponent())).isLeaf()) {
- super.setSelectionPath(path);
- }
- }
-
- @Override
- public void setSelectionPaths(TreePath[] paths) {
- // Only look at first path, as all others will be
- // ignored anyway in single tree selection mode.
- if(((TreeNode)(paths[0].getLastPathComponent())).isLeaf()) {
- super.setSelectionPaths(paths);
- }
- }
-
- @Override
- public void addSelectionPath(TreePath path) {
- if(((TreeNode)(path.getLastPathComponent())).isLeaf()) {
- super.setSelectionPath(path);
- }
- }
-
- @Override
- public void addSelectionPaths(TreePath[] paths) {
- // Only look at first path, as all others will be
- // ignored anyway in single tree selection mode.
- if(((TreeNode)(paths[0].getLastPathComponent())).isLeaf()) {
- super.addSelectionPaths(paths);
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceListener.java
deleted file mode 100644
index 0379cad1f62..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-public interface SourceListener {
- void sourcepathChanged(SourcepathChangedEvent e);
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceManager.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceManager.java
deleted file mode 100644
index f7d8d3cb11e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceManager.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-import com.sun.jdi.*;
-
-import com.sun.tools.example.debug.event.*;
-
-/**
- * Manage the list of source files.
- * Origin of SourceListener events.
- */
-public class SourceManager {
-
- //### TODO: The source cache should be aged, and some cap
- //### put on memory consumption by source files loaded into core.
-
- private List sourceList;
- private SearchPath sourcePath;
-
- private ArrayList sourceListeners = new ArrayList();
-
- private Map classToSource = new HashMap();
-
- private Environment env;
-
- /**
- * Hold on to it so it can be removed.
- */
- private SMClassListener classListener = new SMClassListener();
-
- public SourceManager(Environment env) {
- this(env, new SearchPath(""));
- }
-
- public SourceManager(Environment env, SearchPath sourcePath) {
- this.env = env;
- this.sourceList = new LinkedList();
- this.sourcePath = sourcePath;
- env.getExecutionManager().addJDIListener(classListener);
- }
-
- /**
- * Set path for access to source code.
- */
- public void setSourcePath(SearchPath sp) {
- sourcePath = sp;
- // Old cached sources are now invalid.
- sourceList = new LinkedList();
- notifySourcepathChanged();
- classToSource = new HashMap();
- }
-
- public void addSourceListener(SourceListener l) {
- sourceListeners.add(l);
- }
-
- public void removeSourceListener(SourceListener l) {
- sourceListeners.remove(l);
- }
-
- private void notifySourcepathChanged() {
- ArrayList l = new ArrayList(sourceListeners);
- SourcepathChangedEvent evt = new SourcepathChangedEvent(this);
- for (int i = 0; i < l.size(); i++) {
- l.get(i).sourcepathChanged(evt);
- }
- }
-
- /**
- * Get path for access to source code.
- */
- public SearchPath getSourcePath() {
- return sourcePath;
- }
-
- /**
- * Get source object associated with a Location.
- */
- public SourceModel sourceForLocation(Location loc) {
- return sourceForClass(loc.declaringType());
- }
-
- /**
- * Get source object associated with a class or interface.
- * Returns null if not available.
- */
- public SourceModel sourceForClass(ReferenceType refType) {
- SourceModel sm = classToSource.get(refType);
- if (sm != null) {
- return sm;
- }
- try {
- String filename = refType.sourceName();
- String refName = refType.name();
- int iDot = refName.lastIndexOf('.');
- String pkgName = (iDot >= 0)? refName.substring(0, iDot+1) : "";
- String full = pkgName.replace('.', File.separatorChar) + filename;
- File path = sourcePath.resolve(full);
- if (path != null) {
- sm = sourceForFile(path);
- classToSource.put(refType, sm);
- return sm;
- }
- return null;
- } catch (AbsentInformationException e) {
- return null;
- }
- }
-
- /**
- * Get source object associated with an absolute file path.
- */
- //### Use hash table for this?
- public SourceModel sourceForFile(File path) {
- Iterator iter = sourceList.iterator();
- SourceModel sm = null;
- while (iter.hasNext()) {
- SourceModel candidate = iter.next();
- if (candidate.fileName().equals(path)) {
- sm = candidate;
- iter.remove(); // Will move to start of list.
- break;
- }
- }
- if (sm == null && path.exists()) {
- sm = new SourceModel(env, path);
- }
- if (sm != null) {
- // At start of list for faster access
- sourceList.add(0, sm);
- }
- return sm;
- }
-
- private class SMClassListener extends JDIAdapter
- implements JDIListener {
-
- @Override
- public void classPrepare(ClassPrepareEventSet e) {
- ReferenceType refType = e.getReferenceType();
- SourceModel sm = sourceForClass(refType);
- if (sm != null) {
- sm.addClass(refType);
- }
- }
-
- @Override
- public void classUnload(ClassUnloadEventSet e) {
- //### iterate through looking for (e.getTypeName()).
- //### then remove it.
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceModel.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceModel.java
deleted file mode 100644
index 9b26646a70a..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceModel.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-import com.sun.jdi.*;
-import com.sun.jdi.request.*;
-
-import javax.swing.*;
-
-/**
- * Represents and manages one source file.
- * Caches source lines. Holds other source file info.
- */
-public class SourceModel extends AbstractListModel {
-
- private File path;
-
- boolean isActuallySource = true;
-
- private List classes = new ArrayList();
-
- private Environment env;
-
- // Cached line-by-line access.
-
- //### Unify this with source model used in source view?
- //### What is our cache-management policy for these?
- //### Even with weak refs, we won't discard any part of the
- //### source if the SourceModel object is reachable.
- /**
- * List of Line.
- */
- private List sourceLines = null;
-
- public static class Line {
- public String text;
- public boolean hasBreakpoint = false;
- public ReferenceType refType = null;
- Line(String text) {
- this.text = text;
- }
- public boolean isExecutable() {
- return refType != null;
- }
- public boolean hasBreakpoint() {
- return hasBreakpoint;
- }
- };
-
- // 132 characters long, all printable characters.
- public static final Line prototypeCellValue = new Line(
- "abcdefghijklmnopqrstuvwxyz" +
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
- "1234567890~!@#$%^&*()_+{}|" +
- ":<>?`-=[];',.XXXXXXXXXXXX/\\\"");
-
- SourceModel(Environment env, File path) {
- this.env = env;
- this.path = path;
- }
-
- public SourceModel(String message) {
- this.path = null;
- setMessage(message);
- }
-
- private void setMessage(String message) {
- isActuallySource = false;
- sourceLines = new ArrayList();
- sourceLines.add(new Line(message));
- }
-
- // **** Implement ListModel *****
-
- @Override
- public Object getElementAt(int index) {
- if (sourceLines == null) {
- initialize();
- }
- return sourceLines.get(index);
- }
-
- @Override
- public int getSize() {
- if (sourceLines == null) {
- initialize();
- }
- return sourceLines.size();
- }
-
- // ***** Other functionality *****
-
- public File fileName() {
- return path;
- }
-
- public BufferedReader sourceReader() throws IOException {
- return new BufferedReader(new FileReader(path));
- }
-
- public Line line(int lineNo) {
- if (sourceLines == null) {
- initialize();
- }
- int index = lineNo - 1; // list is 0-indexed
- if (index >= sourceLines.size() || index < 0) {
- return null;
- } else {
- return sourceLines.get(index);
- }
- }
-
- public String sourceLine(int lineNo) {
- Line line = line(lineNo);
- if (line == null) {
- return null;
- } else {
- return line.text;
- }
- }
-
- void addClass(ReferenceType refType) {
- // Logically is Set
- if (classes.indexOf(refType) == -1) {
- classes.add(refType);
- if (sourceLines != null) {
- markClassLines(refType);
- }
- }
- }
-
- /**
- * @return List of currently known {@link com.sun.jdi.ReferenceType}
- * in this source file.
- */
- public List referenceTypes() {
- return Collections.unmodifiableList(classes);
- }
-
- private void initialize() {
- try {
- rawInit();
- } catch (IOException exc) {
- setMessage("[Error reading source code]");
- }
- }
-
- public void showBreakpoint(int ln, boolean hasBreakpoint) {
- line(ln).hasBreakpoint = hasBreakpoint;
- fireContentsChanged(this, ln, ln);
- }
-
- public void showExecutable(int ln, ReferenceType refType) {
- line(ln).refType = refType;
- fireContentsChanged(this, ln, ln);
- }
-
- /**
- * Mark executable lines and breakpoints, but only
- * when sourceLines is set.
- */
- private void markClassLines(ReferenceType refType) {
- for (Method meth : refType.methods()) {
- try {
- for (Location loc : meth.allLineLocations()) {
- showExecutable(loc.lineNumber(), refType);
- }
- } catch (AbsentInformationException exc) {
- // do nothing
- }
- }
- for (BreakpointRequest bp :
- env.getExecutionManager().eventRequestManager().breakpointRequests()) {
- if (bp.location() != null) {
- Location loc = bp.location();
- if (loc.declaringType().equals(refType)) {
- showBreakpoint(loc.lineNumber(),true);
- }
- }
- }
- }
-
- private void rawInit() throws IOException {
- sourceLines = new ArrayList();
- BufferedReader reader = sourceReader();
- try {
- String line = reader.readLine();
- while (line != null) {
- sourceLines.add(new Line(expandTabs(line)));
- line = reader.readLine();
- }
- } finally {
- reader.close();
- }
- for (ReferenceType refType : classes) {
- markClassLines(refType);
- }
- }
-
- private String expandTabs(String s) {
- int col = 0;
- int len = s.length();
- StringBuilder sb = new StringBuilder(132);
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- sb.append(c);
- if (c == '\t') {
- int pad = (8 - (col % 8));
- for (int j = 0; j < pad; j++) {
- sb.append(' ');
- }
- col += pad;
- } else {
- col++;
- }
- }
- return sb.toString();
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceTool.java
deleted file mode 100644
index 4d0d37df4d5..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceTool.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-import com.sun.jdi.*;
-import com.sun.jdi.request.*;
-
-import com.sun.tools.example.debug.bdi.*;
-
-public class SourceTool extends JPanel {
-
- private static final long serialVersionUID = -5461299294186395257L;
-
- private Environment env;
-
- private ExecutionManager runtime;
- private ContextManager context;
- private SourceManager sourceManager;
-
- private JList list;
- private ListModel sourceModel;
-
- // Information on source file that is on display, or failed to be
- // displayed due to inaccessible source. Used to update display
- // when sourcepath is changed.
-
- private String sourceName; // relative path name, if showSourceFile
- private Location sourceLocn; // location, if showSourceForLocation
- private CommandInterpreter interpreter;
-
- public SourceTool(Environment env) {
-
- super(new BorderLayout());
-
- this.env = env;
-
- runtime = env.getExecutionManager();
- sourceManager = env.getSourceManager();
- this.context = env.getContextManager();
- this.interpreter = new CommandInterpreter(env, true);
-
- sourceModel = new DefaultListModel(); // empty
-
- list = new JList(sourceModel);
- list.setCellRenderer(new SourceLineRenderer());
-
- list.setPrototypeCellValue(SourceModel.prototypeCellValue);
-
- SourceToolListener listener = new SourceToolListener();
- context.addContextListener(listener);
- runtime.addSpecListener(listener);
- sourceManager.addSourceListener(listener);
-
- MouseListener squeek = new STMouseListener();
- list.addMouseListener(squeek);
-
- add(new JScrollPane(list));
- }
-
- public void setTextFont(Font f) {
- list.setFont(f);
- list.setPrototypeCellValue(SourceModel.prototypeCellValue);
- }
-
- private class SourceToolListener
- implements ContextListener, SourceListener, SpecListener
- {
-
- // ContextListener
-
- @Override
- public void currentFrameChanged(CurrentFrameChangedEvent e) {
- showSourceContext(e.getThread(), e.getIndex());
- }
-
- // Clear source view.
- // sourceModel = new DefaultListModel(); // empty
-
- // SourceListener
-
- @Override
- public void sourcepathChanged(SourcepathChangedEvent e) {
- // Reload source view if its contents depend
- // on the source path.
- if (sourceName != null) {
- showSourceFile(sourceName);
- } else if (sourceLocn != null) {
- showSourceForLocation(sourceLocn);
- }
- }
-
- // SpecListener
-
- @Override
- public void breakpointSet(SpecEvent e) {
- breakpointResolved(e);
- }
-
- @Override
- public void breakpointDeferred(SpecEvent e) { }
-
- @Override
- public void breakpointDeleted(SpecEvent e) {
- BreakpointRequest req = (BreakpointRequest)e.getEventRequest();
- Location loc = req.location();
- if (loc != null) {
- try {
- SourceModel sm = sourceManager.sourceForLocation(loc);
- sm.showBreakpoint(loc.lineNumber(), false);
- showSourceForLocation(loc);
- } catch (Exception exc) {
- }
- }
- }
-
- @Override
- public void breakpointResolved(SpecEvent e) {
- BreakpointRequest req = (BreakpointRequest)e.getEventRequest();
- Location loc = req.location();
- try {
- SourceModel sm = sourceManager.sourceForLocation(loc);
- sm.showBreakpoint(loc.lineNumber(), true);
- showSourceForLocation(loc);
- } catch (Exception exc) {
- }
- }
-
- @Override
- public void breakpointError(SpecErrorEvent e) {
- breakpointDeleted(e);
- }
-
- @Override
- public void watchpointSet(SpecEvent e) {
- }
- @Override
- public void watchpointDeferred(SpecEvent e) {
- }
- @Override
- public void watchpointDeleted(SpecEvent e) {
- }
- @Override
- public void watchpointResolved(SpecEvent e) {
- }
- @Override
- public void watchpointError(SpecErrorEvent e) {
- }
-
- @Override
- public void exceptionInterceptSet(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptDeferred(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptDeleted(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptResolved(SpecEvent e) {
- }
- @Override
- public void exceptionInterceptError(SpecErrorEvent e) {
- }
- }
-
- private void showSourceContext(ThreadReference thread, int index) {
- //### Should use ThreadInfo here.
- StackFrame frame = null;
- if (thread != null) {
- try {
- frame = thread.frame(index);
- } catch (IncompatibleThreadStateException e) {}
- }
- if (frame == null) {
- return;
- }
- Location locn = frame.location();
- /*****
- if (!showSourceForLocation(locn)) {
- env.notice("Could not display source for "
- + Utils.locationString(locn));
- }
- *****/
- showSourceForLocation(locn);
- }
-
- public boolean showSourceForLocation(Location locn) {
- sourceName = null;
- sourceLocn = locn;
- int lineNo = locn.lineNumber();
- if (lineNo != -1) {
- SourceModel source = sourceManager.sourceForLocation(locn);
- if (source != null) {
- showSourceAtLine(source, lineNo-1);
- return true;
- }
- }
- // Here if we could not display source.
- showSourceUnavailable();
- return false;
- }
-
- public boolean showSourceFile(String fileName) {
- sourceLocn = null;
- File file;
- if (!fileName.startsWith(File.separator)) {
- sourceName = fileName;
- SearchPath sourcePath = sourceManager.getSourcePath();
- file = sourcePath.resolve(fileName);
- if (file == null) {
- //env.failure("Source not found on current source path.");
- showSourceUnavailable();
- return false;
- }
- } else {
- sourceName = null; // Absolute pathname does not depend on sourcepath.
- file = new File(fileName);
- }
- SourceModel source = sourceManager.sourceForFile(file);
- if (source != null) {
- showSource(source);
- return true;
- }
- showSourceUnavailable();
- return false;
- }
-
- private void showSource(SourceModel model) {
- setViewModel(model);
- }
-
- private void showSourceAtLine(SourceModel model, int lineNo) {
- setViewModel(model);
- if (model.isActuallySource && (lineNo < model.getSize())) {
- list.setSelectedIndex(lineNo);
- if (lineNo+4 < model.getSize()) {
- list.ensureIndexIsVisible(lineNo+4); // give some context
- }
- list.ensureIndexIsVisible(lineNo);
- }
- }
-
- private void showSourceUnavailable() {
- SourceModel model = new SourceModel("[Source code is not available]");
- setViewModel(model);
- }
-
- private void setViewModel(SourceModel model) {
- if (model != sourceModel) {
- // install new model
- list.setModel(model);
- sourceModel = model;
- }
- }
-
- private class SourceLineRenderer extends DefaultListCellRenderer {
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
-
- //### Should set background highlight and/or icon if breakpoint on this line.
- // Configures "this"
- super.getListCellRendererComponent(list, value, index,
- isSelected, cellHasFocus);
-
- SourceModel.Line line = (SourceModel.Line)value;
-
- //### Tab expansion is now done when source file is read in,
- //### to speed up display. This costs a lot of space, slows
- //### down source file loading, and has not been demonstrated
- //### to yield an observable improvement in display performance.
- //### Measurements may be appropriate here.
- //String sourceLine = expandTabs((String)value);
- setText(line.text);
- if (line.hasBreakpoint) {
- setIcon(Icons.stopSignIcon);
- } else if (line.isExecutable()) {
- setIcon(Icons.execIcon);
- } else {
- setIcon(Icons.blankIcon);
- }
-
-
- return this;
- }
-
- @Override
- public Dimension getPreferredSize() {
- Dimension dim = super.getPreferredSize();
- return new Dimension(dim.width, dim.height-5);
- }
-
- }
-
- private class STMouseListener extends MouseAdapter implements MouseListener {
- @Override
- public void mousePressed(MouseEvent e) {
- if (e.isPopupTrigger()) {
- showPopupMenu((Component)e.getSource(),
- e.getX(), e.getY());
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- if (e.isPopupTrigger()) {
- showPopupMenu((Component)e.getSource(),
- e.getX(), e.getY());
- }
- }
-
- private void showPopupMenu(Component invoker, int x, int y) {
- JList list = (JList)invoker;
- int ln = list.getSelectedIndex() + 1;
- SourceModel.Line line =
- (SourceModel.Line)list.getSelectedValue();
- JPopupMenu popup = new JPopupMenu();
-
- if (line == null) {
- popup.add(new JMenuItem("please select a line"));
- } else if (line.isExecutable()) {
- String className = line.refType.name();
- if (line.hasBreakpoint()) {
- popup.add(commandItem("Clear Breakpoint",
- "clear " + className +
- ":" + ln));
- } else {
- popup.add(commandItem("Set Breakpoint",
- "stop at " + className +
- ":" + ln));
- }
- } else {
- popup.add(new JMenuItem("not an executable line"));
- }
-
- popup.show(invoker,
- x + popup.getWidth()/2, y + popup.getHeight()/2);
- }
-
- private JMenuItem commandItem(String label, final String cmd) {
- JMenuItem item = new JMenuItem(label);
- item.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- interpreter.executeCommand(cmd);
- }
- });
- return item;
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceTreeTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceTreeTool.java
deleted file mode 100644
index b8591818572..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourceTreeTool.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.tree.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import com.sun.tools.example.debug.bdi.*;
-
-public class SourceTreeTool extends JPanel {
-
- private static final long serialVersionUID = 3336680912107956419L;
-
- private Environment env;
-
- private ExecutionManager runtime;
- private SourceManager sourceManager;
- private ClassManager classManager;
-
- private JTree tree;
- private SourceTreeNode root;
- private SearchPath sourcePath;
- private CommandInterpreter interpreter;
-
- private static String HEADING = "SOURCES";
-
- public SourceTreeTool(Environment env) {
-
- super(new BorderLayout());
-
- this.env = env;
- this.runtime = env.getExecutionManager();
- this.sourceManager = env.getSourceManager();
-
- this.interpreter = new CommandInterpreter(env);
-
- sourcePath = sourceManager.getSourcePath();
- root = createDirectoryTree(HEADING);
-
- // Create a tree that allows one selection at a time.
- tree = new JTree(new DefaultTreeModel(root));
- tree.setSelectionModel(new SingleLeafTreeSelectionModel());
-
- /******
- // Listen for when the selection changes.
- tree.addTreeSelectionListener(new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- SourceTreeNode node = (SourceTreeNode)
- (e.getPath().getLastPathComponent());
- interpreter.executeCommand("view " + node.getRelativePath());
- }
- });
- ******/
-
- MouseListener ml = new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- int selRow = tree.getRowForLocation(e.getX(), e.getY());
- TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
- if(selRow != -1) {
- if(e.getClickCount() == 1) {
- SourceTreeNode node =
- (SourceTreeNode)selPath.getLastPathComponent();
- // If user clicks on leaf, select it, and issue 'view' command.
- if (node.isLeaf()) {
- tree.setSelectionPath(selPath);
- interpreter.executeCommand("view " + node.getRelativePath());
- }
- }
- }
- }
- };
- tree.addMouseListener(ml);
-
- JScrollPane treeView = new JScrollPane(tree);
- add(treeView);
-
- // Create listener for source path changes.
-
- SourceTreeToolListener listener = new SourceTreeToolListener();
- sourceManager.addSourceListener(listener);
-
- //### remove listeners on exit!
- }
-
- private class SourceTreeToolListener implements SourceListener {
-
- @Override
- public void sourcepathChanged(SourcepathChangedEvent e) {
- sourcePath = sourceManager.getSourcePath();
- root = createDirectoryTree(HEADING);
- tree.setModel(new DefaultTreeModel(root));
- }
-
- }
-
- private static class SourceOrDirectoryFilter implements FilenameFilter {
- @Override
- public boolean accept(File dir, String name) {
- return (name.endsWith(".java") ||
- new File(dir, name).isDirectory());
- }
- }
-
- private static FilenameFilter filter = new SourceOrDirectoryFilter();
-
- SourceTreeNode createDirectoryTree(String label) {
- try {
- return new SourceTreeNode(label, null, "", true);
- } catch (SecurityException e) {
- env.failure("Cannot access source file or directory");
- return null;
- }
- }
-
-
- class SourceTreeNode implements TreeNode {
-
- private String name;
- private boolean isDirectory;
- private SourceTreeNode parent;
- private SourceTreeNode[] children;
- private String relativePath;
- private boolean isExpanded;
-
- private SourceTreeNode(String label,
- SourceTreeNode parent,
- String relativePath,
- boolean isDirectory) {
- this.name = label;
- this.relativePath = relativePath;
- this.parent = parent;
- this.isDirectory = isDirectory;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public String getRelativePath() {
- return relativePath;
- }
-
- private void expandIfNeeded() {
- try {
- if (!isExpanded && isDirectory) {
- String[] files = sourcePath.children(relativePath, filter);
- children = new SourceTreeNode[files.length];
- for (int i = 0; i < files.length; i++) {
- String childName =
- (relativePath.equals(""))
- ? files[i]
- : relativePath + File.separator + files[i];
- File file = sourcePath.resolve(childName);
- boolean isDir = (file != null && file.isDirectory());
- children[i] =
- new SourceTreeNode(files[i], this, childName, isDir);
- }
- }
- isExpanded = true;
- } catch (SecurityException e) {
- children = null;
- env.failure("Cannot access source file or directory");
- }
- }
-
- // -- interface TreeNode --
-
- /*
- * Returns the child TreeNode
at index
- * childIndex
.
- */
- @Override
- public TreeNode getChildAt(int childIndex) {
- expandIfNeeded();
- return children[childIndex];
- }
-
- /**
- * Returns the number of children TreeNode
s the receiver
- * contains.
- */
- @Override
- public int getChildCount() {
- expandIfNeeded();
- return children.length;
- }
-
- /**
- * Returns the parent TreeNode
of the receiver.
- */
- @Override
- public TreeNode getParent() {
- return parent;
- }
-
- /**
- * Returns the index of node
in the receivers children.
- * If the receiver does not contain node
, -1 will be
- * returned.
- */
- @Override
- public int getIndex(TreeNode node) {
- expandIfNeeded();
- for (int i = 0; i < children.length; i++) {
- if (children[i] == node) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Returns true if the receiver allows children.
- */
- @Override
- public boolean getAllowsChildren() {
- return isDirectory;
- }
-
- /**
- * Returns true if the receiver is a leaf.
- */
- @Override
- public boolean isLeaf() {
- expandIfNeeded();
- return !isDirectory;
- }
-
- /**
- * Returns the children of the receiver as an Enumeration.
- */
- @Override
- public Enumeration children() {
- expandIfNeeded();
- return new Enumeration() {
- int i = 0;
- @Override
- public boolean hasMoreElements() {
- return (i < children.length);
- }
- @Override
- public Object nextElement() throws NoSuchElementException {
- if (i >= children.length) {
- throw new NoSuchElementException();
- }
- return children[i++];
- }
- };
- }
-
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourcepathChangedEvent.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourcepathChangedEvent.java
deleted file mode 100644
index f6c07ec7ae8..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/SourcepathChangedEvent.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.util.EventObject;
-
-public class SourcepathChangedEvent extends EventObject {
-
- private static final long serialVersionUID = 8762169481005804121L;
-
- public SourcepathChangedEvent(Object source) {
- super(source);
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/StackTraceTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/StackTraceTool.java
deleted file mode 100644
index 538d3a53d88..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/StackTraceTool.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.*;
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.bdi.*;
-
-public class StackTraceTool extends JPanel {
-
- private static final long serialVersionUID = 9140041989427965718L;
-
- private Environment env;
-
- private ExecutionManager runtime;
- private ContextManager context;
-
- private ThreadInfo tinfo;
-
- private JList list;
- private ListModel stackModel;
-
- public StackTraceTool(Environment env) {
-
- super(new BorderLayout());
-
- this.env = env;
- this.runtime = env.getExecutionManager();
- this.context = env.getContextManager();
-
- stackModel = new DefaultListModel(); // empty
-
- list = new JList(stackModel);
- list.setCellRenderer(new StackFrameRenderer());
-
- JScrollPane listView = new JScrollPane(list);
- add(listView);
-
- // Create listener.
- StackTraceToolListener listener = new StackTraceToolListener();
- context.addContextListener(listener);
- list.addListSelectionListener(listener);
-
- //### remove listeners on exit!
- }
-
- private class StackTraceToolListener
- implements ContextListener, ListSelectionListener
- {
-
- // ContextListener
-
- // If the user selects a new current frame, display it in
- // this view.
-
- //### I suspect we handle the case badly that the VM is not interrupted.
-
- @Override
- public void currentFrameChanged(CurrentFrameChangedEvent e) {
- // If the current frame of the thread appearing in this
- // view is changed, move the selection to track it.
- int frameIndex = e.getIndex();
- ThreadInfo ti = e.getThreadInfo();
- if (e.getInvalidate() || tinfo != ti) {
- tinfo = ti;
- showStack(ti, frameIndex);
- } else {
- if (frameIndex < stackModel.getSize()) {
- list.setSelectedIndex(frameIndex);
- list.ensureIndexIsVisible(frameIndex);
- }
- }
- }
-
- // ListSelectionListener
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- int index = list.getSelectedIndex();
- if (index != -1) {
- //### should use listener?
- try {
- context.setCurrentFrameIndex(index);
- } catch (VMNotInterruptedException exc) {
- }
- }
- }
- }
-
- private class StackFrameRenderer extends DefaultListCellRenderer {
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
-
- //### We should indicate the current thread independently of the
- //### selection, e.g., with an icon, because the user may change
- //### the selection graphically without affecting the current
- //### thread.
-
- super.getListCellRendererComponent(list, value, index,
- isSelected, cellHasFocus);
- if (value == null) {
- this.setText("");
- } else {
- StackFrame frame = (StackFrame)value;
- Location loc = frame.location();
- Method meth = loc.method();
- String methName =
- meth.declaringType().name() + '.' + meth.name();
- String position = "";
- if (meth.isNative()) {
- position = " (native method)";
- } else if (loc.lineNumber() != -1) {
- position = ":" + loc.lineNumber();
- } else {
- long pc = loc.codeIndex();
- if (pc != -1) {
- position = ", pc = " + pc;
- }
- }
- // Indices are presented to the user starting from 1, not 0.
- this.setText("[" + (index+1) +"] " + methName + position);
- }
- return this;
- }
- }
-
- // Point this view at the given thread and frame.
-
- private void showStack(ThreadInfo tinfo, int selectFrame) {
- StackTraceListModel model = new StackTraceListModel(tinfo);
- stackModel = model;
- list.setModel(stackModel);
- list.setSelectedIndex(selectFrame);
- list.ensureIndexIsVisible(selectFrame);
- }
-
- private static class StackTraceListModel extends AbstractListModel {
-
- private final ThreadInfo tinfo;
-
- public StackTraceListModel(ThreadInfo tinfo) {
- this.tinfo = tinfo;
- }
-
- @Override
- public Object getElementAt(int index) {
- try {
- return tinfo == null? null : tinfo.getFrame(index);
- } catch (VMNotInterruptedException e) {
- //### Is this the right way to handle this?
- //### Would happen if user scrolled stack trace
- //### while not interrupted -- should probably
- //### block user interaction in this case.
- return null;
- }
- }
-
- @Override
- public int getSize() {
- try {
- return tinfo == null? 1 : tinfo.getFrameCount();
- } catch (VMNotInterruptedException e) {
- //### Is this the right way to handle this?
- return 0;
- }
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ThreadTreeTool.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ThreadTreeTool.java
deleted file mode 100644
index 7a24c963aeb..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/ThreadTreeTool.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.util.*;
-import java.util.List; // Must import explicitly due to conflict with javax.awt.List
-
-import javax.swing.*;
-import javax.swing.tree.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import com.sun.jdi.*;
-import com.sun.tools.example.debug.event.*;
-import com.sun.tools.example.debug.bdi.*;
-
-//### Bug: If the name of a thread is changed via Thread.setName(), the
-//### thread tree view does not reflect this. The name of the thread at
-//### the time it is created is used throughout its lifetime.
-
-public class ThreadTreeTool extends JPanel {
-
- private static final long serialVersionUID = 4168599992853038878L;
-
- private Environment env;
-
- private ExecutionManager runtime;
- private SourceManager sourceManager;
- private ClassManager classManager;
-
- private JTree tree;
- private DefaultTreeModel treeModel;
- private ThreadTreeNode root;
- private SearchPath sourcePath;
-
- private CommandInterpreter interpreter;
-
- private static String HEADING = "THREADS";
-
- public ThreadTreeTool(Environment env) {
-
- super(new BorderLayout());
-
- this.env = env;
- this.runtime = env.getExecutionManager();
- this.sourceManager = env.getSourceManager();
-
- this.interpreter = new CommandInterpreter(env);
-
- root = createThreadTree(HEADING);
- treeModel = new DefaultTreeModel(root);
-
- // Create a tree that allows one selection at a time.
-
- tree = new JTree(treeModel);
- tree.setSelectionModel(new SingleLeafTreeSelectionModel());
-
- MouseListener ml = new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- int selRow = tree.getRowForLocation(e.getX(), e.getY());
- TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
- if(selRow != -1) {
- if(e.getClickCount() == 1) {
- ThreadTreeNode node =
- (ThreadTreeNode)selPath.getLastPathComponent();
- // If user clicks on leaf, select it, and issue 'thread' command.
- if (node.isLeaf()) {
- tree.setSelectionPath(selPath);
- interpreter.executeCommand("thread " +
- node.getThreadId() +
- " (\"" +
- node.getName() + "\")");
- }
- }
- }
- }
- };
-
- tree.addMouseListener(ml);
-
- JScrollPane treeView = new JScrollPane(tree);
- add(treeView);
-
- // Create listener.
- ThreadTreeToolListener listener = new ThreadTreeToolListener();
- runtime.addJDIListener(listener);
- runtime.addSessionListener(listener);
-
- //### remove listeners on exit!
- }
-
- HashMap> threadTable = new HashMap>();
-
- private List threadPath(ThreadReference thread) {
- // May exit abnormally if VM disconnects.
- List l = new ArrayList();
- l.add(0, thread.name());
- ThreadGroupReference group = thread.threadGroup();
- while (group != null) {
- l.add(0, group.name());
- group = group.parent();
- }
- return l;
- }
-
- private class ThreadTreeToolListener extends JDIAdapter
- implements JDIListener, SessionListener {
-
- // SessionListener
-
- @Override
- public void sessionStart(EventObject e) {
- try {
- for (ThreadReference thread : runtime.allThreads()) {
- root.addThread(thread);
- }
- } catch (VMDisconnectedException ee) {
- // VM went away unexpectedly.
- } catch (NoSessionException ee) {
- // Ignore. Should not happen.
- }
- }
-
- @Override
- public void sessionInterrupt(EventObject e) {}
- @Override
- public void sessionContinue(EventObject e) {}
-
-
- // JDIListener
-
- @Override
- public void threadStart(ThreadStartEventSet e) {
- root.addThread(e.getThread());
- }
-
- @Override
- public void threadDeath(ThreadDeathEventSet e) {
- root.removeThread(e.getThread());
- }
-
- @Override
- public void vmDisconnect(VMDisconnectEventSet e) {
- // Clear the contents of this view.
- root = createThreadTree(HEADING);
- treeModel = new DefaultTreeModel(root);
- tree.setModel(treeModel);
- threadTable = new HashMap>();
- }
-
- }
-
- ThreadTreeNode createThreadTree(String label) {
- return new ThreadTreeNode(label, null);
- }
-
- class ThreadTreeNode extends DefaultMutableTreeNode {
-
- String name;
- ThreadReference thread; // null if thread group
- long uid;
- String description;
-
- ThreadTreeNode(String name, ThreadReference thread) {
- if (name == null) {
- name = "";
- }
- this.name = name;
- this.thread = thread;
- if (thread == null) {
- this.uid = -1;
- this.description = name;
- } else {
- this.uid = thread.uniqueID();
- this.description = name + " (t@" + Long.toHexString(uid) + ")";
- }
- }
-
- @Override
- public String toString() {
- return description;
- }
-
- public String getName() {
- return name;
- }
-
- public ThreadReference getThread() {
- return thread;
- }
-
- public String getThreadId() {
- return "t@" + Long.toHexString(uid);
- }
-
- private boolean isThreadGroup() {
- return (thread == null);
- }
-
- @Override
- public boolean isLeaf() {
- return !isThreadGroup();
- }
-
- public void addThread(ThreadReference thread) {
- // This can fail if the VM disconnects.
- // It is important to do all necessary JDI calls
- // before modifying the tree, so we don't abort
- // midway through!
- if (threadTable.get(thread) == null) {
- // Add thread only if not already present.
- try {
- List path = threadPath(thread);
- // May not get here due to exception.
- // If we get here, we are committed.
- // We must not leave the tree partially updated.
- try {
- threadTable.put(thread, path);
- addThread(path, thread);
- } catch (Throwable tt) {
- //### Assertion failure.
- throw new RuntimeException("ThreadTree corrupted");
- }
- } catch (VMDisconnectedException ee) {
- // Ignore. Thread will not be added.
- }
- }
- }
-
- private void addThread(List threadPath, ThreadReference thread) {
- int size = threadPath.size();
- if (size == 0) {
- return;
- } else if (size == 1) {
- String name = threadPath.get(0);
- insertNode(name, thread);
- } else {
- String head = threadPath.get(0);
- List tail = threadPath.subList(1, size);
- ThreadTreeNode child = insertNode(head, null);
- child.addThread(tail, thread);
- }
- }
-
- private ThreadTreeNode insertNode(String name, ThreadReference thread) {
- for (int i = 0; i < getChildCount(); i++) {
- ThreadTreeNode child = (ThreadTreeNode)getChildAt(i);
- int cmp = name.compareTo(child.getName());
- if (cmp == 0 && thread == null) {
- // A like-named interior node already exists.
- return child;
- } else if (cmp < 0) {
- // Insert new node before the child.
- ThreadTreeNode newChild = new ThreadTreeNode(name, thread);
- treeModel.insertNodeInto(newChild, this, i);
- return newChild;
- }
- }
- // Insert new node after last child.
- ThreadTreeNode newChild = new ThreadTreeNode(name, thread);
- treeModel.insertNodeInto(newChild, this, getChildCount());
- return newChild;
- }
-
- public void removeThread(ThreadReference thread) {
- List threadPath = threadTable.get(thread);
- // Only remove thread if we recorded it in table.
- // Original add may have failed due to VM disconnect.
- if (threadPath != null) {
- removeThread(threadPath, thread);
- }
- }
-
- private void removeThread(List threadPath, ThreadReference thread) {
- int size = threadPath.size();
- if (size == 0) {
- return;
- } else if (size == 1) {
- String name = threadPath.get(0);
- ThreadTreeNode child = findLeafNode(thread, name);
- treeModel.removeNodeFromParent(child);
- } else {
- String head = threadPath.get(0);
- List tail = threadPath.subList(1, size);
- ThreadTreeNode child = findInternalNode(head);
- child.removeThread(tail, thread);
- if (child.isThreadGroup() && child.getChildCount() < 1) {
- // Prune non-leaf nodes with no children.
- treeModel.removeNodeFromParent(child);
- }
- }
- }
-
- private ThreadTreeNode findLeafNode(ThreadReference thread, String name) {
- for (int i = 0; i < getChildCount(); i++) {
- ThreadTreeNode child = (ThreadTreeNode)getChildAt(i);
- if (child.getThread() == thread) {
- if (!name.equals(child.getName())) {
- //### Assertion failure.
- throw new RuntimeException("name mismatch");
- }
- return child;
- }
- }
- //### Assertion failure.
- throw new RuntimeException("not found");
- }
-
- private ThreadTreeNode findInternalNode(String name) {
- for (int i = 0; i < getChildCount(); i++) {
- ThreadTreeNode child = (ThreadTreeNode)getChildAt(i);
- if (name.equals(child.getName())) {
- return child;
- }
- }
- //### Assertion failure.
- throw new RuntimeException("not found");
- }
-
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScript.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScript.java
deleted file mode 100644
index 21b55f42fea..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScript.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-public class TypeScript extends JPanel {
-
- private static final long serialVersionUID = -983704841363534885L;
- private JTextArea history;
- private JTextField entry;
-
- private JLabel promptLabel;
-
- private JScrollBar historyVScrollBar;
- private JScrollBar historyHScrollBar;
-
- private boolean echoInput = false;
-
- private static String newline = System.getProperty("line.separator");
-
- public TypeScript(String prompt) {
- this(prompt, true);
- }
-
- public TypeScript(String prompt, boolean echoInput) {
- this.echoInput = echoInput;
-
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- //setBorder(new EmptyBorder(5, 5, 5, 5));
-
- history = new JTextArea(0, 0);
- history.setEditable(false);
- JScrollPane scroller = new JScrollPane(history);
- historyVScrollBar = scroller.getVerticalScrollBar();
- historyHScrollBar = scroller.getHorizontalScrollBar();
-
- add(scroller);
-
- JPanel cmdLine = new JPanel();
- cmdLine.setLayout(new BoxLayout(cmdLine, BoxLayout.X_AXIS));
- //cmdLine.setBorder(new EmptyBorder(5, 5, 0, 0));
-
- promptLabel = new JLabel(prompt + " ");
- cmdLine.add(promptLabel);
- entry = new JTextField();
-//### Swing bug workaround.
-entry.setMaximumSize(new Dimension(1000, 20));
- cmdLine.add(entry);
- add(cmdLine);
- }
-
- /******
- public void setFont(Font f) {
- entry.setFont(f);
- history.setFont(f);
- }
- ******/
-
- public void setPrompt(String prompt) {
- promptLabel.setText(prompt + " ");
- }
-
- public void append(String text) {
- history.append(text);
- historyVScrollBar.setValue(historyVScrollBar.getMaximum());
- historyHScrollBar.setValue(historyHScrollBar.getMinimum());
- }
-
- public void newline() {
- history.append(newline);
- historyVScrollBar.setValue(historyVScrollBar.getMaximum());
- historyHScrollBar.setValue(historyHScrollBar.getMinimum());
- }
-
- public void flush() {}
-
- public void addActionListener(ActionListener a) {
- entry.addActionListener(a);
- }
-
- public void removeActionListener(ActionListener a) {
- entry.removeActionListener(a);
- }
-
- public String readln() {
- String text = entry.getText();
- entry.setText("");
- if (echoInput) {
- history.append(">>>");
- history.append(text);
- history.append(newline);
- historyVScrollBar.setValue(historyVScrollBar.getMaximum());
- historyHScrollBar.setValue(historyHScrollBar.getMinimum());
- }
- return text;
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScriptOutputListener.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScriptOutputListener.java
deleted file mode 100644
index 47b7de3ec1d..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScriptOutputListener.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import com.sun.tools.example.debug.bdi.OutputListener;
-
-public class TypeScriptOutputListener implements OutputListener {
-
- private TypeScript script;
- private boolean appendNewline;
-
- public TypeScriptOutputListener(TypeScript script) {
- this(script, false);
- }
-
- public TypeScriptOutputListener(TypeScript script, boolean appendNewline) {
- this.script = script;
- this.appendNewline = appendNewline;
- }
-
- @Override
- public void putString(String s) {
- script.append(s);
- if (appendNewline) {
- script.newline();
- }
- }
-
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScriptWriter.java b/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScriptWriter.java
deleted file mode 100644
index 03ca648fada..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/debug/gui/TypeScriptWriter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.debug.gui;
-
-import java.io.*;
-
-public class TypeScriptWriter extends Writer {
-
- TypeScript script;
-
- public TypeScriptWriter(TypeScript script) {
- this.script = script;
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- script.append(String.valueOf(cbuf, off, len));
- }
-
- @Override
- public void flush() {
- script.flush();
- }
-
- @Override
- public void close() {
- script.flush();
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/index.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/index.html
deleted file mode 100644
index 0296ae48265..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/index.html
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
- Example JDI Applications
-
-
- Example JDI Applications
-This example download contains the source code and
-documentation for three applications written using
-the JavaTM Debug Interface (JDI)
-of the Java Platform Debugger Architecture (JPDA).
-They are provided as educational tools and as starting
-points for debugger development.
-
-In increasing order of complexity:
-
-Trace displays traces
-of program execution. It is very simple (less than 600 lines)
-yet uses most of the basic JDI functionality. It is a
-good starting point.
-Jdb is the command line debugger
-distributed with the J2SE SDK.
-Javadt is the beginnings of
-a GUI debugger.
-
-
-Trace is in the trace
directory.
-Jdb and Javadt share a package, and are under the
-debug
directory.
-
-Required Set-up
-
-
Where is JPDA?
-New versions of the J2SE SDK have JPDA included. For
-older versions JPDA must be separately downloaded.
-
- SDKs with JPDA included
- J2SE SDK v1.3 and later and J2SE SDK for Linux v1.2.2
- SDKs requiring JPDA download
- J2SE SDK v1.2.1 and v1.2.2 for Solaris and Windows
- Other SDKs
- Check with vendor
-
-
-
Set-up for J2SE SDKs with JPDA included
-Your classpath must include the JDI Library code, which is
-in tools.jar
in the lib
directory.
-This is needed for both compiling the example code and
-executing it.
-
-
Set-up for J2SE SDKs without JPDA - Solaris
-Download JPDA v1.0 from
-http://java.sun.com/products/jpda . Follow the
-Installation Instructions
-found there. Pay particular attention to setting the library
-path.
-
-Your classpath must include the JDI Library code, which is
-in jpda_home /lib/tools.jar
.
-This is needed for both compiling the example code and
-executing it.
-
-
Set-up for J2SE SDKs without JPDA - Windows
-Download JPDA v1.0 from
-http://java.sun.com/products/jpda . Follow the
-Installation Instructions
-found there. Be sure to add:
-
- jpda_home \bin
-
-to your path.
-
-Your classpath must include the JDI Library code, which is
-in jpda_home \lib\tools.jar
.
-This is needed for both compiling the example code and
-executing it.
-
-
- java-debugger@java.sun.com
-
-
-
-
-
-
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html
deleted file mode 100644
index f9d28a166bb..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/javadt.html
+++ /dev/null
@@ -1,174 +0,0 @@
-
-
- Release notes for the javadt debugger
-
-
-Release notes for the javadt debugger
-
-
-As a demonstration of the
-
-JavaTM Platform Debugger Architecture
-we are providing source code for
-a simple GUI debugging tool - javadt .
-It is included as an example and demonstration of
-
-JDI . It is not a finished or polished debugger and is
-missing many features of importance for real debugging work.
-
-
-
Invoking javadt
-
-javadt can be run by executing:
-
- java com.sun.tools.example.debug.gui.GUI <options>.. <class-name>
-
-where <class-name> is the name you would normally
-place on the java
command line.
-Note: the path to the JDI Library and to
-the compiled javadt class files must be on the class path
-used to invoke gui.GUI.
-
-For example, you can invoke the javadt debugger as follows:
-
- java com.sun.tools.example.debug.gui.GUI -classpath . Hello
-
-Note: this -classpath
option controls the
-class path for the Hello
application.
-Once the window appears, you can issue the 'run' command to begin
-execution immediately. It is also
-possible to give the class name in the 'run' command, in
-which case it may be omitted when invoking the debugger from the
-shell.
-
-The classpath may also be set from within the debugger, using the
-'classpath' command. Currently, other arguments to the VM must be
-given on the shell command line when the debugger is initially
-invoked. The most recently mentioned classpath, VM arguments, main
-class name, and program arguments are retained as defaults for later
-'run' and 'load' commands. (Unfortunately, at present, the debugger
-will likely crash if you attempt to begin another debugging session
-with another debuggee process from within the same invocation of the
-debugger. You should exit to the shell and start a new debugger
-process.)
-
-
-
Using javadt
-The javadt normally displays context related to the "current thread",
-that is, the thread that most recently encountered a breakpoint, threw
-an uncaught exception, or was single-stepped by the user. When
-program execution is suspended on account of one of these events, a
-current thread exists, and the javadt displays the following information
-about it:
-
-
- A stack backtrace.
-
- The source code surrounding the line corresponding to the
- instruction counter for the thread, if the source code is
- available.
-
-
-In addition, a tabbed pane allows the user to view one of three
-additional views:
-
-
- A tree of all source files available on the source path.
-
- A tree of all loaded class files, organized hierarchically
- by package.
-
- A tree of all active threads, organized hierarchically
- by thread group.
-
-
-By clicking on the name of a source file, the source view can be
-directed to display it. Likewise, clicking on a thread will make that
-thread the current thread. These features are normally used while the
-program is suspended, e.g, at a breakpoint. Upon resumption and
-encountering another breakpoint, for example, the current thread will
-be automatically reset and the views will be updated. The views tile
-the javadt display, and are adjustable in size.
-
-The javadt functionality is rather basic, thus a command-line interaction
-window is also provided that allows access to functions that are not
-yet exposed in the javadt. In particular, it is necessary to use the
-command line in order to set breakpoints and examine variables. The
-javadt debugger command interpreter implements roughly a subset of the
-jdb
- functionality, but adds a few commands of its own. The
-'help' command lists the complete set of commands and their function.
-Shortcuts for a set of the most common commands is provided on a
-button-bar at the top of the display.
-
-The program to be debugged may be started either as a child of the
-debugger, or the debugger can be attached to an existing process,
-provided that its VM is prepared to accept the connection. If the
-debuggee is started by the debugger as a child, a line-oriented
-interface to its standard input, output, and error streams is provided
-in an application interaction pane.
-
-The debugger expects to find the program source code on its
-sourcepath, set with the 'use' or 'sourcepath' command. If you find
-that sources are not being displayed because the sourcepath is
-incorrect, you may change it at that time, and the source view will be
-immediately updated.
-
-The message "No current thread" is often encountered when stepping
-through a program. This message does not mean that the thread or
-the VM has died, merely that a current thread is undefined. This
-situation can easily occur unexpectedly when the program being
-stepped is waiting, eg., for input. The VM appears to be stopped,
-as it would be after the successful completion of a step, but it
-is considered to be "running", not "interrupted". The prompt
-in the command interaction pane indicates the state by changing
-to a thread name and frame number when the VM is interrupted.
-When it is running, the prompt "Command:" is displayed.
-
-
Source for javadt
-Full source code for javadt is included under the
-debug
directory of examples.jar
.
-Note: these directories also include the
-source for jdb
.
-Source code for these example applications is included to provide concrete
-examples for debugger developers. Example code may be used, modified
-and redistributed by debugger developers providing they adhere to the
-terms in the COPYRIGHT notice.
-
-javadt uses the following packages (found under the
-debug
directory):
-
-gui
-User interface code
- bdi
-Debugger core code
- events
-Event Set code
- expr
-Expression processing code
-
-
-
Building javadt
-To build the javadt classes from the
-provided source files under the debug
directory,
-you need only to compile them. No special
-options are required, aside from those which set your classpath to
-include the JDI Library .
-
-
-However, if you want to modify the expression parser in the file
-Expr.jj
, you will need the
-
-JavaCC parser generator .
-It is available free from
-Metamata
-(now part of WebGain) .
-
-
- java-debugger@java.sun.com
-
-
-
-
-
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html
deleted file mode 100644
index a8232b0207d..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/jdb.html
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
- Release notes for the jdb debugger
-
-
-
-
-
-
-
-
-Release notes for the jdb debugger
-
-
-
-
-
-Home Page
-
-
-As a demonstration of the
-
-JavaTM Platform Debugger Architecture
-we are providing source code for the jdb debugger, which was
-re-written to use
-
-JDI .
-
-
-
jdb man pages
-
-jdb man pages for Windows
-
-jdb man pages for Solaris
-
-
-
Invoking jdb
-The jdb sample can be started by executing:
-
- java com.sun.tools.example.debug.tty.TTY <options>.. <class-name>
-
-where <class-name> is the name you would normally
-place on the java
command line. The -help
-option provides information on options.
-
-
-Note: the path to the JDI Library and to
-the compiled jdb class files must be on the class path
-used to invoke com.sun.tools.example.debug.tty.TTY.
-
-
-For more information on invoking and connecting, refer to the
-
-Connection and Invocation Details section of the
-
-JPDA documentation ,
-particularly the section on jdb .
-
-
-
-
Source for jdb
-Full source code for jdb is included under the
-debug
directory of examples.jar
.
-Note: these directories also include the
-source for javadt
.
-Source code for these example applications is included to provide concrete
-examples for debugger developers. Example code may be used, modified
-and redistributed by debugger developers providing they adhere to the
-terms in the COPYRIGHT notice.
-
-jdb uses the following packages (found under the
-debug
directory):
-
-tty
-Application code
- expr
-Expression processing code
-
-
-
-
Building jdb
-To completely rebuild the jdb classes from the
-provided source files under the debug
directory,
-you need only to compile them. No special
-options are required, aside from those which set your classpath to
-include the JDI Library .
-
-
-However, if you want to modify the expression parser in the file
-Expr.jj
, you will need the
-
-JavaCC parser generator .
-It is available free from
-Metamata
-(now part of WebGain) .
-
-
- java-debugger@java.sun.com
-
-
-
-
-
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/trace.html b/jdk/src/demo/share/jpda/com/sun/tools/example/doc/trace.html
deleted file mode 100644
index 8cae84dfe1e..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/doc/trace.html
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
- trace example
-
-
-trace example
-
-Trace runs the Java language program passed as an argument and
-generates a trace of its execution. Trace is a simple command
-line tool that uses the
-
-Java Debug Interface (JDI) . Programs need
-not be compiled for debugging since this information is not
-used.
-
-Trace can be invoked as follows:
-
- java com.sun.tools.example.trace.Trace options class args
-
-Your classpath must include the JDI Library
-(see set-up ),
-the path to the compiled trace class files,
-and the path for the application being traced.
-
-Available options are:
-
-
- -output filename
- Set destination for output trace. By default output
- goes to the terminal.
-
- -all
- Include system classes in output. By default
- java.*, javax.*, sun.* and com.sun.* events are
- not diplayed.
-
- -fields
- Also show assignments into fields.
-
- -help
- Print a help message
-
-
-class is the program to trace. args are the arguments to class .
-
-
-
Source for trace
-Full source code for trace is included in the
-trace
directory of examples.jar
.
-Source code for these example applications is included to provide concrete
-examples for debugger developers. Example code may be used, modified
-and redistributed by debugger developers providing they adhere to the
-terms in the COPYRIGHT notice.
-
-
-
Building trace
-To completely rebuild the trace classes from the
-provided source files in the trace
directory,
-you need only to compile them. No special
-options are required, aside from those which set your classpath to
-include the JDI Library .
-
-
-
- java-debugger@java.sun.com
-
-
-
-
-
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java b/jdk/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java
deleted file mode 100644
index 11084df5dd2..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/EventThread.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.trace;
-
-import com.sun.jdi.*;
-import com.sun.jdi.request.*;
-import com.sun.jdi.event.*;
-
-import java.util.*;
-import java.io.PrintWriter;
-
-/**
- * This class processes incoming JDI events and displays them
- *
- * @author Robert Field
- */
-public class EventThread extends Thread {
-
- private final VirtualMachine vm; // Running VM
- private final String[] excludes; // Packages to exclude
- private final PrintWriter writer; // Where output goes
-
- static String nextBaseIndent = ""; // Starting indent for next thread
-
- private boolean connected = true; // Connected to VM
- private boolean vmDied = true; // VMDeath occurred
-
- // Maps ThreadReference to ThreadTrace instances
- private Map traceMap =
- new HashMap<>();
-
- EventThread(VirtualMachine vm, String[] excludes, PrintWriter writer) {
- super("event-handler");
- this.vm = vm;
- this.excludes = excludes;
- this.writer = writer;
- }
-
- /**
- * Run the event handling thread.
- * As long as we are connected, get event sets off
- * the queue and dispatch the events within them.
- */
- @Override
- public void run() {
- EventQueue queue = vm.eventQueue();
- while (connected) {
- try {
- EventSet eventSet = queue.remove();
- EventIterator it = eventSet.eventIterator();
- while (it.hasNext()) {
- handleEvent(it.nextEvent());
- }
- eventSet.resume();
- } catch (InterruptedException exc) {
- // Ignore
- } catch (VMDisconnectedException discExc) {
- handleDisconnectedException();
- break;
- }
- }
- }
-
- /**
- * Create the desired event requests, and enable
- * them so that we will get events.
- * @param excludes Class patterns for which we don't want events
- * @param watchFields Do we want to watch assignments to fields
- */
- void setEventRequests(boolean watchFields) {
- EventRequestManager mgr = vm.eventRequestManager();
-
- // want all exceptions
- ExceptionRequest excReq = mgr.createExceptionRequest(null,
- true, true);
- // suspend so we can step
- excReq.setSuspendPolicy(EventRequest.SUSPEND_ALL);
- excReq.enable();
-
- MethodEntryRequest menr = mgr.createMethodEntryRequest();
- for (int i=0; i 0) {
- indent.append("| ");
- }
-
- EventRequestManager mgr = vm.eventRequestManager();
- mgr.deleteEventRequest(event.request());
- }
-
- void threadDeathEvent(ThreadDeathEvent event) {
- indent = new StringBuffer(baseIndent);
- println("====== " + thread.name() + " end ======");
- }
- }
-
- /**
- * Returns the ThreadTrace instance for the specified thread,
- * creating one if needed.
- */
- ThreadTrace threadTrace(ThreadReference thread) {
- ThreadTrace trace = traceMap.get(thread);
- if (trace == null) {
- trace = new ThreadTrace(thread);
- traceMap.put(thread, trace);
- }
- return trace;
- }
-
- /**
- * Dispatch incoming events
- */
- private void handleEvent(Event event) {
- if (event instanceof ExceptionEvent) {
- exceptionEvent((ExceptionEvent)event);
- } else if (event instanceof ModificationWatchpointEvent) {
- fieldWatchEvent((ModificationWatchpointEvent)event);
- } else if (event instanceof MethodEntryEvent) {
- methodEntryEvent((MethodEntryEvent)event);
- } else if (event instanceof MethodExitEvent) {
- methodExitEvent((MethodExitEvent)event);
- } else if (event instanceof StepEvent) {
- stepEvent((StepEvent)event);
- } else if (event instanceof ThreadDeathEvent) {
- threadDeathEvent((ThreadDeathEvent)event);
- } else if (event instanceof ClassPrepareEvent) {
- classPrepareEvent((ClassPrepareEvent)event);
- } else if (event instanceof VMStartEvent) {
- vmStartEvent((VMStartEvent)event);
- } else if (event instanceof VMDeathEvent) {
- vmDeathEvent((VMDeathEvent)event);
- } else if (event instanceof VMDisconnectEvent) {
- vmDisconnectEvent((VMDisconnectEvent)event);
- } else {
- throw new Error("Unexpected event type");
- }
- }
-
- /***
- * A VMDisconnectedException has happened while dealing with
- * another event. We need to flush the event queue, dealing only
- * with exit events (VMDeath, VMDisconnect) so that we terminate
- * correctly.
- */
- synchronized void handleDisconnectedException() {
- EventQueue queue = vm.eventQueue();
- while (connected) {
- try {
- EventSet eventSet = queue.remove();
- EventIterator iter = eventSet.eventIterator();
- while (iter.hasNext()) {
- Event event = iter.nextEvent();
- if (event instanceof VMDeathEvent) {
- vmDeathEvent((VMDeathEvent)event);
- } else if (event instanceof VMDisconnectEvent) {
- vmDisconnectEvent((VMDisconnectEvent)event);
- }
- }
- eventSet.resume(); // Resume the VM
- } catch (InterruptedException exc) {
- // ignore
- }
- }
- }
-
- private void vmStartEvent(VMStartEvent event) {
- writer.println("-- VM Started --");
- }
-
- // Forward event for thread specific processing
- private void methodEntryEvent(MethodEntryEvent event) {
- threadTrace(event.thread()).methodEntryEvent(event);
- }
-
- // Forward event for thread specific processing
- private void methodExitEvent(MethodExitEvent event) {
- threadTrace(event.thread()).methodExitEvent(event);
- }
-
- // Forward event for thread specific processing
- private void stepEvent(StepEvent event) {
- threadTrace(event.thread()).stepEvent(event);
- }
-
- // Forward event for thread specific processing
- private void fieldWatchEvent(ModificationWatchpointEvent event) {
- threadTrace(event.thread()).fieldWatchEvent(event);
- }
-
- void threadDeathEvent(ThreadDeathEvent event) {
- ThreadTrace trace = traceMap.get(event.thread());
- if (trace != null) { // only want threads we care about
- trace.threadDeathEvent(event); // Forward event
- }
- }
-
- /**
- * A new class has been loaded.
- * Set watchpoints on each of its fields
- */
- private void classPrepareEvent(ClassPrepareEvent event) {
- EventRequestManager mgr = vm.eventRequestManager();
- List fields = event.referenceType().visibleFields();
- for (Field field : fields) {
- ModificationWatchpointRequest req =
- mgr.createModificationWatchpointRequest(field);
- for (int i=0; i= 0) {
- out.write(cbuf, 0, count);
- }
- out.flush();
- } catch(IOException exc) {
- System.err.println("Child I/O Transfer - " + exc);
- }
- }
-}
diff --git a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java b/jdk/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java
deleted file mode 100644
index 2ce99f97a01..00000000000
--- a/jdk/src/demo/share/jpda/com/sun/tools/example/trace/Trace.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/*
- * This source code is provided to illustrate the usage of a given feature
- * or technique and has been deliberately simplified. Additional steps
- * required for a production-quality application, such as security checks,
- * input validation and proper error handling, might not be present in
- * this sample code.
- */
-
-
-package com.sun.tools.example.trace;
-
-import com.sun.jdi.VirtualMachine;
-import com.sun.jdi.Bootstrap;
-import com.sun.jdi.connect.*;
-
-import java.util.Map;
-import java.util.List;
-
-import java.io.PrintWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-
-/**
- * This program traces the execution of another program.
- * See "java Trace -help".
- * It is a simple example of the use of the Java Debug Interface.
- *
- * @author Robert Field
- */
-public class Trace {
-
- // Running remote VM
- private final VirtualMachine vm;
-
- // Thread transferring remote error stream to our error stream
- private Thread errThread = null;
-
- // Thread transferring remote output stream to our output stream
- private Thread outThread = null;
-
- // Mode for tracing the Trace program (default= 0 off)
- private int debugTraceMode = 0;
-
- // Do we want to watch assignments to fields
- private boolean watchFields = false;
-
- // Class patterns for which we don't want events
- private String[] excludes = {"java.*", "javax.*", "sun.*",
- "com.sun.*"};
-
- /**
- * main
- */
- public static void main(String[] args) {
- new Trace(args);
- }
-
- /**
- * Parse the command line arguments.
- * Launch target VM.
- * Generate the trace.
- */
- Trace(String[] args) {
- PrintWriter writer = new PrintWriter(System.out);
- int inx;
- for (inx = 0; inx < args.length; ++inx) {
- String arg = args[inx];
- if (arg.charAt(0) != '-') {
- break;
- }
- if (arg.equals("-output")) {
- try {
- writer = new PrintWriter(new FileWriter(args[++inx]));
- } catch (IOException exc) {
- System.err.println("Cannot open output file: " + args[inx]
- + " - " + exc);
- System.exit(1);
- }
- } else if (arg.equals("-all")) {
- excludes = new String[0];
- } else if (arg.equals("-fields")) {
- watchFields = true;
- } else if (arg.equals("-dbgtrace")) {
- debugTraceMode = Integer.parseInt(args[++inx]);
- } else if (arg.equals("-help")) {
- usage();
- System.exit(0);
- } else {
- System.err.println("No option: " + arg);
- usage();
- System.exit(1);
- }
- }
- if (inx >= args.length) {
- System.err.println(" missing");
- usage();
- System.exit(1);
- }
- StringBuilder sb = new StringBuilder();
- sb.append(args[inx]);
- for (++inx; inx < args.length; ++inx) {
- sb.append(' ');
- sb.append(args[inx]);
- }
- vm = launchTarget(sb.toString());
- generateTrace(writer);
- }
-
-
- /**
- * Generate the trace.
- * Enable events, start thread to display events,
- * start threads to forward remote error and output streams,
- * resume the remote VM, wait for the final event, and shutdown.
- */
- void generateTrace(PrintWriter writer) {
- vm.setDebugTraceMode(debugTraceMode);
- EventThread eventThread = new EventThread(vm, excludes, writer);
- eventThread.setEventRequests(watchFields);
- eventThread.start();
- redirectOutput();
- vm.resume();
-
- // Shutdown begins when event thread terminates
- try {
- eventThread.join();
- errThread.join(); // Make sure output is forwarded
- outThread.join(); // before we exit
- } catch (InterruptedException exc) {
- // we don't interrupt
- }
- writer.close();
- }
-
- /**
- * Launch target VM.
- * Forward target's output and error.
- */
- VirtualMachine launchTarget(String mainArgs) {
- LaunchingConnector connector = findLaunchingConnector();
- Map arguments =
- connectorArguments(connector, mainArgs);
- try {
- return connector.launch(arguments);
- } catch (IOException exc) {
- throw new Error("Unable to launch target VM: " + exc);
- } catch (IllegalConnectorArgumentsException exc) {
- throw new Error("Internal error: " + exc);
- } catch (VMStartException exc) {
- throw new Error("Target VM failed to initialize: " +
- exc.getMessage());
- }
- }
-
- void redirectOutput() {
- Process process = vm.process();
-
- // Copy target's output and error to our output and error.
- errThread = new StreamRedirectThread("error reader",
- process.getErrorStream(),
- System.err);
- outThread = new StreamRedirectThread("output reader",
- process.getInputStream(),
- System.out);
- errThread.start();
- outThread.start();
- }
-
- /**
- * Find a com.sun.jdi.CommandLineLaunch connector
- */
- LaunchingConnector findLaunchingConnector() {
- List connectors = Bootstrap.virtualMachineManager().allConnectors();
- for (Connector connector : connectors) {
- if (connector.name().equals("com.sun.jdi.CommandLineLaunch")) {
- return (LaunchingConnector)connector;
- }
- }
- throw new Error("No launching connector");
- }
-
- /**
- * Return the launching connector's arguments.
- */
- Map connectorArguments(LaunchingConnector connector, String mainArgs) {
- Map arguments = connector.defaultArguments();
- Connector.Argument mainArg =
- (Connector.Argument)arguments.get("main");
- if (mainArg == null) {
- throw new Error("Bad launching connector");
- }
- mainArg.setValue(mainArgs);
-
- if (watchFields) {
- // We need a VM that supports watchpoints
- Connector.Argument optionArg =
- (Connector.Argument)arguments.get("options");
- if (optionArg == null) {
- throw new Error("Bad launching connector");
- }
- optionArg.setValue("-classic");
- }
- return arguments;
- }
-
- /**
- * Print command line usage help
- */
- void usage() {
- System.err.println("Usage: java Trace ");
- System.err.println(" are:");
- System.err.println(
-" -output Output trace to ");
- System.err.println(
-" -all Include system classes in output");
- System.err.println(
-" -help Print this help message");
- System.err.println(" is the program to trace");
- System.err.println(" are the arguments to ");
- }
-}
diff --git a/jdk/src/demo/share/jvmti/hprof/sample.makefile.txt b/jdk/src/demo/share/jvmti/hprof/sample.makefile.txt
deleted file mode 100644
index e8f84dc8577..00000000000
--- a/jdk/src/demo/share/jvmti/hprof/sample.makefile.txt
+++ /dev/null
@@ -1,205 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# - Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# - Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# - Neither the name of Oracle nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#
-
-########################################################################
-#
-# Sample GNU Makefile for building
-#
-# Example uses:
-# gnumake JDK= OSNAME=solaris [OPT=true] [LIBARCH=sparc]
-# gnumake JDK= OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
-# gnumake JDK= OSNAME=linux [OPT=true]
-# gnumake JDK= OSNAME=win32 [OPT=true]
-#
-########################################################################
-
-# Source lists
-LIBNAME=hprof
-SOURCES= \
- debug_malloc.c \
- hprof_blocks.c \
- hprof_class.c \
- hprof_cpu.c \
- hprof_error.c \
- hprof_event.c \
- hprof_frame.c \
- hprof_init.c \
- hprof_io.c \
- hprof_ioname.c \
- hprof_listener.c \
- hprof_loader.c \
- hprof_monitor.c \
- hprof_object.c \
- hprof_reference.c \
- hprof_site.c \
- hprof_stack.c \
- hprof_string.c \
- hprof_table.c \
- hprof_tag.c \
- hprof_tls.c \
- hprof_trace.c \
- hprof_tracker.c \
- hprof_util.c \
- hprof_md.c
-
-JAVA_SOURCES=Tracker.java
-
-# Name of jar file that needs to be created
-#JARFILE=hprof.jar
-
-# Solaris Sun C Compiler Version 5.5
-ifeq ($(OSNAME), solaris)
- # Sun Solaris Compiler options needed
- COMMON_FLAGS=-mt -KPIC
- # Options that help find errors
- COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
- # To make hprof logging code available
- COMMON_FLAGS+= -DHPROF_LOGGING
- # Check LIBARCH for any special compiler options
- LIBARCH=$(shell uname -p)
- ifeq ($(LIBARCH), sparc)
- COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
- endif
- ifeq ($(LIBARCH), sparcv9)
- COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
- endif
- ifeq ($(OPT), true)
- CFLAGS=-xO2 $(COMMON_FLAGS) -DNDEBUG
- else
- CFLAGS=-g $(COMMON_FLAGS) -DDEBUG
- endif
- # Object files needed to create library
- OBJECTS=$(SOURCES:%.c=%.o)
- # Library name and options needed to build it
- LIBRARY=lib$(LIBNAME).so
- LDFLAGS=-z defs -ztext
- # Libraries we are dependent on
- LIBRARIES=-lsocket -lnsl -ldl -lc
- # Building a shared library
- LINK_SHARED=$(LINK.c) -G -o $@
-endif
-
-# Linux GNU C Compiler
-ifeq ($(OSNAME), linux)
- # GNU Compiler options needed to build it
- COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
- # Options that help find errors
- COMMON_FLAGS+= -W -Wall -Wno-unused -Wno-parentheses
- # To allow access to dladdr()
- COMMON_FLAGS+= -D_GNU_SOURCE
- # To prevent include of procfs.h
- COMMON_FLAGS+= -DLINUX
- # To make sure code is reentrant
- COMMON_FLAGS+= -D_REENTRANT
- # To make hprof logging code available
- COMMON_FLAGS+= -DHPROF_LOGGING
- ifeq ($(OPT), true)
- CFLAGS=-O2 $(COMMON_FLAGS) -DNDEBUG
- else
- CFLAGS=-g $(COMMON_FLAGS) -DDEBUG
- endif
- # Object files needed to create library
- OBJECTS=$(SOURCES:%.c=%.o)
- # Library name and options needed to build it
- LIBRARY=lib$(LIBNAME).so
- LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
- # Libraries we are dependent on
- LIBRARIES= -ldl -lc
- # Building a shared library
- LINK_SHARED=$(LINK.c) -shared -o $@
-endif
-
-# Windows Microsoft C/C++ Optimizing Compiler Version 12
-ifeq ($(OSNAME), win32)
- CC=cl
- # Compiler options needed to build it
- COMMON_FLAGS=-Gy -DWIN32
- # Options that help find errors
- COMMON_FLAGS+=-W0 -WX
- # To make hprof logging code available
- COMMON_FLAGS+= -DHPROF_LOGGING
- ifeq ($(OPT), true)
- CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS) -DNDEBUG
- else
- CFLAGS= -Od -Zi $(COMMON_FLAGS) -DDEBUG
- endif
- # Add java_crw_demo source
- SOURCES += ../java_crw_demo.c
- # Object files needed to create library
- OBJECTS=$(SOURCES:%.c=%.obj)
- # Library name and options needed to build it
- LIBRARY=$(LIBNAME).dll
- LDFLAGS=
- # Libraries we are dependent on
- LIBRARIES=wsock32.lib winmm.lib
- # Building a shared library
- LINK_SHARED=link -dll -out:$@
-endif
-
-# Common -I options
-CFLAGS += -I.
-CFLAGS += -I../java_crw_demo
-CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
-
-# Default rule (build both native library and jar file)
-all: hprof_md.c $(LIBRARY) $(JARFILE)
-
-# Get platform specific hprof_md.c
-hprof_md.c:
- rm -f $@
- cp $(OSNAME)/hprof_md.c $@
-
-# Build native library
-$(LIBRARY): $(OBJECTS)
- $(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
-
-# Build jar file
-$(JARFILE): $(JAVA_SOURCES)
- rm -f -r classes
- mkdir -p classes
- $(JDK)/bin/javac -d classes $(JAVA_SOURCES)
- (cd classes; $(JDK)/bin/jar cf ../$@ *)
-
-# Cleanup the built bits
-clean:
- rm -f -r classes
- rm -f $(LIBRARY) $(JARFILE) $(OBJECTS)
-
-# Simple tester
-test: all
- LD_LIBRARY_PATH=. $(JDK)/bin/java -agentlib:$(LIBNAME) -Xbootclasspath/a:./$(JARFILE) -version
-
-# Compilation rule only needed on Windows
-ifeq ($(OSNAME), win32)
-%.obj: %.c
- $(COMPILE.c) $<
-endif
-
diff --git a/jdk/src/demo/share/jvmti/index.html b/jdk/src/demo/share/jvmti/index.html
index b66ac8d9bfa..4b479c12468 100644
--- a/jdk/src/demo/share/jvmti/index.html
+++ b/jdk/src/demo/share/jvmti/index.html
@@ -54,17 +54,16 @@ variable (Windows).
This is system and platform specific.
If you are using 64bit Solaris (e.g. 'java -d64'),
you should use LD_LIBRARY_PATH64.
-Some agents such as hprof (heap/cpu profiler) and jdwp (debugger backend)
+Some agents such as the jdwp (debugger backend)
are located inside the primary JDK directories and will always be found
in those locations.
The agents that instrument classfiles
(i.e. BCI, usually through the java_crw_demo library)
-such as hprof, heapTracker, mtrace, and minst,
+such as heapTracker, mtrace, and minst,
also need to have the Java classes they use available in the bootclasspath.
-The one used by hprof is already in the bootclasspath, and the
-other agents will make attempts at automatically adding their jar file
+The agents will make attempts at automatically adding their jar file
(e.g. heapTracker.jar, mtrace.jar, or minst.jar) to the bootclasspath
with AddToBootstrapClassLoaderSearch from JVM TI at startup
(see the agent_util code).
@@ -150,19 +149,6 @@ This is a small agent that gets information about threads
waiting on monitors.
-
-hprof
-
-This is a large agent that does heap and cpu profiling.
-This demo agent is actually built into the
-
-Java Runtime Environment (JRE).
-It uses Bytecode Instrumentation (BCI) via the java_crw_demo library.
-
-Note: hprof is NOT a small or simple agent, the other smaller demos
-should be looked at first.
-
-
diff --git a/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java b/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java
index 71be2db3b47..3d199579249 100644
--- a/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java
+++ b/jdk/src/java.base/share/classes/java/io/ByteArrayOutputStream.java
@@ -93,6 +93,14 @@ public class ByteArrayOutputStream extends OutputStream {
grow(minCapacity);
}
+ /**
+ * The maximum size of array to allocate.
+ * Some VMs reserve some header words in an array.
+ * Attempts to allocate larger arrays may result in
+ * OutOfMemoryError: Requested array size exceeds VM limit
+ */
+ private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
+
/**
* Increases the capacity to ensure that it can hold at least the
* number of elements specified by the minimum capacity argument.
@@ -105,14 +113,19 @@ public class ByteArrayOutputStream extends OutputStream {
int newCapacity = oldCapacity << 1;
if (newCapacity - minCapacity < 0)
newCapacity = minCapacity;
- if (newCapacity < 0) {
- if (minCapacity < 0) // overflow
- throw new OutOfMemoryError();
- newCapacity = Integer.MAX_VALUE;
- }
+ if (newCapacity - MAX_ARRAY_SIZE > 0)
+ newCapacity = hugeCapacity(minCapacity);
buf = Arrays.copyOf(buf, newCapacity);
}
+ private static int hugeCapacity(int minCapacity) {
+ if (minCapacity < 0) // overflow
+ throw new OutOfMemoryError();
+ return (minCapacity > MAX_ARRAY_SIZE) ?
+ Integer.MAX_VALUE :
+ MAX_ARRAY_SIZE;
+ }
+
/**
* Writes the specified byte to this byte array output stream.
*
diff --git a/jdk/src/java.base/share/classes/java/io/FilePermission.java b/jdk/src/java.base/share/classes/java/io/FilePermission.java
index 0744ea28e4a..b008d4f933a 100644
--- a/jdk/src/java.base/share/classes/java/io/FilePermission.java
+++ b/jdk/src/java.base/share/classes/java/io/FilePermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Vector;
import java.util.Collections;
+import java.util.StringJoiner;
import sun.security.util.SecurityConstants;
/**
@@ -556,39 +557,25 @@ public final class FilePermission extends Permission implements Serializable {
* @return the canonical string representation of the actions.
*/
private static String getActions(int mask) {
- StringBuilder sb = new StringBuilder();
- boolean comma = false;
+ StringJoiner sj = new StringJoiner(",");
if ((mask & READ) == READ) {
- comma = true;
- sb.append("read");
+ sj.add("read");
}
-
if ((mask & WRITE) == WRITE) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("write");
+ sj.add("write");
}
-
if ((mask & EXECUTE) == EXECUTE) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("execute");
+ sj.add("execute");
}
-
if ((mask & DELETE) == DELETE) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("delete");
+ sj.add("delete");
}
-
if ((mask & READLINK) == READLINK) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("readlink");
+ sj.add("readlink");
}
- return sb.toString();
+ return sj.toString();
}
/**
diff --git a/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java b/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java
index 7dc6dde469f..e99e0257f31 100644
--- a/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java
+++ b/jdk/src/java.base/share/classes/java/io/ObjectOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, 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
@@ -32,6 +32,7 @@ import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.StringJoiner;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static java.io.ObjectStreamClass.processQueue;
@@ -2465,15 +2466,11 @@ public class ObjectOutputStream
* Returns a string representation of this object
*/
public String toString() {
- StringBuilder buffer = new StringBuilder();
- if (!stack.isEmpty()) {
- for(int i = stack.size(); i > 0; i-- ) {
- buffer.append(stack.get(i - 1));
- if (i != 1)
- buffer.append('\n');
- }
+ StringJoiner sj = new StringJoiner("\n");
+ for (int i = stack.size() - 1; i >= 0; i--) {
+ sj.add(stack.get(i));
}
- return buffer.toString();
+ return sj.toString();
}
}
diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java
index 1afbf5ea710..2179ee809f5 100644
--- a/jdk/src/java.base/share/classes/java/lang/Class.java
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java
@@ -54,6 +54,7 @@ import java.util.Set;
import java.util.Map;
import java.util.HashMap;
import java.util.Objects;
+import java.util.StringJoiner;
import sun.misc.Unsafe;
import sun.reflect.CallerSensitive;
import sun.reflect.ConstantPool;
@@ -3141,19 +3142,14 @@ public final class Class implements java.io.Serializable,
private native Class>[] getDeclaredClasses0();
private static String argumentTypesToString(Class>[] argTypes) {
- StringBuilder buf = new StringBuilder();
- buf.append("(");
+ StringJoiner sj = new StringJoiner(", ", "(", ")");
if (argTypes != null) {
for (int i = 0; i < argTypes.length; i++) {
- if (i > 0) {
- buf.append(", ");
- }
Class> c = argTypes[i];
- buf.append((c == null) ? "null" : c.getName());
+ sj.add((c == null) ? "null" : c.getName());
}
}
- buf.append(")");
- return buf.toString();
+ return sj.toString();
}
/** use serialVersionUID from JDK 1.1 for interoperability */
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
index c26460048b0..2b20ae71935 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
@@ -33,6 +33,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.StringJoiner;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import sun.invoke.util.BytecodeDescriptor;
@@ -717,15 +718,12 @@ class MethodType implements java.io.Serializable {
*/
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("(");
+ StringJoiner sj = new StringJoiner(",", "(",
+ ")" + rtype.getSimpleName());
for (int i = 0; i < ptypes.length; i++) {
- if (i > 0) sb.append(",");
- sb.append(ptypes[i].getSimpleName());
+ sj.add(ptypes[i].getSimpleName());
}
- sb.append(")");
- sb.append(rtype.getSimpleName());
- return sb.toString();
+ return sj.toString();
}
diff --git a/jdk/src/java.base/share/classes/java/net/NetPermission.java b/jdk/src/java.base/share/classes/java/net/NetPermission.java
index 9178f348723..dad3fb99f32 100644
--- a/jdk/src/java.base/share/classes/java/net/NetPermission.java
+++ b/jdk/src/java.base/share/classes/java/net/NetPermission.java
@@ -72,10 +72,10 @@ import java.util.StringTokenizer;
*
*
*
- * getNetworkInformation
- * The ability to retrieve all information about local network interfaces.
- * Malicious code can read information about network hardware such as
- * MAC addresses, which could be used to construct local IPv6 addresses.
+ * getNetworkInformation
+ * The ability to retrieve all information about local network interfaces.
+ * Malicious code can read information about network hardware such as
+ * MAC addresses, which could be used to construct local IPv6 addresses.
*
*
*
@@ -98,8 +98,8 @@ import java.util.StringTokenizer;
*
* requestPasswordAuthentication
* The ability
- * to ask the authenticator registered with the system for
- * a password
+ * to ask the authenticator registered with the system for
+ * a password
* Malicious code may steal this password.
*
*
@@ -116,11 +116,11 @@ import java.util.StringTokenizer;
*
* setDefaultAuthenticator
* The ability to set the
- * way authentication information is retrieved when
- * a proxy or HTTP server asks for authentication
+ * way authentication information is retrieved when
+ * a proxy or HTTP server asks for authentication
* Malicious
- * code can set an authenticator that monitors and steals user
- * authentication input as it retrieves the input from the user.
+ * code can set an authenticator that monitors and steals user
+ * authentication input as it retrieves the input from the user.
*
*
*
@@ -143,13 +143,13 @@ import java.util.StringTokenizer;
*
* specifyStreamHandler
* The ability
- * to specify a stream handler when constructing a URL
+ * to specify a stream handler when constructing a URL
* Malicious code may create a URL with resources that it would
-normally not have access to (like file:/foo/fum/), specifying a
-stream handler that gets the actual bytes from someplace it does
-have access to. Thus it might be able to trick the system into
-creating a ProtectionDomain/CodeSource for a class even though
-that class really didn't come from that location.
+ * normally not have access to (like file:/foo/fum/), specifying a
+ * stream handler that gets the actual bytes from someplace it does
+ * have access to. Thus it might be able to trick the system into
+ * creating a ProtectionDomain/CodeSource for a class even though
+ * that class really didn't come from that location.
*
*
*
diff --git a/jdk/src/java.base/share/classes/java/net/SocketPermission.java b/jdk/src/java.base/share/classes/java/net/SocketPermission.java
index 1f3248077be..8894152512b 100644
--- a/jdk/src/java.base/share/classes/java/net/SocketPermission.java
+++ b/jdk/src/java.base/share/classes/java/net/SocketPermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@ import java.util.Vector;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.net.InetAddress;
import java.security.Permission;
@@ -1112,36 +1113,21 @@ public final class SocketPermission extends Permission
* @param mask a specific integer action mask to translate into a string
* @return the canonical string representation of the actions
*/
- private static String getActions(int mask)
- {
- StringBuilder sb = new StringBuilder();
- boolean comma = false;
-
+ private static String getActions(int mask) {
+ StringJoiner sj = new StringJoiner(",");
if ((mask & CONNECT) == CONNECT) {
- comma = true;
- sb.append("connect");
+ sj.add("connect");
}
-
if ((mask & LISTEN) == LISTEN) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("listen");
+ sj.add("listen");
}
-
if ((mask & ACCEPT) == ACCEPT) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("accept");
+ sj.add("accept");
}
-
-
if ((mask & RESOLVE) == RESOLVE) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("resolve");
+ sj.add("resolve");
}
-
- return sb.toString();
+ return sj.toString();
}
/**
diff --git a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java
index e448a120bdc..6f4691404c3 100644
--- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java
+++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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
@@ -407,6 +407,29 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
return pkg;
}
+ // Also called by VM to define Package for classes loaded from the CDS
+ // archive
+ private void definePackageInternal(String pkgname, Manifest man, URL url)
+ {
+ if (getAndVerifyPackage(pkgname, man, url) == null) {
+ try {
+ if (man != null) {
+ definePackage(pkgname, man, url);
+ } else {
+ definePackage(pkgname, null, null, null, null, null, null, null);
+ }
+ } catch (IllegalArgumentException iae) {
+ // parallel-capable class loaders: re-verify in case of a
+ // race condition
+ if (getAndVerifyPackage(pkgname, man, url) == null) {
+ // Should never happen
+ throw new AssertionError("Cannot find package " +
+ pkgname);
+ }
+ }
+ }
+ }
+
/*
* Defines a Class using the class bytes obtained from the specified
* Resource. The resulting Class must be resolved before it can be
@@ -420,23 +443,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
String pkgname = name.substring(0, i);
// Check if package already loaded.
Manifest man = res.getManifest();
- if (getAndVerifyPackage(pkgname, man, url) == null) {
- try {
- if (man != null) {
- definePackage(pkgname, man, url);
- } else {
- definePackage(pkgname, null, null, null, null, null, null, null);
- }
- } catch (IllegalArgumentException iae) {
- // parallel-capable class loaders: re-verify in case of a
- // race condition
- if (getAndVerifyPackage(pkgname, man, url) == null) {
- // Should never happen
- throw new AssertionError("Cannot find package " +
- pkgname);
- }
- }
- }
+ definePackageInternal(pkgname, man, url);
}
// Now read the class bytes and define the class
java.nio.ByteBuffer bb = res.getByteBuffer();
diff --git a/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java b/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java
index a8246b676ca..cb30a358ea4 100644
--- a/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java
+++ b/jdk/src/java.base/share/classes/java/text/CalendarBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package java.text;
import java.util.Calendar;
+import java.util.StringJoiner;
import static java.util.GregorianCalendar.*;
/**
@@ -146,19 +147,13 @@ class CalendarBuilder {
}
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("CalendarBuilder:[");
+ StringJoiner sj = new StringJoiner(",", "CalendarBuilder:[", "]");
for (int i = 0; i < field.length; i++) {
if (isSet(i)) {
- sb.append(i).append('=').append(field[MAX_FIELD + i]).append(',');
+ sj.add(i + "=" + field[MAX_FIELD + i]);
}
}
- int lastIndex = sb.length() - 1;
- if (sb.charAt(lastIndex) == ',') {
- sb.setLength(lastIndex);
- }
- sb.append(']');
- return sb.toString();
+ return sj.toString();
}
static int toISODayOfWeek(int calendarDayOfWeek) {
diff --git a/jdk/src/java.base/share/classes/java/util/Locale.java b/jdk/src/java.base/share/classes/java/util/Locale.java
index fbcb2f75e66..cf29686e693 100644
--- a/jdk/src/java.base/share/classes/java/util/Locale.java
+++ b/jdk/src/java.base/share/classes/java/util/Locale.java
@@ -2059,14 +2059,11 @@ public final class Locale implements Cloneable, Serializable {
// If we have no list patterns, compose the list in a simple,
// non-localized way.
if (listPattern == null || listCompositionPattern == null) {
- StringBuilder result = new StringBuilder();
+ StringJoiner sj = new StringJoiner(",");
for (int i = 0; i < stringList.length; ++i) {
- if (i > 0) {
- result.append(',');
- }
- result.append(stringList[i]);
+ sj.add(stringList[i]);
}
- return result.toString();
+ return sj.toString();
}
// Compose the list down to three elements if necessary
diff --git a/jdk/src/java.base/share/classes/java/util/PropertyPermission.java b/jdk/src/java.base/share/classes/java/util/PropertyPermission.java
index d532bddabf6..7e818a90b64 100644
--- a/jdk/src/java.base/share/classes/java/util/PropertyPermission.java
+++ b/jdk/src/java.base/share/classes/java/util/PropertyPermission.java
@@ -324,20 +324,16 @@ public final class PropertyPermission extends BasicPermission {
* @return the canonical string representation of the actions.
*/
static String getActions(int mask) {
- StringBuilder sb = new StringBuilder();
- boolean comma = false;
-
- if ((mask & READ) == READ) {
- comma = true;
- sb.append("read");
+ switch (mask & (READ|WRITE)) {
+ case READ:
+ return SecurityConstants.PROPERTY_READ_ACTION;
+ case WRITE:
+ return SecurityConstants.PROPERTY_WRITE_ACTION;
+ case READ|WRITE:
+ return SecurityConstants.PROPERTY_RW_ACTION;
+ default:
+ return "";
}
-
- if ((mask & WRITE) == WRITE) {
- if (comma) sb.append(',');
- else comma = true;
- sb.append("write");
- }
- return sb.toString();
}
/**
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
index 9e89169e15f..8476dcc1237 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
@@ -50,7 +50,6 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;
/**
@@ -77,9 +76,9 @@ import java.util.concurrent.locks.LockSupport;
* All async methods without an explicit Executor
* argument are performed using the {@link ForkJoinPool#commonPool()}
* (unless it does not support a parallelism level of at least two, in
- * which case, a new Thread is used). To simplify monitoring,
- * debugging, and tracking, all generated asynchronous tasks are
- * instances of the marker interface {@link
+ * which case, a new Thread is created to run each task). To simplify
+ * monitoring, debugging, and tracking, all generated asynchronous
+ * tasks are instances of the marker interface {@link
* AsynchronousCompletionTask}.
*
* All CompletionStage methods are implemented independently of
@@ -113,141 +112,1556 @@ public class CompletableFuture implements Future, CompletionStage {
/*
* Overview:
*
- * 1. Non-nullness of field result (set via CAS) indicates done.
- * An AltResult is used to box null as a result, as well as to
- * hold exceptions. Using a single field makes completion fast
- * and simple to detect and trigger, at the expense of a lot of
- * encoding and decoding that infiltrates many methods. One minor
- * simplification relies on the (static) NIL (to box null results)
- * being the only AltResult with a null exception field, so we
- * don't usually need explicit comparisons with NIL. The CF
- * exception propagation mechanics surrounding decoding rely on
- * unchecked casts of decoded results really being unchecked,
- * where user type errors are caught at point of use, as is
- * currently the case in Java. These are highlighted by using
- * SuppressWarnings-annotated temporaries.
+ * A CompletableFuture may have dependent completion actions,
+ * collected in a linked stack. It atomically completes by CASing
+ * a result field, and then pops off and runs those actions. This
+ * applies across normal vs exceptional outcomes, sync vs async
+ * actions, binary triggers, and various forms of completions.
*
- * 2. Waiters are held in a Treiber stack similar to the one used
- * in FutureTask, Phaser, and SynchronousQueue. See their
- * internal documentation for algorithmic details.
+ * Non-nullness of field result (set via CAS) indicates done. An
+ * AltResult is used to box null as a result, as well as to hold
+ * exceptions. Using a single field makes completion simple to
+ * detect and trigger. Encoding and decoding is straightforward
+ * but adds to the sprawl of trapping and associating exceptions
+ * with targets. Minor simplifications rely on (static) NIL (to
+ * box null results) being the only AltResult with a null
+ * exception field, so we don't usually need explicit comparisons.
+ * Even though some of the generics casts are unchecked (see
+ * SuppressWarnings annotations), they are placed to be
+ * appropriate even if checked.
*
- * 3. Completions are also kept in a list/stack, and pulled off
- * and run when completion is triggered. (We could even use the
- * same stack as for waiters, but would give up the potential
- * parallelism obtained because woken waiters help release/run
- * others -- see method postComplete). Because post-processing
- * may race with direct calls, class Completion opportunistically
- * extends AtomicInteger so callers can claim the action via
- * compareAndSet(0, 1). The Completion.run methods are all
- * written a boringly similar uniform way (that sometimes includes
- * unnecessary-looking checks, kept to maintain uniformity).
- * There are enough dimensions upon which they differ that
- * attempts to factor commonalities while maintaining efficiency
- * require more lines of code than they would save.
+ * Dependent actions are represented by Completion objects linked
+ * as Treiber stacks headed by field "stack". There are Completion
+ * classes for each kind of action, grouped into single-input
+ * (UniCompletion), two-input (BiCompletion), projected
+ * (BiCompletions using either (not both) of two inputs), shared
+ * (CoCompletion, used by the second of two sources), zero-input
+ * source actions, and Signallers that unblock waiters. Class
+ * Completion extends ForkJoinTask to enable async execution
+ * (adding no space overhead because we exploit its "tag" methods
+ * to maintain claims). It is also declared as Runnable to allow
+ * usage with arbitrary executors.
*
- * 4. The exported then/and/or methods do support a bit of
- * factoring (see doThenApply etc). They must cope with the
- * intrinsic races surrounding addition of a dependent action
- * versus performing the action directly because the task is
- * already complete. For example, a CF may not be complete upon
- * entry, so a dependent completion is added, but by the time it
- * is added, the target CF is complete, so must be directly
- * executed. This is all done while avoiding unnecessary object
- * construction in safe-bypass cases.
+ * Support for each kind of CompletionStage relies on a separate
+ * class, along with two CompletableFuture methods:
+ *
+ * * A Completion class with name X corresponding to function,
+ * prefaced with "Uni", "Bi", or "Or". Each class contains
+ * fields for source(s), actions, and dependent. They are
+ * boringly similar, differing from others only with respect to
+ * underlying functional forms. We do this so that users don't
+ * encounter layers of adaptors in common usages. We also
+ * include "Relay" classes/methods that don't correspond to user
+ * methods; they copy results from one stage to another.
+ *
+ * * Boolean CompletableFuture method x(...) (for example
+ * uniApply) takes all of the arguments needed to check that an
+ * action is triggerable, and then either runs the action or
+ * arranges its async execution by executing its Completion
+ * argument, if present. The method returns true if known to be
+ * complete.
+ *
+ * * Completion method tryFire(int mode) invokes the associated x
+ * method with its held arguments, and on success cleans up.
+ * The mode argument allows tryFire to be called twice (SYNC,
+ * then ASYNC); the first to screen and trap exceptions while
+ * arranging to execute, and the second when called from a
+ * task. (A few classes are not used async so take slightly
+ * different forms.) The claim() callback suppresses function
+ * invocation if already claimed by another thread.
+ *
+ * * CompletableFuture method xStage(...) is called from a public
+ * stage method of CompletableFuture x. It screens user
+ * arguments and invokes and/or creates the stage object. If
+ * not async and x is already complete, the action is run
+ * immediately. Otherwise a Completion c is created, pushed to
+ * x's stack (unless done), and started or triggered via
+ * c.tryFire. This also covers races possible if x completes
+ * while pushing. Classes with two inputs (for example BiApply)
+ * deal with races across both while pushing actions. The
+ * second completion is a CoCompletion pointing to the first,
+ * shared so that at most one performs the action. The
+ * multiple-arity methods allOf and anyOf do this pairwise to
+ * form trees of completions.
+ *
+ * Note that the generic type parameters of methods vary according
+ * to whether "this" is a source, dependent, or completion.
+ *
+ * Method postComplete is called upon completion unless the target
+ * is guaranteed not to be observable (i.e., not yet returned or
+ * linked). Multiple threads can call postComplete, which
+ * atomically pops each dependent action, and tries to trigger it
+ * via method tryFire, in NESTED mode. Triggering can propagate
+ * recursively, so NESTED mode returns its completed dependent (if
+ * one exists) for further processing by its caller (see method
+ * postFire).
+ *
+ * Blocking methods get() and join() rely on Signaller Completions
+ * that wake up waiting threads. The mechanics are similar to
+ * Treiber stack wait-nodes used in FutureTask, Phaser, and
+ * SynchronousQueue. See their internal documentation for
+ * algorithmic details.
+ *
+ * Without precautions, CompletableFutures would be prone to
+ * garbage accumulation as chains of Completions build up, each
+ * pointing back to its sources. So we null out fields as soon as
+ * possible (see especially method Completion.detach). The
+ * screening checks needed anyway harmlessly ignore null arguments
+ * that may have been obtained during races with threads nulling
+ * out fields. We also try to unlink fired Completions from
+ * stacks that might never be popped (see method postFire).
+ * Completion fields need not be declared as final or volatile
+ * because they are only visible to other threads upon safe
+ * publication.
*/
- // preliminaries
+ volatile Object result; // Either the result or boxed AltResult
+ volatile Completion stack; // Top of Treiber stack of dependent actions
- static final class AltResult {
- final Throwable ex; // null only for NIL
- AltResult(Throwable ex) { this.ex = ex; }
+ final boolean internalComplete(Object r) { // CAS from null to r
+ return UNSAFE.compareAndSwapObject(this, RESULT, null, r);
}
+ final boolean casStack(Completion cmp, Completion val) {
+ return UNSAFE.compareAndSwapObject(this, STACK, cmp, val);
+ }
+
+ /** Returns true if successfully pushed c onto stack. */
+ final boolean tryPushStack(Completion c) {
+ Completion h = stack;
+ lazySetNext(c, h);
+ return UNSAFE.compareAndSwapObject(this, STACK, h, c);
+ }
+
+ /** Unconditionally pushes c onto stack, retrying if necessary. */
+ final void pushStack(Completion c) {
+ do {} while (!tryPushStack(c));
+ }
+
+ /* ------------- Encoding and decoding outcomes -------------- */
+
+ static final class AltResult { // See above
+ final Throwable ex; // null only for NIL
+ AltResult(Throwable x) { this.ex = x; }
+ }
+
+ /** The encoding of the null value. */
static final AltResult NIL = new AltResult(null);
- // Fields
+ /** Completes with the null value, unless already completed. */
+ final boolean completeNull() {
+ return UNSAFE.compareAndSwapObject(this, RESULT, null,
+ NIL);
+ }
- volatile Object result; // Either the result or boxed AltResult
- volatile WaitNode waiters; // Treiber stack of threads blocked on get()
- volatile CompletionNode completions; // list (Treiber stack) of completions
+ /** Returns the encoding of the given non-exceptional value. */
+ final Object encodeValue(T t) {
+ return (t == null) ? NIL : t;
+ }
- // Basic utilities for triggering and processing completions
+ /** Completes with a non-exceptional result, unless already completed. */
+ final boolean completeValue(T t) {
+ return UNSAFE.compareAndSwapObject(this, RESULT, null,
+ (t == null) ? NIL : t);
+ }
/**
- * Removes and signals all waiting threads and runs all completions.
+ * Returns the encoding of the given (non-null) exception as a
+ * wrapped CompletionException unless it is one already.
+ */
+ static AltResult encodeThrowable(Throwable x) {
+ return new AltResult((x instanceof CompletionException) ? x :
+ new CompletionException(x));
+ }
+
+ /** Completes with an exceptional result, unless already completed. */
+ final boolean completeThrowable(Throwable x) {
+ return UNSAFE.compareAndSwapObject(this, RESULT, null,
+ encodeThrowable(x));
+ }
+
+ /**
+ * Returns the encoding of the given (non-null) exception as a
+ * wrapped CompletionException unless it is one already. May
+ * return the given Object r (which must have been the result of a
+ * source future) if it is equivalent, i.e. if this is a simple
+ * relay of an existing CompletionException.
+ */
+ static Object encodeThrowable(Throwable x, Object r) {
+ if (!(x instanceof CompletionException))
+ x = new CompletionException(x);
+ else if (r instanceof AltResult && x == ((AltResult)r).ex)
+ return r;
+ return new AltResult(x);
+ }
+
+ /**
+ * Completes with the given (non-null) exceptional result as a
+ * wrapped CompletionException unless it is one already, unless
+ * already completed. May complete with the given Object r
+ * (which must have been the result of a source future) if it is
+ * equivalent, i.e. if this is a simple propagation of an
+ * existing CompletionException.
+ */
+ final boolean completeThrowable(Throwable x, Object r) {
+ return UNSAFE.compareAndSwapObject(this, RESULT, null,
+ encodeThrowable(x, r));
+ }
+
+ /**
+ * Returns the encoding of the given arguments: if the exception
+ * is non-null, encodes as AltResult. Otherwise uses the given
+ * value, boxed as NIL if null.
+ */
+ Object encodeOutcome(T t, Throwable x) {
+ return (x == null) ? (t == null) ? NIL : t : encodeThrowable(x);
+ }
+
+ /**
+ * Returns the encoding of a copied outcome; if exceptional,
+ * rewraps as a CompletionException, else returns argument.
+ */
+ static Object encodeRelay(Object r) {
+ Throwable x;
+ return (((r instanceof AltResult) &&
+ (x = ((AltResult)r).ex) != null &&
+ !(x instanceof CompletionException)) ?
+ new AltResult(new CompletionException(x)) : r);
+ }
+
+ /**
+ * Completes with r or a copy of r, unless already completed.
+ * If exceptional, r is first coerced to a CompletionException.
+ */
+ final boolean completeRelay(Object r) {
+ return UNSAFE.compareAndSwapObject(this, RESULT, null,
+ encodeRelay(r));
+ }
+
+ /**
+ * Reports result using Future.get conventions.
+ */
+ private static T reportGet(Object r)
+ throws InterruptedException, ExecutionException {
+ if (r == null) // by convention below, null means interrupted
+ throw new InterruptedException();
+ if (r instanceof AltResult) {
+ Throwable x, cause;
+ if ((x = ((AltResult)r).ex) == null)
+ return null;
+ if (x instanceof CancellationException)
+ throw (CancellationException)x;
+ if ((x instanceof CompletionException) &&
+ (cause = x.getCause()) != null)
+ x = cause;
+ throw new ExecutionException(x);
+ }
+ @SuppressWarnings("unchecked") T t = (T) r;
+ return t;
+ }
+
+ /**
+ * Decodes outcome to return result or throw unchecked exception.
+ */
+ private static T reportJoin(Object r) {
+ if (r instanceof AltResult) {
+ Throwable x;
+ if ((x = ((AltResult)r).ex) == null)
+ return null;
+ if (x instanceof CancellationException)
+ throw (CancellationException)x;
+ if (x instanceof CompletionException)
+ throw (CompletionException)x;
+ throw new CompletionException(x);
+ }
+ @SuppressWarnings("unchecked") T t = (T) r;
+ return t;
+ }
+
+ /* ------------- Async task preliminaries -------------- */
+
+ /**
+ * A marker interface identifying asynchronous tasks produced by
+ * {@code async} methods. This may be useful for monitoring,
+ * debugging, and tracking asynchronous activities.
+ *
+ * @since 1.8
+ */
+ public static interface AsynchronousCompletionTask {
+ }
+
+ private static final boolean useCommonPool =
+ (ForkJoinPool.getCommonPoolParallelism() > 1);
+
+ /**
+ * Default executor -- ForkJoinPool.commonPool() unless it cannot
+ * support parallelism.
+ */
+ private static final Executor asyncPool = useCommonPool ?
+ ForkJoinPool.commonPool() : new ThreadPerTaskExecutor();
+
+ /** Fallback if ForkJoinPool.commonPool() cannot support parallelism */
+ static final class ThreadPerTaskExecutor implements Executor {
+ public void execute(Runnable r) { new Thread(r).start(); }
+ }
+
+ /**
+ * Null-checks user executor argument, and translates uses of
+ * commonPool to asyncPool in case parallelism disabled.
+ */
+ static Executor screenExecutor(Executor e) {
+ if (!useCommonPool && e == ForkJoinPool.commonPool())
+ return asyncPool;
+ if (e == null) throw new NullPointerException();
+ return e;
+ }
+
+ // Modes for Completion.tryFire. Signedness matters.
+ static final int SYNC = 0;
+ static final int ASYNC = 1;
+ static final int NESTED = -1;
+
+ /* ------------- Base Completion classes and operations -------------- */
+
+ @SuppressWarnings("serial")
+ abstract static class Completion extends ForkJoinTask
+ implements Runnable, AsynchronousCompletionTask {
+ volatile Completion next; // Treiber stack link
+
+ /**
+ * Performs completion action if triggered, returning a
+ * dependent that may need propagation, if one exists.
+ *
+ * @param mode SYNC, ASYNC, or NESTED
+ */
+ abstract CompletableFuture> tryFire(int mode);
+
+ /** Returns true if possibly still triggerable. Used by cleanStack. */
+ abstract boolean isLive();
+
+ public final void run() { tryFire(ASYNC); }
+ public final boolean exec() { tryFire(ASYNC); return true; }
+ public final Void getRawResult() { return null; }
+ public final void setRawResult(Void v) {}
+ }
+
+ static void lazySetNext(Completion c, Completion next) {
+ UNSAFE.putOrderedObject(c, NEXT, next);
+ }
+
+ /**
+ * Pops and tries to trigger all reachable dependents. Call only
+ * when known to be done.
*/
final void postComplete() {
- WaitNode q; Thread t;
- while ((q = waiters) != null) {
- if (UNSAFE.compareAndSwapObject(this, WAITERS, q, q.next) &&
- (t = q.thread) != null) {
- q.thread = null;
- LockSupport.unpark(t);
+ /*
+ * On each step, variable f holds current dependents to pop
+ * and run. It is extended along only one path at a time,
+ * pushing others to avoid unbounded recursion.
+ */
+ CompletableFuture> f = this; Completion h;
+ while ((h = f.stack) != null ||
+ (f != this && (h = (f = this).stack) != null)) {
+ CompletableFuture> d; Completion t;
+ if (f.casStack(h, t = h.next)) {
+ if (t != null) {
+ if (f != this) {
+ pushStack(h);
+ continue;
+ }
+ h.next = null; // detach
+ }
+ f = (d = h.tryFire(NESTED)) == null ? this : d;
}
}
+ }
- CompletionNode h; Completion c;
- while ((h = completions) != null) {
- if (UNSAFE.compareAndSwapObject(this, COMPLETIONS, h, h.next) &&
- (c = h.completion) != null)
- c.run();
+ /** Traverses stack and unlinks dead Completions. */
+ final void cleanStack() {
+ for (Completion p = null, q = stack; q != null;) {
+ Completion s = q.next;
+ if (q.isLive()) {
+ p = q;
+ q = s;
+ }
+ else if (p == null) {
+ casStack(q, s);
+ q = stack;
+ }
+ else {
+ p.next = s;
+ if (p.isLive())
+ q = s;
+ else {
+ p = null; // restart
+ q = stack;
+ }
+ }
+ }
+ }
+
+ /* ------------- One-input Completions -------------- */
+
+ /** A Completion with a source, dependent, and executor. */
+ @SuppressWarnings("serial")
+ abstract static class UniCompletion extends Completion {
+ Executor executor; // executor to use (null if none)
+ CompletableFuture dep; // the dependent to complete
+ CompletableFuture src; // source for action
+
+ UniCompletion(Executor executor, CompletableFuture dep,
+ CompletableFuture src) {
+ this.executor = executor; this.dep = dep; this.src = src;
+ }
+
+ /**
+ * Returns true if action can be run. Call only when known to
+ * be triggerable. Uses FJ tag bit to ensure that only one
+ * thread claims ownership. If async, starts as task -- a
+ * later call to tryFire will run action.
+ */
+ final boolean claim() {
+ Executor e = executor;
+ if (compareAndSetForkJoinTaskTag((short)0, (short)1)) {
+ if (e == null)
+ return true;
+ executor = null; // disable
+ e.execute(this);
+ }
+ return false;
+ }
+
+ final boolean isLive() { return dep != null; }
+ }
+
+ /** Pushes the given completion (if it exists) unless done. */
+ final void push(UniCompletion,?> c) {
+ if (c != null) {
+ while (result == null && !tryPushStack(c))
+ lazySetNext(c, null); // clear on failure
}
}
/**
- * Triggers completion with the encoding of the given arguments:
- * if the exception is non-null, encodes it as a wrapped
- * CompletionException unless it is one already. Otherwise uses
- * the given result, boxed as NIL if null.
+ * Post-processing by dependent after successful UniCompletion
+ * tryFire. Tries to clean stack of source a, and then either runs
+ * postComplete or returns this to caller, depending on mode.
*/
- final void internalComplete(T v, Throwable ex) {
+ final CompletableFuture postFire(CompletableFuture> a, int mode) {
+ if (a != null && a.stack != null) {
+ if (mode < 0 || a.result == null)
+ a.cleanStack();
+ else
+ a.postComplete();
+ }
+ if (result != null && stack != null) {
+ if (mode < 0)
+ return this;
+ else
+ postComplete();
+ }
+ return null;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniApply extends UniCompletion {
+ Function super T,? extends V> fn;
+ UniApply(Executor executor, CompletableFuture dep,
+ CompletableFuture src,
+ Function super T,? extends V> fn) {
+ super(executor, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null ||
+ !d.uniApply(a = src, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniApply(CompletableFuture a,
+ Function super S,? extends T> f,
+ UniApply c) {
+ Object r; Throwable x;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ tryComplete: if (result == null) {
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ completeThrowable(x, r);
+ break tryComplete;
+ }
+ r = null;
+ }
+ try {
+ if (c != null && !c.claim())
+ return false;
+ @SuppressWarnings("unchecked") S s = (S) r;
+ completeValue(f.apply(s));
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture uniApplyStage(
+ Executor e, Function super T,? extends V> f) {
+ if (f == null) throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.uniApply(this, f, null)) {
+ UniApply c = new UniApply(e, d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniAccept extends UniCompletion {
+ Consumer super T> fn;
+ UniAccept(Executor executor, CompletableFuture dep,
+ CompletableFuture src, Consumer super T> fn) {
+ super(executor, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null ||
+ !d.uniAccept(a = src, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniAccept(CompletableFuture a,
+ Consumer super S> f, UniAccept c) {
+ Object r; Throwable x;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ tryComplete: if (result == null) {
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ completeThrowable(x, r);
+ break tryComplete;
+ }
+ r = null;
+ }
+ try {
+ if (c != null && !c.claim())
+ return false;
+ @SuppressWarnings("unchecked") S s = (S) r;
+ f.accept(s);
+ completeNull();
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture uniAcceptStage(Executor e,
+ Consumer super T> f) {
+ if (f == null) throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.uniAccept(this, f, null)) {
+ UniAccept c = new UniAccept(e, d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniRun extends UniCompletion {
+ Runnable fn;
+ UniRun(Executor executor, CompletableFuture dep,
+ CompletableFuture src, Runnable fn) {
+ super(executor, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null ||
+ !d.uniRun(a = src, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniRun(CompletableFuture> a, Runnable f, UniRun> c) {
+ Object r; Throwable x;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ if (result == null) {
+ if (r instanceof AltResult && (x = ((AltResult)r).ex) != null)
+ completeThrowable(x, r);
+ else
+ try {
+ if (c != null && !c.claim())
+ return false;
+ f.run();
+ completeNull();
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture uniRunStage(Executor e, Runnable f) {
+ if (f == null) throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.uniRun(this, f, null)) {
+ UniRun c = new UniRun(e, d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniWhenComplete extends UniCompletion {
+ BiConsumer super T, ? super Throwable> fn;
+ UniWhenComplete(Executor executor, CompletableFuture dep,
+ CompletableFuture src,
+ BiConsumer super T, ? super Throwable> fn) {
+ super(executor, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null ||
+ !d.uniWhenComplete(a = src, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniWhenComplete(CompletableFuture a,
+ BiConsumer super T,? super Throwable> f,
+ UniWhenComplete c) {
+ Object r; T t; Throwable x = null;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ if (result == null) {
+ try {
+ if (c != null && !c.claim())
+ return false;
+ if (r instanceof AltResult) {
+ x = ((AltResult)r).ex;
+ t = null;
+ } else {
+ @SuppressWarnings("unchecked") T tr = (T) r;
+ t = tr;
+ }
+ f.accept(t, x);
+ if (x == null) {
+ internalComplete(r);
+ return true;
+ }
+ } catch (Throwable ex) {
+ if (x == null)
+ x = ex;
+ }
+ completeThrowable(x, r);
+ }
+ return true;
+ }
+
+ private CompletableFuture uniWhenCompleteStage(
+ Executor e, BiConsumer super T, ? super Throwable> f) {
+ if (f == null) throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.uniWhenComplete(this, f, null)) {
+ UniWhenComplete c = new UniWhenComplete(e, d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniHandle extends UniCompletion {
+ BiFunction super T, Throwable, ? extends V> fn;
+ UniHandle(Executor executor, CompletableFuture dep,
+ CompletableFuture src,
+ BiFunction super T, Throwable, ? extends V> fn) {
+ super(executor, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null ||
+ !d.uniHandle(a = src, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniHandle(CompletableFuture a,
+ BiFunction super S, Throwable, ? extends T> f,
+ UniHandle c) {
+ Object r; S s; Throwable x;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ if (result == null) {
+ try {
+ if (c != null && !c.claim())
+ return false;
+ if (r instanceof AltResult) {
+ x = ((AltResult)r).ex;
+ s = null;
+ } else {
+ x = null;
+ @SuppressWarnings("unchecked") S ss = (S) r;
+ s = ss;
+ }
+ completeValue(f.apply(s, x));
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture uniHandleStage(
+ Executor e, BiFunction super T, Throwable, ? extends V> f) {
+ if (f == null) throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.uniHandle(this, f, null)) {
+ UniHandle c = new UniHandle(e, d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniExceptionally extends UniCompletion {
+ Function super Throwable, ? extends T> fn;
+ UniExceptionally(CompletableFuture dep, CompletableFuture src,
+ Function super Throwable, ? extends T> fn) {
+ super(null, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) { // never ASYNC
+ // assert mode != ASYNC;
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null || !d.uniExceptionally(a = src, fn, this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniExceptionally(CompletableFuture a,
+ Function super Throwable, ? extends T> f,
+ UniExceptionally c) {
+ Object r; Throwable x;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ if (result == null) {
+ try {
+ if (r instanceof AltResult && (x = ((AltResult)r).ex) != null) {
+ if (c != null && !c.claim())
+ return false;
+ completeValue(f.apply(x));
+ } else
+ internalComplete(r);
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture uniExceptionallyStage(
+ Function f) {
+ if (f == null) throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (!d.uniExceptionally(this, f, null)) {
+ UniExceptionally c = new UniExceptionally(d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniRelay extends UniCompletion { // for Compose
+ UniRelay(CompletableFuture dep, CompletableFuture src) {
+ super(null, dep, src);
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null || !d.uniRelay(a = src))
+ return null;
+ src = null; dep = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniRelay(CompletableFuture a) {
+ Object r;
+ if (a == null || (r = a.result) == null)
+ return false;
+ if (result == null) // no need to claim
+ completeRelay(r);
+ return true;
+ }
+
+ @SuppressWarnings("serial")
+ static final class UniCompose extends UniCompletion {
+ Function super T, ? extends CompletionStage> fn;
+ UniCompose(Executor executor, CompletableFuture dep,
+ CompletableFuture src,
+ Function super T, ? extends CompletionStage> fn) {
+ super(executor, dep, src); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d; CompletableFuture a;
+ if ((d = dep) == null ||
+ !d.uniCompose(a = src, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; fn = null;
+ return d.postFire(a, mode);
+ }
+ }
+
+ final boolean uniCompose(
+ CompletableFuture a,
+ Function super S, ? extends CompletionStage> f,
+ UniCompose c) {
+ Object r; Throwable x;
+ if (a == null || (r = a.result) == null || f == null)
+ return false;
+ tryComplete: if (result == null) {
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ completeThrowable(x, r);
+ break tryComplete;
+ }
+ r = null;
+ }
+ try {
+ if (c != null && !c.claim())
+ return false;
+ @SuppressWarnings("unchecked") S s = (S) r;
+ CompletableFuture g = f.apply(s).toCompletableFuture();
+ if (g.result == null || !uniRelay(g)) {
+ UniRelay copy = new UniRelay(this, g);
+ g.push(copy);
+ copy.tryFire(SYNC);
+ if (result == null)
+ return false;
+ }
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture uniComposeStage(
+ Executor e, Function super T, ? extends CompletionStage> f) {
+ if (f == null) throw new NullPointerException();
+ Object r; Throwable x;
+ if (e == null && (r = result) != null) {
+ // try to return function result directly
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ return new CompletableFuture(encodeThrowable(x, r));
+ }
+ r = null;
+ }
+ try {
+ @SuppressWarnings("unchecked") T t = (T) r;
+ return f.apply(t).toCompletableFuture();
+ } catch (Throwable ex) {
+ return new CompletableFuture(encodeThrowable(ex));
+ }
+ }
+ CompletableFuture d = new CompletableFuture();
+ UniCompose c = new UniCompose(e, d, this, f);
+ push(c);
+ c.tryFire(SYNC);
+ return d;
+ }
+
+ /* ------------- Two-input Completions -------------- */
+
+ /** A Completion for an action with two sources */
+ @SuppressWarnings("serial")
+ abstract static class BiCompletion extends UniCompletion {
+ CompletableFuture snd; // second source for action
+ BiCompletion(Executor executor, CompletableFuture dep,
+ CompletableFuture src, CompletableFuture snd) {
+ super(executor, dep, src); this.snd = snd;
+ }
+ }
+
+ /** A Completion delegating to a BiCompletion */
+ @SuppressWarnings("serial")
+ static final class CoCompletion extends Completion {
+ BiCompletion,?,?> base;
+ CoCompletion(BiCompletion,?,?> base) { this.base = base; }
+ final CompletableFuture> tryFire(int mode) {
+ BiCompletion,?,?> c; CompletableFuture> d;
+ if ((c = base) == null || (d = c.tryFire(mode)) == null)
+ return null;
+ base = null; // detach
+ return d;
+ }
+ final boolean isLive() {
+ BiCompletion,?,?> c;
+ return (c = base) != null && c.dep != null;
+ }
+ }
+
+ /** Pushes completion to this and b unless both done. */
+ final void bipush(CompletableFuture> b, BiCompletion,?,?> c) {
+ if (c != null) {
+ Object r;
+ while ((r = result) == null && !tryPushStack(c))
+ lazySetNext(c, null); // clear on failure
+ if (b != null && b != this && b.result == null) {
+ Completion q = (r != null) ? c : new CoCompletion(c);
+ while (b.result == null && !b.tryPushStack(q))
+ lazySetNext(q, null); // clear on failure
+ }
+ }
+ }
+
+ /** Post-processing after successful BiCompletion tryFire. */
+ final CompletableFuture postFire(CompletableFuture> a,
+ CompletableFuture> b, int mode) {
+ if (b != null && b.stack != null) { // clean second source
+ if (mode < 0 || b.result == null)
+ b.cleanStack();
+ else
+ b.postComplete();
+ }
+ return postFire(a, mode);
+ }
+
+ @SuppressWarnings("serial")
+ static final class BiApply extends BiCompletion {
+ BiFunction super T,? super U,? extends V> fn;
+ BiApply(Executor executor, CompletableFuture dep,
+ CompletableFuture src, CompletableFuture snd,
+ BiFunction super T,? super U,? extends V> fn) {
+ super(executor, dep, src, snd); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d;
+ CompletableFuture a;
+ CompletableFuture b;
+ if ((d = dep) == null ||
+ !d.biApply(a = src, b = snd, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; snd = null; fn = null;
+ return d.postFire(a, b, mode);
+ }
+ }
+
+ final boolean biApply(CompletableFuture a,
+ CompletableFuture b,
+ BiFunction super R,? super S,? extends T> f,
+ BiApply c) {
+ Object r, s; Throwable x;
+ if (a == null || (r = a.result) == null ||
+ b == null || (s = b.result) == null || f == null)
+ return false;
+ tryComplete: if (result == null) {
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ completeThrowable(x, r);
+ break tryComplete;
+ }
+ r = null;
+ }
+ if (s instanceof AltResult) {
+ if ((x = ((AltResult)s).ex) != null) {
+ completeThrowable(x, s);
+ break tryComplete;
+ }
+ s = null;
+ }
+ try {
+ if (c != null && !c.claim())
+ return false;
+ @SuppressWarnings("unchecked") R rr = (R) r;
+ @SuppressWarnings("unchecked") S ss = (S) s;
+ completeValue(f.apply(rr, ss));
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture biApplyStage(
+ Executor e, CompletionStage o,
+ BiFunction super T,? super U,? extends V> f) {
+ CompletableFuture b;
+ if (f == null || (b = o.toCompletableFuture()) == null)
+ throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.biApply(this, b, f, null)) {
+ BiApply c = new BiApply(e, d, this, b, f);
+ bipush(b, c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class BiAccept extends BiCompletion {
+ BiConsumer super T,? super U> fn;
+ BiAccept(Executor executor, CompletableFuture dep,
+ CompletableFuture src, CompletableFuture snd,
+ BiConsumer super T,? super U> fn) {
+ super(executor, dep, src, snd); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d;
+ CompletableFuture a;
+ CompletableFuture b;
+ if ((d = dep) == null ||
+ !d.biAccept(a = src, b = snd, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; snd = null; fn = null;
+ return d.postFire(a, b, mode);
+ }
+ }
+
+ final boolean biAccept(CompletableFuture a,
+ CompletableFuture b,
+ BiConsumer super R,? super S> f,
+ BiAccept c) {
+ Object r, s; Throwable x;
+ if (a == null || (r = a.result) == null ||
+ b == null || (s = b.result) == null || f == null)
+ return false;
+ tryComplete: if (result == null) {
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ completeThrowable(x, r);
+ break tryComplete;
+ }
+ r = null;
+ }
+ if (s instanceof AltResult) {
+ if ((x = ((AltResult)s).ex) != null) {
+ completeThrowable(x, s);
+ break tryComplete;
+ }
+ s = null;
+ }
+ try {
+ if (c != null && !c.claim())
+ return false;
+ @SuppressWarnings("unchecked") R rr = (R) r;
+ @SuppressWarnings("unchecked") S ss = (S) s;
+ f.accept(rr, ss);
+ completeNull();
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture biAcceptStage(
+ Executor e, CompletionStage o,
+ BiConsumer super T,? super U> f) {
+ CompletableFuture b;
+ if (f == null || (b = o.toCompletableFuture()) == null)
+ throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.biAccept(this, b, f, null)) {
+ BiAccept c = new BiAccept(e, d, this, b, f);
+ bipush(b, c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class BiRun extends BiCompletion {
+ Runnable fn;
+ BiRun(Executor executor, CompletableFuture dep,
+ CompletableFuture src,
+ CompletableFuture snd,
+ Runnable fn) {
+ super(executor, dep, src, snd); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d;
+ CompletableFuture a;
+ CompletableFuture b;
+ if ((d = dep) == null ||
+ !d.biRun(a = src, b = snd, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; snd = null; fn = null;
+ return d.postFire(a, b, mode);
+ }
+ }
+
+ final boolean biRun(CompletableFuture> a, CompletableFuture> b,
+ Runnable f, BiRun,?> c) {
+ Object r, s; Throwable x;
+ if (a == null || (r = a.result) == null ||
+ b == null || (s = b.result) == null || f == null)
+ return false;
+ if (result == null) {
+ if (r instanceof AltResult && (x = ((AltResult)r).ex) != null)
+ completeThrowable(x, r);
+ else if (s instanceof AltResult && (x = ((AltResult)s).ex) != null)
+ completeThrowable(x, s);
+ else
+ try {
+ if (c != null && !c.claim())
+ return false;
+ f.run();
+ completeNull();
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture biRunStage(Executor e, CompletionStage> o,
+ Runnable f) {
+ CompletableFuture> b;
+ if (f == null || (b = o.toCompletableFuture()) == null)
+ throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.biRun(this, b, f, null)) {
+ BiRun c = new BiRun<>(e, d, this, b, f);
+ bipush(b, c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class BiRelay extends BiCompletion { // for And
+ BiRelay(CompletableFuture dep,
+ CompletableFuture src,
+ CompletableFuture snd) {
+ super(null, dep, src, snd);
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d;
+ CompletableFuture a;
+ CompletableFuture b;
+ if ((d = dep) == null || !d.biRelay(a = src, b = snd))
+ return null;
+ src = null; snd = null; dep = null;
+ return d.postFire(a, b, mode);
+ }
+ }
+
+ boolean biRelay(CompletableFuture> a, CompletableFuture> b) {
+ Object r, s; Throwable x;
+ if (a == null || (r = a.result) == null ||
+ b == null || (s = b.result) == null)
+ return false;
+ if (result == null) {
+ if (r instanceof AltResult && (x = ((AltResult)r).ex) != null)
+ completeThrowable(x, r);
+ else if (s instanceof AltResult && (x = ((AltResult)s).ex) != null)
+ completeThrowable(x, s);
+ else
+ completeNull();
+ }
+ return true;
+ }
+
+ /** Recursively constructs a tree of completions. */
+ static CompletableFuture andTree(CompletableFuture>[] cfs,
+ int lo, int hi) {
+ CompletableFuture d = new CompletableFuture();
+ if (lo > hi) // empty
+ d.result = NIL;
+ else {
+ CompletableFuture> a, b;
+ int mid = (lo + hi) >>> 1;
+ if ((a = (lo == mid ? cfs[lo] :
+ andTree(cfs, lo, mid))) == null ||
+ (b = (lo == hi ? a : (hi == mid+1) ? cfs[hi] :
+ andTree(cfs, mid+1, hi))) == null)
+ throw new NullPointerException();
+ if (!d.biRelay(a, b)) {
+ BiRelay,?> c = new BiRelay<>(d, a, b);
+ a.bipush(b, c);
+ c.tryFire(SYNC);
+ }
+ }
+ return d;
+ }
+
+ /* ------------- Projected (Ored) BiCompletions -------------- */
+
+ /** Pushes completion to this and b unless either done. */
+ final void orpush(CompletableFuture> b, BiCompletion,?,?> c) {
+ if (c != null) {
+ while ((b == null || b.result == null) && result == null) {
+ if (tryPushStack(c)) {
+ if (b != null && b != this && b.result == null) {
+ Completion q = new CoCompletion(c);
+ while (result == null && b.result == null &&
+ !b.tryPushStack(q))
+ lazySetNext(q, null); // clear on failure
+ }
+ break;
+ }
+ lazySetNext(c, null); // clear on failure
+ }
+ }
+ }
+
+ @SuppressWarnings("serial")
+ static final class OrApply extends BiCompletion {
+ Function super T,? extends V> fn;
+ OrApply(Executor executor, CompletableFuture dep,
+ CompletableFuture src,
+ CompletableFuture snd,
+ Function super T,? extends V> fn) {
+ super(executor, dep, src, snd); this.fn = fn;
+ }
+ final CompletableFuture tryFire(int mode) {
+ CompletableFuture d;
+ CompletableFuture a;
+ CompletableFuture b;
+ if ((d = dep) == null ||
+ !d.orApply(a = src, b = snd, fn, mode > 0 ? null : this))
+ return null;
+ dep = null; src = null; snd = null; fn = null;
+ return d.postFire(a, b, mode);
+ }
+ }
+
+ final boolean orApply(CompletableFuture a,
+ CompletableFuture b,
+ Function super R, ? extends T> f,
+ OrApply c) {
+ Object r; Throwable x;
+ if (a == null || b == null ||
+ ((r = a.result) == null && (r = b.result) == null) || f == null)
+ return false;
+ tryComplete: if (result == null) {
+ try {
+ if (c != null && !c.claim())
+ return false;
+ if (r instanceof AltResult) {
+ if ((x = ((AltResult)r).ex) != null) {
+ completeThrowable(x, r);
+ break tryComplete;
+ }
+ r = null;
+ }
+ @SuppressWarnings("unchecked") R rr = (R) r;
+ completeValue(f.apply(rr));
+ } catch (Throwable ex) {
+ completeThrowable(ex);
+ }
+ }
+ return true;
+ }
+
+ private CompletableFuture orApplyStage(
+ Executor e, CompletionStage o,
+ Function super T, ? extends V> f) {
+ CompletableFuture b;
+ if (f == null || (b = o.toCompletableFuture()) == null)
+ throw new NullPointerException();
+ CompletableFuture d = new CompletableFuture();
+ if (e != null || !d.orApply(this, b, f, null)) {
+ OrApply c = new OrApply(e, d, this, b, f);
+ orpush(b, c);
+ c.tryFire(SYNC);
+ }
+ return d;
+ }
+
+ @SuppressWarnings("serial")
+ static final class OrAccept extends BiCompletion