--- a/hotspot/make/bsd/makefiles/vm.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/bsd/makefiles/vm.make Tue Jun 10 20:24:48 2014 -0700
@@ -295,6 +295,7 @@
$(PRECOMPILED_HEADER):
$(QUIETLY) echo Generating precompiled header $@
$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
+ $(QUIETLY) rm -f $@
$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
# making the library:
--- a/hotspot/make/linux/makefiles/vm.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/linux/makefiles/vm.make Tue Jun 10 20:24:48 2014 -0700
@@ -290,6 +290,7 @@
$(PRECOMPILED_HEADER):
$(QUIETLY) echo Generating precompiled header $@
$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
+ $(QUIETLY) rm -f $@
$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
# making the library:
--- a/hotspot/make/windows/create.bat Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/create.bat Tue Jun 10 20:24:48 2014 -0700
@@ -1,6 +1,6 @@
@echo off
REM
-REM Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+REM Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
REM
REM This code is free software; you can redistribute it and/or modify it
@@ -81,33 +81,8 @@
for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i
echo **************************************************************
-set ProjectFile=%HotSpotBuildSpace%\jvm.vcproj
echo MSC_VER = "%MSC_VER%"
-if "%MSC_VER%" == "1200" (
-set ProjectFile=%HotSpotBuildSpace%\jvm.dsp
-echo Will generate VC6 project {unsupported}
-) else (
-if "%MSC_VER%" == "1400" (
-echo Will generate VC8 {Visual Studio 2005}
-) else (
-if "%MSC_VER%" == "1500" (
-echo Will generate VC9 {Visual Studio 2008}
-) else (
-if "%MSC_VER%" == "1600" (
-echo Will generate VC10 {Visual Studio 2010}
set ProjectFile=%HotSpotBuildSpace%\jvm.vcxproj
-) else (
-if "%MSC_VER%" == "1700" (
-echo Will generate VC10 {compatible with Visual Studio 2012}
-echo After opening in VS 2012, click "Update" when prompted.
-set ProjectFile=%HotSpotBuildSpace%\jvm.vcxproj
-) else (
-echo Will generate VC7 project {Visual Studio 2003 .NET}
-)
-)
-)
-)
-)
echo %ProjectFile%
echo **************************************************************
--- a/hotspot/make/windows/makefiles/compile.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/makefiles/compile.make Tue Jun 10 20:24:48 2014 -0700
@@ -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
@@ -63,28 +63,20 @@
# Based on BUILDARCH we add some flags and select the default compiler name
!if "$(BUILDARCH)" == "ia64"
MACHINE=IA64
-DEFAULT_COMPILER_NAME=VS2003
CXX_FLAGS=$(CXX_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64"
!endif
!if "$(BUILDARCH)" == "amd64"
MACHINE=AMD64
-DEFAULT_COMPILER_NAME=VS2005
CXX_FLAGS=$(CXX_FLAGS) /D "_LP64" /D "AMD64"
LP64=1
!endif
!if "$(BUILDARCH)" == "i486"
MACHINE=I386
-DEFAULT_COMPILER_NAME=VS2003
CXX_FLAGS=$(CXX_FLAGS) /D "IA32"
!endif
-# Sanity check, this is the default if not amd64, ia64, or i486
-!ifndef DEFAULT_COMPILER_NAME
-CXX=ARCH_ERROR
-!endif
-
CXX_FLAGS=$(CXX_FLAGS) /D "WIN32" /D "_WINDOWS"
# Must specify this for sharedRuntimeTrig.cpp
CXX_FLAGS=$(CXX_FLAGS) /D "VM_LITTLE_ENDIAN"
@@ -112,6 +104,7 @@
# 1500 is for VS2008
# 1600 is for VS2010
# 1700 is for VS2012
+# 1800 is for VS2013
# Do not confuse this MSC_VER with the predefined macro _MSC_VER that the
# compiler provides, when MSC_VER==1399, _MSC_VER will be 1400.
# Normally they are the same, but a pre-release of the VS2005 compilers
@@ -119,35 +112,6 @@
# closer to VS2003 in terms of option spellings, so we use 1399 for that
# 1400 version that really isn't 1400.
# See the file get_msc_ver.sh for more info.
-!if "x$(MSC_VER)" == "x"
-COMPILER_NAME=$(DEFAULT_COMPILER_NAME)
-!else
-!if "$(MSC_VER)" == "1200"
-COMPILER_NAME=VC6
-!endif
-!if "$(MSC_VER)" == "1300"
-COMPILER_NAME=VS2003
-!endif
-!if "$(MSC_VER)" == "1310"
-COMPILER_NAME=VS2003
-!endif
-!if "$(MSC_VER)" == "1399"
-# Compiler might say 1400, but if it's 14.00.30701, it isn't really VS2005
-COMPILER_NAME=VS2003
-!endif
-!if "$(MSC_VER)" == "1400"
-COMPILER_NAME=VS2005
-!endif
-!if "$(MSC_VER)" == "1500"
-COMPILER_NAME=VS2008
-!endif
-!if "$(MSC_VER)" == "1600"
-COMPILER_NAME=VS2010
-!endif
-!if "$(MSC_VER)" == "1700"
-COMPILER_NAME=VS2012
-!endif
-!endif
# By default, we do not want to use the debug version of the msvcrt.dll file
# but if MFC_DEBUG is defined in the environment it will be used.
@@ -165,60 +129,6 @@
!endif
CXX_FLAGS=$(CXX_FLAGS) $(MS_RUNTIME_OPTION)
-# How /GX option is spelled
-GX_OPTION = /GX
-
-# Optimization settings for various versions of the compilers and types of
-# builds. Three basic sets of settings: product, fastdebug, and debug.
-# These get added into CXX_FLAGS as needed by other makefiles.
-!if "$(COMPILER_NAME)" == "VC6"
-PRODUCT_OPT_OPTION = /Ox /Os /Gy /GF
-FASTDEBUG_OPT_OPTION = /Ox /Os /Gy /GF
-DEBUG_OPT_OPTION = /Od
-!endif
-
-!if "$(COMPILER_NAME)" == "VS2003"
-PRODUCT_OPT_OPTION = /O2 /Oy-
-FASTDEBUG_OPT_OPTION = /O2 /Oy-
-DEBUG_OPT_OPTION = /Od
-SAFESEH_FLAG = /SAFESEH
-!endif
-
-!if "$(COMPILER_NAME)" == "VS2005"
-PRODUCT_OPT_OPTION = /O2 /Oy-
-FASTDEBUG_OPT_OPTION = /O2 /Oy-
-DEBUG_OPT_OPTION = /Od
-GX_OPTION = /EHsc
-# This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib
-# on the link command line, otherwise we get missing __security_check_cookie
-# externals at link time. Even with /GS-, you need bufferoverflowU.lib.
-# NOTE: Currently we decided to not use /GS-
-BUFFEROVERFLOWLIB = bufferoverflowU.lib
-LD_FLAGS = /manifest $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
-# Manifest Tool - used in VS2005 and later to adjust manifests stored
-# as resources inside build artifacts.
-!if "x$(MT)" == "x"
-MT=mt.exe
-!endif
-SAFESEH_FLAG = /SAFESEH
-!endif
-
-!if "$(COMPILER_NAME)" == "VS2008"
-PRODUCT_OPT_OPTION = /O2 /Oy-
-FASTDEBUG_OPT_OPTION = /O2 /Oy-
-DEBUG_OPT_OPTION = /Od
-GX_OPTION = /EHsc
-LD_FLAGS = /manifest $(LD_FLAGS)
-MP_FLAG = /MP
-# Manifest Tool - used in VS2005 and later to adjust manifests stored
-# as resources inside build artifacts.
-!if "x$(MT)" == "x"
-MT=mt.exe
-!endif
-SAFESEH_FLAG = /SAFESEH
-!endif
-
-!if "$(COMPILER_NAME)" == "VS2010"
PRODUCT_OPT_OPTION = /O2 /Oy-
FASTDEBUG_OPT_OPTION = /O2 /Oy-
DEBUG_OPT_OPTION = /Od
@@ -233,26 +143,6 @@
!if "$(BUILDARCH)" == "i486"
LD_FLAGS = /SAFESEH $(LD_FLAGS)
!endif
-!endif
-
-!if "$(COMPILER_NAME)" == "VS2012"
-PRODUCT_OPT_OPTION = /O2 /Oy-
-FASTDEBUG_OPT_OPTION = /O2 /Oy-
-DEBUG_OPT_OPTION = /Od
-GX_OPTION = /EHsc
-LD_FLAGS = /manifest $(LD_FLAGS)
-MP_FLAG = /MP
-# Manifest Tool - used in VS2005 and later to adjust manifests stored
-# as resources inside build artifacts.
-!if "x$(MT)" == "x"
-MT=mt.exe
-!endif
-SAFESEH_FLAG = /SAFESEH
-!endif
-
-!if "$(BUILDARCH)" == "i486"
-LD_FLAGS = $(SAFESEH_FLAG) $(LD_FLAGS)
-!endif
CXX_FLAGS = $(CXX_FLAGS) $(MP_FLAG)
--- a/hotspot/make/windows/makefiles/rules.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/makefiles/rules.make Tue Jun 10 20:24:48 2014 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -49,35 +49,8 @@
JAVAC_FLAGS=-g -encoding ascii
BOOTSTRAP_JAVAC_FLAGS=$(JAVAC_FLAGS) -source $(BOOT_SOURCE_LANGUAGE_VERSION) -target $(BOOT_TARGET_CLASS_VERSION)
-ProjectFile=jvm.vcproj
-
-!if "$(MSC_VER)" == "1200"
-
-VcVersion=VC6
-ProjectFile=jvm.dsp
-
-!elseif "$(MSC_VER)" == "1400"
-
-VcVersion=VC8
-
-!elseif "$(MSC_VER)" == "1500"
-
-VcVersion=VC9
-
-!elseif "$(MSC_VER)" == "1600"
-
+# VS2012 and VS2013 loads VS10 projects just fine (and will
+# upgrade them automatically to VS2012 format).
VcVersion=VC10
ProjectFile=jvm.vcxproj
-!elseif "$(MSC_VER)" == "1700"
-# This is VS2012, but it loads VS10 projects just fine (and will
-# upgrade them automatically to VS2012 format).
-
-VcVersion=VC10
-ProjectFile=jvm.vcxproj
-
-!else
-
-VcVersion=VC7
-
-!endif
--- a/hotspot/make/windows/makefiles/sa.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/makefiles/sa.make Tue Jun 10 20:24:48 2014 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 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
@@ -85,14 +85,9 @@
# will be useful to have the assertion checks in place
!if "$(BUILDARCH)" == "ia64"
-SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -YX -FD -c
+SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -c
!elseif "$(BUILDARCH)" == "amd64"
-SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -YX -FD -c
-!if "$(COMPILER_NAME)" == "VS2005"
-# On amd64, VS2005 compiler requires bufferoverflowU.lib on the link command line,
-# otherwise we get missing __security_check_cookie externals at link time.
-SA_LD_FLAGS = bufferoverflowU.lib
-!endif
+SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "WIN64" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -c
!else
SA_CFLAGS = -nologo $(MS_RUNTIME_OPTION) -W3 $(GX_OPTION) -Od -D "WIN32" -D "_WINDOWS" -D "_DEBUG" -D "_CONSOLE" -D "_MBCS" -FD -RTC1 -c
!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1"
--- a/hotspot/make/windows/makefiles/sanity.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/makefiles/sanity.make Tue Jun 10 20:24:48 2014 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -27,9 +27,9 @@
all: checkCL checkLink
checkCL:
- @ if "$(MSC_VER)" NEQ "1310" if "$(MSC_VER)" NEQ "1399" if "$(MSC_VER)" NEQ "1400" if "$(MSC_VER)" NEQ "1500" if "$(MSC_VER)" NEQ "1600" if "$(MSC_VER)" NEQ "1700" \
- echo *** WARNING *** unrecognized cl.exe version $(MSC_VER) ($(RAW_MSC_VER)). Use FORCE_MSC_VER to override automatic detection.
+ @ if "$(MSC_VER)" NEQ "1600" if "$(MSC_VER)" NEQ "1700" if "$(MSC_VER)" NEQ "1800" \
+ echo *** WARNING *** Unsupported cl.exe version detected: $(MSC_VER) ($(RAW_MSC_VER)), only 1600/1700/1800 (Visual Studio 2010/2012/2013) are supported.
checkLink:
- @ if "$(LD_VER)" NEQ "710" if "$(LD_VER)" NEQ "800" if "$(LD_VER)" NEQ "900" if "$(LD_VER)" NEQ "1000" if "$(LD_VER)" NEQ "1100" \
- echo *** WARNING *** unrecognized link.exe version $(LD_VER) ($(RAW_LD_VER)). Use FORCE_LD_VER to override automatic detection.
+ @ if "$(LD_VER)" NEQ "1000" if "$(LD_VER)" NEQ "1100" if "$(LD_VER)" NEQ "1200" \
+ echo *** WARNING *** Unsupported link.exe version detected: $(LD_VER) ($(RAW_LD_VER)), only 1000/1100/1200 (Visual Studio 2010/2012/2013) are supported.
--- a/hotspot/make/windows/makefiles/vm.make Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/makefiles/vm.make Tue Jun 10 20:24:48 2014 -0700
@@ -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
@@ -132,7 +132,7 @@
!if "$(USE_PRECOMPILED_HEADER)" != "0"
CXX_USE_PCH=/Fp"vm.pch" /Yu"precompiled.hpp"
-!if "$(COMPILER_NAME)" == "VS2012"
+!if "$(MSC_VER)" > "1600"
# VS2012 requires this object file to be listed:
LD_FLAGS=$(LD_FLAGS) _build_pch_file.obj
!endif
--- a/hotspot/make/windows/projectfiles/common/Makefile Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/make/windows/projectfiles/common/Makefile Tue Jun 10 20:24:48 2014 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 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
@@ -120,7 +120,6 @@
ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) $(ReleaseOptions)
$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class
- @if "$(MSC_VER)"=="1500" echo Make sure you have VS2008 SP1 or later, or you may see 'expanded command line too long'
@$(RUN_JAVA) -Djava.class.path="$(HOTSPOTBUILDSPACE)/classes" ProjectCreator WinGammaPlatform$(VcVersion) $(ProjectCreatorIDEOptions)
clean:
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Jun 10 20:24:48 2014 -0700
@@ -2984,9 +2984,12 @@
} else if (tag == vmSymbols::tag_enclosing_method()) {
if (parsed_enclosingmethod_attribute) {
classfile_parse_error("Multiple EnclosingMethod attributes in class file %s", CHECK);
- } else {
+ } else {
parsed_enclosingmethod_attribute = true;
}
+ guarantee_property(attribute_length == 4,
+ "Wrong EnclosingMethod attribute length %u in class file %s",
+ attribute_length, CHECK);
cfs->guarantee_more(4, CHECK); // class_index, method_index
enclosing_method_class_index = cfs->get_u2_fast();
enclosing_method_method_index = cfs->get_u2_fast();
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Tue Jun 10 20:24:48 2014 -0700
@@ -624,6 +624,12 @@
}
}
+void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
+ for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
+ cl->do_cld(cld);
+ }
+}
+
void ClassLoaderDataGraph::classes_do(KlassClosure* klass_closure) {
for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
cld->classes_do(klass_closure);
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp Tue Jun 10 20:24:48 2014 -0700
@@ -77,6 +77,7 @@
static void oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim);
static void always_strong_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim);
static void keep_alive_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim);
+ static void cld_do(CLDClosure* cl);
static void classes_do(KlassClosure* klass_closure);
static void classes_do(void f(Klass* const));
static void methods_do(void f(Method*));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/classfile/classLoaderStats.cpp Tue Jun 10 20:24:48 2014 -0700
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/classLoaderStats.hpp"
+#include "utilities/globalDefinitions.hpp"
+
+
+class ClassStatsClosure : public KlassClosure {
+public:
+ int _num_classes;
+
+ ClassStatsClosure() :
+ _num_classes(0) {
+ }
+
+ virtual void do_klass(Klass* k) {
+ _num_classes++;
+ }
+};
+
+
+void ClassLoaderStatsClosure::do_cld(ClassLoaderData* cld) {
+ oop cl = cld->class_loader();
+ ClassLoaderStats* cls;
+
+ // The hashtable key is the ClassLoader oop since we want to account
+ // for "real" classes and anonymous classes together
+ ClassLoaderStats** cls_ptr = _stats->get(cl);
+ if (cls_ptr == NULL) {
+ cls = new ClassLoaderStats();
+ _stats->put(cl, cls);
+ _total_loaders++;
+ } else {
+ cls = *cls_ptr;
+ }
+
+ if (!cld->is_anonymous()) {
+ cls->_cld = cld;
+ }
+
+ cls->_class_loader = cl;
+ if (cl != NULL) {
+ cls->_parent = java_lang_ClassLoader::parent(cl);
+ addEmptyParents(cls->_parent);
+ }
+
+ ClassStatsClosure csc;
+ cld->classes_do(&csc);
+ if(cld->is_anonymous()) {
+ cls->_anon_classes_count += csc._num_classes;
+ } else {
+ cls->_classes_count = csc._num_classes;
+ }
+ _total_classes += csc._num_classes;
+
+ Metaspace* ms = cld->metaspace_or_null();
+ if (ms != NULL) {
+ if(cld->is_anonymous()) {
+ cls->_anon_chunk_sz += ms->allocated_chunks_bytes();
+ cls->_anon_block_sz += ms->allocated_blocks_bytes();
+ } else {
+ cls->_chunk_sz = ms->allocated_chunks_bytes();
+ cls->_block_sz = ms->allocated_blocks_bytes();
+ }
+ _total_chunk_sz += ms->allocated_chunks_bytes();
+ _total_block_sz += ms->allocated_blocks_bytes();
+ }
+}
+
+
+// Handles the difference in pointer width on 32 and 64 bit platforms
+#ifdef _LP64
+ #define SPACE "%8s"
+#else
+ #define SPACE "%s"
+#endif
+
+
+bool ClassLoaderStatsClosure::do_entry(oop const& key, ClassLoaderStats* const& cls) {
+ Klass* class_loader_klass = (cls->_class_loader == NULL ? NULL : cls->_class_loader->klass());
+ Klass* parent_klass = (cls->_parent == NULL ? NULL : cls->_parent->klass());
+
+ _out->print(INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " UINTX_FORMAT_W(6) " " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " ",
+ p2i(class_loader_klass), p2i(parent_klass), p2i(cls->_cld),
+ cls->_classes_count,
+ cls->_chunk_sz, cls->_block_sz);
+ if (class_loader_klass != NULL) {
+ _out->print("%s", class_loader_klass->external_name());
+ } else {
+ _out->print("<boot class loader>");
+ }
+ _out->cr();
+ if (cls->_anon_classes_count > 0) {
+ _out->print_cr(SPACE SPACE SPACE " " UINTX_FORMAT_W(6) " " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " + unsafe anonymous classes",
+ "", "", "",
+ cls->_anon_classes_count,
+ cls->_anon_chunk_sz, cls->_anon_block_sz);
+ }
+ return true;
+}
+
+
+void ClassLoaderStatsClosure::print() {
+ _out->print_cr("ClassLoader" SPACE " Parent" SPACE " CLD*" SPACE " Classes ChunkSz BlockSz Type", "", "", "");
+ _stats->iterate(this);
+ _out->print("Total = " UINTX_FORMAT_W(-6), _total_loaders);
+ _out->print(SPACE SPACE SPACE " ", "", "", "");
+ _out->print_cr(UINTX_FORMAT_W(6) " " SIZE_FORMAT_W(8) " " SIZE_FORMAT_W(8) " ",
+ _total_classes,
+ _total_chunk_sz,
+ _total_block_sz);
+ _out->print_cr("ChunkSz: Total size of all allocated metaspace chunks");
+ _out->print_cr("BlockSz: Total size of all allocated metaspace blocks (each chunk has several blocks)");
+}
+
+
+void ClassLoaderStatsClosure::addEmptyParents(oop cl) {
+ while (cl != NULL && java_lang_ClassLoader::loader_data(cl) == NULL) {
+ // This classloader has not loaded any classes
+ ClassLoaderStats** cls_ptr = _stats->get(cl);
+ if (cls_ptr == NULL) {
+ // It does not exist in our table - add it
+ ClassLoaderStats* cls = new ClassLoaderStats();
+ cls->_class_loader = cl;
+ cls->_parent = java_lang_ClassLoader::parent(cl);
+ _stats->put(cl, cls);
+ _total_loaders++;
+ }
+
+ cl = java_lang_ClassLoader::parent(cl);
+ }
+}
+
+
+void ClassLoaderStatsVMOperation::doit() {
+ ClassLoaderStatsClosure clsc (_out);
+ ClassLoaderDataGraph::cld_do(&clsc);
+ clsc.print();
+}
+
+
+void ClassLoaderStatsDCmd::execute(DCmdSource source, TRAPS) {
+ ClassLoaderStatsVMOperation op(output());
+ VMThread::execute(&op);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/share/vm/classfile/classLoaderStats.hpp Tue Jun 10 20:24:48 2014 -0700
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_CLASSFILE_CLASSLOADERSTATS_HPP
+#define SHARE_VM_CLASSFILE_CLASSLOADERSTATS_HPP
+
+
+#include "classfile/classLoaderData.hpp"
+#include "oops/klass.hpp"
+#include "oops/oopsHierarchy.hpp"
+#include "runtime/vm_operations.hpp"
+#include "services/diagnosticCommand.hpp"
+#include "utilities/resourceHash.hpp"
+
+
+class ClassLoaderStatsDCmd : public DCmd {
+public:
+ ClassLoaderStatsDCmd(outputStream* output, bool heap) :
+ DCmd(output, heap) {
+ }
+
+ static const char* name() {
+ return "VM.classloader_stats";
+ }
+
+ static const char* description() {
+ return "Print statistics about all ClassLoaders.";
+ }
+
+ static const char* impact() {
+ return "Low";
+ }
+
+ virtual void execute(DCmdSource source, TRAPS);
+
+ static int num_arguments() {
+ return 0;
+ }
+
+ static const JavaPermission permission() {
+ JavaPermission p = {"java.lang.management.ManagementPermission",
+ "monitor", NULL};
+ return p;
+ }
+};
+
+
+class ClassLoaderStats : public ResourceObj {
+public:
+ ClassLoaderData* _cld;
+ oop _class_loader;
+ oop _parent;
+
+ size_t _chunk_sz;
+ size_t _block_sz;
+ uintx _classes_count;
+
+ size_t _anon_chunk_sz;
+ size_t _anon_block_sz;
+ uintx _anon_classes_count;
+
+ ClassLoaderStats() :
+ _cld(0),
+ _class_loader(0),
+ _parent(0),
+ _chunk_sz(0),
+ _block_sz(0),
+ _classes_count(0),
+ _anon_block_sz(0),
+ _anon_chunk_sz(0),
+ _anon_classes_count(0) {
+ }
+};
+
+
+class ClassLoaderStatsClosure : public CLDClosure {
+protected:
+ static bool oop_equals(oop const& s1, oop const& s2) {
+ return s1 == s2;
+ }
+
+ static unsigned oop_hash(oop const& s1) {
+ unsigned hash = (unsigned)((uintptr_t)&s1);
+ return hash ^ (hash >> LogMinObjAlignment);
+ }
+
+ typedef ResourceHashtable<oop, ClassLoaderStats*,
+ ClassLoaderStatsClosure::oop_hash, ClassLoaderStatsClosure::oop_equals> StatsTable;
+
+ outputStream* _out;
+ StatsTable* _stats;
+ uintx _total_loaders;
+ uintx _total_classes;
+ size_t _total_chunk_sz;
+ size_t _total_block_sz;
+
+public:
+ ClassLoaderStatsClosure(outputStream* out) :
+ _out(out),
+ _total_loaders(0),
+ _total_block_sz(0),
+ _total_chunk_sz(0),
+ _total_classes(0),
+ _stats(new StatsTable()) {
+ }
+
+ virtual void do_cld(ClassLoaderData* cld);
+ virtual bool do_entry(oop const& key, ClassLoaderStats* const& cls);
+ void print();
+
+private:
+ void addEmptyParents(oop cl);
+};
+
+
+class ClassLoaderStatsVMOperation : public VM_Operation {
+ outputStream* _out;
+
+public:
+ ClassLoaderStatsVMOperation(outputStream* out) :
+ _out(out) {
+ }
+
+ VMOp_Type type() const {
+ return VMOp_ClassLoaderStatsOperation;
+ }
+
+ void doit();
+};
+
+#endif // SHARE_VM_CLASSFILE_CLASSLOADERSTATS_HPP
--- a/hotspot/src/share/vm/memory/metaspace.cpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.cpp Tue Jun 10 20:24:48 2014 -0700
@@ -697,6 +697,7 @@
size_t allocated_blocks_words() const { return _allocated_blocks_words; }
size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; }
size_t allocated_chunks_words() const { return _allocated_chunks_words; }
+ size_t allocated_chunks_bytes() const { return _allocated_chunks_words * BytesPerWord; }
size_t allocated_chunks_count() const { return _allocated_chunks_count; }
bool is_humongous(size_t word_size) { return word_size > medium_chunk_size(); }
@@ -3365,6 +3366,16 @@
return capacity_words_slow(mdtype) * BytesPerWord;
}
+size_t Metaspace::allocated_blocks_bytes() const {
+ return vsm()->allocated_blocks_bytes() +
+ (using_class_space() ? class_vsm()->allocated_blocks_bytes() : 0);
+}
+
+size_t Metaspace::allocated_chunks_bytes() const {
+ return vsm()->allocated_chunks_bytes() +
+ (using_class_space() ? class_vsm()->allocated_chunks_bytes() : 0);
+}
+
void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
assert(!SafepointSynchronize::is_at_safepoint()
|| Thread::current()->is_VM_thread(), "should be the VM thread");
--- a/hotspot/src/share/vm/memory/metaspace.hpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/memory/metaspace.hpp Tue Jun 10 20:24:48 2014 -0700
@@ -226,6 +226,9 @@
size_t used_bytes_slow(MetadataType mdtype) const;
size_t capacity_bytes_slow(MetadataType mdtype) const;
+ size_t allocated_blocks_bytes() const;
+ size_t allocated_chunks_bytes() const;
+
static MetaWord* allocate(ClassLoaderData* loader_data, size_t word_size,
bool read_only, MetaspaceObj::Type type, TRAPS);
void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp Tue Jun 10 20:24:48 2014 -0700
@@ -98,6 +98,7 @@
template(LinuxDllLoad) \
template(RotateGCLog) \
template(WhiteBoxOperation) \
+ template(ClassLoaderStatsOperation) \
class VM_Operation: public CHeapObj<mtInternal> {
public:
--- a/hotspot/src/share/vm/runtime/vm_version.cpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp Tue Jun 10 20:24:48 2014 -0700
@@ -222,20 +222,12 @@
#ifndef HOTSPOT_BUILD_COMPILER
#ifdef _MSC_VER
- #if _MSC_VER == 1100
- #define HOTSPOT_BUILD_COMPILER "MS VC++ 5.0"
- #elif _MSC_VER == 1200
- #define HOTSPOT_BUILD_COMPILER "MS VC++ 6.0"
- #elif _MSC_VER == 1310
- #define HOTSPOT_BUILD_COMPILER "MS VC++ 7.1 (VS2003)"
- #elif _MSC_VER == 1400
- #define HOTSPOT_BUILD_COMPILER "MS VC++ 8.0 (VS2005)"
- #elif _MSC_VER == 1500
- #define HOTSPOT_BUILD_COMPILER "MS VC++ 9.0 (VS2008)"
- #elif _MSC_VER == 1600
+ #if _MSC_VER == 1600
#define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"
#elif _MSC_VER == 1700
#define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"
+ #elif _MSC_VER == 1800
+ #define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"
#else
#define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
#endif
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp Tue Jun 10 20:24:48 2014 -0700
@@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
+#include "classfile/classLoaderStats.hpp"
#include "gc_implementation/shared/vmGCOperations.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/os.hpp"
@@ -58,6 +59,7 @@
#endif // INCLUDE_SERVICES
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(full_export, true, false));
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<RotateGCLogDCmd>(full_export, true, false));
+ DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassLoaderStatsDCmd>(full_export, true, false));
// Enhanced JMX Agent Support
// These commands won't be exported via the DiagnosticCommandMBean until an
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethTest.jcod Tue Jun 10 20:24:48 2014 -0700
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This test has a EnclosingMethod attribute with an illegal
+ * attribute_length field value of 6. This should cause a
+ * java.lang.ClassFormatError exception to be thrown.
+ */
+
+class EnclMethTest {
+ 0xCAFEBABE;
+ 0; // minor version
+ 52; // version
+ [22] { // Constant Pool
+ ; // first element is empty
+ Field #3 #14; // #1 at 0x0A
+ Method #4 #15; // #2 at 0x0F
+ class #16; // #3 at 0x14
+ class #19; // #4 at 0x17
+ Utf8 "this$0"; // #5 at 0x1A
+ Utf8 "La;"; // #6 at 0x23
+ Utf8 "Synthetic"; // #7 at 0x29
+ Utf8 "<init>"; // #8 at 0x35
+ Utf8 "(Ljava/lang/Object;)V"; // #9 at 0x3E
+ Utf8 "Code"; // #10 at 0x56
+ Utf8 "LineNumberTable"; // #11 at 0x5D
+ Utf8 "SourceFile"; // #12 at 0x6F
+ Utf8 "a.java"; // #13 at 0x7C
+ NameAndType #5 #6; // #14 at 0x85
+ NameAndType #8 #20; // #15 at 0x8A
+ Utf8 "EnclMethTest"; // #16 at 0x8F
+ Utf8 "Loc"; // #17 at 0x9E
+ Utf8 "InnerClasses"; // #18 at 0xA4
+ Utf8 "java/lang/Object"; // #19 at 0xB3
+ Utf8 "()V"; // #20 at 0xC6
+ Utf8 "EnclosingMethod"; // #21 at 0xCC
+ } // Constant Pool
+
+ 0x0000; // access
+ #3;// this_cpx
+ #4;// super_cpx
+
+ [0] { // Interfaces
+ } // Interfaces
+
+ [1] { // fields
+ { // Member at 0xE8
+ 0x0000; // access
+ #5; // name_cpx
+ #6; // sig_cpx
+ [1] { // Attributes
+ Attr(#7, 0) { // Synthetic at 0xF0
+ } // end Synthetic
+ } // Attributes
+ } // Member
+ } // fields
+
+ [1] { // methods
+ { // Member at 0xF8
+ 0x0001; // access
+ #8; // name_cpx
+ #20; // sig_cpx
+ [1] { // Attributes
+ Attr(#10, 17) { // Code at 0x0100
+ 2; // max_stack
+ 2; // max_locals
+ Bytes[5]{
+ 0x2AB70002B1;
+ };
+ [0] { // Traps
+ } // end Traps
+ [0] { // Attributes
+ } // Attributes
+ } // end Code
+ } // Attributes
+ } // Member
+ } // methods
+
+ [3] { // Attributes
+ Attr(#12, 2) { // SourceFile at 0x0119
+ #13;
+ } // end SourceFile
+ ;
+ Attr(#18, 10) { // InnerClasses at 0x0121
+ [1] { // InnerClasses
+ #3 #0 #17 0; // at 0x0131
+ }
+ } // end InnerClasses
+ ;
+ Attr(#21, 6) { // EnclosingMethod at 0x0131
+ // invalid length of EnclosingMethod attr: 6 (should be 4) !!
+ 0x0004000F;
+ } // end EnclosingMethod
+ } // Attributes
+} // end class EnclMethTest
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java Tue Jun 10 20:24:48 2014 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8044738
+ * @library /testlibrary
+ * @summary Check attribute_length of EnclosingMethod attribute
+ * @run main EnclMethodAttr
+ */
+
+import java.io.File;
+import com.oracle.java.testlibrary.*;
+
+public class EnclMethodAttr {
+
+ static final String testsrc = System.getProperty("test.src");
+
+ public static void main(String args[]) throws Throwable {
+ System.out.println("Regression test for bug 8044738");
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-jar", testsrc + File.separator + "enclMethodAttr.jar");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("java.lang.ClassFormatError: Wrong EnclosingMethod");
+ }
+}
+
Binary file hotspot/test/runtime/EnclosingMethodAttr/enclMethodAttr.jar has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/serviceability/dcmd/ClassLoaderStatsTest.java Tue Jun 10 20:24:48 2014 -0700
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ *
+ * @build ClassLoaderStatsTest DcmdUtil
+ * @run main ClassLoaderStatsTest
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ClassLoaderStatsTest {
+
+ // ClassLoader Parent CLD* Classes ChunkSz BlockSz Type
+ // 0x00000007c0215928 0x0000000000000000 0x0000000000000000 0 0 0 org.eclipse.osgi.baseadaptor.BaseAdaptor$1
+ // 0x00000007c0009868 0x0000000000000000 0x00007fc52aebcc80 1 6144 3768 sun.reflect.DelegatingClassLoader
+ // 0x00000007c0009868 0x0000000000000000 0x00007fc52b8916d0 1 6144 3688 sun.reflect.DelegatingClassLoader
+ // 0x00000007c0009868 0x00000007c0038ba8 0x00007fc52afb8760 1 6144 3688 sun.reflect.DelegatingClassLoader
+ // 0x00000007c0009868 0x0000000000000000 0x00007fc52afbb1a0 1 6144 3688 sun.reflect.DelegatingClassLoader
+ // 0x0000000000000000 0x0000000000000000 0x00007fc523416070 5019 30060544 29956216 <boot classloader>
+ // 455 1210368 672848 + unsafe anonymous classes
+ // 0x00000007c016b5c8 0x00000007c0038ba8 0x00007fc52a995000 5 8192 5864 org.netbeans.StandardModule$OneModuleClassLoader
+ // 0x00000007c0009868 0x00000007c016b5c8 0x00007fc52ac13640 1 6144 3896 sun.reflect.DelegatingClassLoader
+ // ...
+
+ static Pattern clLine = Pattern.compile("0x\\p{XDigit}*\\s*0x\\p{XDigit}*\\s*0x\\p{XDigit}*\\s*(\\d*)\\s*(\\d*)\\s*(\\d*)\\s*(.*)");
+ static Pattern anonLine = Pattern.compile("\\s*(\\d*)\\s*(\\d*)\\s*(\\d*)\\s*.*");
+
+ public static DummyClassLoader dummyloader;
+
+ public static void main(String arg[]) throws Exception {
+
+ // create a classloader and load our special class
+ dummyloader = new DummyClassLoader();
+ Class<?> c = Class.forName("TestClass", true, dummyloader);
+ if (c.getClassLoader() != dummyloader) {
+ throw new RuntimeException("TestClass defined by wrong classloader: " + c.getClassLoader());
+ }
+
+ String result = DcmdUtil.executeDcmd("VM.classloader_stats");
+ BufferedReader r = new BufferedReader(new StringReader(result));
+ String line;
+ while((line = r.readLine()) != null) {
+ Matcher m = clLine.matcher(line);
+ if (m.matches()) {
+ // verify that DummyClassLoader has loaded 1 class and 1 anonymous class
+ if (m.group(4).equals("ClassLoaderStatsTest$DummyClassLoader")) {
+ System.out.println("line: " + line);
+ if (!m.group(1).equals("1")) {
+ throw new Exception("Should have loaded 1 class: " + line);
+ }
+ checkPositiveInt(m.group(2));
+ checkPositiveInt(m.group(3));
+
+ String next = r.readLine();
+ System.out.println("next: " + next);
+ Matcher m1 = anonLine.matcher(next);
+ m1.matches();
+ if (!m1.group(1).equals("1")) {
+ throw new Exception("Should have loaded 1 anonymous class, but found : " + m1.group(1));
+ }
+ checkPositiveInt(m1.group(2));
+ checkPositiveInt(m1.group(3));
+ }
+ }
+ }
+ }
+
+ private static void checkPositiveInt(String s) throws Exception {
+ if (Integer.parseInt(s) <= 0) {
+ throw new Exception("Value should have been > 0: " + s);
+ }
+ }
+
+ public static class DummyClassLoader extends ClassLoader {
+
+ public static final String CLASS_NAME = "TestClass";
+
+ static ByteBuffer readClassFile(String name)
+ {
+ File f = new File(System.getProperty("test.classes", "."),
+ name);
+ try (FileInputStream fin = new FileInputStream(f);
+ FileChannel fc = fin.getChannel())
+ {
+ return fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
+ } catch (IOException e) {
+ throw new RuntimeException("Can't open file: " + name, e);
+ }
+ }
+
+ protected Class<?> loadClass(String name, boolean resolve)
+ throws ClassNotFoundException
+ {
+ Class<?> c;
+ if (!"TestClass".equals(name)) {
+ c = super.loadClass(name, resolve);
+ } else {
+ // should not delegate to the system class loader
+ c = findClass(name);
+ if (resolve) {
+ resolveClass(c);
+ }
+ }
+ return c;
+ }
+
+ protected Class<?> findClass(String name)
+ throws ClassNotFoundException
+ {
+ if (!"TestClass".equals(name)) {
+ throw new ClassNotFoundException("Unexpected class: " + name);
+ }
+ return defineClass(name, readClassFile(name + ".class"), null);
+ }
+ } /* DummyClassLoader */
+
+}
+
+class TestClass {
+ static {
+ // force creation of anonymous class (for the lambdaform)
+ Runnable r = () -> System.out.println("Hello");
+ r.run();
+ }
+}
--- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Mon Jun 09 15:42:31 2014 -0700
+++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java Tue Jun 10 20:24:48 2014 -0700
@@ -26,6 +26,7 @@
* @bug 8028623
* @summary Test hashing of extended characters in Serviceability Agent.
* @library /testlibrary
+ * @ignore 8044416
* @build com.oracle.java.testlibrary.*
* @compile -encoding utf8 Test8028623.java
* @run main Test8028623