From 13b3a50623fde05825fa9e7991de08d43c22f095 Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Fri, 23 May 2014 11:04:32 -0400 Subject: [PATCH 001/236] 8043805: Allow using a system-installed libjpeg Reviewed-by: andrew, anthony, prr --- common/autoconf/generated-configure.sh | 77 ++++++++++++++++++++------ common/autoconf/libraries.m4 | 35 ++++++++++-- 2 files changed, 91 insertions(+), 21 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index a146145de81..676ed1e65a9 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -1081,6 +1081,7 @@ enable_freetype_bundling with_alsa with_alsa_include with_alsa_lib +with_libjpeg with_giflib with_lcms with_libpng @@ -1938,6 +1939,8 @@ Optional Packages: headers under PATH/include) --with-alsa-include specify directory for the alsa include files --with-alsa-lib specify directory for the alsa library + --with-libjpeg use libjpeg from build system or OpenJDK source + (system, bundled) [bundled] --with-giflib use giflib from build system or OpenJDK source (system, bundled) [bundled] --with-lcms use lcms2 from build system or OpenJDK source @@ -4253,7 +4256,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1398861894 +DATE_WHEN_GENERATED=1400601642 ############################################################################### # @@ -47176,10 +47179,43 @@ done # Check for the jpeg library # - USE_EXTERNAL_LIBJPEG=true - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ljpeg" >&5 -$as_echo_n "checking for main in -ljpeg... " >&6; } -if ${ac_cv_lib_jpeg_main+:} false; then : + +# Check whether --with-libjpeg was given. +if test "${with_libjpeg+set}" = set; then : + withval=$with_libjpeg; +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which libjpeg to use" >&5 +$as_echo_n "checking for which libjpeg to use... " >&6; } + + # default is bundled + DEFAULT_LIBJPEG=bundled + + # + # if user didn't specify, use DEFAULT_LIBJPEG + # + if test "x${with_libjpeg}" = "x"; then + with_libjpeg=${DEFAULT_LIBJPEG} + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_libjpeg}" >&5 +$as_echo "${with_libjpeg}" >&6; } + + if test "x${with_libjpeg}" = "xbundled"; then + USE_EXTERNAL_LIBJPEG=false + elif test "x${with_libjpeg}" = "xsystem"; then + ac_fn_cxx_check_header_mongrel "$LINENO" "jpeglib.h" "ac_cv_header_jpeglib_h" "$ac_includes_default" +if test "x$ac_cv_header_jpeglib_h" = xyes; then : + +else + as_fn_error $? "--with-libjpeg=system specified, but jpeglib.h not found!" "$LINENO" 5 +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jpeg_CreateDecompress in -ljpeg" >&5 +$as_echo_n "checking for jpeg_CreateDecompress in -ljpeg... " >&6; } +if ${ac_cv_lib_jpeg_jpeg_CreateDecompress+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -47187,27 +47223,33 @@ LIBS="-ljpeg $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char jpeg_CreateDecompress (); int main () { -return main (); +return jpeg_CreateDecompress (); ; return 0; } _ACEOF if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_jpeg_main=yes + ac_cv_lib_jpeg_jpeg_CreateDecompress=yes else - ac_cv_lib_jpeg_main=no + ac_cv_lib_jpeg_jpeg_CreateDecompress=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_main" >&5 -$as_echo "$ac_cv_lib_jpeg_main" >&6; } -if test "x$ac_cv_lib_jpeg_main" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jpeg_jpeg_CreateDecompress" >&5 +$as_echo "$ac_cv_lib_jpeg_jpeg_CreateDecompress" >&6; } +if test "x$ac_cv_lib_jpeg_jpeg_CreateDecompress" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBJPEG 1 _ACEOF @@ -47215,13 +47257,16 @@ _ACEOF LIBS="-ljpeg $LIBS" else - USE_EXTERNAL_LIBJPEG=false - { $as_echo "$as_me:${as_lineno-$LINENO}: Will use jpeg decoder bundled with the OpenJDK source" >&5 -$as_echo "$as_me: Will use jpeg decoder bundled with the OpenJDK source" >&6;} - + as_fn_error $? "--with-libjpeg=system specified, but no libjpeg found" "$LINENO" 5 fi + USE_EXTERNAL_LIBJPEG=true + else + as_fn_error $? "Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled'" "$LINENO" 5 + fi + + ############################################################################### # diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 6ee3221ad96..5f9546f0770 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -620,11 +620,36 @@ AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS], # Check for the jpeg library # - USE_EXTERNAL_LIBJPEG=true - AC_CHECK_LIB(jpeg, main, [], - [ USE_EXTERNAL_LIBJPEG=false - AC_MSG_NOTICE([Will use jpeg decoder bundled with the OpenJDK source]) - ]) + AC_ARG_WITH(libjpeg, [AS_HELP_STRING([--with-libjpeg], + [use libjpeg from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])]) + + AC_MSG_CHECKING([for which libjpeg to use]) + + # default is bundled + DEFAULT_LIBJPEG=bundled + + # + # if user didn't specify, use DEFAULT_LIBJPEG + # + if test "x${with_libjpeg}" = "x"; then + with_libjpeg=${DEFAULT_LIBJPEG} + fi + + AC_MSG_RESULT(${with_libjpeg}) + + if test "x${with_libjpeg}" = "xbundled"; then + USE_EXTERNAL_LIBJPEG=false + elif test "x${with_libjpeg}" = "xsystem"; then + AC_CHECK_HEADER(jpeglib.h, [], + [ AC_MSG_ERROR([--with-libjpeg=system specified, but jpeglib.h not found!])]) + AC_CHECK_LIB(jpeg, jpeg_CreateDecompress, [], + [ AC_MSG_ERROR([--with-libjpeg=system specified, but no libjpeg found])]) + + USE_EXTERNAL_LIBJPEG=true + else + AC_MSG_ERROR([Invalid use of --with-libjpeg: ${with_libjpeg}, use 'system' or 'bundled']) + fi + AC_SUBST(USE_EXTERNAL_LIBJPEG) ############################################################################### From e563a70ab70083a5a7bbc2e6f58cf128d73c9fb9 Mon Sep 17 00:00:00 2001 From: Mikael Auno Date: Mon, 2 Jun 2014 17:21:15 +0200 Subject: [PATCH 002/236] 8044540: serviceability/sa/jmap-hashcode/Test8028623.java should be quarantined Reviewed-by: sla --- hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java index 6f4b2fd689a..815b3f606ca 100644 --- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java +++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java @@ -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 From 8dc26f1a171284dbb206f44ccfa2048f09502636 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Wed, 4 Jun 2014 11:05:30 +0200 Subject: [PATCH 003/236] 8044107: Add Diagnostic Command to list all ClassLoaders Reviewed-by: mgerdin, stefank --- .../share/vm/classfile/classLoaderData.cpp | 6 + .../share/vm/classfile/classLoaderData.hpp | 1 + .../share/vm/classfile/classLoaderStats.cpp | 167 ++++++++++++++++++ .../share/vm/classfile/classLoaderStats.hpp | 152 ++++++++++++++++ hotspot/src/share/vm/memory/metaspace.cpp | 11 ++ hotspot/src/share/vm/memory/metaspace.hpp | 3 + .../src/share/vm/runtime/vm_operations.hpp | 1 + .../share/vm/services/diagnosticCommand.cpp | 2 + .../dcmd/ClassLoaderStatsTest.java | 155 ++++++++++++++++ 9 files changed, 498 insertions(+) create mode 100644 hotspot/src/share/vm/classfile/classLoaderStats.cpp create mode 100644 hotspot/src/share/vm/classfile/classLoaderStats.hpp create mode 100644 hotspot/test/serviceability/dcmd/ClassLoaderStatsTest.java diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index bc88beb4343..efbde89ee30 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -624,6 +624,12 @@ void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, KlassClosure* kl } } +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); diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 5be3caa6515..964e4289ffe 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -77,6 +77,7 @@ class ClassLoaderDataGraph : public AllStatic { 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*)); diff --git a/hotspot/src/share/vm/classfile/classLoaderStats.cpp b/hotspot/src/share/vm/classfile/classLoaderStats.cpp new file mode 100644 index 00000000000..4eb98ed321c --- /dev/null +++ b/hotspot/src/share/vm/classfile/classLoaderStats.cpp @@ -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(""); + } + _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); +} diff --git a/hotspot/src/share/vm/classfile/classLoaderStats.hpp b/hotspot/src/share/vm/classfile/classLoaderStats.hpp new file mode 100644 index 00000000000..89e0e473b3b --- /dev/null +++ b/hotspot/src/share/vm/classfile/classLoaderStats.hpp @@ -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 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 diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index cd5fceff2d0..4dce7a9c3cc 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -697,6 +697,7 @@ class SpaceManager : public CHeapObj { 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(); } @@ -3349,6 +3350,16 @@ size_t Metaspace::capacity_bytes_slow(MetadataType mdtype) const { 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"); diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index 22e21b80d3d..453fef5deee 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -225,6 +225,9 @@ class Metaspace : public CHeapObj { 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); diff --git a/hotspot/src/share/vm/runtime/vm_operations.hpp b/hotspot/src/share/vm/runtime/vm_operations.hpp index 8f2f0ba06f7..4e32a3adfa2 100644 --- a/hotspot/src/share/vm/runtime/vm_operations.hpp +++ b/hotspot/src/share/vm/runtime/vm_operations.hpp @@ -98,6 +98,7 @@ template(LinuxDllLoad) \ template(RotateGCLog) \ template(WhiteBoxOperation) \ + template(ClassLoaderStatsOperation) \ class VM_Operation: public CHeapObj { public: diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp index ca031f87963..892e2ce57b6 100644 --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp @@ -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 @@ void DCmdRegistrant::register_dcmds(){ #endif // INCLUDE_SERVICES DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); + DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); // Enhanced JMX Agent Support // These commands won't be exported via the DiagnosticCommandMBean until an diff --git a/hotspot/test/serviceability/dcmd/ClassLoaderStatsTest.java b/hotspot/test/serviceability/dcmd/ClassLoaderStatsTest.java new file mode 100644 index 00000000000..0b229a8a9a1 --- /dev/null +++ b/hotspot/test/serviceability/dcmd/ClassLoaderStatsTest.java @@ -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 + // 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(); + } +} From 9672a26d514bc59ea6c109e6b66f96a1368e3554 Mon Sep 17 00:00:00 2001 From: Bengt Rutisson Date: Thu, 19 Jun 2014 13:31:14 +0200 Subject: [PATCH 004/236] 8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps Reviewed-by: jwilhelm, ehelin, tschatzl --- .../concurrentMarkSweepGeneration.cpp | 65 +++++++------ .../concurrentMarkSweep/vmCMSOperations.cpp | 4 +- .../gc_implementation/g1/concurrentMark.cpp | 22 ++++- .../gc_implementation/g1/concurrentMark.hpp | 4 + .../g1/concurrentMarkThread.cpp | 27 ++---- .../gc_implementation/g1/g1CollectedHeap.cpp | 11 ++- .../vm/gc_implementation/g1/g1MarkSweep.cpp | 11 ++- .../gc_implementation/g1/vm_operations_g1.cpp | 2 +- .../parNew/parNewGeneration.cpp | 6 +- .../parallelScavenge/pcTasks.cpp | 14 +-- .../parallelScavenge/psMarkSweep.cpp | 12 +-- .../parallelScavenge/psParallelCompact.cpp | 34 +++---- .../parallelScavenge/psParallelCompact.hpp | 4 + .../parallelScavenge/psScavenge.cpp | 14 +-- .../vm/gc_implementation/shared/gcId.cpp | 42 +++++++++ .../vm/gc_implementation/shared/gcId.hpp | 51 +++++++++++ .../vm/gc_implementation/shared/gcTrace.cpp | 20 ++-- .../vm/gc_implementation/shared/gcTrace.hpp | 16 ++-- .../gc_implementation/shared/gcTraceSend.cpp | 38 ++++---- .../gc_implementation/shared/gcTraceTime.cpp | 6 +- .../gc_implementation/shared/gcTraceTime.hpp | 3 +- .../shared/objectCountEventSender.cpp | 3 +- .../share/vm/gc_interface/collectedHeap.cpp | 8 +- .../src/share/vm/memory/defNewGeneration.cpp | 4 +- .../src/share/vm/memory/genCollectedHeap.cpp | 9 +- hotspot/src/share/vm/memory/genMarkSweep.cpp | 12 +-- .../share/vm/memory/referenceProcessor.cpp | 24 ++--- .../share/vm/memory/referenceProcessor.hpp | 7 +- hotspot/src/share/vm/runtime/globals.hpp | 3 + hotspot/src/share/vm/utilities/ostream.cpp | 9 ++ hotspot/src/share/vm/utilities/ostream.hpp | 2 + hotspot/test/gc/logging/TestGCId.java | 91 +++++++++++++++++++ 32 files changed, 404 insertions(+), 174 deletions(-) create mode 100644 hotspot/src/share/vm/gc_implementation/shared/gcId.cpp create mode 100644 hotspot/src/share/vm/gc_implementation/shared/gcId.hpp create mode 100644 hotspot/test/gc/logging/TestGCId.java diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 8cd65e36dca..8e0706b4a10 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -2024,7 +2024,7 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) { SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer(); gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start()); - GCTraceTime t("CMS:MSC ", PrintGCDetails && Verbose, true, NULL); + GCTraceTime t("CMS:MSC ", PrintGCDetails && Verbose, true, NULL, gc_tracer->gc_id()); if (PrintGC && Verbose && !(GCCause::is_user_requested_gc(gch->gc_cause()))) { gclog_or_tty->print_cr("Compact ConcurrentMarkSweepGeneration after %d " "collections passed to foreground collector", _full_gcs_since_conc_gc); @@ -2534,8 +2534,10 @@ void CMSCollector::collect_in_foreground(bool clear_all_soft_refs, GCCause::Caus assert(ConcurrentMarkSweepThread::vm_thread_has_cms_token(), "VM thread should have CMS token"); + // The gc id is created in register_foreground_gc_start if this collection is synchronous + const GCId gc_id = _collectorState == InitialMarking ? GCId::peek() : _gc_tracer_cm->gc_id(); NOT_PRODUCT(GCTraceTime t("CMS:MS (foreground) ", PrintGCDetails && Verbose, - true, NULL);) + true, NULL, gc_id);) if (UseAdaptiveSizePolicy) { size_policy()->ms_collection_begin(); } @@ -3538,6 +3540,7 @@ class CMSPhaseAccounting: public StackObj { public: CMSPhaseAccounting(CMSCollector *collector, const char *phase, + const GCId gc_id, bool print_cr = true); ~CMSPhaseAccounting(); @@ -3546,6 +3549,7 @@ class CMSPhaseAccounting: public StackObj { const char *_phase; elapsedTimer _wallclock; bool _print_cr; + const GCId _gc_id; public: // Not MT-safe; so do not pass around these StackObj's @@ -3561,15 +3565,15 @@ class CMSPhaseAccounting: public StackObj { CMSPhaseAccounting::CMSPhaseAccounting(CMSCollector *collector, const char *phase, + const GCId gc_id, bool print_cr) : - _collector(collector), _phase(phase), _print_cr(print_cr) { + _collector(collector), _phase(phase), _print_cr(print_cr), _gc_id(gc_id) { if (PrintCMSStatistics != 0) { _collector->resetYields(); } if (PrintGCDetails) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(_gc_id); gclog_or_tty->print_cr("[%s-concurrent-%s-start]", _collector->cmsGen()->short_name(), _phase); } @@ -3583,8 +3587,7 @@ CMSPhaseAccounting::~CMSPhaseAccounting() { _collector->stopTimer(); _wallclock.stop(); if (PrintGCDetails) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(_gc_id); gclog_or_tty->print("[%s-concurrent-%s: %3.3f/%3.3f secs]", _collector->cmsGen()->short_name(), _phase, _collector->timerValue(), _wallclock.seconds()); @@ -3682,7 +3685,7 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { setup_cms_unloading_and_verification_state(); NOT_PRODUCT(GCTraceTime t("\ncheckpointRootsInitialWork", - PrintGCDetails && Verbose, true, _gc_timer_cm);) + PrintGCDetails && Verbose, true, _gc_timer_cm, _gc_tracer_cm->gc_id());) if (UseAdaptiveSizePolicy) { size_policy()->checkpoint_roots_initial_begin(); } @@ -3799,7 +3802,7 @@ bool CMSCollector::markFromRoots(bool asynch) { CMSTokenSyncWithLocks ts(true, bitMapLock()); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - CMSPhaseAccounting pa(this, "mark", !PrintGCDetails); + CMSPhaseAccounting pa(this, "mark", _gc_tracer_cm->gc_id(), !PrintGCDetails); res = markFromRootsWork(asynch); if (res) { _collectorState = Precleaning; @@ -4522,7 +4525,7 @@ void CMSCollector::preclean() { _start_sampling = false; } TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - CMSPhaseAccounting pa(this, "preclean", !PrintGCDetails); + CMSPhaseAccounting pa(this, "preclean", _gc_tracer_cm->gc_id(), !PrintGCDetails); preclean_work(CMSPrecleanRefLists1, CMSPrecleanSurvivors1); } CMSTokenSync x(true); // is cms thread @@ -4551,7 +4554,7 @@ void CMSCollector::abortable_preclean() { // we will never do an actual abortable preclean cycle. if (get_eden_used() > CMSScheduleRemarkEdenSizeThreshold) { TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - CMSPhaseAccounting pa(this, "abortable-preclean", !PrintGCDetails); + CMSPhaseAccounting pa(this, "abortable-preclean", _gc_tracer_cm->gc_id(), !PrintGCDetails); // We need more smarts in the abortable preclean // loop below to deal with cases where allocation // in young gen is very very slow, and our precleaning @@ -4696,7 +4699,7 @@ size_t CMSCollector::preclean_work(bool clean_refs, bool clean_survivor) { GCTimer *gc_timer = NULL; // Currently not tracing concurrent phases rp->preclean_discovered_references( rp->is_alive_non_header(), &keep_alive, &complete_trace, &yield_cl, - gc_timer); + gc_timer, _gc_tracer_cm->gc_id()); } if (clean_survivor) { // preclean the active survivor space(s) @@ -5039,7 +5042,7 @@ void CMSCollector::checkpointRootsFinal(bool asynch, // expect it to be false and set to true FlagSetting fl(gch->_is_gc_active, false); NOT_PRODUCT(GCTraceTime t("Scavenge-Before-Remark", - PrintGCDetails && Verbose, true, _gc_timer_cm);) + PrintGCDetails && Verbose, true, _gc_timer_cm, _gc_tracer_cm->gc_id());) int level = _cmsGen->level() - 1; if (level >= 0) { gch->do_collection(true, // full (i.e. force, see below) @@ -5068,7 +5071,7 @@ void CMSCollector::checkpointRootsFinal(bool asynch, void CMSCollector::checkpointRootsFinalWork(bool asynch, bool clear_all_soft_refs, bool init_mark_was_synchronous) { - NOT_PRODUCT(GCTraceTime tr("checkpointRootsFinalWork", PrintGCDetails, false, _gc_timer_cm);) + NOT_PRODUCT(GCTraceTime tr("checkpointRootsFinalWork", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());) assert(haveFreelistLocks(), "must have free list locks"); assert_lock_strong(bitMapLock()); @@ -5123,11 +5126,11 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch, // the most recent young generation GC, minus those cleaned up by the // concurrent precleaning. if (CMSParallelRemarkEnabled && CollectedHeap::use_parallel_gc_threads()) { - GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); do_remark_parallel(); } else { GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false, - _gc_timer_cm); + _gc_timer_cm, _gc_tracer_cm->gc_id()); do_remark_non_parallel(); } } @@ -5140,7 +5143,7 @@ void CMSCollector::checkpointRootsFinalWork(bool asynch, verify_overflow_empty(); { - NOT_PRODUCT(GCTraceTime ts("refProcessingWork", PrintGCDetails, false, _gc_timer_cm);) + NOT_PRODUCT(GCTraceTime ts("refProcessingWork", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());) refProcessingWork(asynch, clear_all_soft_refs); } verify_work_stacks_empty(); @@ -5921,7 +5924,7 @@ void CMSCollector::do_remark_non_parallel() { NULL, // space is set further below &_markBitMap, &_markStack, &mrias_cl); { - GCTraceTime t("grey object rescan", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("grey object rescan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); // Iterate over the dirty cards, setting the corresponding bits in the // mod union table. { @@ -5958,7 +5961,7 @@ void CMSCollector::do_remark_non_parallel() { Universe::verify(); } { - GCTraceTime t("root rescan", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("root rescan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); verify_work_stacks_empty(); @@ -5978,7 +5981,7 @@ void CMSCollector::do_remark_non_parallel() { } { - GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); verify_work_stacks_empty(); @@ -5997,7 +6000,7 @@ void CMSCollector::do_remark_non_parallel() { } { - GCTraceTime t("dirty klass scan", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("dirty klass scan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); verify_work_stacks_empty(); @@ -6199,7 +6202,7 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { _span, &_markBitMap, &_markStack, &cmsKeepAliveClosure, false /* !preclean */); { - GCTraceTime t("weak refs processing", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("weak refs processing", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); ReferenceProcessorStats stats; if (rp->processing_is_mt()) { @@ -6224,13 +6227,15 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { &cmsKeepAliveClosure, &cmsDrainMarkingStackClosure, &task_executor, - _gc_timer_cm); + _gc_timer_cm, + _gc_tracer_cm->gc_id()); } else { stats = rp->process_discovered_references(&_is_alive_closure, &cmsKeepAliveClosure, &cmsDrainMarkingStackClosure, NULL, - _gc_timer_cm); + _gc_timer_cm, + _gc_tracer_cm->gc_id()); } _gc_tracer_cm->report_gc_reference_stats(stats); @@ -6241,7 +6246,7 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { if (should_unload_classes()) { { - GCTraceTime t("class unloading", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("class unloading", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); // Unload classes and purge the SystemDictionary. bool purged_class = SystemDictionary::do_unloading(&_is_alive_closure); @@ -6254,7 +6259,7 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { } { - GCTraceTime t("scrub symbol table", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("scrub symbol table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); // Clean up unreferenced symbols in symbol table. SymbolTable::unlink(); } @@ -6263,7 +6268,7 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) { // CMS doesn't use the StringTable as hard roots when class unloading is turned off. // Need to check if we really scanned the StringTable. if ((roots_scanning_options() & SharedHeap::SO_Strings) == 0) { - GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm); + GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); // Delete entries for dead interned strings. StringTable::unlink(&_is_alive_closure); } @@ -6330,7 +6335,7 @@ void CMSCollector::sweep(bool asynch) { _intra_sweep_timer.start(); if (asynch) { TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - CMSPhaseAccounting pa(this, "sweep", !PrintGCDetails); + CMSPhaseAccounting pa(this, "sweep", _gc_tracer_cm->gc_id(), !PrintGCDetails); // First sweep the old gen { CMSTokenSyncWithLocks ts(true, _cmsGen->freelistLock(), @@ -6551,7 +6556,7 @@ void CMSCollector::reset(bool asynch) { // Clear the mark bitmap (no grey objects to start with) // for the next cycle. TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - CMSPhaseAccounting cmspa(this, "reset", !PrintGCDetails); + CMSPhaseAccounting cmspa(this, "reset", _gc_tracer_cm->gc_id(), !PrintGCDetails); HeapWord* curAddr = _markBitMap.startWord(); while (curAddr < _markBitMap.endWord()) { @@ -6617,7 +6622,7 @@ void CMSCollector::reset(bool asynch) { void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) { gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - GCTraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL); + GCTraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer_cm->gc_id()); TraceCollectorStats tcs(counters()); switch (op) { diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp index ca1a1124643..1b23ecbb554 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp @@ -56,7 +56,7 @@ void VM_CMS_Operation::release_and_notify_pending_list_lock() { void VM_CMS_Operation::verify_before_gc() { if (VerifyBeforeGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { - GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm); + GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm, _collector->_gc_tracer_cm->gc_id()); HandleMark hm; FreelistLocker x(_collector); MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); @@ -68,7 +68,7 @@ void VM_CMS_Operation::verify_before_gc() { void VM_CMS_Operation::verify_after_gc() { if (VerifyAfterGC && GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { - GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm); + GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm, _collector->_gc_tracer_cm->gc_id()); HandleMark hm; FreelistLocker x(_collector); MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 9d80a5c7212..083ae40ca77 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -511,6 +511,7 @@ ConcurrentMark::ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs) : _has_overflown(false), _concurrent(false), _has_aborted(false), + _aborted_gc_id(GCId::undefined()), _restart_for_overflow(false), _concurrent_marking_in_progress(false), @@ -1020,8 +1021,7 @@ void ConcurrentMark::enter_first_sync_barrier(uint worker_id) { force_overflow()->update(); if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-mark-reset-for-overflow]"); } } @@ -2469,7 +2469,7 @@ void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { if (G1Log::finer()) { gclog_or_tty->put(' '); } - GCTraceTime t("GC ref-proc", G1Log::finer(), false, g1h->gc_timer_cm()); + GCTraceTime t("GC ref-proc", G1Log::finer(), false, g1h->gc_timer_cm(), concurrent_gc_id()); ReferenceProcessor* rp = g1h->ref_processor_cm(); @@ -2526,7 +2526,8 @@ void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) { &g1_keep_alive, &g1_drain_mark_stack, executor, - g1h->gc_timer_cm()); + g1h->gc_timer_cm(), + concurrent_gc_id()); g1h->gc_tracer_cm()->report_gc_reference_stats(stats); // The do_oop work routines of the keep_alive and drain_marking_stack @@ -3261,6 +3262,12 @@ void ConcurrentMark::abort() { } _first_overflow_barrier_sync.abort(); _second_overflow_barrier_sync.abort(); + const GCId& gc_id = _g1h->gc_tracer_cm()->gc_id(); + if (!gc_id.is_undefined()) { + // We can do multiple full GCs before ConcurrentMarkThread::run() gets a chance + // to detect that it was aborted. Only keep track of the first GC id that we aborted. + _aborted_gc_id = gc_id; + } _has_aborted = true; SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); @@ -3275,6 +3282,13 @@ void ConcurrentMark::abort() { _g1h->register_concurrent_cycle_end(); } +const GCId& ConcurrentMark::concurrent_gc_id() { + if (has_aborted()) { + return _aborted_gc_id; + } + return _g1h->gc_tracer_cm()->gc_id(); +} + static void print_ms_time_info(const char* prefix, const char* name, NumberSeq& ns) { gclog_or_tty->print_cr("%s%5d %12s: total time = %8.2f s (avg = %8.2f ms).", diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp index 9d049a2a255..1e4ad366c75 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_HPP #include "gc_implementation/g1/heapRegionSet.hpp" +#include "gc_implementation/shared/gcId.hpp" #include "utilities/taskqueue.hpp" class G1CollectedHeap; @@ -444,6 +445,7 @@ protected: volatile bool _concurrent; // Set at the end of a Full GC so that marking aborts volatile bool _has_aborted; + GCId _aborted_gc_id; // Used when remark aborts due to an overflow to indicate that // another concurrent marking phase should start @@ -824,6 +826,8 @@ public: bool has_aborted() { return _has_aborted; } + const GCId& concurrent_gc_id(); + // This prints the global/local fingers. It is used for debugging. NOT_PRODUCT(void print_finger();) diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp index ad11c016e66..f8392143db8 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp @@ -1,4 +1,4 @@ -/* + /* * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,6 +29,7 @@ #include "gc_implementation/g1/g1Log.hpp" #include "gc_implementation/g1/g1MMUTracker.hpp" #include "gc_implementation/g1/vm_operations_g1.hpp" +#include "gc_implementation/shared/gcTrace.hpp" #include "memory/resourceArea.hpp" #include "runtime/vmThread.hpp" @@ -111,8 +112,7 @@ void ConcurrentMarkThread::run() { double scan_start = os::elapsedTime(); if (!cm()->has_aborted()) { if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-root-region-scan-start]"); } @@ -120,8 +120,7 @@ void ConcurrentMarkThread::run() { double scan_end = os::elapsedTime(); if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf secs]", scan_end - scan_start); } @@ -129,8 +128,7 @@ void ConcurrentMarkThread::run() { double mark_start_sec = os::elapsedTime(); if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-mark-start]"); } @@ -153,8 +151,7 @@ void ConcurrentMarkThread::run() { } if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf secs]", mark_end_sec - mark_start_sec); } @@ -169,8 +166,7 @@ void ConcurrentMarkThread::run() { "in remark (restart #%d).", iter); } if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-mark-restart-for-overflow]"); } } @@ -213,8 +209,7 @@ void ConcurrentMarkThread::run() { double cleanup_start_sec = os::elapsedTime(); if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-cleanup-start]"); } @@ -234,8 +229,7 @@ void ConcurrentMarkThread::run() { double cleanup_end_sec = os::elapsedTime(); if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf secs]", cleanup_end_sec - cleanup_start_sec); } @@ -276,8 +270,7 @@ void ConcurrentMarkThread::run() { if (cm()->has_aborted()) { if (G1Log::fine()) { - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); gclog_or_tty->print_cr("[GC concurrent-mark-abort]"); } } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 2f259ea1beb..23c72eac957 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -1298,7 +1298,7 @@ bool G1CollectedHeap::do_collection(bool explicit_gc, TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); { - GCTraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, NULL); + GCTraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, NULL, gc_tracer->gc_id()); TraceCollectorStats tcs(g1mm()->full_collection_counters()); TraceMemoryManagerStats tms(true /* fullGC */, gc_cause()); @@ -3858,8 +3858,7 @@ void G1CollectedHeap::log_gc_header() { return; } - gclog_or_tty->date_stamp(PrintGCDateStamps); - gclog_or_tty->stamp(PrintGCTimeStamps); + gclog_or_tty->gclog_stamp(_gc_tracer_stw->gc_id()); GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause()) .append(g1_policy()->gcs_are_young() ? "(young)" : "(mixed)") @@ -5743,7 +5742,8 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) { &keep_alive, &drain_queue, NULL, - _gc_timer_stw); + _gc_timer_stw, + _gc_tracer_stw->gc_id()); } else { // Parallel reference processing assert(rp->num_q() == no_of_gc_workers, "sanity"); @@ -5754,7 +5754,8 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) { &keep_alive, &drain_queue, &par_task_executor, - _gc_timer_stw); + _gc_timer_stw, + _gc_tracer_stw->gc_id()); } _gc_tracer_stw->report_gc_reference_stats(stats); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp index d8bda059bb8..639c09e774f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @@ -123,7 +123,7 @@ void G1MarkSweep::allocate_stacks() { void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, bool clear_all_softrefs) { // Recursively traverse all live objects and mark them - GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer()); + GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); GenMarkSweep::trace(" 1"); SharedHeap* sh = SharedHeap::heap(); @@ -146,7 +146,8 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, &GenMarkSweep::keep_alive, &GenMarkSweep::follow_stack_closure, NULL, - gc_timer()); + gc_timer(), + gc_tracer()->gc_id()); gc_tracer()->report_gc_reference_stats(stats); @@ -260,7 +261,7 @@ void G1MarkSweep::mark_sweep_phase2() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); - GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer()); + GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); GenMarkSweep::trace("2"); // find the first region @@ -297,7 +298,7 @@ void G1MarkSweep::mark_sweep_phase3() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); // Adjust the pointers to reflect the new locations - GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer()); + GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); GenMarkSweep::trace("3"); SharedHeap* sh = SharedHeap::heap(); @@ -358,7 +359,7 @@ void G1MarkSweep::mark_sweep_phase4() { // to use a higher index (saved from phase2) when verifying perm_gen. G1CollectedHeap* g1h = G1CollectedHeap::heap(); - GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer()); + GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); GenMarkSweep::trace("4"); G1SpaceCompactClosure blk; diff --git a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp index 9f298da3873..1c3c17b5ccf 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp @@ -226,7 +226,7 @@ void VM_CGC_Operation::release_and_notify_pending_list_lock() { void VM_CGC_Operation::doit() { gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps); TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); - GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm()); + GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm(), G1CollectedHeap::heap()->concurrent_mark()->concurrent_gc_id()); SharedHeap* sh = SharedHeap::heap(); // This could go away if CollectedHeap gave access to _gc_is_active... if (sh != NULL) { diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index 5e979965731..7ac8dfd2489 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -955,7 +955,7 @@ void ParNewGeneration::collect(bool full, size_policy->minor_collection_begin(); } - GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL); + GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, gc_tracer.gc_id()); // Capture heap used before collection (for printing). size_t gch_prev_used = gch->used(); @@ -1013,14 +1013,14 @@ void ParNewGeneration::collect(bool full, ParNewRefProcTaskExecutor task_executor(*this, thread_state_set); stats = rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, &task_executor, - _gc_timer); + _gc_timer, gc_tracer.gc_id()); } else { thread_state_set.flush(); gch->set_par_threads(0); // 0 ==> non-parallel. gch->save_marks(); stats = rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, NULL, - _gc_timer); + _gc_timer, gc_tracer.gc_id()); } gc_tracer.report_gc_reference_stats(stats); if (!promotion_failed()) { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp index 5037c207c62..01790ef9310 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp @@ -53,7 +53,7 @@ void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) { ResourceMark rm; NOT_PRODUCT(GCTraceTime tm("ThreadRootsMarkingTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); @@ -82,7 +82,7 @@ void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { assert(Universe::heap()->is_gc_active(), "called outside gc"); NOT_PRODUCT(GCTraceTime tm("MarkFromRootsTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); @@ -153,7 +153,7 @@ void RefProcTaskProxy::do_it(GCTaskManager* manager, uint which) assert(Universe::heap()->is_gc_active(), "called outside gc"); NOT_PRODUCT(GCTraceTime tm("RefProcTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); @@ -209,7 +209,7 @@ void StealMarkingTask::do_it(GCTaskManager* manager, uint which) { assert(Universe::heap()->is_gc_active(), "called outside gc"); NOT_PRODUCT(GCTraceTime tm("StealMarkingTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); @@ -242,7 +242,7 @@ void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) { assert(Universe::heap()->is_gc_active(), "called outside gc"); NOT_PRODUCT(GCTraceTime tm("StealRegionCompactionTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); @@ -309,7 +309,7 @@ UpdateDensePrefixTask::UpdateDensePrefixTask( void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { NOT_PRODUCT(GCTraceTime tm("UpdateDensePrefixTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); @@ -324,7 +324,7 @@ void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) { assert(Universe::heap()->is_gc_active(), "called outside gc"); NOT_PRODUCT(GCTraceTime tm("DrainStacksCompactionTask", - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp index bb829f99602..51867d1622f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @@ -170,7 +170,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL); + GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer->gc_id()); TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); @@ -521,7 +521,7 @@ void PSMarkSweep::deallocate_stacks() { void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { // Recursively traverse all live objects and mark them - GCTraceTime tm("phase 1", PrintGCDetails && Verbose, true, _gc_timer); + GCTraceTime tm("phase 1", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace(" 1"); ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); @@ -556,7 +556,7 @@ void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { ref_processor()->setup_policy(clear_all_softrefs); const ReferenceProcessorStats& stats = ref_processor()->process_discovered_references( - is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer); + is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer, _gc_tracer->gc_id()); gc_tracer()->report_gc_reference_stats(stats); } @@ -582,7 +582,7 @@ void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { void PSMarkSweep::mark_sweep_phase2() { - GCTraceTime tm("phase 2", PrintGCDetails && Verbose, true, _gc_timer); + GCTraceTime tm("phase 2", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace("2"); // Now all live objects are marked, compute the new object addresses. @@ -612,7 +612,7 @@ static PSAlwaysTrueClosure always_true; void PSMarkSweep::mark_sweep_phase3() { // Adjust the pointers to reflect the new locations - GCTraceTime tm("phase 3", PrintGCDetails && Verbose, true, _gc_timer); + GCTraceTime tm("phase 3", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace("3"); ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); @@ -655,7 +655,7 @@ void PSMarkSweep::mark_sweep_phase3() { void PSMarkSweep::mark_sweep_phase4() { EventMark m("4 compact heap"); - GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer); + GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace("4"); // All pointers are now adjusted, move objects accordingly diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index cba23adae9f..a709586b34d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -979,7 +979,7 @@ void PSParallelCompact::pre_compact(PreGCValues* pre_gc_values) // at each young gen gc. Do the update unconditionally (even though a // promotion failure does not swap spaces) because an unknown number of minor // collections will have swapped the spaces an unknown number of times. - GCTraceTime tm("pre compact", print_phases(), true, &_gc_timer); + GCTraceTime tm("pre compact", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ParallelScavengeHeap* heap = gc_heap(); _space_info[from_space_id].set_space(heap->young_gen()->from_space()); _space_info[to_space_id].set_space(heap->young_gen()->to_space()); @@ -1022,7 +1022,7 @@ void PSParallelCompact::pre_compact(PreGCValues* pre_gc_values) void PSParallelCompact::post_compact() { - GCTraceTime tm("post compact", print_phases(), true, &_gc_timer); + GCTraceTime tm("post compact", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); for (unsigned int id = old_space_id; id < last_space_id; ++id) { // Clear the marking bitmap, summary data and split info. @@ -1848,7 +1848,7 @@ void PSParallelCompact::summary_phase_msg(SpaceId dst_space_id, void PSParallelCompact::summary_phase(ParCompactionManager* cm, bool maximum_compaction) { - GCTraceTime tm("summary phase", print_phases(), true, &_gc_timer); + GCTraceTime tm("summary phase", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); // trace("2"); #ifdef ASSERT @@ -2057,7 +2057,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL); + GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer.gc_id()); TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); @@ -2359,7 +2359,7 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm, bool maximum_heap_compaction, ParallelOldTracer *gc_tracer) { // Recursively traverse all live objects and mark them - GCTraceTime tm("marking phase", print_phases(), true, &_gc_timer); + GCTraceTime tm("marking phase", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ParallelScavengeHeap* heap = gc_heap(); uint parallel_gc_threads = heap->gc_task_manager()->workers(); @@ -2374,7 +2374,7 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm, ClassLoaderDataGraph::clear_claimed_marks(); { - GCTraceTime tm_m("par mark", print_phases(), true, &_gc_timer); + GCTraceTime tm_m("par mark", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ParallelScavengeHeap::ParStrongRootsScope psrs; @@ -2403,24 +2403,24 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm, // Process reference objects found during marking { - GCTraceTime tm_r("reference processing", print_phases(), true, &_gc_timer); + GCTraceTime tm_r("reference processing", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ReferenceProcessorStats stats; if (ref_processor()->processing_is_mt()) { RefProcTaskExecutor task_executor; stats = ref_processor()->process_discovered_references( is_alive_closure(), &mark_and_push_closure, &follow_stack_closure, - &task_executor, &_gc_timer); + &task_executor, &_gc_timer, _gc_tracer.gc_id()); } else { stats = ref_processor()->process_discovered_references( is_alive_closure(), &mark_and_push_closure, &follow_stack_closure, NULL, - &_gc_timer); + &_gc_timer, _gc_tracer.gc_id()); } gc_tracer->report_gc_reference_stats(stats); } - GCTraceTime tm_c("class unloading", print_phases(), true, &_gc_timer); + GCTraceTime tm_c("class unloading", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); // This is the point where the entire marking should have completed. assert(cm->marking_stacks_empty(), "Marking should have completed"); @@ -2459,7 +2459,7 @@ static PSAlwaysTrueClosure always_true; void PSParallelCompact::adjust_roots() { // Adjust the pointers to reflect the new locations - GCTraceTime tm("adjust roots", print_phases(), true, &_gc_timer); + GCTraceTime tm("adjust roots", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); // Need new claim bits when tracing through and adjusting pointers. ClassLoaderDataGraph::clear_claimed_marks(); @@ -2495,7 +2495,7 @@ void PSParallelCompact::adjust_roots() { void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q, uint parallel_gc_threads) { - GCTraceTime tm("drain task setup", print_phases(), true, &_gc_timer); + GCTraceTime tm("drain task setup", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); // Find the threads that are active unsigned int which = 0; @@ -2569,7 +2569,7 @@ void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q, void PSParallelCompact::enqueue_dense_prefix_tasks(GCTaskQueue* q, uint parallel_gc_threads) { - GCTraceTime tm("dense prefix task setup", print_phases(), true, &_gc_timer); + GCTraceTime tm("dense prefix task setup", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ParallelCompactData& sd = PSParallelCompact::summary_data(); @@ -2651,7 +2651,7 @@ void PSParallelCompact::enqueue_region_stealing_tasks( GCTaskQueue* q, ParallelTaskTerminator* terminator_ptr, uint parallel_gc_threads) { - GCTraceTime tm("steal task setup", print_phases(), true, &_gc_timer); + GCTraceTime tm("steal task setup", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); // Once a thread has drained it's stack, it should try to steal regions from // other threads. @@ -2699,7 +2699,7 @@ void PSParallelCompact::write_block_fill_histogram(outputStream* const out) void PSParallelCompact::compact() { // trace("5"); - GCTraceTime tm("compaction phase", print_phases(), true, &_gc_timer); + GCTraceTime tm("compaction phase", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); @@ -2716,7 +2716,7 @@ void PSParallelCompact::compact() { enqueue_region_stealing_tasks(q, &terminator, active_gc_threads); { - GCTraceTime tm_pc("par compact", print_phases(), true, &_gc_timer); + GCTraceTime tm_pc("par compact", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); gc_task_manager()->execute_and_wait(q); @@ -2730,7 +2730,7 @@ void PSParallelCompact::compact() { { // Update the deferred objects, if any. Any compaction manager can be used. - GCTraceTime tm_du("deferred updates", print_phases(), true, &_gc_timer); + GCTraceTime tm_du("deferred updates", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); ParCompactionManager* cm = ParCompactionManager::manager_array(0); for (unsigned int id = old_space_id; id < last_space_id; ++id) { update_deferred_objects(cm, SpaceId(id)); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp index 9d37b133b05..c098e455741 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp @@ -1004,6 +1004,10 @@ class PSParallelCompact : AllStatic { static bool _dwl_initialized; #endif // #ifdef ASSERT + + public: + static ParallelOldTracer* gc_tracer() { return &_gc_tracer; } + private: static void initialize_space_info(); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index e71122529b1..7371832d5a3 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -332,7 +332,7 @@ bool PSScavenge::invoke_no_policy() { gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - GCTraceTime t1(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL); + GCTraceTime t1(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer.gc_id()); TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(false /* not full GC */,gc_cause); @@ -398,7 +398,7 @@ bool PSScavenge::invoke_no_policy() { // We'll use the promotion manager again later. PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager(); { - GCTraceTime tm("Scavenge", false, false, &_gc_timer); + GCTraceTime tm("Scavenge", false, false, &_gc_timer, _gc_tracer.gc_id()); ParallelScavengeHeap::ParStrongRootsScope psrs; GCTaskQueue* q = GCTaskQueue::create(); @@ -440,7 +440,7 @@ bool PSScavenge::invoke_no_policy() { // Process reference objects discovered during scavenge { - GCTraceTime tm("References", false, false, &_gc_timer); + GCTraceTime tm("References", false, false, &_gc_timer, _gc_tracer.gc_id()); reference_processor()->setup_policy(false); // not always_clear reference_processor()->set_active_mt_degree(active_workers); @@ -451,10 +451,10 @@ bool PSScavenge::invoke_no_policy() { PSRefProcTaskExecutor task_executor; stats = reference_processor()->process_discovered_references( &_is_alive_closure, &keep_alive, &evac_followers, &task_executor, - &_gc_timer); + &_gc_timer, _gc_tracer.gc_id()); } else { stats = reference_processor()->process_discovered_references( - &_is_alive_closure, &keep_alive, &evac_followers, NULL, &_gc_timer); + &_is_alive_closure, &keep_alive, &evac_followers, NULL, &_gc_timer, _gc_tracer.gc_id()); } _gc_tracer.report_gc_reference_stats(stats); @@ -469,7 +469,7 @@ bool PSScavenge::invoke_no_policy() { } { - GCTraceTime tm("StringTable", false, false, &_gc_timer); + GCTraceTime tm("StringTable", false, false, &_gc_timer, _gc_tracer.gc_id()); // Unlink any dead interned Strings and process the remaining live ones. PSScavengeRootsClosure root_closure(promotion_manager); StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); @@ -641,7 +641,7 @@ bool PSScavenge::invoke_no_policy() { NOT_PRODUCT(reference_processor()->verify_no_references_recorded()); { - GCTraceTime tm("Prune Scavenge Root Methods", false, false, &_gc_timer); + GCTraceTime tm("Prune Scavenge Root Methods", false, false, &_gc_timer, _gc_tracer.gc_id()); CodeCache::prune_scavenge_root_nmethods(); } diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcId.cpp b/hotspot/src/share/vm/gc_implementation/shared/gcId.cpp new file mode 100644 index 00000000000..ced64a46204 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/shared/gcId.cpp @@ -0,0 +1,42 @@ +/* + * 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 "gc_implementation/shared/gcId.hpp" +#include "runtime/safepoint.hpp" + +uint GCId::_next_id = 0; + +const GCId GCId::create() { + return GCId(_next_id++); +} +const GCId GCId::peek() { + return GCId(_next_id); +} +const GCId GCId::undefined() { + return GCId(UNDEFINED); +} +bool GCId::is_undefined() const { + return _id == UNDEFINED; +} diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcId.hpp b/hotspot/src/share/vm/gc_implementation/shared/gcId.hpp new file mode 100644 index 00000000000..1d2decc6bb5 --- /dev/null +++ b/hotspot/src/share/vm/gc_implementation/shared/gcId.hpp @@ -0,0 +1,51 @@ +/* + * 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_GC_IMPLEMENTATION_SHARED_GCID_HPP +#define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCID_HPP + +#include "memory/allocation.hpp" + +class GCId VALUE_OBJ_CLASS_SPEC { + private: + uint _id; + GCId(uint id) : _id(id) {} + GCId() { } // Unused + + static uint _next_id; + static const uint UNDEFINED = (uint)-1; + + public: + uint id() const { + assert(_id != UNDEFINED, "Using undefined GC ID"); + return _id; + } + bool is_undefined() const; + + static const GCId create(); + static const GCId peek(); + static const GCId undefined(); +}; + +#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCID_HPP diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp index 994d468bbc5..ddac9531667 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc_implementation/shared/copyFailedInfo.hpp" #include "gc_implementation/shared/gcHeapSummary.hpp" +#include "gc_implementation/shared/gcId.hpp" #include "gc_implementation/shared/gcTimer.hpp" #include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/objectCountEventSender.hpp" @@ -38,19 +39,14 @@ #include "gc_implementation/g1/evacuationInfo.hpp" #endif -#define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?") -#define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?") - -static GCId GCTracer_next_gc_id = 0; -static GCId create_new_gc_id() { - return GCTracer_next_gc_id++; -} +#define assert_unset_gc_id() assert(_shared_gc_info.gc_id().is_undefined(), "GC already started?") +#define assert_set_gc_id() assert(!_shared_gc_info.gc_id().is_undefined(), "GC not started?") void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) { assert_unset_gc_id(); - GCId gc_id = create_new_gc_id(); - _shared_gc_info.set_id(gc_id); + GCId gc_id = GCId::create(); + _shared_gc_info.set_gc_id(gc_id); _shared_gc_info.set_cause(cause); _shared_gc_info.set_start_timestamp(timestamp); } @@ -62,7 +58,7 @@ void GCTracer::report_gc_start(GCCause::Cause cause, const Ticks& timestamp) { } bool GCTracer::has_reported_gc_start() const { - return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID; + return !_shared_gc_info.gc_id().is_undefined(); } void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { @@ -81,7 +77,7 @@ void GCTracer::report_gc_end(const Ticks& timestamp, TimePartitions* time_partit report_gc_end_impl(timestamp, time_partitions); - _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID); + _shared_gc_info.set_gc_id(GCId::undefined()); } void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const { @@ -132,7 +128,7 @@ void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) { if (!cit.allocation_failed()) { HeapInspection hi(false, false, false, NULL); hi.populate_table(&cit, is_alive_cl); - ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), Ticks::now()); + ObjectCountEventSenderClosure event_sender(_shared_gc_info.gc_id(), cit.size_of_instances_in_words(), Ticks::now()); cit.iterate(&event_sender); } } diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp index 3b55211a724..dd13344155f 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcTrace.hpp @@ -27,6 +27,7 @@ #include "gc_interface/gcCause.hpp" #include "gc_interface/gcName.hpp" +#include "gc_implementation/shared/gcId.hpp" #include "gc_implementation/shared/gcWhen.hpp" #include "gc_implementation/shared/copyFailedInfo.hpp" #include "memory/allocation.hpp" @@ -38,7 +39,6 @@ #include "utilities/macros.hpp" #include "utilities/ticks.hpp" -typedef uint GCId; class EvacuationInfo; class GCHeapSummary; @@ -50,11 +50,8 @@ class TimePartitions; class BoolObjectClosure; class SharedGCInfo VALUE_OBJ_CLASS_SPEC { - public: - static const GCId UNSET_GCID = (GCId)-1; - private: - GCId _id; + GCId _gc_id; GCName _name; GCCause::Cause _cause; Ticks _start_timestamp; @@ -64,7 +61,7 @@ class SharedGCInfo VALUE_OBJ_CLASS_SPEC { public: SharedGCInfo(GCName name) : - _id(UNSET_GCID), + _gc_id(GCId::undefined()), _name(name), _cause(GCCause::_last_gc_cause), _start_timestamp(), @@ -73,8 +70,8 @@ class SharedGCInfo VALUE_OBJ_CLASS_SPEC { _longest_pause() { } - void set_id(GCId id) { _id = id; } - GCId id() const { return _id; } + void set_gc_id(GCId gc_id) { _gc_id = gc_id; } + const GCId& gc_id() const { return _gc_id; } void set_start_timestamp(const Ticks& timestamp) { _start_timestamp = timestamp; } const Ticks start_timestamp() const { return _start_timestamp; } @@ -131,10 +128,11 @@ class GCTracer : public ResourceObj { void report_gc_reference_stats(const ReferenceProcessorStats& rp) const; void report_object_count_after_gc(BoolObjectClosure* object_filter) NOT_SERVICES_RETURN; bool has_reported_gc_start() const; + const GCId& gc_id() { return _shared_gc_info.gc_id(); } protected: GCTracer(GCName name) : _shared_gc_info(name) {} - virtual void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp); + void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp); virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); private: diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp b/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp index 95ca83a4a1d..5462135a014 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp @@ -43,7 +43,7 @@ typedef uintptr_t TraceAddress; void GCTracer::send_garbage_collection_event() const { EventGCGarbageCollection event(UNTIMED); if (event.should_commit()) { - event.set_gcId(_shared_gc_info.id()); + event.set_gcId(_shared_gc_info.gc_id().id()); event.set_name(_shared_gc_info.name()); event.set_cause((u2) _shared_gc_info.cause()); event.set_sumOfPauses(_shared_gc_info.sum_of_pauses()); @@ -57,7 +57,7 @@ void GCTracer::send_garbage_collection_event() const { void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const { EventGCReferenceStatistics e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_type((u1)type); e.set_count(count); e.commit(); @@ -68,7 +68,7 @@ void GCTracer::send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspa const MetaspaceChunkFreeListSummary& summary) const { EventMetaspaceChunkFreeListSummary e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_when(when); e.set_metadataType(mdtype); @@ -91,7 +91,7 @@ void GCTracer::send_metaspace_chunk_free_list_summary(GCWhen::Type when, Metaspa void ParallelOldTracer::send_parallel_old_event() const { EventGCParallelOld e(UNTIMED); if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix()); e.set_starttime(_shared_gc_info.start_timestamp()); e.set_endtime(_shared_gc_info.end_timestamp()); @@ -102,7 +102,7 @@ void ParallelOldTracer::send_parallel_old_event() const { void YoungGCTracer::send_young_gc_event() const { EventGCYoungGarbageCollection e(UNTIMED); if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_tenuringThreshold(_tenuring_threshold); e.set_starttime(_shared_gc_info.start_timestamp()); e.set_endtime(_shared_gc_info.end_timestamp()); @@ -113,7 +113,7 @@ void YoungGCTracer::send_young_gc_event() const { void OldGCTracer::send_old_gc_event() const { EventGCOldGarbageCollection e(UNTIMED); if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_starttime(_shared_gc_info.start_timestamp()); e.set_endtime(_shared_gc_info.end_timestamp()); e.commit(); @@ -132,7 +132,7 @@ static TraceStructCopyFailed to_trace_struct(const CopyFailedInfo& cf_info) { void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const { EventPromotionFailed e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_data(to_trace_struct(pf_info)); e.set_thread(pf_info.thread()->thread_id()); e.commit(); @@ -143,7 +143,7 @@ void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_in void OldGCTracer::send_concurrent_mode_failure_event() { EventConcurrentModeFailure e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.commit(); } } @@ -152,7 +152,7 @@ void OldGCTracer::send_concurrent_mode_failure_event() { void G1NewTracer::send_g1_young_gc_event() { EventGCG1GarbageCollection e(UNTIMED); if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_type(_g1_young_gc_info.type()); e.set_starttime(_shared_gc_info.start_timestamp()); e.set_endtime(_shared_gc_info.end_timestamp()); @@ -163,7 +163,7 @@ void G1NewTracer::send_g1_young_gc_event() { void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) { EventEvacuationInfo e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_cSetRegions(info->collectionset_regions()); e.set_cSetUsedBefore(info->collectionset_used_before()); e.set_cSetUsedAfter(info->collectionset_used_after()); @@ -179,7 +179,7 @@ void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) { void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const { EventEvacuationFailed e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_data(to_trace_struct(ef_info)); e.commit(); } @@ -206,17 +206,17 @@ static TraceStructObjectSpace to_trace_struct(const SpaceSummary& summary) { } class GCHeapSummaryEventSender : public GCHeapSummaryVisitor { - GCId _id; + GCId _gc_id; GCWhen::Type _when; public: - GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {} + GCHeapSummaryEventSender(GCId gc_id, GCWhen::Type when) : _gc_id(gc_id), _when(when) {} void visit(const GCHeapSummary* heap_summary) const { const VirtualSpaceSummary& heap_space = heap_summary->heap(); EventGCHeapSummary e; if (e.should_commit()) { - e.set_gcId(_id); + e.set_gcId(_gc_id.id()); e.set_when((u1)_when); e.set_heapSpace(to_trace_struct(heap_space)); e.set_heapUsed(heap_summary->used()); @@ -236,7 +236,7 @@ class GCHeapSummaryEventSender : public GCHeapSummaryVisitor { EventPSHeapSummary e; if (e.should_commit()) { - e.set_gcId(_id); + e.set_gcId(_gc_id.id()); e.set_when((u1)_when); e.set_oldSpace(to_trace_struct(ps_heap_summary->old())); @@ -251,7 +251,7 @@ class GCHeapSummaryEventSender : public GCHeapSummaryVisitor { }; void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const { - GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when); + GCHeapSummaryEventSender visitor(_shared_gc_info.gc_id(), when); heap_summary.accept(&visitor); } @@ -268,7 +268,7 @@ static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) { void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const { EventMetaspaceSummary e; if (e.should_commit()) { - e.set_gcId(_shared_gc_info.id()); + e.set_gcId(_shared_gc_info.gc_id().id()); e.set_when((u1) when); e.set_gcThreshold(meta_space_summary.capacity_until_GC()); e.set_metaspace(to_trace_struct(meta_space_summary.meta_space())); @@ -287,7 +287,7 @@ class PhaseSender : public PhaseVisitor { void send_phase(PausePhase* pause) { T event(UNTIMED); if (event.should_commit()) { - event.set_gcId(_gc_id); + event.set_gcId(_gc_id.id()); event.set_name(pause->name()); event.set_starttime(pause->start()); event.set_endtime(pause->end()); @@ -311,7 +311,7 @@ class PhaseSender : public PhaseVisitor { }; void GCTracer::send_phase_events(TimePartitions* time_partitions) const { - PhaseSender phase_reporter(_shared_gc_info.id()); + PhaseSender phase_reporter(_shared_gc_info.gc_id()); TimePartitionPhasesIterator iter(time_partitions); while (iter.has_next()) { diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.cpp b/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.cpp index 033ca6b779d..83890611ec5 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc_implementation/shared/gcTimer.hpp" +#include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/gcTraceTime.hpp" #include "runtime/globals.hpp" #include "runtime/os.hpp" @@ -34,7 +35,7 @@ #include "utilities/ticks.inline.hpp" -GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) : +GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer, GCId gc_id) : _title(title), _doit(doit), _print_cr(print_cr), _timer(timer), _start_counter() { if (_doit || _timer != NULL) { _start_counter.stamp(); @@ -52,6 +53,9 @@ GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* t gclog_or_tty->stamp(); gclog_or_tty->print(": "); } + if (PrintGCID) { + gclog_or_tty->print("#%u: ", gc_id.id()); + } gclog_or_tty->print("[%s", title); gclog_or_tty->flush(); } diff --git a/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.hpp b/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.hpp index 83df182f90c..30e494baa52 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/gcTraceTime.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACETIME_HPP #define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACETIME_HPP +#include "gc_implementation/shared/gcTrace.hpp" #include "prims/jni_md.h" #include "utilities/ticks.hpp" @@ -38,7 +39,7 @@ class GCTraceTime { Ticks _start_counter; public: - GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer); + GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer, GCId gc_id); ~GCTraceTime(); }; diff --git a/hotspot/src/share/vm/gc_implementation/shared/objectCountEventSender.cpp b/hotspot/src/share/vm/gc_implementation/shared/objectCountEventSender.cpp index 7504a21c2cd..4e0dc6077a6 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/objectCountEventSender.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/objectCountEventSender.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" +#include "gc_implementation/shared/gcId.hpp" #include "gc_implementation/shared/objectCountEventSender.hpp" #include "memory/heapInspection.hpp" #include "trace/tracing.hpp" @@ -38,7 +39,7 @@ void ObjectCountEventSender::send(const KlassInfoEntry* entry, GCId gc_id, const "Only call this method if the event is enabled"); EventObjectCountAfterGC event(UNTIMED); - event.set_gcId(gc_id); + event.set_gcId(gc_id.id()); event.set_class(entry->klass()); event.set_count(entry->count()); event.set_totalSize(entry->words() * BytesPerWord); diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp index 1304092002e..ddad402c259 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp @@ -558,13 +558,13 @@ void CollectedHeap::resize_all_tlabs() { void CollectedHeap::pre_full_gc_dump(GCTimer* timer) { if (HeapDumpBeforeFullGC) { - GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer); + GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer, GCId::create()); // We are doing a "major" collection and a heap dump before // major collection has been requested. HeapDumper::dump_heap(); } if (PrintClassHistogramBeforeFullGC) { - GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer); + GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer, GCId::create()); VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */); inspector.doit(); } @@ -572,11 +572,11 @@ void CollectedHeap::pre_full_gc_dump(GCTimer* timer) { void CollectedHeap::post_full_gc_dump(GCTimer* timer) { if (HeapDumpAfterFullGC) { - GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer); + GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer, GCId::create()); HeapDumper::dump_heap(); } if (PrintClassHistogramAfterFullGC) { - GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer); + GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer, GCId::create()); VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */); inspector.doit(); } diff --git a/hotspot/src/share/vm/memory/defNewGeneration.cpp b/hotspot/src/share/vm/memory/defNewGeneration.cpp index bf51090df12..ee2b50365b1 100644 --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp @@ -585,7 +585,7 @@ void DefNewGeneration::collect(bool full, init_assuming_no_promotion_failure(); - GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL); + GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, gc_tracer.gc_id()); // Capture heap used before collection (for printing). size_t gch_prev_used = gch->used(); @@ -641,7 +641,7 @@ void DefNewGeneration::collect(bool full, rp->setup_policy(clear_all_soft_refs); const ReferenceProcessorStats& stats = rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, - NULL, _gc_timer); + NULL, _gc_timer, gc_tracer.gc_id()); gc_tracer.report_gc_reference_stats(stats); if (!_promotion_failed) { diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index a774f4051e6..bdb915ebb0c 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -28,6 +28,7 @@ #include "classfile/vmSymbols.hpp" #include "code/icBuffer.hpp" #include "gc_implementation/shared/collectorCounters.hpp" +#include "gc_implementation/shared/gcTrace.hpp" #include "gc_implementation/shared/gcTraceTime.hpp" #include "gc_implementation/shared/vmGCOperations.hpp" #include "gc_interface/collectedHeap.inline.hpp" @@ -384,7 +385,9 @@ void GenCollectedHeap::do_collection(bool full, const char* gc_cause_prefix = complete ? "Full GC" : "GC"; gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); - GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL); + // The PrintGCDetails logging starts before we have incremented the GC id. We will do that later + // so we can assume here that the next GC id is what we want. + GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL, GCId::peek()); gc_prologue(complete); increment_total_collections(complete); @@ -417,7 +420,9 @@ void GenCollectedHeap::do_collection(bool full, } // Timer for individual generations. Last argument is false: no CR // FIXME: We should try to start the timing earlier to cover more of the GC pause - GCTraceTime t1(_gens[i]->short_name(), PrintGCDetails, false, NULL); + // The PrintGCDetails logging starts before we have incremented the GC id. We will do that later + // so we can assume here that the next GC id is what we want. + GCTraceTime t1(_gens[i]->short_name(), PrintGCDetails, false, NULL, GCId::peek()); TraceCollectorStats tcs(_gens[i]->counters()); TraceMemoryManagerStats tmms(_gens[i]->kind(),gc_cause()); diff --git a/hotspot/src/share/vm/memory/genMarkSweep.cpp b/hotspot/src/share/vm/memory/genMarkSweep.cpp index 64d7c3eaa61..dcd7308843e 100644 --- a/hotspot/src/share/vm/memory/genMarkSweep.cpp +++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp @@ -69,7 +69,7 @@ void GenMarkSweep::invoke_at_safepoint(int level, ReferenceProcessor* rp, bool c _ref_processor = rp; rp->setup_policy(clear_all_softrefs); - GCTraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL); + GCTraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, _gc_tracer->gc_id()); gch->trace_heap_before_gc(_gc_tracer); @@ -193,7 +193,7 @@ void GenMarkSweep::deallocate_stacks() { void GenMarkSweep::mark_sweep_phase1(int level, bool clear_all_softrefs) { // Recursively traverse all live objects and mark them - GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer); + GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace(" 1"); GenCollectedHeap* gch = GenCollectedHeap::heap(); @@ -220,7 +220,7 @@ void GenMarkSweep::mark_sweep_phase1(int level, ref_processor()->setup_policy(clear_all_softrefs); const ReferenceProcessorStats& stats = ref_processor()->process_discovered_references( - &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer); + &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer, _gc_tracer->gc_id()); gc_tracer()->report_gc_reference_stats(stats); } @@ -262,7 +262,7 @@ void GenMarkSweep::mark_sweep_phase2() { GenCollectedHeap* gch = GenCollectedHeap::heap(); - GCTraceTime tm("phase 2", PrintGC && Verbose, true, _gc_timer); + GCTraceTime tm("phase 2", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace("2"); gch->prepare_for_compaction(); @@ -279,7 +279,7 @@ void GenMarkSweep::mark_sweep_phase3(int level) { GenCollectedHeap* gch = GenCollectedHeap::heap(); // Adjust the pointers to reflect the new locations - GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer); + GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace("3"); // Need new claim bits for the pointer adjustment tracing. @@ -327,7 +327,7 @@ void GenMarkSweep::mark_sweep_phase4() { // to use a higher index (saved from phase2) when verifying perm_gen. GenCollectedHeap* gch = GenCollectedHeap::heap(); - GCTraceTime tm("phase 4", PrintGC && Verbose, true, _gc_timer); + GCTraceTime tm("phase 4", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); trace("4"); GenCompactClosure blk; diff --git a/hotspot/src/share/vm/memory/referenceProcessor.cpp b/hotspot/src/share/vm/memory/referenceProcessor.cpp index 2a074f21f15..cb14dd8541b 100644 --- a/hotspot/src/share/vm/memory/referenceProcessor.cpp +++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp @@ -190,7 +190,8 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references( OopClosure* keep_alive, VoidClosure* complete_gc, AbstractRefProcTaskExecutor* task_executor, - GCTimer* gc_timer) { + GCTimer* gc_timer, + GCId gc_id) { NOT_PRODUCT(verify_ok_to_handle_reflists()); assert(!enqueuing_is_done(), "If here enqueuing should not be complete"); @@ -212,7 +213,7 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references( // Soft references size_t soft_count = 0; { - GCTraceTime tt("SoftReference", trace_time, false, gc_timer); + GCTraceTime tt("SoftReference", trace_time, false, gc_timer, gc_id); soft_count = process_discovered_reflist(_discoveredSoftRefs, _current_soft_ref_policy, true, is_alive, keep_alive, complete_gc, task_executor); @@ -223,7 +224,7 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references( // Weak references size_t weak_count = 0; { - GCTraceTime tt("WeakReference", trace_time, false, gc_timer); + GCTraceTime tt("WeakReference", trace_time, false, gc_timer, gc_id); weak_count = process_discovered_reflist(_discoveredWeakRefs, NULL, true, is_alive, keep_alive, complete_gc, task_executor); @@ -232,7 +233,7 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references( // Final references size_t final_count = 0; { - GCTraceTime tt("FinalReference", trace_time, false, gc_timer); + GCTraceTime tt("FinalReference", trace_time, false, gc_timer, gc_id); final_count = process_discovered_reflist(_discoveredFinalRefs, NULL, false, is_alive, keep_alive, complete_gc, task_executor); @@ -241,7 +242,7 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references( // Phantom references size_t phantom_count = 0; { - GCTraceTime tt("PhantomReference", trace_time, false, gc_timer); + GCTraceTime tt("PhantomReference", trace_time, false, gc_timer, gc_id); phantom_count = process_discovered_reflist(_discoveredPhantomRefs, NULL, false, is_alive, keep_alive, complete_gc, task_executor); @@ -253,7 +254,7 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references( // thus use JNI weak references to circumvent the phantom references and // resurrect a "post-mortem" object. { - GCTraceTime tt("JNI Weak Reference", trace_time, false, gc_timer); + GCTraceTime tt("JNI Weak Reference", trace_time, false, gc_timer, gc_id); if (task_executor != NULL) { task_executor->set_single_threaded_mode(); } @@ -1251,14 +1252,15 @@ void ReferenceProcessor::preclean_discovered_references( OopClosure* keep_alive, VoidClosure* complete_gc, YieldClosure* yield, - GCTimer* gc_timer) { + GCTimer* gc_timer, + GCId gc_id) { NOT_PRODUCT(verify_ok_to_handle_reflists()); // Soft references { GCTraceTime tt("Preclean SoftReferences", PrintGCDetails && PrintReferenceGC, - false, gc_timer); + false, gc_timer, gc_id); for (uint i = 0; i < _max_num_q; i++) { if (yield->should_return()) { return; @@ -1271,7 +1273,7 @@ void ReferenceProcessor::preclean_discovered_references( // Weak references { GCTraceTime tt("Preclean WeakReferences", PrintGCDetails && PrintReferenceGC, - false, gc_timer); + false, gc_timer, gc_id); for (uint i = 0; i < _max_num_q; i++) { if (yield->should_return()) { return; @@ -1284,7 +1286,7 @@ void ReferenceProcessor::preclean_discovered_references( // Final references { GCTraceTime tt("Preclean FinalReferences", PrintGCDetails && PrintReferenceGC, - false, gc_timer); + false, gc_timer, gc_id); for (uint i = 0; i < _max_num_q; i++) { if (yield->should_return()) { return; @@ -1297,7 +1299,7 @@ void ReferenceProcessor::preclean_discovered_references( // Phantom references { GCTraceTime tt("Preclean PhantomReferences", PrintGCDetails && PrintReferenceGC, - false, gc_timer); + false, gc_timer, gc_id); for (uint i = 0; i < _max_num_q; i++) { if (yield->should_return()) { return; diff --git a/hotspot/src/share/vm/memory/referenceProcessor.hpp b/hotspot/src/share/vm/memory/referenceProcessor.hpp index 26ac9f1c5d4..d4d2b89866e 100644 --- a/hotspot/src/share/vm/memory/referenceProcessor.hpp +++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP #define SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP +#include "gc_implementation/shared/gcTrace.hpp" #include "memory/referencePolicy.hpp" #include "memory/referenceProcessorStats.hpp" #include "memory/referenceType.hpp" @@ -349,7 +350,8 @@ class ReferenceProcessor : public CHeapObj { OopClosure* keep_alive, VoidClosure* complete_gc, YieldClosure* yield, - GCTimer* gc_timer); + GCTimer* gc_timer, + GCId gc_id); // Delete entries in the discovered lists that have // either a null referent or are not active. Such @@ -480,7 +482,8 @@ class ReferenceProcessor : public CHeapObj { OopClosure* keep_alive, VoidClosure* complete_gc, AbstractRefProcTaskExecutor* task_executor, - GCTimer *gc_timer); + GCTimer *gc_timer, + GCId gc_id); // Enqueue references at end of GC (called by the garbage collector) bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL); diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 1dbf51c8632..56cafb65600 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2299,6 +2299,9 @@ class CommandLineFlags { manageable(bool, PrintGCTimeStamps, false, \ "Print timestamps at garbage collection") \ \ + manageable(bool, PrintGCID, true, \ + "Print an identifier for each garbage collection") \ + \ product(bool, PrintGCTaskTimeStamps, false, \ "Print timestamps for individual gc worker thread tasks") \ \ diff --git a/hotspot/src/share/vm/utilities/ostream.cpp b/hotspot/src/share/vm/utilities/ostream.cpp index 54536c50742..8dcab1a9782 100644 --- a/hotspot/src/share/vm/utilities/ostream.cpp +++ b/hotspot/src/share/vm/utilities/ostream.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "compiler/compileLog.hpp" +#include "gc_implementation/shared/gcId.hpp" #include "oops/oop.inline.hpp" #include "runtime/arguments.hpp" #include "utilities/defaultStream.hpp" @@ -240,6 +241,14 @@ void outputStream::date_stamp(bool guard, return; } +void outputStream::gclog_stamp(const GCId& gc_id) { + date_stamp(PrintGCDateStamps); + stamp(PrintGCTimeStamps); + if (PrintGCID) { + print("#%u: ", gc_id.id()); + } +} + outputStream& outputStream::indent() { while (_position < _indentation) sp(); return *this; diff --git a/hotspot/src/share/vm/utilities/ostream.hpp b/hotspot/src/share/vm/utilities/ostream.hpp index 563bbe432b5..86d8099caa9 100644 --- a/hotspot/src/share/vm/utilities/ostream.hpp +++ b/hotspot/src/share/vm/utilities/ostream.hpp @@ -28,6 +28,7 @@ #include "memory/allocation.hpp" #include "runtime/timer.hpp" +class GCId; DEBUG_ONLY(class ResourceMark;) // Output streams for printing @@ -107,6 +108,7 @@ class outputStream : public ResourceObj { void date_stamp(bool guard) { date_stamp(guard, "", ": "); } + void gclog_stamp(const GCId& gc_id); // portable printing of 64 bit integers void print_jlong(jlong value); diff --git a/hotspot/test/gc/logging/TestGCId.java b/hotspot/test/gc/logging/TestGCId.java new file mode 100644 index 00000000000..98f9491467b --- /dev/null +++ b/hotspot/test/gc/logging/TestGCId.java @@ -0,0 +1,91 @@ +/* + * 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 TestGCId + * @bug 8043607 + * @summary Ensure that the GCId is logged + * @key gc + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.ProcessTools; +import com.oracle.java.testlibrary.OutputAnalyzer; + +public class TestGCId { + public static void main(String[] args) throws Exception { + testGCId("UseParallelGC", "PrintGC"); + testGCId("UseParallelGC", "PrintGCDetails"); + + testGCId("UseG1GC", "PrintGC"); + testGCId("UseG1GC", "PrintGCDetails"); + + testGCId("UseConcMarkSweepGC", "PrintGC"); + testGCId("UseConcMarkSweepGC", "PrintGCDetails"); + + testGCId("UseSerialGC", "PrintGC"); + testGCId("UseSerialGC", "PrintGCDetails"); + } + + private static void verifyContainsGCIDs(OutputAnalyzer output) { + output.shouldMatch("^#0: \\["); + output.shouldMatch("^#1: \\["); + output.shouldHaveExitValue(0); + } + + private static void verifyContainsNoGCIDs(OutputAnalyzer output) { + output.shouldNotMatch("^#[0-9]+: \\["); + output.shouldHaveExitValue(0); + } + + private static void testGCId(String gcFlag, String logFlag) throws Exception { + // GCID logging enabled + ProcessBuilder pb_enabled = + ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName()); + verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start())); + + // GCID logging disabled + ProcessBuilder pb_disabled = + ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName()); + verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start())); + + // GCID logging default + ProcessBuilder pb_default = + ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName()); + verifyContainsGCIDs(new OutputAnalyzer(pb_default.start())); + } + + static class GCTest { + private static byte[] garbage; + public static void main(String [] args) { + System.out.println("Creating garbage"); + // create 128MB of garbage. This should result in at least one GC + for (int i = 0; i < 1024; i++) { + garbage = new byte[128 * 1024]; + } + // do a system gc to get one more gc + System.gc(); + System.out.println("Done"); + } + } +} From 8e7c8f1d8897bf9a77b5665d10afd5c8b62245aa Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 4 Jun 2014 11:56:44 +0200 Subject: [PATCH 005/236] 8044775: Improve usage of umbrella header atomic.inline.hpp Reviewed-by: stefank, kvn --- .../src/cpu/zero/vm/cppInterpreter_zero.cpp | 1 + hotspot/src/os/aix/vm/osThread_aix.cpp | 6 +- hotspot/src/os/aix/vm/os_aix.cpp | 1 + hotspot/src/os/bsd/vm/os_bsd.cpp | 1 + hotspot/src/os/linux/vm/os_linux.cpp | 1 + .../src/os/solaris/vm/osThread_solaris.cpp | 1 - hotspot/src/os/solaris/vm/os_solaris.cpp | 1 + .../os/solaris/vm/thread_solaris.inline.hpp | 1 - .../src/os/windows/vm/osThread_windows.cpp | 1 - hotspot/src/os/windows/vm/os_windows.cpp | 1 + .../os/windows/vm/threadCritical_windows.cpp | 1 + .../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 1 + hotspot/src/share/vm/asm/assembler.cpp | 1 - hotspot/src/share/vm/c1/c1_Runtime1.cpp | 1 + .../share/vm/classfile/classLoaderData.cpp | 1 + .../src/share/vm/classfile/stringTable.cpp | 1 + .../src/share/vm/classfile/symbolTable.cpp | 1 + hotspot/src/share/vm/code/nmethod.cpp | 1 + .../src/share/vm/compiler/compileBroker.cpp | 1 + .../concurrentMarkSweepGeneration.cpp | 1 + .../g1/collectionSetChooser.cpp | 1 + .../gc_implementation/g1/concurrentMark.cpp | 1 + .../gc_implementation/g1/dirtyCardQueue.cpp | 2 +- .../gc_implementation/g1/g1CollectedHeap.cpp | 1 + .../gc_implementation/g1/g1GCPhaseTimes.cpp | 1 + .../gc_implementation/g1/g1HotCardCache.cpp | 2 +- .../vm/gc_implementation/g1/g1MarkSweep.cpp | 1 + .../g1/g1SATBCardTableModRefBS.cpp | 1 + .../vm/gc_implementation/g1/g1StringDedup.cpp | 14 +++++ .../vm/gc_implementation/g1/g1StringDedup.hpp | 9 +-- .../g1/g1StringDedupQueue.cpp | 1 + .../g1/g1StringDedupThread.cpp | 1 + .../vm/gc_implementation/g1/heapRegion.cpp | 1 + .../gc_implementation/g1/heapRegionRemSet.cpp | 1 + .../vm/gc_implementation/g1/sparsePRT.cpp | 1 + .../parNew/parNewGeneration.cpp | 1 + .../parallelScavenge/parMarkBitMap.cpp | 1 + .../parallelScavenge/psCompactionManager.cpp | 1 + .../parallelScavenge/psParallelCompact.cpp | 1 + .../vm/gc_implementation/shared/ageTable.cpp | 1 + .../shared/mutableNUMASpace.cpp | 1 + .../gc_implementation/shared/mutableSpace.cpp | 1 + .../vm/interpreter/bytecodeInterpreter.cpp | 1 + .../vm/interpreter/interpreterRuntime.cpp | 1 + hotspot/src/share/vm/memory/allocation.cpp | 2 +- hotspot/src/share/vm/memory/cardTableRS.cpp | 1 + .../src/share/vm/memory/defNewGeneration.cpp | 1 + hotspot/src/share/vm/memory/gcLocker.cpp | 12 ++++ hotspot/src/share/vm/memory/gcLocker.hpp | 14 +---- hotspot/src/share/vm/memory/space.cpp | 1 + .../vm/memory/specialized_oop_closures.hpp | 1 - .../memory/threadLocalAllocBuffer.inline.hpp | 1 - hotspot/src/share/vm/memory/universe.cpp | 1 + .../src/share/vm/oops/compiledICHolder.cpp | 24 +++++++ .../src/share/vm/oops/compiledICHolder.hpp | 23 ++----- hotspot/src/share/vm/oops/cpCache.cpp | 1 + hotspot/src/share/vm/oops/instanceKlass.cpp | 1 + hotspot/src/share/vm/oops/instanceKlass.hpp | 1 - hotspot/src/share/vm/oops/oop.pcgc.inline.hpp | 1 + hotspot/src/share/vm/oops/symbol.cpp | 4 +- hotspot/src/share/vm/opto/matcher.cpp | 1 - hotspot/src/share/vm/opto/runtime.cpp | 1 + hotspot/src/share/vm/prims/jni.cpp | 1 + hotspot/src/share/vm/prims/jvm.cpp | 2 + hotspot/src/share/vm/prims/jvmtiImpl.cpp | 2 +- .../src/share/vm/prims/jvmtiRawMonitor.cpp | 1 + hotspot/src/share/vm/prims/unsafe.cpp | 1 + .../src/share/vm/runtime/biasedLocking.cpp | 1 + hotspot/src/share/vm/runtime/extendedPC.hpp | 3 + hotspot/src/share/vm/runtime/frame.cpp | 1 + hotspot/src/share/vm/runtime/handles.cpp | 1 + .../src/share/vm/runtime/interfaceSupport.cpp | 1 + hotspot/src/share/vm/runtime/mutex.cpp | 1 + .../src/share/vm/runtime/objectMonitor.cpp | 1 + hotspot/src/share/vm/runtime/os.cpp | 1 + hotspot/src/share/vm/runtime/os.hpp | 1 - hotspot/src/share/vm/runtime/safepoint.cpp | 2 + .../src/share/vm/runtime/sharedRuntime.cpp | 1 + hotspot/src/share/vm/runtime/sweeper.cpp | 2 +- hotspot/src/share/vm/runtime/synchronizer.cpp | 1 + hotspot/src/share/vm/runtime/thread.cpp | 1 + hotspot/src/share/vm/runtime/thread.hpp | 56 ++++------------- .../src/share/vm/runtime/thread.inline.hpp | 62 +++++++++++++++++++ hotspot/src/share/vm/services/memPtr.cpp | 1 + hotspot/src/share/vm/services/memPtr.hpp | 1 - hotspot/src/share/vm/services/memRecorder.cpp | 2 +- hotspot/src/share/vm/services/memTracker.cpp | 2 +- .../src/share/vm/services/threadService.cpp | 1 + hotspot/src/share/vm/shark/sharkRuntime.cpp | 1 + .../src/share/vm/utilities/accessFlags.cpp | 1 + hotspot/src/share/vm/utilities/bitMap.cpp | 1 + .../src/share/vm/utilities/bitMap.inline.hpp | 2 +- hotspot/src/share/vm/utilities/debug.cpp | 1 + hotspot/src/share/vm/utilities/histogram.cpp | 1 + hotspot/src/share/vm/utilities/taskqueue.cpp | 1 + hotspot/src/share/vm/utilities/vmError.cpp | 1 + hotspot/src/share/vm/utilities/workgroup.cpp | 1 + 97 files changed, 218 insertions(+), 105 deletions(-) diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp index 9272724addc..fe9115be9ec 100644 --- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -37,6 +37,7 @@ #include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/os/aix/vm/osThread_aix.cpp b/hotspot/src/os/aix/vm/osThread_aix.cpp index 11f9c39168e..5c56387163c 100644 --- a/hotspot/src/os/aix/vm/osThread_aix.cpp +++ b/hotspot/src/os/aix/vm/osThread_aix.cpp @@ -24,17 +24,13 @@ */ // no precompiled headers -#include "runtime/atomic.hpp" + #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" #include "runtime/osThread.hpp" #include "runtime/safepoint.hpp" #include "runtime/vmThread.hpp" -#ifdef TARGET_ARCH_ppc -# include "assembler_ppc.inline.hpp" -#endif - void OSThread::pd_initialize() { assert(this != NULL, "check"); diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index e9d57c580ce..7ed2cce9480 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -48,6 +48,7 @@ #include "prims/jvm.h" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/extendedPC.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 7facffe684d..273bb308f32 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -41,6 +41,7 @@ #include "prims/jvm.h" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/extendedPC.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 7057bcd557b..fb780a4a0f8 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -41,6 +41,7 @@ #include "prims/jvm.h" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/extendedPC.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/os/solaris/vm/osThread_solaris.cpp b/hotspot/src/os/solaris/vm/osThread_solaris.cpp index 2ccd164e15b..d0e945c0246 100644 --- a/hotspot/src/os/solaris/vm/osThread_solaris.cpp +++ b/hotspot/src/os/solaris/vm/osThread_solaris.cpp @@ -23,7 +23,6 @@ */ // no precompiled headers -#include "runtime/atomic.hpp" #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 77cc8abb192..b952dc2d26a 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -41,6 +41,7 @@ #include "prims/jvm.h" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/extendedPC.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp b/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp index d7d6d378f1a..b5355335f39 100644 --- a/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp +++ b/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp @@ -29,7 +29,6 @@ #error "This file should only be included from thread.inline.hpp" #endif -#include "runtime/atomic.inline.hpp" #include "runtime/thread.hpp" #include "runtime/threadLocalStorage.hpp" diff --git a/hotspot/src/os/windows/vm/osThread_windows.cpp b/hotspot/src/os/windows/vm/osThread_windows.cpp index d65d0d6f557..7e8877a2099 100644 --- a/hotspot/src/os/windows/vm/osThread_windows.cpp +++ b/hotspot/src/os/windows/vm/osThread_windows.cpp @@ -23,7 +23,6 @@ */ // no precompiled headers -#include "runtime/atomic.hpp" #include "runtime/handles.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.hpp" diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index e3ca08a747e..219e9258885 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -44,6 +44,7 @@ #include "prims/jvm.h" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/extendedPC.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/os/windows/vm/threadCritical_windows.cpp b/hotspot/src/os/windows/vm/threadCritical_windows.cpp index c61a2961710..3ea83c1acb6 100644 --- a/hotspot/src/os/windows/vm/threadCritical_windows.cpp +++ b/hotspot/src/os/windows/vm/threadCritical_windows.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadCritical.hpp" diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index e78a2dba30b..7eccbe47013 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -38,6 +38,7 @@ #include "prims/jvm.h" #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/extendedPC.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/share/vm/asm/assembler.cpp b/hotspot/src/share/vm/asm/assembler.cpp index 274aa872e6f..2141d93b0da 100644 --- a/hotspot/src/share/vm/asm/assembler.cpp +++ b/hotspot/src/share/vm/asm/assembler.cpp @@ -26,7 +26,6 @@ #include "asm/macroAssembler.hpp" #include "asm/macroAssembler.inline.hpp" #include "asm/codeBuffer.hpp" -#include "runtime/atomic.hpp" #include "runtime/atomic.inline.hpp" #include "runtime/icache.hpp" #include "runtime/os.hpp" diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 3c2e2ecf8fe..a472718a64e 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -47,6 +47,7 @@ #include "memory/resourceArea.hpp" #include "oops/objArrayKlass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index efbde89ee30..e2e8302ffce 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -57,6 +57,7 @@ #include "memory/metadataFactory.hpp" #include "memory/metaspaceShared.hpp" #include "memory/oopFactory.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/jniHandles.hpp" #include "runtime/mutex.hpp" #include "runtime/safepoint.hpp" diff --git a/hotspot/src/share/vm/classfile/stringTable.cpp b/hotspot/src/share/vm/classfile/stringTable.cpp index 07ccbd354dc..4958e5ce7ee 100644 --- a/hotspot/src/share/vm/classfile/stringTable.cpp +++ b/hotspot/src/share/vm/classfile/stringTable.cpp @@ -33,6 +33,7 @@ #include "memory/gcLocker.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.inline2.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" #include "utilities/hashtable.inline.hpp" #if INCLUDE_ALL_GCS diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index dddf271e42a..00761e478ad 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -33,6 +33,7 @@ #include "memory/gcLocker.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.inline2.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" #include "utilities/hashtable.inline.hpp" diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 86264436755..40ca55a9b96 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -37,6 +37,7 @@ #include "oops/methodData.hpp" #include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/jvmtiImpl.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/sweeper.hpp" diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index ff292fbd747..738ec274517 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -36,6 +36,7 @@ #include "oops/oop.inline.hpp" #include "prims/nativeLookup.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 8e0706b4a10..104b9c4c4e8 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -56,6 +56,7 @@ #include "memory/tenuredGeneration.hpp" #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/globals_extension.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp index 07b92d0fbe5..b1d255051be 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/collectionSetChooser.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/g1/g1CollectorPolicy.hpp" #include "gc_implementation/g1/g1ErgoVerbose.hpp" #include "memory/space.inline.hpp" +#include "runtime/atomic.inline.hpp" // Even though we don't use the GC efficiency in our heuristics as // much as we used to, we still order according to GC efficiency. This diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 083ae40ca77..aba4dbb11f3 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -45,6 +45,7 @@ #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/prefetch.inline.hpp" #include "services/memTracker.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp b/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp index 6e84e514aa7..32b1f763f25 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp @@ -26,7 +26,7 @@ #include "gc_implementation/g1/dirtyCardQueue.hpp" #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #include "gc_implementation/g1/heapRegionRemSet.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" #include "runtime/thread.inline.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 23c72eac957..770060cb808 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -62,6 +62,7 @@ #include "memory/referenceProcessor.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.pcgc.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/prefetch.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/vmThread.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp index 8e361b63638..3dc72522c07 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/g1/g1GCPhaseTimes.hpp" #include "gc_implementation/g1/g1Log.hpp" #include "gc_implementation/g1/g1StringDedup.hpp" +#include "runtime/atomic.inline.hpp" // Helper class for avoiding interleaved logging class LineBuffer: public StackObj { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp index 9020961df88..a75ba66e06f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp @@ -28,7 +28,7 @@ #include "gc_implementation/g1/g1HotCardCache.hpp" #include "gc_implementation/g1/g1RemSet.hpp" #include "gc_implementation/g1/heapRegion.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h): _g1h(g1h), _hot_cache(NULL), _use_cache(false), _card_counts(g1h) {} diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp index 639c09e774f..ae3b83072da 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @@ -44,6 +44,7 @@ #include "oops/instanceRefKlass.hpp" #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/fprofiler.hpp" #include "runtime/synchronizer.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp index e741a0f7951..53d88d9cb64 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.cpp @@ -26,6 +26,7 @@ #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" #include "gc_implementation/g1/heapRegion.hpp" #include "gc_implementation/g1/satbQueue.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/thread.inline.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp index d353d7ebd2d..4bf636594e2 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.cpp @@ -31,6 +31,7 @@ #include "gc_implementation/g1/g1StringDedupStat.hpp" #include "gc_implementation/g1/g1StringDedupTable.hpp" #include "gc_implementation/g1/g1StringDedupThread.hpp" +#include "runtime/atomic.inline.hpp" bool G1StringDedup::_enabled = false; @@ -211,3 +212,16 @@ G1StringDedupUnlinkOrOopsDoClosure::~G1StringDedupUnlinkOrOopsDoClosure() { G1StringDedupTable::finish_rehash(_rehashed_table); } } + +// Atomically claims the next available queue for exclusive access by +// the current thread. Returns the queue number of the claimed queue. +size_t G1StringDedupUnlinkOrOopsDoClosure::claim_queue() { + return (size_t)Atomic::add_ptr(1, &_next_queue) - 1; +} + +// Atomically claims the next available table partition for exclusive +// access by the current thread. Returns the table bucket number where +// the claimed partition starts. +size_t G1StringDedupUnlinkOrOopsDoClosure::claim_table_partition(size_t partition_size) { + return (size_t)Atomic::add_ptr(partition_size, &_next_bucket) - partition_size; +} diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.hpp index 68f700f6585..80ee1fd02ad 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedup.hpp @@ -84,6 +84,7 @@ #include "memory/allocation.hpp" #include "oops/oop.hpp" +#include "runtime/atomic.hpp" class OopClosure; class BoolObjectClosure; @@ -174,16 +175,12 @@ public: // Atomically claims the next available queue for exclusive access by // the current thread. Returns the queue number of the claimed queue. - size_t claim_queue() { - return (size_t)Atomic::add_ptr(1, &_next_queue) - 1; - } + size_t claim_queue(); // Atomically claims the next available table partition for exclusive // access by the current thread. Returns the table bucket number where // the claimed partition starts. - size_t claim_table_partition(size_t partition_size) { - return (size_t)Atomic::add_ptr(partition_size, &_next_bucket) - partition_size; - } + size_t claim_table_partition(size_t partition_size); // Applies and returns the result from the is_alive closure, or // returns true if no such closure was provided. diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupQueue.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupQueue.cpp index 8ae53e353bc..723abbae095 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupQueue.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupQueue.cpp @@ -26,6 +26,7 @@ #include "classfile/javaClasses.hpp" #include "gc_implementation/g1/g1StringDedupQueue.hpp" #include "memory/gcLocker.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" #include "utilities/stack.inline.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp index 2187fbe89b3..3069770313e 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/g1/g1StringDedupTable.hpp" #include "gc_implementation/g1/g1StringDedupThread.hpp" #include "gc_implementation/g1/g1StringDedupQueue.hpp" +#include "runtime/atomic.inline.hpp" G1StringDedupThread* G1StringDedupThread::_thread = NULL; diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp index c12e3fe840c..f81ce0d6226 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -34,6 +34,7 @@ #include "memory/iterator.hpp" #include "memory/space.inline.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/orderAccess.inline.hpp" PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp index 382a3fb32ec..08f016d83d9 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp @@ -32,6 +32,7 @@ #include "memory/padded.inline.hpp" #include "memory/space.inline.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp index fe33cef7d28..bdb5899c928 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/sparsePRT.cpp @@ -29,6 +29,7 @@ #include "memory/allocation.inline.hpp" #include "memory/cardTableModRefBS.hpp" #include "memory/space.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" #define SPARSE_PRT_VERBOSE 0 diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index 7ac8dfd2489..c97f97516f1 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -47,6 +47,7 @@ #include "oops/objArrayOop.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.pcgc.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp index 19a055cc040..320e649e7c9 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp @@ -26,6 +26,7 @@ #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp" #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/os.hpp" #include "utilities/bitMap.inline.hpp" #include "services/memTracker.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp index 415d6294795..f838787bfdc 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp @@ -34,6 +34,7 @@ #include "oops/objArrayKlass.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.pcgc.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/stack.inline.hpp" PSOldGen* ParCompactionManager::_old_gen = NULL; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index a709586b34d..9f552fd1874 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -51,6 +51,7 @@ #include "oops/methodData.hpp" #include "oops/oop.inline.hpp" #include "oops/oop.pcgc.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/fprofiler.hpp" #include "runtime/safepoint.hpp" #include "runtime/vmThread.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/shared/ageTable.cpp b/hotspot/src/share/vm/gc_implementation/shared/ageTable.cpp index 634d0a5ddc5..d69035625ad 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/ageTable.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/ageTable.cpp @@ -28,6 +28,7 @@ #include "memory/collectorPolicy.hpp" #include "memory/resourceArea.hpp" #include "memory/sharedHeap.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/copy.hpp" /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University. diff --git a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp index 8590e850b60..965aedea053 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableNUMASpace.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/shared/spaceDecorator.hpp" #include "memory/sharedHeap.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/thread.inline.hpp" PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC diff --git a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp index 17a3ecbc14a..f5661fbb412 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/mutableSpace.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/macros.hpp" #if INCLUDE_ALL_GCS #include "gc_implementation/shared/mutableSpace.hpp" diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index 6c30983c2ea..cdb99f58670 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -37,6 +37,7 @@ #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/frame.inline.hpp" #include "runtime/handles.inline.hpp" diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp index 0f79ab5072f..42a721839a8 100644 --- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp +++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp @@ -42,6 +42,7 @@ #include "oops/symbol.hpp" #include "prims/jvmtiExport.hpp" #include "prims/nativeLookup.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/deoptimization.hpp" diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index c0254d9123f..588b01981d0 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -29,7 +29,7 @@ #include "memory/metaspaceShared.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/os.hpp" #include "runtime/task.hpp" #include "runtime/threadCritical.hpp" diff --git a/hotspot/src/share/vm/memory/cardTableRS.cpp b/hotspot/src/share/vm/memory/cardTableRS.cpp index 56af890a421..7c9d3618673 100644 --- a/hotspot/src/share/vm/memory/cardTableRS.cpp +++ b/hotspot/src/share/vm/memory/cardTableRS.cpp @@ -29,6 +29,7 @@ #include "memory/generation.hpp" #include "memory/space.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/java.hpp" #include "runtime/os.hpp" #include "utilities/macros.hpp" diff --git a/hotspot/src/share/vm/memory/defNewGeneration.cpp b/hotspot/src/share/vm/memory/defNewGeneration.cpp index ee2b50365b1..1a904b5c636 100644 --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp @@ -41,6 +41,7 @@ #include "memory/space.inline.hpp" #include "oops/instanceRefKlass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/java.hpp" #include "runtime/prefetch.inline.hpp" #include "runtime/thread.inline.hpp" diff --git a/hotspot/src/share/vm/memory/gcLocker.cpp b/hotspot/src/share/vm/memory/gcLocker.cpp index 96742637939..fae40920a87 100644 --- a/hotspot/src/share/vm/memory/gcLocker.cpp +++ b/hotspot/src/share/vm/memory/gcLocker.cpp @@ -26,6 +26,7 @@ #include "memory/gcLocker.inline.hpp" #include "memory/resourceArea.hpp" #include "memory/sharedHeap.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/thread.inline.hpp" volatile jint GC_locker::_jni_lock_count = 0; @@ -59,6 +60,17 @@ void GC_locker::verify_critical_count() { assert(_jni_lock_count == count, "must be equal"); } } + +// In debug mode track the locking state at all times +void GC_locker::increment_debug_jni_lock_count() { + assert(_debug_jni_lock_count >= 0, "bad value"); + Atomic::inc(&_debug_jni_lock_count); +} + +void GC_locker::decrement_debug_jni_lock_count() { + assert(_debug_jni_lock_count > 0, "bad value"); + Atomic::dec(&_debug_jni_lock_count); +} #endif bool GC_locker::check_active_before_gc() { diff --git a/hotspot/src/share/vm/memory/gcLocker.hpp b/hotspot/src/share/vm/memory/gcLocker.hpp index f12aa675552..161bd42993f 100644 --- a/hotspot/src/share/vm/memory/gcLocker.hpp +++ b/hotspot/src/share/vm/memory/gcLocker.hpp @@ -94,18 +94,8 @@ class GC_locker: public AllStatic { } // In debug mode track the locking state at all times - static void increment_debug_jni_lock_count() { -#ifdef ASSERT - assert(_debug_jni_lock_count >= 0, "bad value"); - Atomic::inc(&_debug_jni_lock_count); -#endif - } - static void decrement_debug_jni_lock_count() { -#ifdef ASSERT - assert(_debug_jni_lock_count > 0, "bad value"); - Atomic::dec(&_debug_jni_lock_count); -#endif - } + static void increment_debug_jni_lock_count() NOT_DEBUG_RETURN; + static void decrement_debug_jni_lock_count() NOT_DEBUG_RETURN; // Set the current lock count static void set_jni_lock_count(int count) { diff --git a/hotspot/src/share/vm/memory/space.cpp b/hotspot/src/share/vm/memory/space.cpp index ae29692a62b..396a743ac3b 100644 --- a/hotspot/src/share/vm/memory/space.cpp +++ b/hotspot/src/share/vm/memory/space.cpp @@ -37,6 +37,7 @@ #include "oops/oop.inline.hpp" #include "oops/oop.inline2.hpp" #include "runtime/java.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/prefetch.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/safepoint.hpp" diff --git a/hotspot/src/share/vm/memory/specialized_oop_closures.hpp b/hotspot/src/share/vm/memory/specialized_oop_closures.hpp index 24986b95089..b4e2fa33a22 100644 --- a/hotspot/src/share/vm/memory/specialized_oop_closures.hpp +++ b/hotspot/src/share/vm/memory/specialized_oop_closures.hpp @@ -25,7 +25,6 @@ #ifndef SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP #define SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP -#include "runtime/atomic.hpp" #include "utilities/macros.hpp" #if INCLUDE_ALL_GCS #include "gc_implementation/g1/g1_specialized_oop_closures.hpp" diff --git a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.inline.hpp b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.inline.hpp index cf3fefbfe3a..60e645fa6ff 100644 --- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.inline.hpp +++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.inline.hpp @@ -27,7 +27,6 @@ #include "gc_interface/collectedHeap.hpp" #include "memory/threadLocalAllocBuffer.hpp" -#include "runtime/atomic.hpp" #include "runtime/thread.hpp" #include "utilities/copy.hpp" diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 5053b46e8c8..9d5a2a6cbae 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -53,6 +53,7 @@ #include "oops/typeArrayKlass.hpp" #include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/deoptimization.hpp" #include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" diff --git a/hotspot/src/share/vm/oops/compiledICHolder.cpp b/hotspot/src/share/vm/oops/compiledICHolder.cpp index 72268079296..c17ca240a85 100644 --- a/hotspot/src/share/vm/oops/compiledICHolder.cpp +++ b/hotspot/src/share/vm/oops/compiledICHolder.cpp @@ -27,11 +27,27 @@ #include "oops/klass.hpp" #include "oops/method.hpp" #include "oops/oop.inline2.hpp" +#include "runtime/atomic.inline.hpp" volatile int CompiledICHolder::_live_count; volatile int CompiledICHolder::_live_not_claimed_count; +CompiledICHolder::CompiledICHolder(Method* method, Klass* klass) + : _holder_method(method), _holder_klass(klass) { +#ifdef ASSERT + Atomic::inc(&_live_count); + Atomic::inc(&_live_not_claimed_count); +#endif // ASSERT +} + +#ifdef ASSERT +CompiledICHolder::~CompiledICHolder() { + assert(_live_count > 0, "underflow"); + Atomic::dec(&_live_count); +} +#endif // ASSERT + // Printing void CompiledICHolder::print_on(outputStream* st) const { @@ -51,3 +67,11 @@ void CompiledICHolder::verify_on(outputStream* st) { guarantee(holder_method()->is_method(), "should be method"); guarantee(holder_klass()->is_klass(), "should be klass"); } + +#ifdef ASSERT + +void CompiledICHolder::claim() { + Atomic::dec(&_live_not_claimed_count); +} + +#endif // ASSERT diff --git a/hotspot/src/share/vm/oops/compiledICHolder.hpp b/hotspot/src/share/vm/oops/compiledICHolder.hpp index d3ca41f6ba8..c3e899fde88 100644 --- a/hotspot/src/share/vm/oops/compiledICHolder.hpp +++ b/hotspot/src/share/vm/oops/compiledICHolder.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP #include "oops/oop.hpp" +#include "utilities/macros.hpp" // A CompiledICHolder* is a helper object for the inline cache implementation. // It holds an intermediate value (method+klass pair) used when converting from @@ -50,20 +51,8 @@ class CompiledICHolder : public CHeapObj { public: // Constructor - CompiledICHolder(Method* method, Klass* klass) - : _holder_method(method), _holder_klass(klass) { -#ifdef ASSERT - Atomic::inc(&_live_count); - Atomic::inc(&_live_not_claimed_count); -#endif - } - - ~CompiledICHolder() { -#ifdef ASSERT - assert(_live_count > 0, "underflow"); - Atomic::dec(&_live_count); -#endif - } + CompiledICHolder(Method* method, Klass* klass); + ~CompiledICHolder() NOT_DEBUG_RETURN; static int live_count() { return _live_count; } static int live_not_claimed_count() { return _live_not_claimed_count; } @@ -91,11 +80,7 @@ class CompiledICHolder : public CHeapObj { const char* internal_name() const { return "{compiledICHolder}"; } - void claim() { -#ifdef ASSERT - Atomic::dec(&_live_not_claimed_count); -#endif - } + void claim() NOT_DEBUG_RETURN; }; #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index d601367ba99..0c956e01029 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -32,6 +32,7 @@ #include "oops/oop.inline.hpp" #include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/methodHandles.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "utilities/macros.hpp" diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index bcf9dc0a097..a3bb98e43ea 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -51,6 +51,7 @@ #include "prims/jvmtiRedefineClasses.hpp" #include "prims/jvmtiThreadState.hpp" #include "prims/methodComparator.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 57b06870290..d6c919e9462 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -32,7 +32,6 @@ #include "oops/fieldInfo.hpp" #include "oops/instanceOop.hpp" #include "oops/klassVtable.hpp" -#include "runtime/atomic.hpp" #include "runtime/handles.hpp" #include "runtime/os.hpp" #include "utilities/accessFlags.hpp" diff --git a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp index 596bbc6d123..5a8d4d0afaf 100644 --- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp +++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP #include "utilities/macros.hpp" +#include "runtime/atomic.inline.hpp" #if INCLUDE_ALL_GCS #include "gc_implementation/parNew/parNewGeneration.hpp" #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" diff --git a/hotspot/src/share/vm/oops/symbol.cpp b/hotspot/src/share/vm/oops/symbol.cpp index cab865503fa..d3d1f13b63f 100644 --- a/hotspot/src/share/vm/oops/symbol.cpp +++ b/hotspot/src/share/vm/oops/symbol.cpp @@ -26,11 +26,11 @@ #include "precompiled.hpp" #include "classfile/altHashing.hpp" #include "classfile/classLoaderData.hpp" +#include "memory/allocation.inline.hpp" +#include "memory/resourceArea.hpp" #include "oops/symbol.hpp" #include "runtime/atomic.inline.hpp" #include "runtime/os.hpp" -#include "memory/allocation.inline.hpp" -#include "memory/resourceArea.hpp" Symbol::Symbol(const u1* name, int length, int refcount) { _refcount = refcount; diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index 2b2f11f9b4e..a8321b07753 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -36,7 +36,6 @@ #include "opto/runtime.hpp" #include "opto/type.hpp" #include "opto/vectornode.hpp" -#include "runtime/atomic.hpp" #include "runtime/os.hpp" #ifdef TARGET_ARCH_MODEL_x86_32 # include "adfiles/ad_x86_32.hpp" diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index 632a03f2304..dba4f047b5a 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -55,6 +55,7 @@ #include "opto/mulnode.hpp" #include "opto/runtime.hpp" #include "opto/subnode.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index cdb53afe1b7..109a31af586 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -59,6 +59,7 @@ #include "prims/jvm_misc.hpp" #include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/fprofiler.hpp" diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 69e45bd11f7..0dbeea8a8a4 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -44,6 +44,7 @@ #include "prims/nativeLookup.hpp" #include "prims/privilegedStack.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/dtraceJSDT.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" @@ -55,6 +56,7 @@ #include "runtime/os.hpp" #include "runtime/perfData.hpp" #include "runtime/reflection.hpp" +#include "runtime/thread.inline.hpp" #include "runtime/vframe.hpp" #include "runtime/vm_operations.hpp" #include "services/attachListener.hpp" diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index 0d6d00d4ec6..328e9d869af 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -32,7 +32,7 @@ #include "prims/jvmtiEventController.inline.hpp" #include "prims/jvmtiImpl.hpp" #include "prims/jvmtiRedefineClasses.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/deoptimization.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" diff --git a/hotspot/src/share/vm/prims/jvmtiRawMonitor.cpp b/hotspot/src/share/vm/prims/jvmtiRawMonitor.cpp index 4be4d277055..003f12f0c0a 100644 --- a/hotspot/src/share/vm/prims/jvmtiRawMonitor.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRawMonitor.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "prims/jvmtiRawMonitor.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/thread.inline.hpp" diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 332f8fb74ab..4763d6f13e5 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -31,6 +31,7 @@ #include "memory/allocation.inline.hpp" #include "prims/jni.h" #include "prims/jvm.h" +#include "runtime/atomic.inline.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/prefetch.inline.hpp" diff --git a/hotspot/src/share/vm/runtime/biasedLocking.cpp b/hotspot/src/share/vm/runtime/biasedLocking.cpp index c8c2acf37df..f89f71bca6a 100644 --- a/hotspot/src/share/vm/runtime/biasedLocking.cpp +++ b/hotspot/src/share/vm/runtime/biasedLocking.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "oops/klass.inline.hpp" #include "oops/markOop.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/basicLock.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/task.hpp" diff --git a/hotspot/src/share/vm/runtime/extendedPC.hpp b/hotspot/src/share/vm/runtime/extendedPC.hpp index 7a1ca4abe45..ea937416ac5 100644 --- a/hotspot/src/share/vm/runtime/extendedPC.hpp +++ b/hotspot/src/share/vm/runtime/extendedPC.hpp @@ -25,6 +25,9 @@ #ifndef SHARE_VM_RUNTIME_EXTENDEDPC_HPP #define SHARE_VM_RUNTIME_EXTENDEDPC_HPP +#include "memory/allocation.hpp" +#include "utilities/globalDefinitions.hpp" + // An ExtendedPC contains the _pc from a signal handler in a platform // independent way. diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp index 2f7cb8f186a..5768693b406 100644 --- a/hotspot/src/share/vm/runtime/frame.cpp +++ b/hotspot/src/share/vm/runtime/frame.cpp @@ -44,6 +44,7 @@ #include "runtime/signature.hpp" #include "runtime/stubCodeGenerator.hpp" #include "runtime/stubRoutines.hpp" +#include "runtime/thread.inline.hpp" #include "utilities/decoder.hpp" #ifdef TARGET_ARCH_x86 diff --git a/hotspot/src/share/vm/runtime/handles.cpp b/hotspot/src/share/vm/runtime/handles.cpp index e80b6d79828..5d358538930 100644 --- a/hotspot/src/share/vm/runtime/handles.cpp +++ b/hotspot/src/share/vm/runtime/handles.cpp @@ -26,6 +26,7 @@ #include "memory/allocation.inline.hpp" #include "oops/constantPool.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/thread.inline.hpp" #ifdef TARGET_OS_FAMILY_linux diff --git a/hotspot/src/share/vm/runtime/interfaceSupport.cpp b/hotspot/src/share/vm/runtime/interfaceSupport.cpp index 09757155d9d..25953f3d3bc 100644 --- a/hotspot/src/share/vm/runtime/interfaceSupport.cpp +++ b/hotspot/src/share/vm/runtime/interfaceSupport.cpp @@ -28,6 +28,7 @@ #include "gc_interface/collectedHeap.inline.hpp" #include "memory/genCollectedHeap.hpp" #include "memory/resourceArea.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/orderAccess.inline.hpp" diff --git a/hotspot/src/share/vm/runtime/mutex.cpp b/hotspot/src/share/vm/runtime/mutex.cpp index 34c9366f0d1..42bbd5c1e95 100644 --- a/hotspot/src/share/vm/runtime/mutex.cpp +++ b/hotspot/src/share/vm/runtime/mutex.cpp @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/mutex.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/osThread.hpp" diff --git a/hotspot/src/share/vm/runtime/objectMonitor.cpp b/hotspot/src/share/vm/runtime/objectMonitor.cpp index d9682ebf601..c7a91f470c6 100644 --- a/hotspot/src/share/vm/runtime/objectMonitor.cpp +++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp @@ -27,6 +27,7 @@ #include "memory/resourceArea.hpp" #include "oops/markOop.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/mutexLocker.hpp" diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index dc5d664989b..5666aa0d45f 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -40,6 +40,7 @@ #include "prims/jvm_misc.hpp" #include "prims/privilegedStack.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/java.hpp" diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index c0c81a1f2ad..2c4355ad9eb 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -26,7 +26,6 @@ #define SHARE_VM_RUNTIME_OS_HPP #include "jvmtifiles/jvmti.h" -#include "runtime/atomic.hpp" #include "runtime/extendedPC.hpp" #include "runtime/handles.hpp" #include "utilities/top.hpp" diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index e71185d431d..7e756b07cd4 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -32,10 +32,12 @@ #include "code/scopeDesc.hpp" #include "gc_interface/collectedHeap.hpp" #include "interpreter/interpreter.hpp" +#include "memory/gcLocker.inline.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index efd8be473b3..3610b9295f0 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -42,6 +42,7 @@ #include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/methodHandles.hpp" #include "prims/nativeLookup.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/arguments.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/handles.inline.hpp" diff --git a/hotspot/src/share/vm/runtime/sweeper.cpp b/hotspot/src/share/vm/runtime/sweeper.cpp index 5ec575aa356..0a964ac8728 100644 --- a/hotspot/src/share/vm/runtime/sweeper.cpp +++ b/hotspot/src/share/vm/runtime/sweeper.cpp @@ -30,7 +30,7 @@ #include "compiler/compileBroker.hpp" #include "memory/resourceArea.hpp" #include "oops/method.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/orderAccess.inline.hpp" diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp index 7af5fe72b62..a7de4bda77a 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.cpp +++ b/hotspot/src/share/vm/runtime/synchronizer.cpp @@ -27,6 +27,7 @@ #include "memory/resourceArea.hpp" #include "oops/markOop.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 7031620a283..f66a056aa51 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -46,6 +46,7 @@ #include "prims/jvmtiThreadState.hpp" #include "prims/privilegedStack.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/deoptimization.hpp" #include "runtime/fprofiler.hpp" diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 68c9248dea4..003932e74f3 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -343,42 +343,16 @@ class Thread: public ThreadShadow { bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; } - void set_suspend_flag(SuspendFlags f) { - assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch"); - uint32_t flags; - do { - flags = _suspend_flags; - } - while (Atomic::cmpxchg((jint)(flags | f), - (volatile jint*)&_suspend_flags, - (jint)flags) != (jint)flags); - } - void clear_suspend_flag(SuspendFlags f) { - assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch"); - uint32_t flags; - do { - flags = _suspend_flags; - } - while (Atomic::cmpxchg((jint)(flags & ~f), - (volatile jint*)&_suspend_flags, - (jint)flags) != (jint)flags); - } + inline void set_suspend_flag(SuspendFlags f); + inline void clear_suspend_flag(SuspendFlags f); - void set_has_async_exception() { - set_suspend_flag(_has_async_exception); - } - void clear_has_async_exception() { - clear_suspend_flag(_has_async_exception); - } + inline void set_has_async_exception(); + inline void clear_has_async_exception(); bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; } - void set_critical_native_unlock() { - set_suspend_flag(_critical_native_unlock); - } - void clear_critical_native_unlock() { - clear_suspend_flag(_critical_native_unlock); - } + inline void set_critical_native_unlock(); + inline void clear_critical_native_unlock(); // Support for Unhandled Oop detection #ifdef CHECK_UNHANDLED_OOPS @@ -1074,8 +1048,8 @@ class JavaThread: public Thread { // Suspend/resume support for JavaThread private: - void set_ext_suspended() { set_suspend_flag (_ext_suspended); } - void clear_ext_suspended() { clear_suspend_flag(_ext_suspended); } + inline void set_ext_suspended(); + inline void clear_ext_suspended(); public: void java_suspend(); @@ -1123,11 +1097,11 @@ class JavaThread: public Thread { // via the appropriate -XX options. bool wait_for_ext_suspend_completion(int count, int delay, uint32_t *bits); - void set_external_suspend() { set_suspend_flag (_external_suspend); } - void clear_external_suspend() { clear_suspend_flag(_external_suspend); } + inline void set_external_suspend(); + inline void clear_external_suspend(); - void set_deopt_suspend() { set_suspend_flag (_deopt_suspend); } - void clear_deopt_suspend() { clear_suspend_flag(_deopt_suspend); } + inline void set_deopt_suspend(); + inline void clear_deopt_suspend(); bool is_deopt_suspend() { return (_suspend_flags & _deopt_suspend) != 0; } bool is_external_suspend() const { @@ -1215,11 +1189,7 @@ class JavaThread: public Thread { void set_pending_unsafe_access_error() { _special_runtime_exit_condition = _async_unsafe_access_error; } - void set_pending_async_exception(oop e) { - _pending_async_exception = e; - _special_runtime_exit_condition = _async_exception; - set_has_async_exception(); - } + inline void set_pending_async_exception(oop e); // Fast-locking support bool is_lock_owned(address adr) const; diff --git a/hotspot/src/share/vm/runtime/thread.inline.hpp b/hotspot/src/share/vm/runtime/thread.inline.hpp index b68e7d1ae38..26a3330805b 100644 --- a/hotspot/src/share/vm/runtime/thread.inline.hpp +++ b/hotspot/src/share/vm/runtime/thread.inline.hpp @@ -27,6 +27,7 @@ #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE +#include "runtime/atomic.inline.hpp" #include "runtime/thread.hpp" #ifdef TARGET_OS_FAMILY_linux # include "thread_linux.inline.hpp" @@ -46,6 +47,40 @@ #undef SHARE_VM_RUNTIME_THREAD_INLINE_HPP_SCOPE +inline void Thread::set_suspend_flag(SuspendFlags f) { + assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch"); + uint32_t flags; + do { + flags = _suspend_flags; + } + while (Atomic::cmpxchg((jint)(flags | f), + (volatile jint*)&_suspend_flags, + (jint)flags) != (jint)flags); +} +inline void Thread::clear_suspend_flag(SuspendFlags f) { + assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch"); + uint32_t flags; + do { + flags = _suspend_flags; + } + while (Atomic::cmpxchg((jint)(flags & ~f), + (volatile jint*)&_suspend_flags, + (jint)flags) != (jint)flags); +} + +inline void Thread::set_has_async_exception() { + set_suspend_flag(_has_async_exception); +} +inline void Thread::clear_has_async_exception() { + clear_suspend_flag(_has_async_exception); +} +inline void Thread::set_critical_native_unlock() { + set_suspend_flag(_critical_native_unlock); +} +inline void Thread::clear_critical_native_unlock() { + clear_suspend_flag(_critical_native_unlock); +} + inline jlong Thread::cooked_allocated_bytes() { jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes); if (UseTLAB) { @@ -59,6 +94,33 @@ inline jlong Thread::cooked_allocated_bytes() { return allocated_bytes; } +inline void JavaThread::set_ext_suspended() { + set_suspend_flag (_ext_suspended); +} +inline void JavaThread::clear_ext_suspended() { + clear_suspend_flag(_ext_suspended); +} + +inline void JavaThread::set_external_suspend() { + set_suspend_flag(_external_suspend); +} +inline void JavaThread::clear_external_suspend() { + clear_suspend_flag(_external_suspend); +} + +inline void JavaThread::set_deopt_suspend() { + set_suspend_flag(_deopt_suspend); +} +inline void JavaThread::clear_deopt_suspend() { + clear_suspend_flag(_deopt_suspend); +} + +inline void JavaThread::set_pending_async_exception(oop e) { + _pending_async_exception = e; + _special_runtime_exit_condition = _async_exception; + set_has_async_exception(); +} + #ifdef PPC64 inline JavaThreadState JavaThread::thread_state() const { return (JavaThreadState) OrderAccess::load_acquire((volatile jint*)&_thread_state); diff --git a/hotspot/src/share/vm/services/memPtr.cpp b/hotspot/src/share/vm/services/memPtr.cpp index bc460517c58..2bab4b28d9a 100644 --- a/hotspot/src/share/vm/services/memPtr.cpp +++ b/hotspot/src/share/vm/services/memPtr.cpp @@ -23,6 +23,7 @@ */ #include "precompiled.hpp" +#include "runtime/atomic.inline.hpp" #include "services/memPtr.hpp" #include "services/memTracker.hpp" diff --git a/hotspot/src/share/vm/services/memPtr.hpp b/hotspot/src/share/vm/services/memPtr.hpp index c54f0934a94..cae454cc318 100644 --- a/hotspot/src/share/vm/services/memPtr.hpp +++ b/hotspot/src/share/vm/services/memPtr.hpp @@ -26,7 +26,6 @@ #define SHARE_VM_SERVICES_MEM_PTR_HPP #include "memory/allocation.hpp" -#include "runtime/atomic.hpp" #include "runtime/os.hpp" #include "runtime/safepoint.hpp" diff --git a/hotspot/src/share/vm/services/memRecorder.cpp b/hotspot/src/share/vm/services/memRecorder.cpp index afe7bd245df..b8707f58360 100644 --- a/hotspot/src/share/vm/services/memRecorder.cpp +++ b/hotspot/src/share/vm/services/memRecorder.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "services/memBaseline.hpp" #include "services/memRecorder.hpp" #include "services/memPtr.hpp" diff --git a/hotspot/src/share/vm/services/memTracker.cpp b/hotspot/src/share/vm/services/memTracker.cpp index 213e24e1bd0..190c004b374 100644 --- a/hotspot/src/share/vm/services/memTracker.cpp +++ b/hotspot/src/share/vm/services/memTracker.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "oops/instanceKlass.hpp" -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" diff --git a/hotspot/src/share/vm/services/threadService.cpp b/hotspot/src/share/vm/services/threadService.cpp index 21d87567eed..74d3ea1383a 100644 --- a/hotspot/src/share/vm/services/threadService.cpp +++ b/hotspot/src/share/vm/services/threadService.cpp @@ -29,6 +29,7 @@ #include "memory/oopFactory.hpp" #include "oops/instanceKlass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/thread.hpp" diff --git a/hotspot/src/share/vm/shark/sharkRuntime.cpp b/hotspot/src/share/vm/shark/sharkRuntime.cpp index fd9916e111b..bf609bce455 100644 --- a/hotspot/src/share/vm/shark/sharkRuntime.cpp +++ b/hotspot/src/share/vm/shark/sharkRuntime.cpp @@ -24,6 +24,7 @@ */ #include "precompiled.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/deoptimization.hpp" #include "runtime/thread.hpp" diff --git a/hotspot/src/share/vm/utilities/accessFlags.cpp b/hotspot/src/share/vm/utilities/accessFlags.cpp index d9279428ed0..936fdc1e933 100644 --- a/hotspot/src/share/vm/utilities/accessFlags.cpp +++ b/hotspot/src/share/vm/utilities/accessFlags.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/accessFlags.hpp" #ifdef TARGET_OS_FAMILY_linux # include "os_linux.inline.hpp" diff --git a/hotspot/src/share/vm/utilities/bitMap.cpp b/hotspot/src/share/vm/utilities/bitMap.cpp index bfcda11fdea..446af01e6fa 100644 --- a/hotspot/src/share/vm/utilities/bitMap.cpp +++ b/hotspot/src/share/vm/utilities/bitMap.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/copy.hpp" #ifdef TARGET_OS_FAMILY_linux diff --git a/hotspot/src/share/vm/utilities/bitMap.inline.hpp b/hotspot/src/share/vm/utilities/bitMap.inline.hpp index 318b178f147..f565462a1a7 100644 --- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_VM_UTILITIES_BITMAP_INLINE_HPP #define SHARE_VM_UTILITIES_BITMAP_INLINE_HPP -#include "runtime/atomic.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/bitMap.hpp" #ifdef ASSERT diff --git a/hotspot/src/share/vm/utilities/debug.cpp b/hotspot/src/share/vm/utilities/debug.cpp index ff3bc5d4c81..445cf55a7f7 100644 --- a/hotspot/src/share/vm/utilities/debug.cpp +++ b/hotspot/src/share/vm/utilities/debug.cpp @@ -39,6 +39,7 @@ #include "oops/oop.inline.hpp" #include "prims/privilegedStack.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/frame.hpp" #include "runtime/java.hpp" #include "runtime/sharedRuntime.hpp" diff --git a/hotspot/src/share/vm/utilities/histogram.cpp b/hotspot/src/share/vm/utilities/histogram.cpp index 5bc7c59e90d..f4d7091cd22 100644 --- a/hotspot/src/share/vm/utilities/histogram.cpp +++ b/hotspot/src/share/vm/utilities/histogram.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "utilities/histogram.hpp" #ifdef ASSERT diff --git a/hotspot/src/share/vm/utilities/taskqueue.cpp b/hotspot/src/share/vm/utilities/taskqueue.cpp index a3daa8847b6..9a992c1664d 100644 --- a/hotspot/src/share/vm/utilities/taskqueue.cpp +++ b/hotspot/src/share/vm/utilities/taskqueue.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "oops/oop.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/os.hpp" #include "runtime/thread.inline.hpp" #include "utilities/debug.hpp" diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index 62d8ba6b176..d18df9ad4e3 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -27,6 +27,7 @@ #include "gc_interface/collectedHeap.hpp" #include "prims/whitebox.hpp" #include "runtime/arguments.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/frame.inline.hpp" #include "runtime/init.hpp" #include "runtime/os.hpp" diff --git a/hotspot/src/share/vm/utilities/workgroup.cpp b/hotspot/src/share/vm/utilities/workgroup.cpp index 3d1f1eef7a6..6b5d8969798 100644 --- a/hotspot/src/share/vm/utilities/workgroup.cpp +++ b/hotspot/src/share/vm/utilities/workgroup.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" +#include "runtime/atomic.inline.hpp" #include "runtime/os.hpp" #include "utilities/workgroup.hpp" From 71b76d4073ca7f764b5bbc72dab0e678b392eac2 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Fri, 6 Jun 2014 14:46:42 +0200 Subject: [PATCH 006/236] 8043492: ad_x86_64_misc.obj : error LNK2011: precompiled object not linked in; image may not run Added _build_pch_file.obj to LD_FLAGS and cleaned up support for older Visual Studio versions Reviewed-by: twisti, lfoltan, sla, kvn --- hotspot/make/windows/create.bat | 27 +---- hotspot/make/windows/makefiles/compile.make | 114 +----------------- hotspot/make/windows/makefiles/rules.make | 31 +---- hotspot/make/windows/makefiles/sa.make | 11 +- hotspot/make/windows/makefiles/sanity.make | 10 +- hotspot/make/windows/makefiles/vm.make | 4 +- .../make/windows/projectfiles/common/Makefile | 3 +- hotspot/src/share/vm/runtime/vm_version.cpp | 14 +-- 8 files changed, 19 insertions(+), 195 deletions(-) diff --git a/hotspot/make/windows/create.bat b/hotspot/make/windows/create.bat index a9a8acea6d2..fb0d450187a 100644 --- a/hotspot/make/windows/create.bat +++ b/hotspot/make/windows/create.bat @@ -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 @@ REM figure out MSC version 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 ************************************************************** diff --git a/hotspot/make/windows/makefiles/compile.make b/hotspot/make/windows/makefiles/compile.make index 9da2742335e..a4d1c0d4c3e 100644 --- a/hotspot/make/windows/makefiles/compile.make +++ b/hotspot/make/windows/makefiles/compile.make @@ -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 @@ CXX_FLAGS=$(CXX_FLAGS) /Zi # 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 @@ CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP # 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 @@ CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP # 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 @@ MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION) !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 @@ MT=mt.exe !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) diff --git a/hotspot/make/windows/makefiles/rules.make b/hotspot/make/windows/makefiles/rules.make index c5d565a2880..08a6a85e101 100644 --- a/hotspot/make/windows/makefiles/rules.make +++ b/hotspot/make/windows/makefiles/rules.make @@ -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 @@ BOOT_TARGET_CLASS_VERSION=6 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" - -VcVersion=VC10 -ProjectFile=jvm.vcxproj - -!elseif "$(MSC_VER)" == "1700" -# This is VS2012, but it loads VS10 projects just fine (and will +# VS2012 and VS2013 loads VS10 projects just fine (and will # upgrade them automatically to VS2012 format). - VcVersion=VC10 ProjectFile=jvm.vcxproj -!else - -VcVersion=VC7 - -!endif diff --git a/hotspot/make/windows/makefiles/sa.make b/hotspot/make/windows/makefiles/sa.make index 2208da9e3d8..13bb8130ef4 100644 --- a/hotspot/make/windows/makefiles/sa.make +++ b/hotspot/make/windows/makefiles/sa.make @@ -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 @@ checkAndBuildSA:: $(SAWINDBG) # 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" diff --git a/hotspot/make/windows/makefiles/sanity.make b/hotspot/make/windows/makefiles/sanity.make index b502cfaa65f..515b0bb1b50 100644 --- a/hotspot/make/windows/makefiles/sanity.make +++ b/hotspot/make/windows/makefiles/sanity.make @@ -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. diff --git a/hotspot/make/windows/makefiles/vm.make b/hotspot/make/windows/makefiles/vm.make index e4caa13dea2..d8040f89ed8 100644 --- a/hotspot/make/windows/makefiles/vm.make +++ b/hotspot/make/windows/makefiles/vm.make @@ -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 @@ CXX_DONT_USE_PCH=/D DONT_USE_PRECOMPILED_HEADER !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 diff --git a/hotspot/make/windows/projectfiles/common/Makefile b/hotspot/make/windows/projectfiles/common/Makefile index 51d4e6f1f11..1fc1350706e 100644 --- a/hotspot/make/windows/projectfiles/common/Makefile +++ b/hotspot/make/windows/projectfiles/common/Makefile @@ -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 @@ ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -def 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: diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp index 5df7d221a2b..03fd43355bf 100644 --- a/hotspot/src/share/vm/runtime/vm_version.cpp +++ b/hotspot/src/share/vm/runtime/vm_version.cpp @@ -222,20 +222,12 @@ const char* Abstract_VM_Version::internal_vm_info_string() { #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 From 1510b7c75e2c6e3ab862653614f1e10c324265fb Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Mon, 9 Jun 2014 11:03:09 +0200 Subject: [PATCH 007/236] 8044797: Building with clang gives: fatal error: file '...' has been modified since the precompiled header was built Reviewed-by: dholmes, dcubed --- hotspot/make/bsd/makefiles/vm.make | 1 + hotspot/make/linux/makefiles/vm.make | 1 + 2 files changed, 2 insertions(+) diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make index 77dde8bc930..56beb6c6ba5 100644 --- a/hotspot/make/bsd/makefiles/vm.make +++ b/hotspot/make/bsd/makefiles/vm.make @@ -295,6 +295,7 @@ endif $(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: diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make index bcf87c043ec..c91463aae13 100644 --- a/hotspot/make/linux/makefiles/vm.make +++ b/hotspot/make/linux/makefiles/vm.make @@ -290,6 +290,7 @@ LINK_VM = $(LINK_LIB.CC) $(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: From 70c76ec8c45b4e0d9bad4168a558a95a25b901eb Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Tue, 10 Jun 2014 14:04:37 -0400 Subject: [PATCH 008/236] 8044738: Check attribute_length of EnclosingMethod attribute Add check that attribute_length == 4. Reviewed-by: fparain, coleenp, lfoltan --- .../share/vm/classfile/classFileParser.cpp | 5 +- .../EnclosingMethodAttr/EnclMethTest.jcod | 115 ++++++++++++++++++ .../EnclosingMethodAttr/EnclMethodAttr.java | 47 +++++++ .../EnclosingMethodAttr/enclMethodAttr.jar | Bin 0 -> 738 bytes 4 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 hotspot/test/runtime/EnclosingMethodAttr/EnclMethTest.jcod create mode 100644 hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java create mode 100644 hotspot/test/runtime/EnclosingMethodAttr/enclMethodAttr.jar diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 608b43ae150..c7fe1c7d5a2 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -2984,9 +2984,12 @@ void ClassFileParser::parse_classfile_attributes(ClassFileParser::ClassAnnotatio } 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(); diff --git a/hotspot/test/runtime/EnclosingMethodAttr/EnclMethTest.jcod b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethTest.jcod new file mode 100644 index 00000000000..956b643b055 --- /dev/null +++ b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethTest.jcod @@ -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 ""; // #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 diff --git a/hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java new file mode 100644 index 00000000000..82b5424813f --- /dev/null +++ b/hotspot/test/runtime/EnclosingMethodAttr/EnclMethodAttr.java @@ -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"); + } +} + diff --git a/hotspot/test/runtime/EnclosingMethodAttr/enclMethodAttr.jar b/hotspot/test/runtime/EnclosingMethodAttr/enclMethodAttr.jar new file mode 100644 index 0000000000000000000000000000000000000000..590e7ae37b641964ac60d566a76f73450aa3f57a GIT binary patch literal 738 zcmWIWW@Zs#;Nak3cwKkYg#ih0GO#fCx`sIFdiuHP|2xINz|0Wf&CUT*!30$nfK#&w zPz7AGucM!*n`>~0p0C?y-!rFuymj?1@_OrPojY@WbCAIm;|EWR^t^m^Jbf>gu43Vg zcqRE_nVMF{4{=qs=S#FKo{Nh<5m%kYFg5#A(NDFsXD_XutB8q5Ywmca`uxYTX(=rX zzE7S$dddWLox3TyHXpUyt#0niX6*jqscBeVUO0VC2 zxq1Jt|MU6x*XJ{sTSz-SFgVWO+7{R*>?9@i`22d#MIpwA3V!A}FK%A>Gc#`u=k}J5 zOYW>PH_e@T*Ju9fwd)SQdDLnUv16;6$kL6!GQUT?%v-u@TK=b{w@bI~GY?$yN~_HK zjpEcB$2A@A-P~1sWnpBdywWX0Kf8$4yIoiBxjxU}SAWWVm7wk$Z}x1QZE Date: Wed, 11 Jun 2014 12:09:12 +0200 Subject: [PATCH 009/236] 6311046: -Xcheck:jni should support checking of GetPrimitiveArrayCritical Wrapped memory with standard bounds checking "GuardedMemory". Reviewed-by: zgu, fparain, dcubed --- hotspot/src/share/vm/memory/guardedMemory.cpp | 161 +++++++++ hotspot/src/share/vm/memory/guardedMemory.hpp | 326 ++++++++++++++++++ hotspot/src/share/vm/prims/jni.cpp | 2 + hotspot/src/share/vm/prims/jniCheck.cpp | 163 +++++++-- hotspot/src/share/vm/runtime/os.cpp | 210 +++-------- 5 files changed, 671 insertions(+), 191 deletions(-) create mode 100644 hotspot/src/share/vm/memory/guardedMemory.cpp create mode 100644 hotspot/src/share/vm/memory/guardedMemory.hpp diff --git a/hotspot/src/share/vm/memory/guardedMemory.cpp b/hotspot/src/share/vm/memory/guardedMemory.cpp new file mode 100644 index 00000000000..763548fd35d --- /dev/null +++ b/hotspot/src/share/vm/memory/guardedMemory.cpp @@ -0,0 +1,161 @@ +/* + * 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 "memory/allocation.hpp" +#include "memory/allocation.inline.hpp" +#include "memory/guardedMemory.hpp" +#include "runtime/os.hpp" + +void* GuardedMemory::wrap_copy(const void* ptr, const size_t len, const void* tag) { + size_t total_sz = GuardedMemory::get_total_size(len); + void* outerp = os::malloc(total_sz, mtInternal); + if (outerp != NULL) { + GuardedMemory guarded(outerp, len, tag); + void* innerp = guarded.get_user_ptr(); + memcpy(innerp, ptr, len); + return innerp; + } + return NULL; // OOM +} + +bool GuardedMemory::free_copy(void* p) { + if (p == NULL) { + return true; + } + GuardedMemory guarded((u_char*)p); + bool verify_ok = guarded.verify_guards(); + + /* always attempt to free, pass problem on to any nested memchecker */ + os::free(guarded.release_for_freeing()); + + return verify_ok; +} + +void GuardedMemory::print_on(outputStream* st) const { + if (_base_addr == NULL) { + st->print_cr("GuardedMemory(" PTR_FORMAT ") not associated to any memory", p2i(this)); + return; + } + st->print_cr("GuardedMemory(" PTR_FORMAT ") base_addr=" PTR_FORMAT + " tag=" PTR_FORMAT " user_size=" SIZE_FORMAT " user_data=" PTR_FORMAT, + p2i(this), p2i(_base_addr), p2i(get_tag()), get_user_size(), p2i(get_user_ptr())); + + Guard* guard = get_head_guard(); + st->print_cr(" Header guard @" PTR_FORMAT " is %s", p2i(guard), (guard->verify() ? "OK" : "BROKEN")); + guard = get_tail_guard(); + st->print_cr(" Trailer guard @" PTR_FORMAT " is %s", p2i(guard), (guard->verify() ? "OK" : "BROKEN")); + + u_char udata = *get_user_ptr(); + switch (udata) { + case uninitBlockPad: + st->print_cr(" User data appears unused"); + break; + case freeBlockPad: + st->print_cr(" User data appears to have been freed"); + break; + default: + st->print_cr(" User data appears to be in use"); + break; + } +} + +// test code... + +#ifndef PRODUCT + +static void guarded_memory_test_check(void* p, size_t sz, void* tag) { + assert(p != NULL, "NULL pointer given to check"); + u_char* c = (u_char*) p; + GuardedMemory guarded(c); + assert(guarded.get_tag() == tag, "Tag is not the same as supplied"); + assert(guarded.get_user_ptr() == c, "User pointer is not the same as supplied"); + assert(guarded.get_user_size() == sz, "User size is not the same as supplied"); + assert(guarded.verify_guards(), "Guard broken"); +} + +void GuardedMemory::test_guarded_memory() { + // Test the basic characteristics... + size_t total_sz = GuardedMemory::get_total_size(1); + assert(total_sz > 1 && total_sz >= (sizeof(GuardHeader) + 1 + sizeof(Guard)), "Unexpected size"); + u_char* basep = (u_char*) os::malloc(total_sz, mtInternal); + + GuardedMemory guarded(basep, 1, (void*)0xf000f000); + + assert(*basep == badResourceValue, "Expected guard in the form of badResourceValue"); + u_char* userp = guarded.get_user_ptr(); + assert(*userp == uninitBlockPad, "Expected uninitialized data in the form of uninitBlockPad"); + guarded_memory_test_check(userp, 1, (void*)0xf000f000); + + void* freep = guarded.release_for_freeing(); + assert((u_char*)freep == basep, "Expected the same pointer guard was "); + assert(*userp == freeBlockPad, "Expected user data to be free block padded"); + assert(!guarded.verify_guards(), "Expected failed"); + os::free(freep); + + // Test a number of odd sizes... + size_t sz = 0; + do { + void* p = os::malloc(GuardedMemory::get_total_size(sz), mtInternal); + void* up = guarded.wrap_with_guards(p, sz, (void*)1); + memset(up, 0, sz); + guarded_memory_test_check(up, sz, (void*)1); + os::free(guarded.release_for_freeing()); + sz = (sz << 4) + 1; + } while (sz < (256 * 1024)); + + // Test buffer overrun into head... + basep = (u_char*) os::malloc(GuardedMemory::get_total_size(1), mtInternal); + guarded.wrap_with_guards(basep, 1); + *basep = 0; + assert(!guarded.verify_guards(), "Expected failure"); + os::free(basep); + + // Test buffer overrun into tail with a number of odd sizes... + sz = 1; + do { + void* p = os::malloc(GuardedMemory::get_total_size(sz), mtInternal); + void* up = guarded.wrap_with_guards(p, sz, (void*)1); + memset(up, 0, sz + 1); // Buffer-overwrite (within guard) + assert(!guarded.verify_guards(), "Guard was not broken as expected"); + os::free(guarded.release_for_freeing()); + sz = (sz << 4) + 1; + } while (sz < (256 * 1024)); + + // Test wrap_copy/wrap_free... + assert(GuardedMemory::free_copy(NULL), "Expected free NULL to be OK"); + + const char* str = "Check my bounds out"; + size_t str_sz = strlen(str) + 1; + char* str_copy = (char*) GuardedMemory::wrap_copy(str, str_sz); + guarded_memory_test_check(str_copy, str_sz, NULL); + assert(strcmp(str, str_copy) == 0, "Not identical copy"); + assert(GuardedMemory::free_copy(str_copy), "Free copy failed to verify"); + + void* no_data = NULL; + void* no_data_copy = GuardedMemory::wrap_copy(no_data, 0); + assert(GuardedMemory::free_copy(no_data_copy), "Expected valid guards even for no data copy"); +} + +#endif // !PRODUCT + diff --git a/hotspot/src/share/vm/memory/guardedMemory.hpp b/hotspot/src/share/vm/memory/guardedMemory.hpp new file mode 100644 index 00000000000..dada10d84bf --- /dev/null +++ b/hotspot/src/share/vm/memory/guardedMemory.hpp @@ -0,0 +1,326 @@ +/* + * 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_MEMORY_GUARDED_MEMORY_HPP +#define SHARE_VM_MEMORY_GUARDED_MEMORY_HPP + +#include "memory/allocation.hpp" +#include "utilities/globalDefinitions.hpp" + +/** + * Guarded memory for detecting buffer overrun. + * + * Allows allocations to be wrapped with padded bytes of a known byte pattern, + * that is a "guard". Guard patterns may be verified to detect buffer overruns. + * + * Primarily used by "debug malloc" and "checked JNI". + * + * Memory layout: + * + * |Offset | Content | Description | + * |------------------------------------------------------------ + * |base_addr | 0xABABABABABABABAB | Head guard | + * |+16 | | User data size | + * |+sizeof(uintptr_t) | | Tag word | + * |+sizeof(void*) | 0xF1 ( | User data | + * |+user_size | 0xABABABABABABABAB | Tail guard | + * ------------------------------------------------------------- + * + * Where: + * - guard padding uses "badResourceValue" (0xAB) + * - tag word is general purpose + * - user data + * -- initially padded with "uninitBlockPad" (0xF1), + * -- to "freeBlockPad" (0xBA), when freed + * + * Usage: + * + * * Allocations: one may wrap allocations with guard memory: + * + * Thing* alloc_thing() { + * void* mem = user_alloc_fn(GuardedMemory::get_total_size(sizeof(thing))); + * GuardedMemory guarded(mem, sizeof(thing)); + * return (Thing*) guarded.get_user_ptr(); + * } + * + * * Verify: memory guards are still in tact + * + * bool verify_thing(Thing* thing) { + * GuardedMemory guarded((void*)thing); + * return guarded.verify_guards(); + * } + * + * * Free: one may mark bytes as freed (further debugging support) + * + * void free_thing(Thing* thing) { + * GuardedMemory guarded((void*)thing); + * assert(guarded.verify_guards(), "Corrupt thing"); + * user_free_fn(guards.release_for_freeing(); + * } + * + */ +class GuardedMemory : StackObj { // Wrapper on stack + + // Private inner classes for memory layout... + +protected: + + /** + * Guard class for header and trailer known pattern to test for overwrites. + */ + class Guard { // Class for raw memory (no vtbl allowed) + friend class GuardedMemory; + protected: + enum { + GUARD_SIZE = 16 + }; + + u_char _guard[GUARD_SIZE]; + + public: + + void build() { + u_char* c = _guard; // Possibly unaligned if tail guard + u_char* end = c + GUARD_SIZE; + while (c < end) { + *c = badResourceValue; + c++; + } + } + + bool verify() const { + u_char* c = (u_char*) _guard; + u_char* end = c + GUARD_SIZE; + while (c < end) { + if (*c != badResourceValue) { + return false; + } + c++; + } + return true; + } + + }; // GuardedMemory::Guard + + /** + * Header guard and size + */ + class GuardHeader : Guard { + friend class GuardedMemory; + protected: + // Take care in modifying fields here, will effect alignment + // e.g. x86 ABI 16 byte stack alignment + union { + uintptr_t __unused_full_word1; + size_t _user_size; + }; + void* _tag; + public: + void set_user_size(const size_t usz) { _user_size = usz; } + size_t get_user_size() const { return _user_size; } + + void set_tag(const void* tag) { _tag = (void*) tag; } + void* get_tag() const { return _tag; } + + }; // GuardedMemory::GuardHeader + + // Guarded Memory... + + protected: + u_char* _base_addr; + + public: + + /** + * Create new guarded memory. + * + * Wraps, starting at the given "base_ptr" with guards. Use "get_user_ptr()" + * to return a pointer suitable for user data. + * + * @param base_ptr allocation wishing to be wrapped, must be at least "GuardedMemory::get_total_size()" bytes. + * @param user_size the size of the user data to be wrapped. + * @param tag optional general purpose tag. + */ + GuardedMemory(void* base_ptr, const size_t user_size, const void* tag = NULL) { + wrap_with_guards(base_ptr, user_size, tag); + } + + /** + * Wrap existing guarded memory. + * + * To use this constructor, one must have created guarded memory with + * "GuardedMemory(void*, size_t, void*)" (or indirectly via helper, e.g. "wrap_copy()"). + * + * @param user_p existing wrapped memory. + */ + GuardedMemory(void* userp) { + u_char* user_ptr = (u_char*) userp; + assert((uintptr_t)user_ptr > (sizeof(GuardHeader) + 0x1000), "Invalid pointer"); + _base_addr = (user_ptr - sizeof(GuardHeader)); + } + + /** + * Create new guarded memory. + * + * Wraps, starting at the given "base_ptr" with guards. Allows reuse of stack allocated helper. + * + * @param base_ptr allocation wishing to be wrapped, must be at least "GuardedMemory::get_total_size()" bytes. + * @param user_size the size of the user data to be wrapped. + * @param tag optional general purpose tag. + * + * @return user data pointer (inner pointer to supplied "base_ptr"). + */ + void* wrap_with_guards(void* base_ptr, size_t user_size, const void* tag = NULL) { + assert(base_ptr != NULL, "Attempt to wrap NULL with memory guard"); + _base_addr = (u_char*)base_ptr; + get_head_guard()->build(); + get_head_guard()->set_user_size(user_size); + get_tail_guard()->build(); + set_tag(tag); + set_user_bytes(uninitBlockPad); + assert(verify_guards(), "Expected valid memory guards"); + return get_user_ptr(); + } + + /** + * Verify head and tail guards. + * + * @return true if guards are intact, false would indicate a buffer overrun. + */ + bool verify_guards() const { + if (_base_addr != NULL) { + return (get_head_guard()->verify() && get_tail_guard()->verify()); + } + return false; + } + + /** + * Set the general purpose tag. + * + * @param tag general purpose tag. + */ + void set_tag(const void* tag) { get_head_guard()->set_tag(tag); } + + /** + * Return the general purpose tag. + * + * @return the general purpose tag, defaults to NULL. + */ + void* get_tag() const { return get_head_guard()->get_tag(); } + + /** + * Return the size of the user data. + * + * @return the size of the user data. + */ + size_t get_user_size() const { + assert(_base_addr, "Not wrapping any memory"); + return get_head_guard()->get_user_size(); + } + + /** + * Return the user data pointer. + * + * @return the user data pointer. + */ + u_char* get_user_ptr() const { + assert(_base_addr, "Not wrapping any memory"); + return _base_addr + sizeof(GuardHeader); + } + + /** + * Release the wrapped pointer for resource freeing. + * + * Pads the user data with "freeBlockPad", and dis-associates the helper. + * + * @return the original base pointer used to wrap the data. + */ + void* release_for_freeing() { + set_user_bytes(freeBlockPad); + return release(); + } + + /** + * Dis-associate the help from the original base address. + * + * @return the original base pointer used to wrap the data. + */ + void* release() { + void* p = (void*) _base_addr; + _base_addr = NULL; + return p; + } + + virtual void print_on(outputStream* st) const; + + protected: + GuardHeader* get_head_guard() const { return (GuardHeader*) _base_addr; } + Guard* get_tail_guard() const { return (Guard*) (get_user_ptr() + get_user_size()); }; + void set_user_bytes(u_char ch) { + memset(get_user_ptr(), ch, get_user_size()); + } + +public: + /** + * Return the total size required for wrapping the given user size. + * + * @return the total size required for wrapping the given user size. + */ + static size_t get_total_size(size_t user_size) { + size_t total_size = sizeof(GuardHeader) + user_size + sizeof(Guard); + assert(total_size > user_size, "Unexpected wrap-around"); + return total_size; + } + + // Helper functions... + + /** + * Wrap a copy of size "len" of "ptr". + * + * @param ptr the memory to be copied + * @param len the length of the copy + * @param tag optional general purpose tag (see GuardedMemory::get_tag()) + * + * @return guarded wrapped memory pointer to the user area, or NULL if OOM. + */ + static void* wrap_copy(const void* p, const size_t len, const void* tag = NULL); + + /** + * Free wrapped copy. + * + * Frees memory copied with "wrap_copy()". + * + * @param p memory returned by "wrap_copy()". + * + * @return true if guards were verified as intact. false indicates a buffer overrun. + */ + static bool free_copy(void* p); + + // Testing... +#ifndef PRODUCT + static void test_guarded_memory(void); +#endif +}; // GuardedMemory + +#endif // SHARE_VM_MEMORY_GUARDED_MEMORY_HPP diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 6bbe5feb691..cdb53afe1b7 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -3858,6 +3858,7 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { #if INCLUDE_ALL_GCS #include "gc_implementation/g1/heapRegionRemSet.hpp" #endif +#include "memory/guardedMemory.hpp" #include "utilities/quickSort.hpp" #include "utilities/ostream.hpp" #if INCLUDE_VM_STRUCTS @@ -3901,6 +3902,7 @@ void execute_internal_vm_tests() { run_unit_test(arrayOopDesc::test_max_array_length()); run_unit_test(CollectedHeap::test_is_in()); run_unit_test(QuickSort::test_quick_sort()); + run_unit_test(GuardedMemory::test_guarded_memory()); run_unit_test(AltHashing::test_alt_hash()); run_unit_test(test_loggc_filename()); run_unit_test(TestNewSize_test()); diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp index 0d5ffab1cdc..446c23143ae 100644 --- a/hotspot/src/share/vm/prims/jniCheck.cpp +++ b/hotspot/src/share/vm/prims/jniCheck.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" +#include "memory/guardedMemory.hpp" #include "oops/instanceKlass.hpp" #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" @@ -323,6 +324,74 @@ check_is_obj_array(JavaThread* thr, jarray jArray) { } } +/* + * Copy and wrap array elements for bounds checking. + * Remember the original elements (GuardedMemory::get_tag()) + */ +static void* check_jni_wrap_copy_array(JavaThread* thr, jarray array, + void* orig_elements) { + void* result; + IN_VM( + oop a = JNIHandles::resolve_non_null(array); + size_t len = arrayOop(a)->length() << + TypeArrayKlass::cast(a->klass())->log2_element_size(); + result = GuardedMemory::wrap_copy(orig_elements, len, orig_elements); + ) + return result; +} + +static void* check_wrapped_array(JavaThread* thr, const char* fn_name, + void* obj, void* carray, size_t* rsz) { + if (carray == NULL) { + tty->print_cr("%s: elements vector NULL" PTR_FORMAT, fn_name, p2i(obj)); + NativeReportJNIFatalError(thr, "Elements vector NULL"); + } + GuardedMemory guarded(carray); + void* orig_result = guarded.get_tag(); + if (!guarded.verify_guards()) { + tty->print_cr("ReleasePrimitiveArrayCritical: release array failed bounds " + "check, incorrect pointer returned ? array: " PTR_FORMAT " carray: " + PTR_FORMAT, p2i(obj), p2i(carray)); + guarded.print_on(tty); + NativeReportJNIFatalError(thr, "ReleasePrimitiveArrayCritical: " + "failed bounds check"); + } + if (orig_result == NULL) { + tty->print_cr("ReleasePrimitiveArrayCritical: unrecognized elements. array: " + PTR_FORMAT " carray: " PTR_FORMAT, p2i(obj), p2i(carray)); + guarded.print_on(tty); + NativeReportJNIFatalError(thr, "ReleasePrimitiveArrayCritical: " + "unrecognized elements"); + } + if (rsz != NULL) { + *rsz = guarded.get_user_size(); + } + return orig_result; +} + +static void* check_wrapped_array_release(JavaThread* thr, const char* fn_name, + void* obj, void* carray, jint mode) { + size_t sz; + void* orig_result = check_wrapped_array(thr, fn_name, obj, carray, &sz); + switch (mode) { + case 0: + memcpy(orig_result, carray, sz); + GuardedMemory::free_copy(carray); + break; + case JNI_COMMIT: + memcpy(orig_result, carray, sz); + break; + case JNI_ABORT: + GuardedMemory::free_copy(carray); + break; + default: + tty->print_cr("%s: Unrecognized mode %i releasing array " + PTR_FORMAT " elements " PTR_FORMAT, fn_name, mode, p2i(obj), p2i(carray)); + NativeReportJNIFatalError(thr, "Unrecognized array release mode"); + } + return orig_result; +} + oop jniCheck::validate_handle(JavaThread* thr, jobject obj) { if (JNIHandles::is_frame_handle(thr, obj) || JNIHandles::is_local_handle(thr, obj) || @@ -1314,7 +1383,7 @@ JNI_ENTRY_CHECKED(jsize, JNI_END // Arbitrary (but well-known) tag -const jint STRING_TAG = 0x47114711; +const void* STRING_TAG = (void*)0x47114711; JNI_ENTRY_CHECKED(const jchar *, checked_jni_GetStringChars(JNIEnv *env, @@ -1324,21 +1393,22 @@ JNI_ENTRY_CHECKED(const jchar *, IN_VM( checkString(thr, str); ) - jchar* newResult = NULL; + jchar* new_result = NULL; const jchar *result = UNCHECKED()->GetStringChars(env,str,isCopy); assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringChars didn't return a copy as expected"); if (result != NULL) { size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for NULL termination - jint* tagLocation = (jint*) AllocateHeap(len * sizeof(jchar) + sizeof(jint), mtInternal); - *tagLocation = STRING_TAG; - newResult = (jchar*) (tagLocation + 1); - memcpy(newResult, result, len * sizeof(jchar)); + len *= sizeof(jchar); + new_result = (jchar*) GuardedMemory::wrap_copy(result, len, STRING_TAG); + if (new_result == NULL) { + vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringChars"); + } // Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes // Note that the dtrace arguments for the allocated memory will not match up with this solution. FreeHeap((char*)result); } functionExit(env); - return newResult; + return new_result; JNI_END JNI_ENTRY_CHECKED(void, @@ -1354,11 +1424,23 @@ JNI_ENTRY_CHECKED(void, UNCHECKED()->ReleaseStringChars(env,str,chars); } else { - jint* tagLocation = ((jint*) chars) - 1; - if (*tagLocation != STRING_TAG) { - NativeReportJNIFatalError(thr, "ReleaseStringChars called on something not allocated by GetStringChars"); - } - UNCHECKED()->ReleaseStringChars(env,str,(const jchar*)tagLocation); + GuardedMemory guarded((void*)chars); + if (guarded.verify_guards()) { + tty->print_cr("ReleaseStringChars: release chars failed bounds check. " + "string: " PTR_FORMAT " chars: " PTR_FORMAT, p2i(str), p2i(chars)); + guarded.print_on(tty); + NativeReportJNIFatalError(thr, "ReleaseStringChars: " + "release chars failed bounds check."); + } + if (guarded.get_tag() != STRING_TAG) { + tty->print_cr("ReleaseStringChars: called on something not allocated " + "by GetStringChars. string: " PTR_FORMAT " chars: " PTR_FORMAT, + p2i(str), p2i(chars)); + NativeReportJNIFatalError(thr, "ReleaseStringChars called on something " + "not allocated by GetStringChars"); + } + UNCHECKED()->ReleaseStringChars(env, str, + (const jchar*) guarded.release_for_freeing()); } functionExit(env); JNI_END @@ -1385,7 +1467,7 @@ JNI_ENTRY_CHECKED(jsize, JNI_END // Arbitrary (but well-known) tag - different than GetStringChars -const jint STRING_UTF_TAG = 0x48124812; +const void* STRING_UTF_TAG = (void*) 0x48124812; JNI_ENTRY_CHECKED(const char *, checked_jni_GetStringUTFChars(JNIEnv *env, @@ -1395,21 +1477,21 @@ JNI_ENTRY_CHECKED(const char *, IN_VM( checkString(thr, str); ) - char* newResult = NULL; + char* new_result = NULL; const char *result = UNCHECKED()->GetStringUTFChars(env,str,isCopy); assert (isCopy == NULL || *isCopy == JNI_TRUE, "GetStringUTFChars didn't return a copy as expected"); if (result != NULL) { size_t len = strlen(result) + 1; // + 1 for NULL termination - jint* tagLocation = (jint*) AllocateHeap(len + sizeof(jint), mtInternal); - *tagLocation = STRING_UTF_TAG; - newResult = (char*) (tagLocation + 1); - strcpy(newResult, result); + new_result = (char*) GuardedMemory::wrap_copy(result, len, STRING_UTF_TAG); + if (new_result == NULL) { + vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringUTFChars"); + } // Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes // Note that the dtrace arguments for the allocated memory will not match up with this solution. FreeHeap((char*)result, mtInternal); } functionExit(env); - return newResult; + return new_result; JNI_END JNI_ENTRY_CHECKED(void, @@ -1425,11 +1507,23 @@ JNI_ENTRY_CHECKED(void, UNCHECKED()->ReleaseStringUTFChars(env,str,chars); } else { - jint* tagLocation = ((jint*) chars) - 1; - if (*tagLocation != STRING_UTF_TAG) { - NativeReportJNIFatalError(thr, "ReleaseStringUTFChars called on something not allocated by GetStringUTFChars"); - } - UNCHECKED()->ReleaseStringUTFChars(env,str,(const char*)tagLocation); + GuardedMemory guarded((void*)chars); + if (guarded.verify_guards()) { + tty->print_cr("ReleaseStringUTFChars: release chars failed bounds check. " + "string: " PTR_FORMAT " chars: " PTR_FORMAT, p2i(str), p2i(chars)); + guarded.print_on(tty); + NativeReportJNIFatalError(thr, "ReleaseStringUTFChars: " + "release chars failed bounds check."); + } + if (guarded.get_tag() != STRING_UTF_TAG) { + tty->print_cr("ReleaseStringUTFChars: called on something not " + "allocated by GetStringUTFChars. string: " PTR_FORMAT " chars: " + PTR_FORMAT, p2i(str), p2i(chars)); + NativeReportJNIFatalError(thr, "ReleaseStringUTFChars " + "called on something not allocated by GetStringUTFChars"); + } + UNCHECKED()->ReleaseStringUTFChars(env, str, + (const char*) guarded.release_for_freeing()); } functionExit(env); JNI_END @@ -1514,6 +1608,9 @@ JNI_ENTRY_CHECKED(ElementType *, \ ElementType *result = UNCHECKED()->Get##Result##ArrayElements(env, \ array, \ isCopy); \ + if (result != NULL) { \ + result = (ElementType *) check_jni_wrap_copy_array(thr, array, result); \ + } \ functionExit(env); \ return result; \ JNI_END @@ -1538,12 +1635,10 @@ JNI_ENTRY_CHECKED(void, \ check_primitive_array_type(thr, array, ElementTag); \ ASSERT_OOPS_ALLOWED; \ typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ - /* cannot check validity of copy, unless every request is logged by - * checking code. Implementation of this check is deferred until a - * subsequent release. - */ \ ) \ - UNCHECKED()->Release##Result##ArrayElements(env,array,elems,mode); \ + ElementType* orig_result = (ElementType *) check_wrapped_array_release( \ + thr, "checked_jni_Release"#Result"ArrayElements", array, elems, mode); \ + UNCHECKED()->Release##Result##ArrayElements(env, array, orig_result, mode); \ functionExit(env); \ JNI_END @@ -1694,6 +1789,9 @@ JNI_ENTRY_CHECKED(void *, check_is_primitive_array(thr, array); ) void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy); + if (result != NULL) { + result = check_jni_wrap_copy_array(thr, array, result); + } functionExit(env); return result; JNI_END @@ -1707,10 +1805,9 @@ JNI_ENTRY_CHECKED(void, IN_VM( check_is_primitive_array(thr, array); ) - /* The Hotspot JNI code does not use the parameters, so just check the - * array parameter as a minor sanity check - */ - UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, carray, mode); + // Check the element array... + void* orig_result = check_wrapped_array_release(thr, "ReleasePrimitiveArrayCritical", array, carray, mode); + UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, orig_result, mode); functionExit(env); JNI_END diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 04c008431c7..dc5d664989b 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -32,6 +32,9 @@ #include "gc_implementation/shared/vmGCOperations.hpp" #include "interpreter/interpreter.hpp" #include "memory/allocation.inline.hpp" +#ifdef ASSERT +#include "memory/guardedMemory.hpp" +#endif #include "oops/oop.inline.hpp" #include "prims/jvm.h" #include "prims/jvm_misc.hpp" @@ -523,121 +526,20 @@ char *os::strdup(const char *str, MEMFLAGS flags) { } - -#ifdef ASSERT -#define space_before (MallocCushion + sizeof(double)) -#define space_after MallocCushion -#define size_addr_from_base(p) (size_t*)(p + space_before - sizeof(size_t)) -#define size_addr_from_obj(p) ((size_t*)p - 1) -// MallocCushion: size of extra cushion allocated around objects with +UseMallocOnly -// NB: cannot be debug variable, because these aren't set from the command line until -// *after* the first few allocs already happened -#define MallocCushion 16 -#else -#define space_before 0 -#define space_after 0 -#define size_addr_from_base(p) should not use w/o ASSERT -#define size_addr_from_obj(p) should not use w/o ASSERT -#define MallocCushion 0 -#endif #define paranoid 0 /* only set to 1 if you suspect checking code has bug */ #ifdef ASSERT -inline size_t get_size(void* obj) { - size_t size = *size_addr_from_obj(obj); - if (size < 0) { - fatal(err_msg("free: size field of object #" PTR_FORMAT " was overwritten (" - SIZE_FORMAT ")", obj, size)); - } - return size; -} -u_char* find_cushion_backwards(u_char* start) { - u_char* p = start; - while (p[ 0] != badResourceValue || p[-1] != badResourceValue || - p[-2] != badResourceValue || p[-3] != badResourceValue) p--; - // ok, we have four consecutive marker bytes; find start - u_char* q = p - 4; - while (*q == badResourceValue) q--; - return q + 1; -} - -u_char* find_cushion_forwards(u_char* start) { - u_char* p = start; - while (p[0] != badResourceValue || p[1] != badResourceValue || - p[2] != badResourceValue || p[3] != badResourceValue) p++; - // ok, we have four consecutive marker bytes; find end of cushion - u_char* q = p + 4; - while (*q == badResourceValue) q++; - return q - MallocCushion; -} - -void print_neighbor_blocks(void* ptr) { - // find block allocated before ptr (not entirely crash-proof) - if (MallocCushion < 4) { - tty->print_cr("### cannot find previous block (MallocCushion < 4)"); - return; - } - u_char* start_of_this_block = (u_char*)ptr - space_before; - u_char* end_of_prev_block_data = start_of_this_block - space_after -1; - // look for cushion in front of prev. block - u_char* start_of_prev_block = find_cushion_backwards(end_of_prev_block_data); - ptrdiff_t size = *size_addr_from_base(start_of_prev_block); - u_char* obj = start_of_prev_block + space_before; - if (size <= 0 ) { - // start is bad; may have been confused by OS data in between objects - // search one more backwards - start_of_prev_block = find_cushion_backwards(start_of_prev_block); - size = *size_addr_from_base(start_of_prev_block); - obj = start_of_prev_block + space_before; - } - - if (start_of_prev_block + space_before + size + space_after == start_of_this_block) { - tty->print_cr("### previous object: " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size); - } else { - tty->print_cr("### previous object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size); - } - - // now find successor block - u_char* start_of_next_block = (u_char*)ptr + *size_addr_from_obj(ptr) + space_after; - start_of_next_block = find_cushion_forwards(start_of_next_block); - u_char* next_obj = start_of_next_block + space_before; - ptrdiff_t next_size = *size_addr_from_base(start_of_next_block); - if (start_of_next_block[0] == badResourceValue && - start_of_next_block[1] == badResourceValue && - start_of_next_block[2] == badResourceValue && - start_of_next_block[3] == badResourceValue) { - tty->print_cr("### next object: " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size); - } else { - tty->print_cr("### next object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size); +static void verify_memory(void* ptr) { + GuardedMemory guarded(ptr); + if (!guarded.verify_guards()) { + tty->print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees); + tty->print_cr("## memory stomp:"); + guarded.print_on(tty); + fatal("memory stomping error"); } } - -void report_heap_error(void* memblock, void* bad, const char* where) { - tty->print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees); - tty->print_cr("## memory stomp: byte at " PTR_FORMAT " %s object " PTR_FORMAT, bad, where, memblock); - print_neighbor_blocks(memblock); - fatal("memory stomping error"); -} - -void verify_block(void* memblock) { - size_t size = get_size(memblock); - if (MallocCushion) { - u_char* ptr = (u_char*)memblock - space_before; - for (int i = 0; i < MallocCushion; i++) { - if (ptr[i] != badResourceValue) { - report_heap_error(memblock, ptr+i, "in front of"); - } - } - u_char* end = (u_char*)memblock + size + space_after; - for (int j = -MallocCushion; j < 0; j++) { - if (end[j] != badResourceValue) { - report_heap_error(memblock, end+j, "after"); - } - } - } -} #endif // @@ -686,16 +588,18 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { size = 1; } - const size_t alloc_size = size + space_before + space_after; - +#ifndef ASSERT + const size_t alloc_size = size; +#else + const size_t alloc_size = GuardedMemory::get_total_size(size); if (size > alloc_size) { // Check for rollover. return NULL; } +#endif NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); u_char* ptr; - if (MallocMaxTestWords > 0) { ptr = testMalloc(alloc_size); } else { @@ -703,28 +607,26 @@ void* os::malloc(size_t size, MEMFLAGS memflags, address caller) { } #ifdef ASSERT - if (ptr == NULL) return NULL; - if (MallocCushion) { - for (u_char* p = ptr; p < ptr + MallocCushion; p++) *p = (u_char)badResourceValue; - u_char* end = ptr + space_before + size; - for (u_char* pq = ptr+MallocCushion; pq < end; pq++) *pq = (u_char)uninitBlockPad; - for (u_char* q = end; q < end + MallocCushion; q++) *q = (u_char)badResourceValue; + if (ptr == NULL) { + return NULL; } - // put size just before data - *size_addr_from_base(ptr) = size; + // Wrap memory with guard + GuardedMemory guarded(ptr, size); + ptr = guarded.get_user_ptr(); #endif - u_char* memblock = ptr + space_before; - if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { - tty->print_cr("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock); + if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) { + tty->print_cr("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, ptr); breakpoint(); } - debug_only(if (paranoid) verify_block(memblock)); - if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock); + debug_only(if (paranoid) verify_memory(ptr)); + if (PrintMalloc && tty != NULL) { + tty->print_cr("os::malloc " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, ptr); + } - // we do not track MallocCushion memory - MemTracker::record_malloc((address)memblock, size, memflags, caller == 0 ? CALLER_PC : caller); + // we do not track guard memory + MemTracker::record_malloc((address)ptr, size, memflags, caller == 0 ? CALLER_PC : caller); - return memblock; + return ptr; } @@ -743,27 +645,32 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, address caller return ptr; #else if (memblock == NULL) { - return malloc(size, memflags, (caller == 0 ? CALLER_PC : caller)); + return os::malloc(size, memflags, (caller == 0 ? CALLER_PC : caller)); } if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { tty->print_cr("os::realloc caught " PTR_FORMAT, memblock); breakpoint(); } - verify_block(memblock); + verify_memory(memblock); NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); - if (size == 0) return NULL; + if (size == 0) { + return NULL; + } // always move the block - void* ptr = malloc(size, memflags, caller == 0 ? CALLER_PC : caller); - if (PrintMalloc) tty->print_cr("os::remalloc " SIZE_FORMAT " bytes, " PTR_FORMAT " --> " PTR_FORMAT, size, memblock, ptr); + void* ptr = os::malloc(size, memflags, caller == 0 ? CALLER_PC : caller); + if (PrintMalloc) { + tty->print_cr("os::remalloc " SIZE_FORMAT " bytes, " PTR_FORMAT " --> " PTR_FORMAT, size, memblock, ptr); + } // Copy to new memory if malloc didn't fail if ( ptr != NULL ) { - memcpy(ptr, memblock, MIN2(size, get_size(memblock))); - if (paranoid) verify_block(ptr); + GuardedMemory guarded(memblock); + memcpy(ptr, memblock, MIN2(size, guarded.get_user_size())); + if (paranoid) verify_memory(ptr); if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) { tty->print_cr("os::realloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, ptr); breakpoint(); } - free(memblock); + os::free(memblock); } return ptr; #endif @@ -771,6 +678,7 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, address caller void os::free(void *memblock, MEMFLAGS memflags) { + address trackp = (address) memblock; NOT_PRODUCT(inc_stat_counter(&num_frees, 1)); #ifdef ASSERT if (memblock == NULL) return; @@ -778,34 +686,20 @@ void os::free(void *memblock, MEMFLAGS memflags) { if (tty != NULL) tty->print_cr("os::free caught " PTR_FORMAT, memblock); breakpoint(); } - verify_block(memblock); + verify_memory(memblock); NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); - // Added by detlefs. - if (MallocCushion) { - u_char* ptr = (u_char*)memblock - space_before; - for (u_char* p = ptr; p < ptr + MallocCushion; p++) { - guarantee(*p == badResourceValue, - "Thing freed should be malloc result."); - *p = (u_char)freeBlockPad; - } - size_t size = get_size(memblock); - inc_stat_counter(&free_bytes, size); - u_char* end = ptr + space_before + size; - for (u_char* q = end; q < end + MallocCushion; q++) { - guarantee(*q == badResourceValue, - "Thing freed should be malloc result."); - *q = (u_char)freeBlockPad; - } - if (PrintMalloc && tty != NULL) + + GuardedMemory guarded(memblock); + size_t size = guarded.get_user_size(); + inc_stat_counter(&free_bytes, size); + memblock = guarded.release_for_freeing(); + if (PrintMalloc && tty != NULL) { fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, (uintptr_t)memblock); - } else if (PrintMalloc && tty != NULL) { - // tty->print_cr("os::free %p", memblock); - fprintf(stderr, "os::free " PTR_FORMAT "\n", (uintptr_t)memblock); } #endif - MemTracker::record_free((address)memblock, memflags); + MemTracker::record_free(trackp, memflags); - ::free((char*)memblock - space_before); + ::free(memblock); } void os::init_random(long initval) { From b6a2f946f6c80c2dc54a3d315ea3dae5d30b6829 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 11 Jun 2014 09:58:23 -0400 Subject: [PATCH 010/236] 8031819: Remove legacy jdk checks and code Delete old jdk specific code. Reviewed-by: dholmes, coleenp, zgu, lfoltan --- .../share/vm/classfile/classFileParser.cpp | 4 +- .../src/share/vm/classfile/classLoader.cpp | 98 +++---------------- .../src/share/vm/classfile/classLoader.hpp | 6 +- .../src/share/vm/classfile/javaClasses.cpp | 51 +++------- .../share/vm/classfile/systemDictionary.cpp | 2 - .../share/vm/classfile/systemDictionary.hpp | 23 +---- hotspot/src/share/vm/classfile/vmSymbols.hpp | 1 - .../src/share/vm/interpreter/linkResolver.cpp | 8 +- hotspot/src/share/vm/memory/universe.cpp | 8 -- hotspot/src/share/vm/oops/method.cpp | 3 +- hotspot/src/share/vm/prims/jvm.cpp | 44 --------- hotspot/src/share/vm/prims/unsafe.cpp | 62 +----------- hotspot/src/share/vm/runtime/arguments.cpp | 14 +-- hotspot/src/share/vm/runtime/java.hpp | 54 +--------- hotspot/src/share/vm/runtime/reflection.cpp | 81 ++------------- hotspot/src/share/vm/runtime/reflection.hpp | 3 - .../src/share/vm/runtime/reflectionUtils.cpp | 15 +-- .../src/share/vm/runtime/serviceThread.cpp | 5 +- hotspot/src/share/vm/runtime/thread.cpp | 78 ++++----------- hotspot/src/share/vm/runtime/vframe.cpp | 3 +- .../src/share/vm/runtime/vm_operations.cpp | 10 +- hotspot/src/share/vm/runtime/vm_version.cpp | 3 +- hotspot/src/share/vm/services/management.cpp | 12 +-- .../src/share/vm/services/threadService.cpp | 14 ++- 24 files changed, 95 insertions(+), 507 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index c7fe1c7d5a2..d72a50cbb52 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -4667,9 +4667,7 @@ bool ClassFileParser::has_illegal_visibility(jint flags) { } bool ClassFileParser::is_supported_version(u2 major, u2 minor) { - u2 max_version = - JDK_Version::is_gte_jdk17x_version() ? JAVA_MAX_SUPPORTED_VERSION : - (JDK_Version::is_gte_jdk16x_version() ? JAVA_6_VERSION : JAVA_1_5_VERSION); + u2 max_version = JAVA_MAX_SUPPORTED_VERSION; return (major >= JAVA_MIN_SUPPORTED_VERSION) && (major <= max_version) && ((major != max_version) || diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 8366c8fc4ce..46d979ed1df 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -1126,7 +1126,7 @@ void ClassLoader::verify() { // JDK 1.3 version -typedef struct real_jzentry13 { /* Zip file entry */ +typedef struct real_jzentry { /* Zip file entry */ char *name; /* entry name */ jint time; /* modification time */ jint size; /* size of uncompressed data */ @@ -1135,9 +1135,9 @@ typedef struct real_jzentry13 { /* Zip file entry */ char *comment; /* optional zip file comment */ jbyte *extra; /* optional extra data */ jint pos; /* position of LOC header (if negative) or data */ -} real_jzentry13; +} real_jzentry; -typedef struct real_jzfile13 { /* Zip file */ +typedef struct real_jzfile { /* Zip file */ char *name; /* zip file name */ jint refs; /* number of active references */ jint fd; /* open file descriptor */ @@ -1148,42 +1148,14 @@ typedef struct real_jzfile13 { /* Zip file */ jint total; /* total number of entries */ unsigned short *table; /* Hash chain heads: indexes into entries */ jint tablelen; /* number of hash eads */ - real_jzfile13 *next; /* next zip file in search list */ + real_jzfile *next; /* next zip file in search list */ jzentry *cache; /* we cache the most recently freed jzentry */ /* Information on metadata names in META-INF directory */ char **metanames; /* array of meta names (may have null names) */ jint metacount; /* number of slots in metanames array */ /* If there are any per-entry comments, they are in the comments array */ char **comments; -} real_jzfile13; - -// JDK 1.2 version -typedef struct real_jzentry12 { /* Zip file entry */ - char *name; /* entry name */ - jint time; /* modification time */ - jint size; /* size of uncompressed data */ - jint csize; /* size of compressed data (zero if uncompressed) */ - jint crc; /* crc of uncompressed data */ - char *comment; /* optional zip file comment */ - jbyte *extra; /* optional extra data */ - jint pos; /* position of LOC header (if negative) or data */ - struct real_jzentry12 *next; /* next entry in hash table */ -} real_jzentry12; - -typedef struct real_jzfile12 { /* Zip file */ - char *name; /* zip file name */ - jint refs; /* number of active references */ - jint fd; /* open file descriptor */ - void *lock; /* read lock */ - char *comment; /* zip file comment */ - char *msg; /* zip error message */ - real_jzentry12 *entries; /* array of zip entries */ - jint total; /* total number of entries */ - real_jzentry12 **table; /* hash table of entries */ - jint tablelen; /* number of buckets */ - jzfile *next; /* next zip file in search list */ -} real_jzfile12; - +} real_jzfile; void ClassPathDirEntry::compile_the_world(Handle loader, TRAPS) { // For now we only compile all methods in all classes in zip/jar files @@ -1197,10 +1169,14 @@ bool ClassPathDirEntry::is_rt_jar() { } void ClassPathZipEntry::compile_the_world(Handle loader, TRAPS) { - if (JDK_Version::is_jdk12x_version()) { - compile_the_world12(loader, THREAD); - } else { - compile_the_world13(loader, THREAD); + real_jzfile* zip = (real_jzfile*) _zip; + tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name); + tty->cr(); + // Iterate over all entries in zip file + for (int n = 0; ; n++) { + real_jzentry * ze = (real_jzentry *)((*GetNextEntry)(_zip, n)); + if (ze == NULL) break; + ClassLoader::compile_the_world_in(ze->name, loader, CHECK); } if (HAS_PENDING_EXCEPTION) { if (PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) { @@ -1213,54 +1189,8 @@ void ClassPathZipEntry::compile_the_world(Handle loader, TRAPS) { } } -// Version that works for JDK 1.3.x -void ClassPathZipEntry::compile_the_world13(Handle loader, TRAPS) { - real_jzfile13* zip = (real_jzfile13*) _zip; - tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name); - tty->cr(); - // Iterate over all entries in zip file - for (int n = 0; ; n++) { - real_jzentry13 * ze = (real_jzentry13 *)((*GetNextEntry)(_zip, n)); - if (ze == NULL) break; - ClassLoader::compile_the_world_in(ze->name, loader, CHECK); - } -} - - -// Version that works for JDK 1.2.x -void ClassPathZipEntry::compile_the_world12(Handle loader, TRAPS) { - real_jzfile12* zip = (real_jzfile12*) _zip; - tty->print_cr("CompileTheWorld : Compiling all classes in %s", zip->name); - tty->cr(); - // Iterate over all entries in zip file - for (int n = 0; ; n++) { - real_jzentry12 * ze = (real_jzentry12 *)((*GetNextEntry)(_zip, n)); - if (ze == NULL) break; - ClassLoader::compile_the_world_in(ze->name, loader, CHECK); - } -} - bool ClassPathZipEntry::is_rt_jar() { - if (JDK_Version::is_jdk12x_version()) { - return is_rt_jar12(); - } else { - return is_rt_jar13(); - } -} - -// JDK 1.3 version -bool ClassPathZipEntry::is_rt_jar13() { - real_jzfile13* zip = (real_jzfile13*) _zip; - int len = (int)strlen(zip->name); - // Check whether zip name ends in "rt.jar" - // This will match other archives named rt.jar as well, but this is - // only used for debugging. - return (len >= 6) && (strcasecmp(zip->name + len - 6, "rt.jar") == 0); -} - -// JDK 1.2 version -bool ClassPathZipEntry::is_rt_jar12() { - real_jzfile12* zip = (real_jzfile12*) _zip; + real_jzfile* zip = (real_jzfile*) _zip; int len = (int)strlen(zip->name); // Check whether zip name ends in "rt.jar" // This will match other archives named rt.jar as well, but this is diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp index e03cfad1b57..2cfcde6387e 100644 --- a/hotspot/src/share/vm/classfile/classLoader.hpp +++ b/hotspot/src/share/vm/classfile/classLoader.hpp @@ -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 @@ -111,11 +111,7 @@ class ClassPathZipEntry: public ClassPathEntry { void contents_do(void f(const char* name, void* context), void* context); // Debugging NOT_PRODUCT(void compile_the_world(Handle loader, TRAPS);) - NOT_PRODUCT(void compile_the_world12(Handle loader, TRAPS);) // JDK 1.2 version - NOT_PRODUCT(void compile_the_world13(Handle loader, TRAPS);) // JDK 1.3 version NOT_PRODUCT(bool is_rt_jar();) - NOT_PRODUCT(bool is_rt_jar12();) - NOT_PRODUCT(bool is_rt_jar13();) }; diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 628ddf910b7..0e61ff9f391 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -857,9 +857,7 @@ void java_lang_Class::compute_offsets() { } int java_lang_Class::classRedefinedCount(oop the_class_mirror) { - if (!JDK_Version::is_gte_jdk15x_version() - || classRedefinedCount_offset == -1) { - // The classRedefinedCount field is only present starting in 1.5. + if (classRedefinedCount_offset == -1) { // If we don't have an offset for it then just return -1 as a marker. return -1; } @@ -868,9 +866,7 @@ int java_lang_Class::classRedefinedCount(oop the_class_mirror) { } void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) { - if (!JDK_Version::is_gte_jdk15x_version() - || classRedefinedCount_offset == -1) { - // The classRedefinedCount field is only present starting in 1.5. + if (classRedefinedCount_offset == -1) { // If we don't have an offset for it then nothing to set. return; } @@ -1000,9 +996,7 @@ oop java_lang_Thread::inherited_access_control_context(oop java_thread) { jlong java_lang_Thread::stackSize(oop java_thread) { - // The stackSize field is only present starting in 1.4 if (_stackSize_offset > 0) { - assert(JDK_Version::is_gte_jdk14x_version(), "sanity check"); return java_thread->long_field(_stackSize_offset); } else { return 0; @@ -1078,7 +1072,7 @@ bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) { const char* java_lang_Thread::thread_status_name(oop java_thread) { - assert(JDK_Version::is_gte_jdk15x_version() && _thread_status_offset != 0, "Must have thread status"); + assert(_thread_status_offset != 0, "Must have thread status"); ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset); switch (status) { case NEW : return "NEW"; @@ -1217,7 +1211,6 @@ void java_lang_Throwable::set_stacktrace(oop throwable, oop st_element_array) { } void java_lang_Throwable::clear_stacktrace(oop throwable) { - assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4"); set_stacktrace(throwable, NULL); } @@ -1548,12 +1541,9 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, methodHandle met // Start out by clearing the backtrace for this object, in case the VM // runs out of memory while allocating the stack trace set_backtrace(throwable(), NULL); - if (JDK_Version::is_gte_jdk14x_version()) { - // New since 1.4, clear lazily constructed Java level stacktrace if - // refilling occurs - // This is unnecessary in 1.7+ but harmless - clear_stacktrace(throwable()); - } + // Clear lazily constructed Java level stacktrace if refilling occurs + // This is unnecessary in 1.7+ but harmless + clear_stacktrace(throwable()); int max_depth = MaxJavaStackTraceDepth; JavaThread* thread = (JavaThread*)THREAD; @@ -1739,13 +1729,9 @@ void java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(Handle t if (chunk_count >= max_chunks) break; } - // For Java 7+ we support the Throwable immutability protocol defined for Java 7. This support - // was missing in 7u0 so in 7u0 there is a workaround in the Throwable class. That workaround - // can be removed in a JDK using this JVM version - if (JDK_Version::is_gte_jdk17x_version()) { - java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace()); - assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized"); - } + // We support the Throwable immutability protocol defined for Java 7. + java_lang_Throwable::set_stacktrace(throwable(), java_lang_Throwable::unassigned_stacktrace()); + assert(java_lang_Throwable::unassigned_stacktrace() != NULL, "not initialized"); } @@ -3022,8 +3008,7 @@ bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) { // based on non-null field // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it bool java_lang_ClassLoader::parallelCapable(oop class_loader) { - if (!JDK_Version::is_gte_jdk17x_version() - || parallelCapable_offset == -1) { + if (parallelCapable_offset == -1) { // Default for backward compatibility is false return false; } @@ -3219,7 +3204,6 @@ void java_nio_Buffer::compute_offsets() { void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) { if (_owner_offset != 0) return; - assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later"); SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK); Klass* k = SystemDictionary::abstract_ownable_synchronizer_klass(); compute_offset(_owner_offset, k, @@ -3309,15 +3293,10 @@ void JavaClasses::compute_offsets() { java_lang_reflect_Method::compute_offsets(); java_lang_reflect_Constructor::compute_offsets(); java_lang_reflect_Field::compute_offsets(); - if (JDK_Version::is_gte_jdk14x_version()) { - java_nio_Buffer::compute_offsets(); - } - if (JDK_Version::is_gte_jdk15x_version()) { - sun_reflect_ConstantPool::compute_offsets(); - sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets(); - } - if (JDK_Version::is_gte_jdk18x_version()) - java_lang_reflect_Parameter::compute_offsets(); + java_nio_Buffer::compute_offsets(); + sun_reflect_ConstantPool::compute_offsets(); + sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets(); + java_lang_reflect_Parameter::compute_offsets(); // generated interpreter code wants to know about the offsets we just computed: AbstractAssembler::update_delayed_values(); @@ -3502,7 +3481,7 @@ void JavaClasses::check_offsets() { // into merlin "for some time." Without it, the vm will fail with early // merlin builds. - if (CheckAssertionStatusDirectives && JDK_Version::is_gte_jdk14x_version()) { + if (CheckAssertionStatusDirectives) { const char* nm = "java/lang/AssertionStatusDirectives"; const char* sig = "[Ljava/lang/String;"; CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig); diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index d09de41114d..9a6fa98908b 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1754,8 +1754,6 @@ void SystemDictionary::methods_do(void f(Method*)) { // Lazily load klasses void SystemDictionary::load_abstract_ownable_synchronizer_klass(TRAPS) { - assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later"); - // if multiple threads calling this function, only one thread will load // the class. The other threads will find the loaded version once the // class is loaded. diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index 4e1b75dc241..f26a9d8c56e 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -139,14 +139,13 @@ class Ticks; do_klass(reflect_Constructor_klass, java_lang_reflect_Constructor, Pre ) \ \ /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \ - /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ do_klass(reflect_MagicAccessorImpl_klass, sun_reflect_MagicAccessorImpl, Opt ) \ - do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \ - do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \ + do_klass(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Pre ) \ + do_klass(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Pre ) \ do_klass(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt ) \ - do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt_Only_JDK15 ) \ - do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15 ) \ + do_klass(reflect_ConstantPool_klass, sun_reflect_ConstantPool, Opt ) \ + do_klass(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt ) \ do_klass(reflect_CallerSensitive_klass, sun_reflect_CallerSensitive, Opt ) \ \ /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \ @@ -169,7 +168,6 @@ class Ticks; \ /* It's NULL in non-1.4 JDKs. */ \ do_klass(StackTraceElement_klass, java_lang_StackTraceElement, Opt ) \ - /* Universe::is_gte_jdk14x_version() is not set up by this point. */ \ /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \ \ @@ -209,10 +207,8 @@ class SystemDictionary : AllStatic { // Options after this point will use resolve_or_null instead. Opt, // preload tried; NULL if not present - Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection - Opt_Only_JDK15, // preload tried; use only with JDK1.5+ OPTION_LIMIT, - CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<is_anonymous() ? current_klass() : InstanceKlass::cast(current_klass())->host_klass(); - // As of the fix for 4486457 we disable verification for all of the - // dynamically-generated bytecodes associated with the 1.4 - // reflection implementation, not just those associated with - // sun/reflect/SerializationConstructorAccessor. - bool is_reflect = JDK_Version::is_gte_jdk14x_version() && - klass_to_check->is_subclass_of( + // Disable verification for the dynamically-generated reflection bytecodes. + bool is_reflect = klass_to_check->is_subclass_of( SystemDictionary::reflect_MagicAccessorImpl_klass()); if (!is_reflect && diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 0250f1a1b8d..5053b46e8c8 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -1000,9 +1000,6 @@ void universe2_init() { } -// This function is defined in JVM.cpp -extern void initialize_converter_functions(); - bool universe_post_init() { assert(!is_init_completed(), "Error: initialization not yet completed!"); Universe::_fully_initialized = true; @@ -1144,11 +1141,6 @@ bool universe_post_init() { SystemDictionary::ProtectionDomain_klass(), m);; } - // The following is initializing converter functions for serialization in - // JVM.cpp. If we clean up the StrictMath code above we may want to find - // a better solution for this as well. - initialize_converter_functions(); - // This needs to be done before the first scavenge/gc, since // it's an input to soft ref clearing policy. { diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 01ef61f2386..4549c68871f 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -1023,8 +1023,7 @@ bool Method::is_ignored_by_security_stack_walk() const { // This is Method.invoke() -- ignore it return true; } - if (JDK_Version::is_gte_jdk14x_version() && - method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { + if (method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass())) { // This is an auxilary frame -- ignore it return true; } diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 5b96377b24a..69e45bd11f7 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -3923,50 +3923,6 @@ JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) { } -// Support for Serialization - -typedef jfloat (JNICALL *IntBitsToFloatFn )(JNIEnv* env, jclass cb, jint value); -typedef jdouble (JNICALL *LongBitsToDoubleFn)(JNIEnv* env, jclass cb, jlong value); -typedef jint (JNICALL *FloatToIntBitsFn )(JNIEnv* env, jclass cb, jfloat value); -typedef jlong (JNICALL *DoubleToLongBitsFn)(JNIEnv* env, jclass cb, jdouble value); - -static IntBitsToFloatFn int_bits_to_float_fn = NULL; -static LongBitsToDoubleFn long_bits_to_double_fn = NULL; -static FloatToIntBitsFn float_to_int_bits_fn = NULL; -static DoubleToLongBitsFn double_to_long_bits_fn = NULL; - - -void initialize_converter_functions() { - if (JDK_Version::is_gte_jdk14x_version()) { - // These functions only exist for compatibility with 1.3.1 and earlier - return; - } - - // called from universe_post_init() - assert( - int_bits_to_float_fn == NULL && - long_bits_to_double_fn == NULL && - float_to_int_bits_fn == NULL && - double_to_long_bits_fn == NULL , - "initialization done twice" - ); - // initialize - int_bits_to_float_fn = CAST_TO_FN_PTR(IntBitsToFloatFn , NativeLookup::base_library_lookup("java/lang/Float" , "intBitsToFloat" , "(I)F")); - long_bits_to_double_fn = CAST_TO_FN_PTR(LongBitsToDoubleFn, NativeLookup::base_library_lookup("java/lang/Double", "longBitsToDouble", "(J)D")); - float_to_int_bits_fn = CAST_TO_FN_PTR(FloatToIntBitsFn , NativeLookup::base_library_lookup("java/lang/Float" , "floatToIntBits" , "(F)I")); - double_to_long_bits_fn = CAST_TO_FN_PTR(DoubleToLongBitsFn, NativeLookup::base_library_lookup("java/lang/Double", "doubleToLongBits", "(D)J")); - // verify - assert( - int_bits_to_float_fn != NULL && - long_bits_to_double_fn != NULL && - float_to_int_bits_fn != NULL && - double_to_long_bits_fn != NULL , - "initialization failed" - ); -} - - - // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) { diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 4dd10cfca57..332f8fb74ab 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -185,64 +185,7 @@ jint Unsafe_invocation_key_to_method_slot(jint key) { // Get/SetObject must be special-cased, since it works with handles. -// The xxx140 variants for backward compatibility do not allow a full-width offset. -UNSAFE_ENTRY(jobject, Unsafe_GetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset)) - UnsafeWrapper("Unsafe_GetObject"); - if (obj == NULL) THROW_0(vmSymbols::java_lang_NullPointerException()); - GET_OOP_FIELD(obj, offset, v) - jobject ret = JNIHandles::make_local(env, v); -#if INCLUDE_ALL_GCS - // We could be accessing the referent field in a reference - // object. If G1 is enabled then we need to register a non-null - // referent with the SATB barrier. - if (UseG1GC) { - bool needs_barrier = false; - - if (ret != NULL) { - if (offset == java_lang_ref_Reference::referent_offset) { - oop o = JNIHandles::resolve_non_null(obj); - Klass* k = o->klass(); - if (InstanceKlass::cast(k)->reference_type() != REF_NONE) { - assert(InstanceKlass::cast(k)->is_subclass_of(SystemDictionary::Reference_klass()), "sanity"); - needs_barrier = true; - } - } - } - - if (needs_barrier) { - oop referent = JNIHandles::resolve(ret); - G1SATBCardTableModRefBS::enqueue(referent); - } - } -#endif // INCLUDE_ALL_GCS - return ret; -UNSAFE_END - -UNSAFE_ENTRY(void, Unsafe_SetObject140(JNIEnv *env, jobject unsafe, jobject obj, jint offset, jobject x_h)) - UnsafeWrapper("Unsafe_SetObject"); - if (obj == NULL) THROW(vmSymbols::java_lang_NullPointerException()); - oop x = JNIHandles::resolve(x_h); - //SET_FIELD(obj, offset, oop, x); - oop p = JNIHandles::resolve(obj); - if (UseCompressedOops) { - if (x != NULL) { - // If there is a heap base pointer, we are obliged to emit a store barrier. - oop_store((narrowOop*)index_oop_from_field_offset_long(p, offset), x); - } else { - narrowOop n = oopDesc::encode_heap_oop_not_null(x); - *(narrowOop*)index_oop_from_field_offset_long(p, offset) = n; - } - } else { - if (x != NULL) { - // If there is a heap base pointer, we are obliged to emit a store barrier. - oop_store((oop*)index_oop_from_field_offset_long(p, offset), x); - } else { - *(oop*)index_oop_from_field_offset_long(p, offset) = x; - } - } -UNSAFE_END - -// The normal variants allow a null base pointer with an arbitrary address. +// These functions allow a null base pointer with an arbitrary address. // But if the base pointer is non-null, the offset should make some sense. // That is, it should be in the range [0, MAX_OBJECT_SIZE]. UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) @@ -1350,9 +1293,6 @@ UNSAFE_END // These are the methods for 1.4.0 static JNINativeMethod methods_140[] = { - {CC"getObject", CC"("OBJ"I)"OBJ"", FN_PTR(Unsafe_GetObject140)}, - {CC"putObject", CC"("OBJ"I"OBJ")V", FN_PTR(Unsafe_SetObject140)}, - DECLARE_GETSETOOP_140(Boolean, Z), DECLARE_GETSETOOP_140(Byte, B), DECLARE_GETSETOOP_140(Short, S), diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 91e485e7aed..88f1bfb400f 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -222,10 +222,8 @@ void Arguments::init_version_specific_system_properties() { const char* spec_vendor = "Sun Microsystems Inc."; uint32_t spec_version = 0; - if (JDK_Version::is_gte_jdk17x_version()) { - spec_vendor = "Oracle Corporation"; - spec_version = JDK_Version::current().major_version(); - } + spec_vendor = "Oracle Corporation"; + spec_version = JDK_Version::current().major_version(); jio_snprintf(buffer, bufsz, "1." UINT32_FORMAT, spec_version); PropertyList_add(&_system_properties, @@ -3695,14 +3693,6 @@ jint Arguments::parse(const JavaVMInitArgs* args) { PrintGC = true; } - if (!JDK_Version::is_gte_jdk18x_version()) { - // To avoid changing the log format for 7 updates this flag is only - // true by default in JDK8 and above. - if (FLAG_IS_DEFAULT(PrintGCCause)) { - FLAG_SET_DEFAULT(PrintGCCause, false); - } - } - // Set object alignment values. set_object_alignment(); diff --git a/hotspot/src/share/vm/runtime/java.hpp b/hotspot/src/share/vm/runtime/java.hpp index e5bae38c171..02ac99ebb60 100644 --- a/hotspot/src/share/vm/runtime/java.hpp +++ b/hotspot/src/share/vm/runtime/java.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -197,58 +197,6 @@ class JDK_Version VALUE_OBJ_CLASS_SPEC { _runtime_version = version; } - // Convenience methods for queries on the current major/minor version - static bool is_jdk12x_version() { - return current().compare_major(2) == 0; - } - - static bool is_jdk13x_version() { - return current().compare_major(3) == 0; - } - - static bool is_jdk14x_version() { - return current().compare_major(4) == 0; - } - - static bool is_jdk15x_version() { - return current().compare_major(5) == 0; - } - - static bool is_jdk16x_version() { - return current().compare_major(6) == 0; - } - - static bool is_jdk17x_version() { - return current().compare_major(7) == 0; - } - - static bool is_jdk18x_version() { - return current().compare_major(8) == 0; - } - - static bool is_gte_jdk13x_version() { - return current().compare_major(3) >= 0; - } - - static bool is_gte_jdk14x_version() { - return current().compare_major(4) >= 0; - } - - static bool is_gte_jdk15x_version() { - return current().compare_major(5) >= 0; - } - - static bool is_gte_jdk16x_version() { - return current().compare_major(6) >= 0; - } - - static bool is_gte_jdk17x_version() { - return current().compare_major(7) >= 0; - } - - static bool is_gte_jdk18x_version() { - return current().compare_major(8) >= 0; - } }; #endif // SHARE_VM_RUNTIME_JAVA_HPP diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index 872d73c72e8..cc35fea494b 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -410,49 +410,6 @@ oop Reflection::array_component_type(oop mirror, TRAPS) { } -bool Reflection::reflect_check_access(Klass* field_class, AccessFlags acc, Klass* target_class, bool is_method_invoke, TRAPS) { - // field_class : declaring class - // acc : declared field access - // target_class : for protected - - // Check if field or method is accessible to client. Throw an - // IllegalAccessException and return false if not. - - // The "client" is the class associated with the nearest real frame - // getCallerClass already skips Method.invoke frames, so pass 0 in - // that case (same as classic). - ResourceMark rm(THREAD); - assert(THREAD->is_Java_thread(), "sanity check"); - Klass* client_class = ((JavaThread *)THREAD)->security_get_caller_class(is_method_invoke ? 0 : 1); - - if (client_class != field_class) { - if (!verify_class_access(client_class, field_class, false) - || !verify_field_access(client_class, - field_class, - field_class, - acc, - false)) { - THROW_(vmSymbols::java_lang_IllegalAccessException(), false); - } - } - - // Additional test for protected members: JLS 6.6.2 - - if (acc.is_protected()) { - if (target_class != client_class) { - if (!is_same_class_package(client_class, field_class)) { - if (!target_class->is_subclass_of(client_class)) { - THROW_(vmSymbols::java_lang_IllegalAccessException(), false); - } - } - } - } - - // Passed all tests - return true; -} - - bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, bool classloader_only) { // Verify that current_class can access new_class. If the classloader_only // flag is set, we automatically allow any accesses in which current_class @@ -463,10 +420,9 @@ bool Reflection::verify_class_access(Klass* current_class, Klass* new_class, boo is_same_class_package(current_class, new_class)) { return true; } - // New (1.4) reflection implementation. Allow all accesses from - // sun/reflect/MagicAccessorImpl subclasses to succeed trivially. - if ( JDK_Version::is_gte_jdk14x_version() - && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { + // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to + // succeed trivially. + if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { return true; } @@ -567,10 +523,9 @@ bool Reflection::verify_field_access(Klass* current_class, return true; } - // New (1.4) reflection implementation. Allow all accesses from - // sun/reflect/MagicAccessorImpl subclasses to succeed trivially. - if ( JDK_Version::is_gte_jdk14x_version() - && current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { + // Allow all accesses from sun/reflect/MagicAccessorImpl subclasses to + // succeed trivially. + if (current_class->is_subclass_of(SystemDictionary::reflect_MagicAccessorImpl_klass())) { return true; } @@ -707,12 +662,10 @@ Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) { oop Reflection::new_method(methodHandle method, bool for_constant_pool_access, TRAPS) { - // In jdk1.2.x, getMethods on an interface erroneously includes , thus the complicated assert. - // Also allow sun.reflect.ConstantPool to refer to methods as java.lang.reflect.Methods. + // Allow sun.reflect.ConstantPool to refer to methods as java.lang.reflect.Methods. assert(!method()->is_initializer() || - (for_constant_pool_access && method()->is_static()) || - (method()->name() == vmSymbols::class_initializer_name() - && method()->method_holder()->is_interface() && JDK_Version::is_jdk12x_version()), "should call new_constructor instead"); + (for_constant_pool_access && method()->is_static()), + "should call new_constructor instead"); instanceKlassHandle holder (THREAD, method->method_holder()); int slot = method->method_idnum(); @@ -978,22 +931,6 @@ oop Reflection::invoke(instanceKlassHandle klass, methodHandle reflected_method, reflected_method->signature())); } - // In the JDK 1.4 reflection implementation, the security check is - // done at the Java level - if (!JDK_Version::is_gte_jdk14x_version()) { - - // Access checking (unless overridden by Method) - if (!override) { - if (!(klass->is_public() && reflected_method->is_public())) { - bool access = Reflection::reflect_check_access(klass(), reflected_method->access_flags(), target_klass(), is_method_invoke, CHECK_NULL); - if (!access) { - return NULL; // exception - } - } - } - - } // !Universe::is_gte_jdk14x_version() - assert(ptypes->is_objArray(), "just checking"); int args_len = args.is_null() ? 0 : args->length(); // Check number of arguments diff --git a/hotspot/src/share/vm/runtime/reflection.hpp b/hotspot/src/share/vm/runtime/reflection.hpp index 5757cfc39f5..593ff7ecc49 100644 --- a/hotspot/src/share/vm/runtime/reflection.hpp +++ b/hotspot/src/share/vm/runtime/reflection.hpp @@ -44,9 +44,6 @@ class FieldStream; class Reflection: public AllStatic { private: - // Access checking - static bool reflect_check_access(Klass* field_class, AccessFlags acc, Klass* target_class, bool is_method_invoke, TRAPS); - // Conversion static Klass* basic_type_mirror_to_arrayklass(oop basic_type_mirror, TRAPS); static oop basic_type_arrayklass_to_mirror(Klass* basic_type_arrayklass, TRAPS); diff --git a/hotspot/src/share/vm/runtime/reflectionUtils.cpp b/hotspot/src/share/vm/runtime/reflectionUtils.cpp index 2ec82abc91a..331d5a750a0 100644 --- a/hotspot/src/share/vm/runtime/reflectionUtils.cpp +++ b/hotspot/src/share/vm/runtime/reflectionUtils.cpp @@ -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 @@ -76,15 +76,10 @@ void FilteredFieldsMap::initialize() { int offset; offset = java_lang_Throwable::get_backtrace_offset(); _filtered_fields->append(new FilteredField(SystemDictionary::Throwable_klass(), offset)); - // The latest version of vm may be used with old jdk. - if (JDK_Version::is_gte_jdk16x_version()) { - // The following class fields do not exist in - // previous version of jdk. - offset = sun_reflect_ConstantPool::oop_offset(); - _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset)); - offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset(); - _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); - } + offset = sun_reflect_ConstantPool::oop_offset(); + _filtered_fields->append(new FilteredField(SystemDictionary::reflect_ConstantPool_klass(), offset)); + offset = sun_reflect_UnsafeStaticFieldAccessorImpl::base_offset(); + _filtered_fields->append(new FilteredField(SystemDictionary::reflect_UnsafeStaticFieldAccessorImpl_klass(), offset)); } int FilteredFieldStream::field_count() { diff --git a/hotspot/src/share/vm/runtime/serviceThread.cpp b/hotspot/src/share/vm/runtime/serviceThread.cpp index 3c1224abb2c..eb7cb4a439c 100644 --- a/hotspot/src/share/vm/runtime/serviceThread.cpp +++ b/hotspot/src/share/vm/runtime/serviceThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -41,8 +41,7 @@ void ServiceThread::initialize() { instanceKlassHandle klass (THREAD, SystemDictionary::Thread_klass()); instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); - const char* name = JDK_Version::is_gte_jdk17x_version() ? - "Service Thread" : "Low Memory Detector"; + const char* name = "Service Thread"; Handle string = java_lang_String::create_from_str(name, CHECK); diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index e9e9d22f197..061509ae144 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1738,55 +1738,26 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { CLEAR_PENDING_EXCEPTION; } - // FIXIT: The is_null check is only so it works better on JDK1.2 VM's. This - // has to be fixed by a runtime query method - if (!destroy_vm || JDK_Version::is_jdk12x_version()) { - // JSR-166: change call from from ThreadGroup.uncaughtException to - // java.lang.Thread.dispatchUncaughtException + if (!destroy_vm) { if (uncaught_exception.not_null()) { - Handle group(this, java_lang_Thread::threadGroup(threadObj())); - { - EXCEPTION_MARK; - // Check if the method Thread.dispatchUncaughtException() exists. If so - // call it. Otherwise we have an older library without the JSR-166 changes, - // so call ThreadGroup.uncaughtException() - KlassHandle recvrKlass(THREAD, threadObj->klass()); - CallInfo callinfo; - KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass()); - LinkResolver::resolve_virtual_call(callinfo, threadObj, recvrKlass, thread_klass, - vmSymbols::dispatchUncaughtException_name(), - vmSymbols::throwable_void_signature(), - KlassHandle(), false, false, THREAD); + EXCEPTION_MARK; + // Call method Thread.dispatchUncaughtException(). + KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass()); + JavaValue result(T_VOID); + JavaCalls::call_virtual(&result, + threadObj, thread_klass, + vmSymbols::dispatchUncaughtException_name(), + vmSymbols::throwable_void_signature(), + uncaught_exception, + THREAD); + if (HAS_PENDING_EXCEPTION) { + ResourceMark rm(this); + jio_fprintf(defaultStream::error_stream(), + "\nException: %s thrown from the UncaughtExceptionHandler" + " in thread \"%s\"\n", + pending_exception()->klass()->external_name(), + get_thread_name()); CLEAR_PENDING_EXCEPTION; - methodHandle method = callinfo.selected_method(); - if (method.not_null()) { - JavaValue result(T_VOID); - JavaCalls::call_virtual(&result, - threadObj, thread_klass, - vmSymbols::dispatchUncaughtException_name(), - vmSymbols::throwable_void_signature(), - uncaught_exception, - THREAD); - } else { - KlassHandle thread_group(THREAD, SystemDictionary::ThreadGroup_klass()); - JavaValue result(T_VOID); - JavaCalls::call_virtual(&result, - group, thread_group, - vmSymbols::uncaughtException_name(), - vmSymbols::thread_throwable_void_signature(), - threadObj, // Arg 1 - uncaught_exception, // Arg 2 - THREAD); - } - if (HAS_PENDING_EXCEPTION) { - ResourceMark rm(this); - jio_fprintf(defaultStream::error_stream(), - "\nException: %s thrown from the UncaughtExceptionHandler" - " in thread \"%s\"\n", - pending_exception()->klass()->external_name(), - get_thread_name()); - CLEAR_PENDING_EXCEPTION; - } } } @@ -2848,7 +2819,7 @@ void JavaThread::print_on(outputStream *st) const { Thread::print_on(st); // print guess for valid stack memory region (assume 4K pages); helps lock debugging st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12)); - if (thread_oop != NULL && JDK_Version::is_gte_jdk15x_version()) { + if (thread_oop != NULL) { st->print_cr(" java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop)); } #ifndef PRODUCT @@ -3948,15 +3919,8 @@ bool Threads::destroy_vm() { } os::wait_for_keypress_at_exit(); - if (JDK_Version::is_jdk12x_version()) { - // We are the last thread running, so check if finalizers should be run. - // For 1.3 or later this is done in thread->invoke_shutdown_hooks() - HandleMark rm(thread); - Universe::run_finalizers_on_exit(); - } else { - // run Java level shutdown hooks - thread->invoke_shutdown_hooks(); - } + // run Java level shutdown hooks + thread->invoke_shutdown_hooks(); before_exit(thread); diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index 79da635c443..57900245436 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -480,9 +480,8 @@ void vframeStreamCommon::skip_prefixed_method_and_wrappers() { void vframeStreamCommon::skip_reflection_related_frames() { while (!at_end() && - (JDK_Version::is_gte_jdk14x_version() && (method()->method_holder()->is_subclass_of(SystemDictionary::reflect_MethodAccessorImpl_klass()) || - method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass())))) { + method()->method_holder()->is_subclass_of(SystemDictionary::reflect_ConstructorAccessorImpl_klass()))) { next(); } } diff --git a/hotspot/src/share/vm/runtime/vm_operations.cpp b/hotspot/src/share/vm/runtime/vm_operations.cpp index d46e1f775ac..6f27fe3fecc 100644 --- a/hotspot/src/share/vm/runtime/vm_operations.cpp +++ b/hotspot/src/share/vm/runtime/vm_operations.cpp @@ -184,9 +184,7 @@ bool VM_PrintThreads::doit_prologue() { assert(Thread::current()->is_Java_thread(), "just checking"); // Make sure AbstractOwnableSynchronizer is loaded - if (JDK_Version::is_gte_jdk16x_version()) { - java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current()); - } + java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current()); // Get Heap_lock if concurrent locks will be dumped if (_print_concurrent_locks) { @@ -225,7 +223,7 @@ bool VM_FindDeadlocks::doit_prologue() { assert(Thread::current()->is_Java_thread(), "just checking"); // Load AbstractOwnableSynchronizer class - if (_concurrent_locks && JDK_Version::is_gte_jdk16x_version()) { + if (_concurrent_locks) { java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current()); } @@ -283,9 +281,7 @@ bool VM_ThreadDump::doit_prologue() { assert(Thread::current()->is_Java_thread(), "just checking"); // Load AbstractOwnableSynchronizer class before taking thread snapshots - if (JDK_Version::is_gte_jdk16x_version()) { - java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current()); - } + java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(JavaThread::current()); if (_with_locked_synchronizers) { // Acquire Heap_lock to dump concurrent locks diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp index 03fd43355bf..9fee996f687 100644 --- a/hotspot/src/share/vm/runtime/vm_version.cpp +++ b/hotspot/src/share/vm/runtime/vm_version.cpp @@ -160,8 +160,7 @@ const char* Abstract_VM_Version::vm_vendor() { #ifdef VENDOR return XSTR(VENDOR); #else - return JDK_Version::is_gte_jdk17x_version() ? - "Oracle Corporation" : "Sun Microsystems Inc."; + return "Oracle Corporation"; #endif } diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index dc901876104..2d6f2ff1d23 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1229,10 +1229,8 @@ JVM_ENTRY(jint, jmm_GetThreadInfo(JNIEnv *env, jlongArray ids, jint maxDepth, jo "The length of the given ThreadInfo array does not match the length of the given array of thread IDs", -1); } - if (JDK_Version::is_gte_jdk16x_version()) { - // make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots - java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_0); - } + // make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots + java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_0); // Must use ThreadDumpResult to store the ThreadSnapshot. // GC may occur after the thread snapshots are taken but before @@ -1303,10 +1301,8 @@ JVM_END JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboolean locked_monitors, jboolean locked_synchronizers)) ResourceMark rm(THREAD); - if (JDK_Version::is_gte_jdk16x_version()) { - // make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots - java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_NULL); - } + // make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots + java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(CHECK_NULL); typeArrayOop ta = typeArrayOop(JNIHandles::resolve(thread_ids)); int num_threads = (ta != NULL ? ta->length() : 0); diff --git a/hotspot/src/share/vm/services/threadService.cpp b/hotspot/src/share/vm/services/threadService.cpp index 02156a2f3e2..21d87567eed 100644 --- a/hotspot/src/share/vm/services/threadService.cpp +++ b/hotspot/src/share/vm/services/threadService.cpp @@ -665,17 +665,15 @@ void ConcurrentLocksDump::dump_at_safepoint() { // dump all locked concurrent locks assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped"); - if (JDK_Version::is_gte_jdk16x_version()) { - ResourceMark rm; + ResourceMark rm; - GrowableArray* aos_objects = new GrowableArray(INITIAL_ARRAY_SIZE); + GrowableArray* aos_objects = new GrowableArray(INITIAL_ARRAY_SIZE); - // Find all instances of AbstractOwnableSynchronizer - HeapInspection::find_instances_at_safepoint(SystemDictionary::abstract_ownable_synchronizer_klass(), + // Find all instances of AbstractOwnableSynchronizer + HeapInspection::find_instances_at_safepoint(SystemDictionary::abstract_ownable_synchronizer_klass(), aos_objects); - // Build a map of thread to its owned AQS locks - build_map(aos_objects); - } + // Build a map of thread to its owned AQS locks + build_map(aos_objects); } From d9b63bdbdd02b9ad8e5cf90a811b2759e191104d Mon Sep 17 00:00:00 2001 From: David Simms Date: Wed, 11 Jun 2014 18:34:09 +0200 Subject: [PATCH 011/236] 8043224: -Xcheck:jni improvements to exception checking and excessive local refs Warning when not checking exceptions from function that require so, also when local refs expand beyond capacity. Reviewed-by: zgu, coleenp, hseigel --- hotspot/src/share/vm/memory/guardedMemory.hpp | 6 +- hotspot/src/share/vm/prims/jniCheck.cpp | 269 +++++++++++------- hotspot/src/share/vm/runtime/jniHandles.cpp | 7 + hotspot/src/share/vm/runtime/jniHandles.hpp | 10 +- hotspot/src/share/vm/runtime/thread.cpp | 1 + hotspot/src/share/vm/runtime/thread.hpp | 9 + 6 files changed, 201 insertions(+), 101 deletions(-) diff --git a/hotspot/src/share/vm/memory/guardedMemory.hpp b/hotspot/src/share/vm/memory/guardedMemory.hpp index dada10d84bf..0d37bb03361 100644 --- a/hotspot/src/share/vm/memory/guardedMemory.hpp +++ b/hotspot/src/share/vm/memory/guardedMemory.hpp @@ -235,7 +235,7 @@ protected: * @return the size of the user data. */ size_t get_user_size() const { - assert(_base_addr, "Not wrapping any memory"); + assert(_base_addr != NULL, "Not wrapping any memory"); return get_head_guard()->get_user_size(); } @@ -245,7 +245,7 @@ protected: * @return the user data pointer. */ u_char* get_user_ptr() const { - assert(_base_addr, "Not wrapping any memory"); + assert(_base_addr != NULL, "Not wrapping any memory"); return _base_addr + sizeof(GuardHeader); } @@ -281,7 +281,7 @@ protected: memset(get_user_ptr(), ch, get_user_size()); } -public: + public: /** * Return the total size required for wrapping the given user size. * diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp index 446c23143ae..de9b4e56a86 100644 --- a/hotspot/src/share/vm/prims/jniCheck.cpp +++ b/hotspot/src/share/vm/prims/jniCheck.cpp @@ -53,6 +53,8 @@ # include "jniTypes_ppc.hpp" #endif +// Complain every extra number of unplanned local refs +#define CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD 32 // Heap objects are allowed to be directly referenced only in VM code, // not in native code. @@ -168,12 +170,42 @@ static void NativeReportJNIWarning(JavaThread* thr, const char *msg) { * SUPPORT FUNCTIONS */ +/** + * Check whether or not a programmer has actually checked for exceptions. According + * to the JNI Specification ("jni/spec/design.html#java_exceptions"): + * + * There are two cases where the programmer needs to check for exceptions without + * being able to first check an error code: + * + * - The JNI functions that invoke a Java method return the result of the Java method. + * The programmer must call ExceptionOccurred() to check for possible exceptions + * that occurred during the execution of the Java method. + * + * - Some of the JNI array access functions do not return an error code, but may + * throw an ArrayIndexOutOfBoundsException or ArrayStoreException. + * + * In all other cases, a non-error return value guarantees that no exceptions have been thrown. + */ static inline void -functionEnterCritical(JavaThread* thr) -{ +check_pending_exception(JavaThread* thr) { if (thr->has_pending_exception()) { NativeReportJNIWarning(thr, "JNI call made with exception pending"); } + if (thr->is_pending_jni_exception_check()) { + IN_VM( + tty->print_cr("WARNING in native method: JNI call made without checking exceptions when required to from %s", + thr->get_pending_jni_exception_check()); + thr->print_stack(); + ) + thr->clear_pending_jni_exception_check(); // Just complain once + } +} + + +static inline void +functionEnterCritical(JavaThread* thr) +{ + check_pending_exception(thr); } static inline void @@ -187,9 +219,7 @@ functionEnter(JavaThread* thr) if (thr->in_critical()) { tty->print_cr("%s", warn_other_function_in_critical); } - if (thr->has_pending_exception()) { - NativeReportJNIWarning(thr, "JNI call made with exception pending"); - } + check_pending_exception(thr); } static inline void @@ -201,9 +231,20 @@ functionEnterExceptionAllowed(JavaThread* thr) } static inline void -functionExit(JNIEnv *env) +functionExit(JavaThread* thr) { - /* nothing to do at this time */ + JNIHandleBlock* handles = thr->active_handles(); + size_t planned_capacity = handles->get_planned_capacity(); + size_t live_handles = handles->get_number_of_live_handles(); + if (live_handles > planned_capacity) { + IN_VM( + tty->print_cr("WARNING: JNI local refs: %zu, exceeds capacity: %zu", + live_handles, planned_capacity); + thr->print_stack(); + ) + // Complain just the once, reset to current + warn threshold + handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); + } } static inline void @@ -508,7 +549,7 @@ JNI_ENTRY_CHECKED(jclass, jniCheck::validate_object(thr, loader); ) jclass result = UNCHECKED()->DefineClass(env, name, loader, buf, len); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -520,7 +561,7 @@ JNI_ENTRY_CHECKED(jclass, jniCheck::validate_class_descriptor(thr, name); ) jclass result = UNCHECKED()->FindClass(env, name); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -532,7 +573,7 @@ JNI_ENTRY_CHECKED(jmethodID, jniCheck::validate_object(thr, method); ) jmethodID result = UNCHECKED()->FromReflectedMethod(env, method); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -544,7 +585,7 @@ JNI_ENTRY_CHECKED(jfieldID, jniCheck::validate_object(thr, field); ) jfieldID result = UNCHECKED()->FromReflectedField(env, field); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -560,7 +601,7 @@ JNI_ENTRY_CHECKED(jobject, ) jobject result = UNCHECKED()->ToReflectedMethod(env, cls, methodID, isStatic); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -572,7 +613,7 @@ JNI_ENTRY_CHECKED(jclass, jniCheck::validate_class(thr, sub, true); ) jclass result = UNCHECKED()->GetSuperclass(env, sub); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -586,7 +627,7 @@ JNI_ENTRY_CHECKED(jboolean, jniCheck::validate_class(thr, sup, true); ) jboolean result = UNCHECKED()->IsAssignableFrom(env, sub, sup); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -601,7 +642,7 @@ JNI_ENTRY_CHECKED(jobject, ) jobject result = UNCHECKED()->ToReflectedField(env, cls, fieldID, isStatic); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -619,7 +660,7 @@ JNI_ENTRY_CHECKED(jint, } ) jint result = UNCHECKED()->Throw(env, obj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -634,15 +675,16 @@ JNI_ENTRY_CHECKED(jint, jniCheck::validate_throwable_klass(thr, k); ) jint result = UNCHECKED()->ThrowNew(env, clazz, msg); - functionExit(env); + functionExit(thr); return result; JNI_END JNI_ENTRY_CHECKED(jthrowable, checked_jni_ExceptionOccurred(JNIEnv *env)) + thr->clear_pending_jni_exception_check(); functionEnterExceptionAllowed(thr); jthrowable result = UNCHECKED()->ExceptionOccurred(env); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -650,22 +692,24 @@ JNI_ENTRY_CHECKED(void, checked_jni_ExceptionDescribe(JNIEnv *env)) functionEnterExceptionAllowed(thr); UNCHECKED()->ExceptionDescribe(env); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, checked_jni_ExceptionClear(JNIEnv *env)) + thr->clear_pending_jni_exception_check(); functionEnterExceptionAllowed(thr); UNCHECKED()->ExceptionClear(env); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, checked_jni_FatalError(JNIEnv *env, const char *msg)) + thr->clear_pending_jni_exception_check(); functionEnter(thr); UNCHECKED()->FatalError(env, msg); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jint, @@ -675,7 +719,10 @@ JNI_ENTRY_CHECKED(jint, if (capacity < 0) NativeReportJNIFatalError(thr, "negative capacity"); jint result = UNCHECKED()->PushLocalFrame(env, capacity); - functionExit(env); + if (result == JNI_OK) { + thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); + } + functionExit(thr); return result; JNI_END @@ -684,7 +731,7 @@ JNI_ENTRY_CHECKED(jobject, jobject result)) functionEnterExceptionAllowed(thr); jobject res = UNCHECKED()->PopLocalFrame(env, result); - functionExit(env); + functionExit(thr); return res; JNI_END @@ -698,7 +745,7 @@ JNI_ENTRY_CHECKED(jobject, } ) jobject result = UNCHECKED()->NewGlobalRef(env,lobj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -714,7 +761,7 @@ JNI_ENTRY_CHECKED(void, } ) UNCHECKED()->DeleteGlobalRef(env,gref); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -729,7 +776,7 @@ JNI_ENTRY_CHECKED(void, "Invalid local JNI handle passed to DeleteLocalRef"); ) UNCHECKED()->DeleteLocalRef(env, obj); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jboolean, @@ -750,7 +797,7 @@ JNI_ENTRY_CHECKED(jboolean, } ) jboolean result = UNCHECKED()->IsSameObject(env,obj1,obj2); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -764,7 +811,7 @@ JNI_ENTRY_CHECKED(jobject, } ) jobject result = UNCHECKED()->NewLocalRef(env, ref); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -776,7 +823,10 @@ JNI_ENTRY_CHECKED(jint, NativeReportJNIFatalError(thr, "negative capacity"); } jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity); - functionExit(env); + if (result == JNI_OK) { + thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD); + } + functionExit(thr); return result; JNI_END @@ -788,7 +838,7 @@ JNI_ENTRY_CHECKED(jobject, jniCheck::validate_class(thr, clazz, false); ) jobject result = UNCHECKED()->AllocObject(env,clazz); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -806,7 +856,7 @@ JNI_ENTRY_CHECKED(jobject, va_start(args, methodID); jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args); va_end(args); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -821,7 +871,7 @@ JNI_ENTRY_CHECKED(jobject, jniCheck::validate_jmethod_id(thr, methodID); ) jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -836,7 +886,7 @@ JNI_ENTRY_CHECKED(jobject, jniCheck::validate_jmethod_id(thr, methodID); ) jobject result = UNCHECKED()->NewObjectA(env,clazz,methodID,args); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -848,7 +898,7 @@ JNI_ENTRY_CHECKED(jclass, jniCheck::validate_object(thr, obj); ) jclass result = UNCHECKED()->GetObjectClass(env,obj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -862,7 +912,7 @@ JNI_ENTRY_CHECKED(jboolean, jniCheck::validate_class(thr, clazz, true); ) jboolean result = UNCHECKED()->IsInstanceOf(env,obj,clazz); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -876,7 +926,7 @@ JNI_ENTRY_CHECKED(jmethodID, jniCheck::validate_class(thr, clazz, false); ) jmethodID result = UNCHECKED()->GetMethodID(env,clazz,name,sig); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -895,7 +945,8 @@ JNI_ENTRY_CHECKED(ResultType, \ ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \ args); \ va_end(args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("Call"#Result"Method"); \ + functionExit(thr); \ return result; \ JNI_END \ \ @@ -910,7 +961,8 @@ JNI_ENTRY_CHECKED(ResultType, \ ) \ ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\ args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("Call"#Result"MethodV"); \ + functionExit(thr); \ return result; \ JNI_END \ \ @@ -925,7 +977,8 @@ JNI_ENTRY_CHECKED(ResultType, \ ) \ ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\ args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("Call"#Result"MethodA"); \ + functionExit(thr); \ return result; \ JNI_END @@ -952,7 +1005,8 @@ JNI_ENTRY_CHECKED(void, va_start(args,methodID); UNCHECKED()->CallVoidMethodV(env,obj,methodID,args); va_end(args); - functionExit(env); + thr->set_pending_jni_exception_check("CallVoidMethod"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -965,7 +1019,8 @@ JNI_ENTRY_CHECKED(void, jniCheck::validate_call_object(thr, obj, methodID); ) UNCHECKED()->CallVoidMethodV(env,obj,methodID,args); - functionExit(env); + thr->set_pending_jni_exception_check("CallVoidMethodV"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -978,7 +1033,8 @@ JNI_ENTRY_CHECKED(void, jniCheck::validate_call_object(thr, obj, methodID); ) UNCHECKED()->CallVoidMethodA(env,obj,methodID,args); - functionExit(env); + thr->set_pending_jni_exception_check("CallVoidMethodA"); + functionExit(thr); JNI_END #define WRAPPER_CallNonvirtualMethod(ResultType, Result) \ @@ -1001,7 +1057,8 @@ JNI_ENTRY_CHECKED(ResultType, \ methodID,\ args); \ va_end(args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("CallNonvirtual"#Result"Method"); \ + functionExit(thr); \ return result; \ JNI_END \ \ @@ -1021,7 +1078,8 @@ JNI_ENTRY_CHECKED(ResultType, \ clazz, \ methodID,\ args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodV"); \ + functionExit(thr); \ return result; \ JNI_END \ \ @@ -1041,7 +1099,8 @@ JNI_ENTRY_CHECKED(ResultType, \ clazz, \ methodID,\ args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodA"); \ + functionExit(thr); \ return result; \ JNI_END @@ -1070,7 +1129,8 @@ JNI_ENTRY_CHECKED(void, va_start(args,methodID); UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args); va_end(args); - functionExit(env); + thr->set_pending_jni_exception_check("CallNonvirtualVoidMethod"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -1085,7 +1145,8 @@ JNI_ENTRY_CHECKED(void, jniCheck::validate_call_class(thr, clazz, methodID); ) UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args); - functionExit(env); + thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodV"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -1100,7 +1161,8 @@ JNI_ENTRY_CHECKED(void, jniCheck::validate_call_class(thr, clazz, methodID); ) UNCHECKED()->CallNonvirtualVoidMethodA(env,obj,clazz,methodID,args); - functionExit(env); + thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodA"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jfieldID, @@ -1113,7 +1175,7 @@ JNI_ENTRY_CHECKED(jfieldID, jniCheck::validate_class(thr, clazz, false); ) jfieldID result = UNCHECKED()->GetFieldID(env,clazz,name,sig); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1127,7 +1189,7 @@ JNI_ENTRY_CHECKED(ReturnType, \ checkInstanceFieldID(thr, fieldID, obj, FieldType); \ ) \ ReturnType result = UNCHECKED()->Get##Result##Field(env,obj,fieldID); \ - functionExit(env); \ + functionExit(thr); \ return result; \ JNI_END @@ -1152,7 +1214,7 @@ JNI_ENTRY_CHECKED(void, \ checkInstanceFieldID(thr, fieldID, obj, FieldType); \ ) \ UNCHECKED()->Set##Result##Field(env,obj,fieldID,val); \ - functionExit(env); \ + functionExit(thr); \ JNI_END WRAPPER_SetField(jobject, Object, T_OBJECT) @@ -1176,7 +1238,7 @@ JNI_ENTRY_CHECKED(jmethodID, jniCheck::validate_class(thr, clazz, false); ) jmethodID result = UNCHECKED()->GetStaticMethodID(env,clazz,name,sig); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1198,7 +1260,8 @@ JNI_ENTRY_CHECKED(ReturnType, \ methodID, \ args); \ va_end(args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("CallStatic"#Result"Method"); \ + functionExit(thr); \ return result; \ JNI_END \ \ @@ -1216,7 +1279,8 @@ JNI_ENTRY_CHECKED(ReturnType, \ clazz, \ methodID, \ args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("CallStatic"#Result"MethodV"); \ + functionExit(thr); \ return result; \ JNI_END \ \ @@ -1234,7 +1298,8 @@ JNI_ENTRY_CHECKED(ReturnType, \ clazz, \ methodID, \ args); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("CallStatic"#Result"MethodA"); \ + functionExit(thr); \ return result; \ JNI_END @@ -1262,7 +1327,8 @@ JNI_ENTRY_CHECKED(void, va_start(args,methodID); UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args); va_end(args); - functionExit(env); + thr->set_pending_jni_exception_check("CallStaticVoidMethod"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -1276,7 +1342,8 @@ JNI_ENTRY_CHECKED(void, jniCheck::validate_class(thr, cls, false); ) UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args); - functionExit(env); + thr->set_pending_jni_exception_check("CallStaticVoidMethodV"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -1290,7 +1357,8 @@ JNI_ENTRY_CHECKED(void, jniCheck::validate_class(thr, cls, false); ) UNCHECKED()->CallStaticVoidMethodA(env,cls,methodID,args); - functionExit(env); + thr->set_pending_jni_exception_check("CallStaticVoidMethodA"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jfieldID, @@ -1303,7 +1371,7 @@ JNI_ENTRY_CHECKED(jfieldID, jniCheck::validate_class(thr, clazz, false); ) jfieldID result = UNCHECKED()->GetStaticFieldID(env,clazz,name,sig); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1320,7 +1388,7 @@ JNI_ENTRY_CHECKED(ReturnType, \ ReturnType result = UNCHECKED()->GetStatic##Result##Field(env, \ clazz, \ fieldID); \ - functionExit(env); \ + functionExit(thr); \ return result; \ JNI_END @@ -1346,7 +1414,7 @@ JNI_ENTRY_CHECKED(void, \ checkStaticFieldID(thr, fieldID, clazz, FieldType); \ ) \ UNCHECKED()->SetStatic##Result##Field(env,clazz,fieldID,value); \ - functionExit(env); \ + functionExit(thr); \ JNI_END WRAPPER_SetStaticField(jobject, Object, T_OBJECT) @@ -1366,7 +1434,7 @@ JNI_ENTRY_CHECKED(jstring, jsize len)) functionEnter(thr); jstring result = UNCHECKED()->NewString(env,unicode,len); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1378,7 +1446,7 @@ JNI_ENTRY_CHECKED(jsize, checkString(thr, str); ) jsize result = UNCHECKED()->GetStringLength(env,str); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1407,7 +1475,7 @@ JNI_ENTRY_CHECKED(const jchar *, // Note that the dtrace arguments for the allocated memory will not match up with this solution. FreeHeap((char*)result); } - functionExit(env); + functionExit(thr); return new_result; JNI_END @@ -1442,7 +1510,7 @@ JNI_ENTRY_CHECKED(void, UNCHECKED()->ReleaseStringChars(env, str, (const jchar*) guarded.release_for_freeing()); } - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jstring, @@ -1450,7 +1518,7 @@ JNI_ENTRY_CHECKED(jstring, const char *utf)) functionEnter(thr); jstring result = UNCHECKED()->NewStringUTF(env,utf); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1462,7 +1530,7 @@ JNI_ENTRY_CHECKED(jsize, checkString(thr, str); ) jsize result = UNCHECKED()->GetStringUTFLength(env,str); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1490,7 +1558,7 @@ JNI_ENTRY_CHECKED(const char *, // Note that the dtrace arguments for the allocated memory will not match up with this solution. FreeHeap((char*)result, mtInternal); } - functionExit(env); + functionExit(thr); return new_result; JNI_END @@ -1525,7 +1593,7 @@ JNI_ENTRY_CHECKED(void, UNCHECKED()->ReleaseStringUTFChars(env, str, (const char*) guarded.release_for_freeing()); } - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jsize, @@ -1536,7 +1604,7 @@ JNI_ENTRY_CHECKED(jsize, check_is_array(thr, array); ) jsize result = UNCHECKED()->GetArrayLength(env,array); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1547,7 +1615,7 @@ JNI_ENTRY_CHECKED(jobjectArray, jobject init)) functionEnter(thr); jobjectArray result = UNCHECKED()->NewObjectArray(env,len,clazz,init); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1560,7 +1628,8 @@ JNI_ENTRY_CHECKED(jobject, check_is_obj_array(thr, array); ) jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index); - functionExit(env); + thr->set_pending_jni_exception_check("GetObjectArrayElement"); + functionExit(thr); return result; JNI_END @@ -1574,7 +1643,8 @@ JNI_ENTRY_CHECKED(void, check_is_obj_array(thr, array); ) UNCHECKED()->SetObjectArrayElement(env,array,index,val); - functionExit(env); + thr->set_pending_jni_exception_check("SetObjectArrayElement"); + functionExit(thr); JNI_END #define WRAPPER_NewScalarArray(Return, Result) \ @@ -1583,7 +1653,7 @@ JNI_ENTRY_CHECKED(Return, \ jsize len)) \ functionEnter(thr); \ Return result = UNCHECKED()->New##Result##Array(env,len); \ - functionExit(env); \ + functionExit(thr); \ return (Return) result; \ JNI_END @@ -1611,7 +1681,7 @@ JNI_ENTRY_CHECKED(ElementType *, \ if (result != NULL) { \ result = (ElementType *) check_jni_wrap_copy_array(thr, array, result); \ } \ - functionExit(env); \ + functionExit(thr); \ return result; \ JNI_END @@ -1639,7 +1709,7 @@ JNI_ENTRY_CHECKED(void, \ ElementType* orig_result = (ElementType *) check_wrapped_array_release( \ thr, "checked_jni_Release"#Result"ArrayElements", array, elems, mode); \ UNCHECKED()->Release##Result##ArrayElements(env, array, orig_result, mode); \ - functionExit(env); \ + functionExit(thr); \ JNI_END WRAPPER_ReleaseScalarArrayElements(T_BOOLEAN,jboolean, Boolean, bool) @@ -1663,7 +1733,8 @@ JNI_ENTRY_CHECKED(void, \ check_primitive_array_type(thr, array, ElementTag); \ ) \ UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \ + functionExit(thr); \ JNI_END WRAPPER_GetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean) @@ -1687,7 +1758,8 @@ JNI_ENTRY_CHECKED(void, \ check_primitive_array_type(thr, array, ElementTag); \ ) \ UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \ - functionExit(env); \ + thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \ + functionExit(thr); \ JNI_END WRAPPER_SetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean) @@ -1706,7 +1778,7 @@ JNI_ENTRY_CHECKED(jint, jint nMethods)) functionEnter(thr); jint result = UNCHECKED()->RegisterNatives(env,clazz,methods,nMethods); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1715,7 +1787,7 @@ JNI_ENTRY_CHECKED(jint, jclass clazz)) functionEnter(thr); jint result = UNCHECKED()->UnregisterNatives(env,clazz); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1727,7 +1799,7 @@ JNI_ENTRY_CHECKED(jint, jniCheck::validate_object(thr, obj); ) jint result = UNCHECKED()->MonitorEnter(env,obj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1739,7 +1811,7 @@ JNI_ENTRY_CHECKED(jint, jniCheck::validate_object(thr, obj); ) jint result = UNCHECKED()->MonitorExit(env,obj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1748,7 +1820,7 @@ JNI_ENTRY_CHECKED(jint, JavaVM **vm)) functionEnter(thr); jint result = UNCHECKED()->GetJavaVM(env,vm); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1763,7 +1835,8 @@ JNI_ENTRY_CHECKED(void, checkString(thr, str); ) UNCHECKED()->GetStringRegion(env, str, start, len, buf); - functionExit(env); + thr->set_pending_jni_exception_check("GetStringRegion"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void, @@ -1777,7 +1850,8 @@ JNI_ENTRY_CHECKED(void, checkString(thr, str); ) UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf); - functionExit(env); + thr->set_pending_jni_exception_check("GetStringUTFRegion"); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(void *, @@ -1792,7 +1866,7 @@ JNI_ENTRY_CHECKED(void *, if (result != NULL) { result = check_jni_wrap_copy_array(thr, array, result); } - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1808,7 +1882,7 @@ JNI_ENTRY_CHECKED(void, // Check the element array... void* orig_result = check_wrapped_array_release(thr, "ReleasePrimitiveArrayCritical", array, carray, mode); UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, orig_result, mode); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(const jchar*, @@ -1820,7 +1894,7 @@ JNI_ENTRY_CHECKED(const jchar*, checkString(thr, string); ) const jchar *result = UNCHECKED()->GetStringCritical(env, string, isCopy); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1836,7 +1910,7 @@ JNI_ENTRY_CHECKED(void, * string parameter as a minor sanity check */ UNCHECKED()->ReleaseStringCritical(env, str, chars); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jweak, @@ -1849,7 +1923,7 @@ JNI_ENTRY_CHECKED(jweak, } ) jweak result = UNCHECKED()->NewWeakGlobalRef(env, obj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1858,14 +1932,15 @@ JNI_ENTRY_CHECKED(void, jweak ref)) functionEnterExceptionAllowed(thr); UNCHECKED()->DeleteWeakGlobalRef(env, ref); - functionExit(env); + functionExit(thr); JNI_END JNI_ENTRY_CHECKED(jboolean, checked_jni_ExceptionCheck(JNIEnv *env)) + thr->clear_pending_jni_exception_check(); functionEnterExceptionAllowed(thr); jboolean result = UNCHECKED()->ExceptionCheck(env); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1875,7 +1950,7 @@ JNI_ENTRY_CHECKED(jobject, jlong capacity)) functionEnter(thr); jobject result = UNCHECKED()->NewDirectByteBuffer(env, address, capacity); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1884,7 +1959,7 @@ JNI_ENTRY_CHECKED(void *, jobject buf)) functionEnter(thr); void* result = UNCHECKED()->GetDirectBufferAddress(env, buf); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1893,7 +1968,7 @@ JNI_ENTRY_CHECKED(jlong, jobject buf)) functionEnter(thr); jlong result = UNCHECKED()->GetDirectBufferCapacity(env, buf); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1906,7 +1981,7 @@ JNI_ENTRY_CHECKED(jobjectRefType, jniCheck::validate_object(thr, obj); ) jobjectRefType result = UNCHECKED()->GetObjectRefType(env, obj); - functionExit(env); + functionExit(thr); return result; JNI_END @@ -1915,7 +1990,7 @@ JNI_ENTRY_CHECKED(jint, checked_jni_GetVersion(JNIEnv *env)) functionEnter(thr); jint result = UNCHECKED()->GetVersion(env); - functionExit(env); + functionExit(thr); return result; JNI_END diff --git a/hotspot/src/share/vm/runtime/jniHandles.cpp b/hotspot/src/share/vm/runtime/jniHandles.cpp index 7ff38335029..9ce7ce8ae44 100644 --- a/hotspot/src/share/vm/runtime/jniHandles.cpp +++ b/hotspot/src/share/vm/runtime/jniHandles.cpp @@ -298,6 +298,7 @@ JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread) { block->_top = 0; block->_next = NULL; block->_pop_frame_link = NULL; + block->_planned_capacity = block_size_in_oops; // _last, _free_list & _allocate_before_rebuild initialized in allocate_handle debug_only(block->_last = NULL); debug_only(block->_free_list = NULL); @@ -531,6 +532,12 @@ int JNIHandleBlock::length() const { return result; } +const size_t JNIHandleBlock::get_number_of_live_handles() { + CountHandleClosure counter; + oops_do(&counter); + return counter.count(); +} + // This method is not thread-safe, i.e., must be called while holding a lock on the // structure. long JNIHandleBlock::memory_usage() const { diff --git a/hotspot/src/share/vm/runtime/jniHandles.hpp b/hotspot/src/share/vm/runtime/jniHandles.hpp index 1bd97c3cf09..069a1f35cfa 100644 --- a/hotspot/src/share/vm/runtime/jniHandles.hpp +++ b/hotspot/src/share/vm/runtime/jniHandles.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -112,6 +112,9 @@ class JNIHandleBlock : public CHeapObj { oop* _free_list; // Handle free list int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list + // Check JNI, "planned capacity" for current frame (or push/ensure) + size_t _planned_capacity; + #ifndef PRODUCT JNIHandleBlock* _block_list_link; // Link for list below static JNIHandleBlock* _block_list; // List of all allocated blocks (for debugging only) @@ -152,6 +155,11 @@ class JNIHandleBlock : public CHeapObj { // Traversal of weak handles. Unreachable oops are cleared. void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f); + // Checked JNI support + void set_planned_capacity(size_t planned_capacity) { _planned_capacity = planned_capacity; } + const size_t get_planned_capacity() { return _planned_capacity; } + const size_t get_number_of_live_handles(); + // Debugging bool chain_contains(jobject handle) const; // Does this block or following blocks contain handle bool contains(jobject handle) const; // Does this block contain handle diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 061509ae144..e3ab1725a1d 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1448,6 +1448,7 @@ void JavaThread::initialize() { _thread_stat = new ThreadStatistics(); _blocked_on_compilation = false; _jni_active_critical = 0; + _pending_jni_exception_check_fn = NULL; _do_not_unlock_if_synchronized = false; _cached_monitor_info = NULL; _parker = Parker::Allocate(this) ; diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index a5f0a92246d..64bed4610b0 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -915,6 +915,9 @@ class JavaThread: public Thread { // support for JNI critical regions jint _jni_active_critical; // count of entries into JNI critical region + // Checked JNI: function name requires exception check + char* _pending_jni_exception_check_fn; + // For deadlock detection. int _depth_first_number; @@ -1400,6 +1403,12 @@ class JavaThread: public Thread { assert(_jni_active_critical >= 0, "JNI critical nesting problem?"); } + // Checked JNI, is the programmer required to check for exceptions, specify which function name + bool is_pending_jni_exception_check() const { return _pending_jni_exception_check_fn != NULL; } + void clear_pending_jni_exception_check() { _pending_jni_exception_check_fn = NULL; } + const char* get_pending_jni_exception_check() const { return _pending_jni_exception_check_fn; } + void set_pending_jni_exception_check(const char* fn_name) { _pending_jni_exception_check_fn = (char*) fn_name; } + // For deadlock detection int depth_first_number() { return _depth_first_number; } void set_depth_first_number(int dfn) { _depth_first_number = dfn; } From ba00ce514e2726fdd1b9a179b7c31391897a45fa Mon Sep 17 00:00:00 2001 From: David Simms Date: Thu, 12 Jun 2014 11:34:35 +0200 Subject: [PATCH 012/236] 8046662: Check JNI ReleaseStringChars / ReleaseStringUTFChars verify_guards test inverted Negative verify_guards when testing for corruption Reviewed-by: sla, fparain --- hotspot/src/share/vm/prims/jniCheck.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp index de9b4e56a86..cdce2643775 100644 --- a/hotspot/src/share/vm/prims/jniCheck.cpp +++ b/hotspot/src/share/vm/prims/jniCheck.cpp @@ -1493,7 +1493,7 @@ JNI_ENTRY_CHECKED(void, } else { GuardedMemory guarded((void*)chars); - if (guarded.verify_guards()) { + if (!guarded.verify_guards()) { tty->print_cr("ReleaseStringChars: release chars failed bounds check. " "string: " PTR_FORMAT " chars: " PTR_FORMAT, p2i(str), p2i(chars)); guarded.print_on(tty); @@ -1576,7 +1576,7 @@ JNI_ENTRY_CHECKED(void, } else { GuardedMemory guarded((void*)chars); - if (guarded.verify_guards()) { + if (!guarded.verify_guards()) { tty->print_cr("ReleaseStringUTFChars: release chars failed bounds check. " "string: " PTR_FORMAT " chars: " PTR_FORMAT, p2i(str), p2i(chars)); guarded.print_on(tty); From 466ed1ae11aef3f98eb61da13f0dad4f21ebb8ef Mon Sep 17 00:00:00 2001 From: Lois Foltan Date: Thu, 12 Jun 2014 13:37:53 -0400 Subject: [PATCH 013/236] 6961433: Revisit need to disable Windows C++ compiler optimisation of sharedRuntimeTrig.cpp Remove pragma optimize ("", off) to turn off optimization for WIN32. Reviewed-by: coleenp, dcubed, kvn --- .../share/vm/runtime/sharedRuntimeTrig.cpp | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp b/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp index 1691bdf7690..84f35aa9317 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntimeTrig.cpp @@ -26,6 +26,7 @@ #include "prims/jni.h" #include "runtime/interfaceSupport.hpp" #include "runtime/sharedRuntime.hpp" +#include "runtime/sharedRuntimeMath.hpp" // This file contains copies of the fdlibm routines used by // StrictMath. It turns out that it is almost always required to use @@ -36,35 +37,6 @@ // pointer out to libjava.so in SharedRuntime speeds these routines up // by roughly 15% on both Win32/x86 and Solaris/SPARC. -// Enabling optimizations in this file causes incorrect code to be -// generated; can not figure out how to turn down optimization for one -// file in the IDE on Windows -#ifdef WIN32 -# pragma optimize ( "", off ) -#endif - -/* The above workaround now causes more problems with the latest MS compiler. - * Visual Studio 2010's /GS option tries to guard against buffer overruns. - * /GS is on by default if you specify optimizations, which we do globally - * via /W3 /O2. However the above selective turning off of optimizations means - * that /GS issues a warning "4748". And since we treat warnings as errors (/WX) - * then the compilation fails. There are several possible solutions - * (1) Remove that pragma above as obsolete with VS2010 - requires testing. - * (2) Stop treating warnings as errors - would be a backward step - * (3) Disable /GS - may help performance but you lose the security checks - * (4) Disable the warning with "#pragma warning( disable : 4748 )" - * (5) Disable planting the code with __declspec(safebuffers) - * I've opted for (5) although we should investigate the local performance - * benefits of (1) and global performance benefit of (3). - */ -#if defined(WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1600)) -#define SAFEBUF __declspec(safebuffers) -#else -#define SAFEBUF -#endif - -#include "runtime/sharedRuntimeMath.hpp" - /* * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) * double x[],y[]; int e0,nx,prec; int ipio2[]; @@ -201,7 +173,7 @@ one = 1.0, two24B = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ -static SAFEBUF int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int *ipio2) { +static int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int *ipio2) { int jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; double z,fw,f[20],fq[20],q[20]; @@ -417,7 +389,7 @@ pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ -static SAFEBUF int __ieee754_rem_pio2(double x, double *y) { +static int __ieee754_rem_pio2(double x, double *y) { double z,w,t,r,fn; double tx[3]; int e0,i,j,nx,n,ix,hx,i0; @@ -916,8 +888,3 @@ JRT_LEAF(jdouble, SharedRuntime::dtan(jdouble x)) -1 -- n odd */ } JRT_END - - -#ifdef WIN32 -# pragma optimize ( "", on ) -#endif From 17dd5faf6d26c78a30a83a80d5a971def6dd0181 Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Thu, 12 Jun 2014 20:15:51 +0200 Subject: [PATCH 014/236] 8046715: Add a way to verify an extended set of command line options Added arguments_ext.cpp to make place for initialization of extended features Reviewed-by: sla, mgronlun --- hotspot/src/share/vm/runtime/arguments.cpp | 2 ++ hotspot/src/share/vm/runtime/arguments.hpp | 1 + .../src/share/vm/runtime/arguments_ext.cpp | 30 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 hotspot/src/share/vm/runtime/arguments_ext.cpp diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 3c032fbf270..36189305801 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2455,6 +2455,8 @@ bool Arguments::check_vm_args_consistency() { warning("The VM option CICompilerCountPerCPU overrides CICompilerCount."); } + status &= check_vm_args_consistency_ext(); + return status; } diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index 69551e3c96e..a6329dab66e 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -462,6 +462,7 @@ class Arguments : AllStatic { static void check_deprecated_gc_flags(); // Check consistency or otherwise of VM argument settings static bool check_vm_args_consistency(); + static bool check_vm_args_consistency_ext(); // Check stack pages settings static bool check_stack_pages(); // Used by os_solaris diff --git a/hotspot/src/share/vm/runtime/arguments_ext.cpp b/hotspot/src/share/vm/runtime/arguments_ext.cpp new file mode 100644 index 00000000000..5edd449b3da --- /dev/null +++ b/hotspot/src/share/vm/runtime/arguments_ext.cpp @@ -0,0 +1,30 @@ +/* + * 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 "runtime/arguments.hpp" + +bool Arguments::check_vm_args_consistency_ext() { + return true; +} From 833620662c6be71cf09398477b00897f7977ee6a Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Thu, 12 Jun 2014 15:57:16 -0700 Subject: [PATCH 015/236] 8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12 Added a new header waiting pattern to catch the case where the target thread waiting on a condition (like a VM op); several other test improvements Reviewed-by: sspitsyn, dholmes --- .../TestThreadDumpMonitorContention.java | 209 ++++++++++++++---- 1 file changed, 169 insertions(+), 40 deletions(-) diff --git a/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java b/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java index 06b2274d823..979aefcd446 100644 --- a/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java +++ b/hotspot/test/runtime/Thread/TestThreadDumpMonitorContention.java @@ -24,6 +24,7 @@ /* * @test * @bug 8036823 + * @bug 8046287 * @summary Creates two threads contending for the same lock and checks * whether jstack reports "locked" by more than one thread. * @@ -52,10 +53,13 @@ public class TestThreadDumpMonitorContention { // looking for header lines with these patterns: // "ContendingThread-1" #19 prio=5 os_prio=64 tid=0x000000000079c000 nid=0x23 runnable [0xffff80ffb8b87000] // "ContendingThread-2" #21 prio=5 os_prio=64 tid=0x0000000000780000 nid=0x2f waiting for monitor entry [0xfffffd7fc1111000] + // "ContendingThread-2" #24 prio=5 os_prio=64 tid=0x0000000000ec8800 nid=0x31 waiting on condition [0xfffffd7bbfffe000] final static Pattern HEADER_PREFIX_PATTERN = Pattern.compile( "^\"ContendingThread-.*"); - final static Pattern HEADER_WAITING_PATTERN = Pattern.compile( + final static Pattern HEADER_WAITING_PATTERN1 = Pattern.compile( "^\"ContendingThread-.* waiting for monitor entry .*"); + final static Pattern HEADER_WAITING_PATTERN2 = Pattern.compile( + "^\"ContendingThread-.* waiting on condition .*"); final static Pattern HEADER_RUNNABLE_PATTERN = Pattern.compile( "^\"ContendingThread-.* runnable .*"); @@ -80,17 +84,34 @@ public class TestThreadDumpMonitorContention { final static Pattern WAITING_PATTERN = Pattern.compile( ".* waiting to lock \\<.*\\(a TestThreadDumpMonitorContention.*"); + final static Object barrier = new Object(); volatile static boolean done = false; + static int barrier_cnt = 0; + static int blank_line_match_cnt = 0; static int error_cnt = 0; - static String header_line = null; static boolean have_header_line = false; static boolean have_thread_state_line = false; - static int match_cnt = 0; - static String[] match_list = new String[2]; + static String header_line = null; + static int header_prefix_match_cnt = 0; + static int locked_line_match_cnt = 0; + static String[] locked_match_list = new String[2]; static int n_samples = 15; + static int sum_both_running_cnt = 0; + static int sum_both_waiting_cnt = 0; + static int sum_contended_cnt = 0; + static int sum_locked_hdr_runnable_cnt = 0; + static int sum_locked_hdr_waiting1_cnt = 0; + static int sum_locked_hdr_waiting2_cnt = 0; + static int sum_locked_thr_state_blocked_cnt = 0; + static int sum_locked_thr_state_runnable_cnt = 0; + static int sum_one_waiting_cnt = 0; + static int sum_uncontended_cnt = 0; + static int sum_waiting_hdr_waiting1_cnt = 0; + static int sum_waiting_thr_state_blocked_cnt = 0; static String thread_state_line = null; static boolean verbose = false; + static int waiting_line_match_cnt = 0; public static void main(String[] args) throws Exception { if (args.length != 0) { @@ -110,6 +131,11 @@ public class TestThreadDumpMonitorContention { Runnable runnable = new Runnable() { public void run() { + synchronized (barrier) { + // let the main thread know we're running + barrier_cnt++; + barrier.notify(); + } while (!done) { synchronized (this) { } } @@ -118,8 +144,16 @@ public class TestThreadDumpMonitorContention { Thread[] thread_list = new Thread[2]; thread_list[0] = new Thread(runnable, "ContendingThread-1"); thread_list[1] = new Thread(runnable, "ContendingThread-2"); - thread_list[0].start(); - thread_list[1].start(); + synchronized (barrier) { + thread_list[0].start(); + thread_list[1].start(); + + // Wait until the contending threads are running so that + // we don't sample any thread init states. + while (barrier_cnt < 2) { + barrier.wait(); + } + } doSamples(); @@ -143,11 +177,12 @@ public class TestThreadDumpMonitorContention { // Example: // "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f runnable [0xfffffd7fc1111000] // java.lang.Thread.State: RUNNABLE - // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67) + // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) // at java.lang.Thread.run(Thread.java:745) // static boolean checkBlankLine(String line) { if (line.length() == 0) { + blank_line_match_cnt++; have_header_line = false; have_thread_state_line = false; return true; @@ -161,49 +196,73 @@ public class TestThreadDumpMonitorContention { // Example 1: // "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f runnable [0xfffffd7fc1111000] // java.lang.Thread.State: RUNNABLE - // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67) + // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) // - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) // at java.lang.Thread.run(Thread.java:745) // // Example 2: // "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f waiting for monitor entry [0xfffffd7fc1111000] // java.lang.Thread.State: BLOCKED (on object monitor) - // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67) + // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) // - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) // at java.lang.Thread.run(Thread.java:745) // + // Example 3: + // "ContendingThread-2" #24 prio=5 os_prio=64 tid=0x0000000000ec8800 nid=0x31 waiting on condition [0xfffffd7bbfffe000] + // java.lang.Thread.State: RUNNABLE + // JavaThread state: _thread_blocked + // Thread: 0x0000000000ec8800 [0x31] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 + // JavaThread state: _thread_blocked + // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) + // - locked <0xfffffd7e6d03eb28> (a TestThreadDumpMonitorContention$1) + // at java.lang.Thread.run(Thread.java:745) + // static boolean checkLockedLine(String line) { Matcher matcher = LOCK_PATTERN.matcher(line); if (matcher.matches()) { if (verbose) { System.out.println("locked_line='" + line + "'"); } - match_list[match_cnt] = new String(line); - match_cnt++; + locked_match_list[locked_line_match_cnt] = new String(line); + locked_line_match_cnt++; matcher = HEADER_RUNNABLE_PATTERN.matcher(header_line); - if (!matcher.matches()) { + if (matcher.matches()) { + sum_locked_hdr_runnable_cnt++; + } else { // It's strange, but a locked line can also - // match the HEADER_WAITING_PATTERN. - matcher = HEADER_WAITING_PATTERN.matcher(header_line); - if (!matcher.matches()) { - System.err.println(); - System.err.println("ERROR: header line does " + - "not match runnable or waiting patterns."); - System.err.println("ERROR: header_line='" + - header_line + "'"); - System.err.println("ERROR: locked_line='" + line + "'"); - error_cnt++; + // match the HEADER_WAITING_PATTERN{1,2}. + matcher = HEADER_WAITING_PATTERN1.matcher(header_line); + if (matcher.matches()) { + sum_locked_hdr_waiting1_cnt++; + } else { + matcher = HEADER_WAITING_PATTERN2.matcher(header_line); + if (matcher.matches()) { + sum_locked_hdr_waiting2_cnt++; + } else { + System.err.println(); + System.err.println("ERROR: header line does " + + "not match runnable or waiting patterns."); + System.err.println("ERROR: header_line='" + + header_line + "'"); + System.err.println("ERROR: locked_line='" + line + + "'"); + error_cnt++; + } } } matcher = THREAD_STATE_RUNNABLE_PATTERN.matcher(thread_state_line); - if (!matcher.matches()) { + if (matcher.matches()) { + sum_locked_thr_state_runnable_cnt++; + } else { // It's strange, but a locked line can also // match the THREAD_STATE_BLOCKED_PATTERN. matcher = THREAD_STATE_BLOCKED_PATTERN.matcher( thread_state_line); - if (!matcher.matches()) { + if (matcher.matches()) { + sum_locked_thr_state_blocked_cnt++; + } else { System.err.println(); System.err.println("ERROR: thread state line does not " + "match runnable or waiting patterns."); @@ -229,19 +288,22 @@ public class TestThreadDumpMonitorContention { // Example: // "ContendingThread-2" #22 prio=5 os_prio=64 tid=0x00000000007b9800 nid=0x30 waiting for monitor entry [0xfffffd7fc1010000] // java.lang.Thread.State: BLOCKED (on object monitor) - // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:67) + // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) // - waiting to lock <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) // at java.lang.Thread.run(Thread.java:745) // static boolean checkWaitingLine(String line) { Matcher matcher = WAITING_PATTERN.matcher(line); if (matcher.matches()) { + waiting_line_match_cnt++; if (verbose) { System.out.println("waiting_line='" + line + "'"); } - matcher = HEADER_WAITING_PATTERN.matcher(header_line); - if (!matcher.matches()) { + matcher = HEADER_WAITING_PATTERN1.matcher(header_line); + if (matcher.matches()) { + sum_waiting_hdr_waiting1_cnt++; + } else { System.err.println(); System.err.println("ERROR: header line does " + "not match a waiting pattern."); @@ -251,7 +313,9 @@ public class TestThreadDumpMonitorContention { } matcher = THREAD_STATE_BLOCKED_PATTERN.matcher(thread_state_line); - if (!matcher.matches()) { + if (matcher.matches()) { + sum_waiting_thr_state_blocked_cnt++; + } else { System.err.println(); System.err.println("ERROR: thread state line " + "does not match a waiting pattern."); @@ -273,7 +337,10 @@ public class TestThreadDumpMonitorContention { static void doSamples() throws Exception { for (int count = 0; count < n_samples; count++) { - match_cnt = 0; + blank_line_match_cnt = 0; + header_prefix_match_cnt = 0; + locked_line_match_cnt = 0; + waiting_line_match_cnt = 0; // verbose mode or an error has a lot of output so add more space if (verbose || error_cnt > 0) System.out.println(); System.out.println("Sample #" + count); @@ -290,12 +357,12 @@ public class TestThreadDumpMonitorContention { // a failure and we report it // - for a stack trace that matches LOCKED_PATTERN, we verify: // - the header line matches HEADER_RUNNABLE_PATTERN - // or HEADER_WAITING_PATTERN + // or HEADER_WAITING_PATTERN{1,2} // - the thread state line matches THREAD_STATE_BLOCKED_PATTERN // or THREAD_STATE_RUNNABLE_PATTERN // - we report any mismatches as failures // - for a stack trace that matches WAITING_PATTERN, we verify: - // - the header line matches HEADER_WAITING_PATTERN + // - the header line matches HEADER_WAITING_PATTERN1 // - the thread state line matches THREAD_STATE_BLOCKED_PATTERN // - we report any mismatches as failures // - the stack traces that match HEADER_PREFIX_PATTERN may @@ -324,6 +391,7 @@ public class TestThreadDumpMonitorContention { if (!have_header_line) { matcher = HEADER_PREFIX_PATTERN.matcher(line); if (matcher.matches()) { + header_prefix_match_cnt++; if (verbose) { System.out.println(); System.out.println("header='" + line + "'"); @@ -366,19 +434,80 @@ public class TestThreadDumpMonitorContention { } process.waitFor(); - if (match_cnt == 2) { - if (match_list[0].equals(match_list[1])) { - System.err.println(); - System.err.println("ERROR: matching lock lines:"); - System.err.println("ERROR: line[0]'" + match_list[0] + "'"); - System.err.println("ERROR: line[1]'" + match_list[1] + "'"); - error_cnt++; - } - } + if (header_prefix_match_cnt != 2) { + System.err.println(); + System.err.println("ERROR: should match exactly two headers."); + System.err.println("ERROR: header_prefix_match_cnt=" + + header_prefix_match_cnt); + error_cnt++; + } + + if (locked_line_match_cnt == 2) { + if (locked_match_list[0].equals(locked_match_list[1])) { + System.err.println(); + System.err.println("ERROR: matching lock lines:"); + System.err.println("ERROR: line[0]'" + + locked_match_list[0] + "'"); + System.err.println("ERROR: line[1]'" + + locked_match_list[1] + "'"); + error_cnt++; + } + } + + if (locked_line_match_cnt == 1) { + // one thread has the lock + if (waiting_line_match_cnt == 1) { + // and the other contended for it + sum_contended_cnt++; + } else { + // and the other is just running + sum_uncontended_cnt++; + } + } else if (waiting_line_match_cnt == 1) { + // one thread is waiting + sum_one_waiting_cnt++; + } else if (waiting_line_match_cnt == 2) { + // both threads are waiting + sum_both_waiting_cnt++; + } else { + // both threads are running + sum_both_running_cnt++; + } // slight delay between jstack launches Thread.sleep(500); } + + if (error_cnt != 0) { + // skip summary info since there were errors + return; + } + + System.out.println("INFO: Summary for all samples:"); + System.out.println("INFO: both_running_cnt=" + sum_both_running_cnt); + System.out.println("INFO: both_waiting_cnt=" + sum_both_waiting_cnt); + System.out.println("INFO: contended_cnt=" + sum_contended_cnt); + System.out.println("INFO: one_waiting_cnt=" + sum_one_waiting_cnt); + System.out.println("INFO: uncontended_cnt=" + sum_uncontended_cnt); + System.out.println("INFO: locked_hdr_runnable_cnt=" + + sum_locked_hdr_runnable_cnt); + System.out.println("INFO: locked_hdr_waiting1_cnt=" + + sum_locked_hdr_waiting1_cnt); + System.out.println("INFO: locked_hdr_waiting2_cnt=" + + sum_locked_hdr_waiting2_cnt); + System.out.println("INFO: locked_thr_state_blocked_cnt=" + + sum_locked_thr_state_blocked_cnt); + System.out.println("INFO: locked_thr_state_runnable_cnt=" + + sum_locked_thr_state_runnable_cnt); + System.out.println("INFO: waiting_hdr_waiting1_cnt=" + + sum_waiting_hdr_waiting1_cnt); + System.out.println("INFO: waiting_thr_state_blocked_cnt=" + + sum_waiting_thr_state_blocked_cnt); + + if (sum_contended_cnt == 0) { + System.err.println("WARNING: the primary scenario for 8036823" + + " has not been exercised by this test run."); + } } // This helper relies on RuntimeMXBean.getName() returning a string From 5e1811cd0edd34d794f0652ab362fddd13a3e3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Lid=C3=A9n?= Date: Fri, 13 Jun 2014 13:46:06 +0200 Subject: [PATCH 016/236] 8044796: G1: Enable G1CollectedHeap::stop() Reviewed-by: brutisso, sjohanss --- .../gc_implementation/g1/g1CollectedHeap.cpp | 28 +++++-------------- .../gc_implementation/g1/g1CollectedHeap.hpp | 2 -- hotspot/src/share/vm/runtime/java.cpp | 9 ++---- hotspot/src/share/vm/runtime/thread.cpp | 10 ++----- 4 files changed, 11 insertions(+), 38 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index a1dbb6f1b18..2f259ea1beb 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -433,14 +433,6 @@ HeapRegion* G1CollectedHeap::pop_dirty_cards_region() return hr; } -void G1CollectedHeap::stop_conc_gc_threads() { - _cg1r->stop(); - _cmThread->stop(); - if (G1StringDedup::is_enabled()) { - G1StringDedup::stop(); - } -} - #ifdef ASSERT // A region is added to the collection set as it is retired // so an address p can point to a region which will be in the @@ -2174,20 +2166,14 @@ jint G1CollectedHeap::initialize() { } void G1CollectedHeap::stop() { -#if 0 - // Stopping concurrent worker threads is currently disabled until - // some bugs in concurrent mark has been resolve. Without fixing - // those bugs first we risk haning during VM exit when trying to - // stop these threads. - - // Abort any ongoing concurrent root region scanning and stop all - // concurrent threads. We do this to make sure these threads do - // not continue to execute and access resources (e.g. gclog_or_tty) + // Stop all concurrent threads. We do this to make sure these threads + // do not continue to execute and access resources (e.g. gclog_or_tty) // that are destroyed during shutdown. - _cm->root_regions()->abort(); - _cm->root_regions()->wait_until_scan_finished(); - stop_conc_gc_threads(); -#endif + _cg1r->stop(); + _cmThread->stop(); + if (G1StringDedup::is_enabled()) { + G1StringDedup::stop(); + } } size_t G1CollectedHeap::conservative_max_heap_alignment() { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 77918a64aae..f4d0baae983 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -1684,8 +1684,6 @@ public: void print_all_rsets() PRODUCT_RETURN; public: - void stop_conc_gc_threads(); - size_t pending_card_num(); size_t cards_scanned(); diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index e852b56ef54..3a075117afe 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -501,9 +501,6 @@ void before_exit(JavaThread * thread) { os::infinite_sleep(); } - // Stop any ongoing concurrent GC work - Universe::heap()->stop(); - // Terminate watcher thread - must before disenrolling any periodic task if (PeriodicTask::num_tasks() > 0) WatcherThread::stop(); @@ -518,10 +515,8 @@ void before_exit(JavaThread * thread) { StatSampler::disengage(); StatSampler::destroy(); - // We do not need to explicitly stop concurrent GC threads because the - // JVM will be taken down at a safepoint when such threads are inactive -- - // except for some concurrent G1 threads, see (comment in) - // Threads::destroy_vm(). + // Stop concurrent GC threads + Universe::heap()->stop(); // Print GC/heap related information. if (PrintGCDetails) { diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index e9e9d22f197..3296a5d1436 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -3968,14 +3968,8 @@ bool Threads::destroy_vm() { // GC vm_operations can get caught at the safepoint, and the // heap is unparseable if they are caught. Grab the Heap_lock // to prevent this. The GC vm_operations will not be able to - // queue until after the vm thread is dead. - // After this point, we'll never emerge out of the safepoint before - // the VM exits, so concurrent GC threads do not need to be explicitly - // stopped; they remain inactive until the process exits. - // Note: some concurrent G1 threads may be running during a safepoint, - // but these will not be accessing the heap, just some G1-specific side - // data structures that are not accessed by any other threads but them - // after this point in a terminal safepoint. + // queue until after the vm thread is dead. After this point, + // we'll never emerge out of the safepoint before the VM exits. MutexLocker ml(Heap_lock); From 92675f5272c5576ad932197947a4a955cd1c9721 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Fri, 13 Jun 2014 05:10:44 -0700 Subject: [PATCH 017/236] 8038392: Generating prelink cache breaks JAVA 'jinfo' utility normal behaviour Better parsing of /proc/pid/maps in sa Reviewed-by: sspitsyn, sla --- hotspot/agent/src/os/linux/ps_proc.c | 41 ++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/hotspot/agent/src/os/linux/ps_proc.c b/hotspot/agent/src/os/linux/ps_proc.c index 61923a25529..a3c18c9e0de 100644 --- a/hotspot/agent/src/os/linux/ps_proc.c +++ b/hotspot/agent/src/os/linux/ps_proc.c @@ -263,7 +263,7 @@ static bool add_new_thread(struct ps_prochandle* ph, pthread_t pthread_id, lwpid static bool read_lib_info(struct ps_prochandle* ph) { char fname[32]; - char buf[256]; + char buf[PATH_MAX]; FILE *fp = NULL; sprintf(fname, "/proc/%d/maps", ph->pid); @@ -273,10 +273,41 @@ static bool read_lib_info(struct ps_prochandle* ph) { return false; } - while(fgets_no_cr(buf, 256, fp)){ - char * word[6]; - int nwords = split_n_str(buf, 6, word, ' ', '\0'); - if (nwords > 5 && find_lib(ph, word[5]) == false) { + while(fgets_no_cr(buf, PATH_MAX, fp)){ + char * word[7]; + int nwords = split_n_str(buf, 7, word, ' ', '\0'); + + if (nwords < 6) { + // not a shared library entry. ignore. + continue; + } + + // SA does not handle the lines with patterns: + // "[stack]", "[heap]", "[vdso]", "[vsyscall]", etc. + if (word[5][0] == '[') { + // not a shared library entry. ignore. + continue; + } + + if (nwords > 6) { + // prelink altered mapfile when the program is running. + // Entries like one below have to be skipped + // /lib64/libc-2.15.so (deleted) + // SO name in entries like one below have to be stripped. + // /lib64/libpthread-2.15.so.#prelink#.EECVts + char *s = strstr(word[5],".#prelink#"); + if (s == NULL) { + // No prelink keyword. skip deleted library + print_debug("skip shared object %s deleted by prelink\n", word[5]); + continue; + } + + // Fall through + print_debug("rectifying shared object name %s changed by prelink\n", word[5]); + *s = 0; + } + + if (find_lib(ph, word[5]) == false) { intptr_t base; lib_info* lib; #ifdef _LP64 From e5749d72fd777a2dd3191a55f9f642be40d59f0f Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Fri, 13 Jun 2014 17:07:39 -0400 Subject: [PATCH 018/236] 8046408: Build failure from multiple ptrace.h Prefer over Reviewed-by: sla, mikael --- hotspot/agent/src/os/linux/libproc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/agent/src/os/linux/libproc.h b/hotspot/agent/src/os/linux/libproc.h index c917a938c5a..b07c090bfec 100644 --- a/hotspot/agent/src/os/linux/libproc.h +++ b/hotspot/agent/src/os/linux/libproc.h @@ -34,7 +34,7 @@ #include "libproc_md.h" #endif -#include +#include /************************************************************************************ From 50e8d8b28d797abb0e945dfab2070f35bb0b23e8 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Thu, 3 Jul 2014 15:48:23 -0700 Subject: [PATCH 019/236] 8049284: Missing bug id in test/tools/javac/varargs/warning/Warn* Reviewed-by: darcy --- langtools/test/tools/javac/varargs/warning/Warn4.java | 2 +- langtools/test/tools/javac/varargs/warning/Warn5.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/javac/varargs/warning/Warn4.java b/langtools/test/tools/javac/varargs/warning/Warn4.java index 4598c483fd4..2f4e76939d3 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn4.java +++ b/langtools/test/tools/javac/varargs/warning/Warn4.java @@ -23,7 +23,7 @@ /** * @test - * @bug 6945418 6993978 8006694 + * @bug 6945418 6993978 8006694 7196160 * @summary Project Coin: Simplified Varargs Method Invocation * temporarily workaround combo tests are causing time out in several platforms * @author mcimadamore diff --git a/langtools/test/tools/javac/varargs/warning/Warn5.java b/langtools/test/tools/javac/varargs/warning/Warn5.java index b73d1af5fa8..4deee640864 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn5.java +++ b/langtools/test/tools/javac/varargs/warning/Warn5.java @@ -23,7 +23,7 @@ /** * @test - * @bug 6993978 7097436 8006694 + * @bug 6993978 7097436 8006694 7196160 * @summary Project Coin: Annotation to reduce varargs warnings * temporarily workaround combo tests are causing time out in several platforms * @author mcimadamore From 12b653bb021cdda3c87dbb1913dc51d2a9975562 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 4 Jul 2014 10:52:22 +0100 Subject: [PATCH 020/236] 8042261: Implement classfile tests for Deprecated attribute Reviewed-by: jjg, anazarov, shurailine --- .../SourceFile/SourceFileTestBase.java | 2 +- .../deprecated/DeprecatedPackageTest.java | 88 +++++ .../attributes/deprecated/DeprecatedTest.java | 314 ++++++++++++++++++ .../classfiles/attributes/lib/TestBase.java | 107 ++++-- .../classfiles/attributes/lib/TestResult.java | 168 ++++++++++ 5 files changed, 656 insertions(+), 23 deletions(-) create mode 100644 langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedPackageTest.java create mode 100644 langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedTest.java create mode 100644 langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java diff --git a/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java b/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java index 9fe76a2e2b9..dd0a7c3aa4a 100644 --- a/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java +++ b/langtools/test/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase.java @@ -45,7 +45,7 @@ public class SourceFileTestBase extends TestBase { */ protected void compileAndTest(String sourceCode, String... classesToTest) throws Exception { - Map classes = compile(sourceCode); + Map classes = compile(sourceCode).getClasses(); String fileName = ToolBox.getJavaFileNameFromSource(sourceCode); for (String className : classesToTest) { assertAttributePresent(ClassFile.read(classes.get(className).openInputStream()), fileName); diff --git a/langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedPackageTest.java b/langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedPackageTest.java new file mode 100644 index 00000000000..5f6d139291d --- /dev/null +++ b/langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedPackageTest.java @@ -0,0 +1,88 @@ +/* + * 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 8042261 + * @summary Checking that deprecated attribute does not apply to classes of deprecated package. + * @library /tools/javac/lib ../lib + * @build DeprecatedPackageTest TestBase TestResult InMemoryFileManager ToolBox + * @run main DeprecatedPackageTest + */ + +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Deprecated_attribute; + +public class DeprecatedPackageTest extends TestResult { + + private static final String[] sourceTest = new String[]{ + "package deprecated;\n" + + "public class notDeprecated{}", + "package deprecated;\n" + + "public interface notDeprecated{}", + "package deprecated;\n" + + "public @interface notDeprecated{}", + "package deprecated;\n" + + "public enum notDeprecated{}" + }; + + private static final String CLASS_NAME = "deprecated.notDeprecated"; + + private static final String PACKAGE_INFO = + "@Deprecated\n" + + "package deprecated;"; + + public static void main(String[] args) throws TestFailedException { + new DeprecatedPackageTest().test(); + } + + private void test() throws TestFailedException { + try { + for (String src : sourceTest) { + test(PACKAGE_INFO, src); + test(PACKAGE_INFO.replaceAll("@Deprecated", "/** @deprecated */"), src); + } + } catch (Exception e) { + addFailure(e); + } finally { + checkStatus(); + } + } + + private void test(String package_info, String src) { + addTestCase(src); + printf("Testing test case: \n%s\n", src); + try { + ClassFile cf = ClassFile.read(compile( + new String[]{"package-info.java", package_info}, + new String[]{"notDeprecated.java", src}) + .getClasses().get(CLASS_NAME).openInputStream()); + Deprecated_attribute attr = + (Deprecated_attribute) cf.getAttribute(Attribute.Deprecated); + assertNull(attr, "Class can not have deprecated attribute : " + CLASS_NAME); + } catch (Exception e) { + addFailure(e); + } + } +} diff --git a/langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedTest.java b/langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedTest.java new file mode 100644 index 00000000000..5788520eab3 --- /dev/null +++ b/langtools/test/tools/javac/classfiles/attributes/deprecated/DeprecatedTest.java @@ -0,0 +1,314 @@ +/* + * 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 8042261 + * @summary Checking what attribute is generated by annotation Deprecated + * or javadoc deprecated for field, method, class(inner/local), interface. + * @library /tools/javac/lib ../lib + * @build DeprecatedTest TestBase TestResult InMemoryFileManager ToolBox + * @run main DeprecatedTest + */ + +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.Deprecated_attribute; +import com.sun.tools.classfile.Field; +import com.sun.tools.classfile.InnerClasses_attribute; +import com.sun.tools.classfile.InnerClasses_attribute.Info; +import com.sun.tools.classfile.Method; + +import javax.tools.JavaFileObject; +import java.io.IOException; +import java.util.Map; + +public class DeprecatedTest extends TestResult { + + private static final String[] sources = new String[]{ + "@Deprecated public class deprecated {\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated public void deprecated() {}\n" + + "@Deprecated public int deprecated;\n" + + "public void notDeprecated() {}\n" + + "public int notDeprecated;\n" + + "public void f() {\n" + + " @Deprecated class deprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }\n" + + " class notDeprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }}\n" + + "}", + "@Deprecated public interface deprecated {\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated void deprecated01();\n" + + "void notDeprecated01();\n" + + "@Deprecated default void deprecated02() {}\n" + + "default void notDeprecated02() {}\n" + + "@Deprecated int deprecated = 0;\n" + + "int notDeprecated = 0;\n" + + "}", + "@Deprecated public enum deprecated {\n" + + "@Deprecated deprecated, notDeprecated;\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated public void deprecated() {}\n" + + "public void notDeprecated() {}\n" + + "public void f() {\n" + + " @Deprecated class deprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }\n" + + " class notDeprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }}\n" + + "}", + "@Deprecated public @interface deprecated {\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated int deprecated() default 0;\n" + + "int notDeprecated() default 0;\n" + + "@Deprecated int deprecated = 0;\n" + + "int notDeprecated = 0;\n" + + "}", + "public class notDeprecated {\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated public void deprecated() {}\n" + + "@Deprecated public int deprecated;\n" + + "public void notDeprecated() {}\n" + + "public int notDeprecated;\n" + + "public void f() {\n" + + " @Deprecated class deprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }\n" + + " class notDeprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }}\n" + + "}", + "public interface notDeprecated {\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated void deprecated01();\n" + + "void notDeprecated01();\n" + + "@Deprecated default void deprecated02() {}\n" + + "default void notDeprecated02() {}\n" + + "@Deprecated int deprecated = 0;\n" + + "int notDeprecated = 0;\n" + + "}", + "public enum notDeprecated {\n" + + "@Deprecated deprecated, notDeprecated;\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated public void deprecated() {}\n" + + "public void notDeprecated() {}\n" + + "public void f() {\n" + + " @Deprecated class deprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }\n" + + " class notDeprecatedLocal {\n" + + " @Deprecated int deprecated;\n" + + " @Deprecated void deprecated() {}\n" + + " int notDeprecated;\n" + + " void notDeprecated(){}\n" + + " }}\n" + + "}", + "public @interface notDeprecated {\n" + + "@Deprecated class deprecatedInner01 {}\n" + + "@Deprecated interface deprecatedInner02 {}\n" + + "@Deprecated enum deprecatedInner03 {}\n" + + "@Deprecated @interface deprecatedInner04 {}\n" + + "class notDeprecatedInner01 {}\n" + + "interface notDeprecatedInner02 {}\n" + + "enum notDeprecatedInner03 {}\n" + + "@interface notDeprecatedInner04 {}\n" + + "@Deprecated int deprecated() default 0;\n" + + "int notDeprecated() default 0;\n" + + "@Deprecated int deprecated = 0;\n" + + "int notDeprecated = 0;\n" + + "}"}; + + public static void main(String[] args) throws TestFailedException { + new DeprecatedTest().test(); + } + + public void test() throws TestFailedException { + try { + for (String src : sources) { + test(src); + test(src.replaceAll("@Deprecated", "/** @deprecated */")); + } + } catch (Exception e) { + addFailure(e); + } finally { + checkStatus(); + } + } + + private void test(String src) { + addTestCase(src); + printf("Testing test case :\n%s\n", src); + try { + Map classes = compile(src).getClasses(); + String outerClassName = classes.containsKey("deprecated") + ? "deprecated" + : "notDeprecated"; + echo("Testing outer class : " + outerClassName); + ClassFile cf = ClassFile.read(classes.get(outerClassName).openInputStream()); + Deprecated_attribute attr = (Deprecated_attribute) + cf.getAttribute(Attribute.Deprecated); + testAttribute(outerClassName, attr, cf); + testInnerClasses(cf, classes); + testMethods(cf); + testFields(cf); + } catch (Exception e) { + addFailure(e); + } + } + + private void testInnerClasses(ClassFile cf, Map classes) + throws ConstantPoolException, IOException { + InnerClasses_attribute innerAttr = (InnerClasses_attribute) + cf.getAttribute(Attribute.InnerClasses); + for (Info innerClass : innerAttr.classes) { + String innerClassName = cf.constant_pool. + getClassInfo(innerClass.inner_class_info_index).getName(); + echo("Testing inner class : " + innerClassName); + ClassFile innerCf = ClassFile.read(classes.get(innerClassName).openInputStream()); + Deprecated_attribute attr = (Deprecated_attribute) + innerCf.getAttribute(Attribute.Deprecated); + String innerClassSimpleName = innerClass.getInnerName(cf.constant_pool); + testAttribute(innerClassSimpleName, attr, innerCf); + if (innerClassName.contains("Local")) { + testMethods(innerCf); + testFields(innerCf); + } + } + } + + private void testMethods(ClassFile cf) + throws ConstantPoolException { + for (Method m : cf.methods) { + String methodName = cf.constant_pool.getUTF8Value(m.name_index); + echo("Testing method : " + methodName); + Deprecated_attribute attr = (Deprecated_attribute) + m.attributes.get(Attribute.Deprecated); + testAttribute(methodName, attr, cf); + } + } + + private void testFields(ClassFile cf) throws ConstantPoolException { + for (Field f : cf.fields) { + String fieldName = cf.constant_pool.getUTF8Value(f.name_index); + echo("Testing field : " + fieldName); + Deprecated_attribute attr = (Deprecated_attribute) + f.attributes.get(Attribute.Deprecated); + testAttribute(fieldName, attr, cf); + } + } + + private void testAttribute(String name, Deprecated_attribute attr, ClassFile cf) + throws ConstantPoolException { + if (name.contains("deprecated")) { + testDeprecatedAttribute(name, attr, cf); + } else { + assertNull(attr, name + " should not have deprecated attribute"); + } + } + + private void testDeprecatedAttribute(String name, Deprecated_attribute attr, ClassFile cf) + throws ConstantPoolException { + assertNotNull(attr, name + " must have deprecated attribute"); + assertEquals(0, attr.attribute_length, + "attribute_length should equal to 0"); + assertEquals("Deprecated", + cf.constant_pool.getUTF8Value(attr.attribute_name_index), + name + " attribute_name_index"); + } +} diff --git a/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java b/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java index 380c67bbd1e..85a252313b8 100644 --- a/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java +++ b/langtools/test/tools/javac/classfiles/attributes/lib/TestBase.java @@ -23,47 +23,85 @@ import java.io.File; import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.io.PrintStream; +import java.util.*; +import java.util.function.Function; import java.util.stream.Stream; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileObject; -import javax.tools.ToolProvider; +import javax.tools.*; import static java.lang.String.format; +import static java.lang.System.lineSeparator; +import static java.util.Arrays.asList; import static java.util.Collections.emptyList; +import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; public class TestBase { - public Map compile(String... sources) throws IOException, + public static final String LINE_SEPARATOR = lineSeparator(); + + private InMemoryFileManager compile( + List options, + Function src2JavaFileObject, + List sources) + throws IOException, CompilationException { + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + List src = sources.stream() + .map(src2JavaFileObject) + .collect(toList()); + + DiagnosticCollector dc = new DiagnosticCollector<>(); + try (InMemoryFileManager fileManager + = new InMemoryFileManager(compiler.getStandardFileManager(null, null, null))) { + JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, dc, options, null, src); + boolean success = task.call(); + if (!success) { + String errorMessage = dc.getDiagnostics().stream() + .map(Object::toString) + .collect(joining("\n")); + throw new CompilationException("Compilation Error\n\n" + errorMessage); + } + return fileManager; + } + } + + public InMemoryFileManager compile(String... sources) + throws IOException, CompilationException { + return compile(emptyList(), sources); + } + + /** + * @param options - compiler options + * @param sources + * @return map where key is className, value is corresponding ClassFile. + * @throws IOException + */ + public InMemoryFileManager compile(List options, String...sources) + throws IOException, CompilationException { + return compile(options, ToolBox.JavaSource::new, asList(sources)); + } + + public InMemoryFileManager compile(String[]... sources) throws IOException, CompilationException { return compile(emptyList(), sources); } /** * @param options - compiler options - * @param sources + * @param sources - sources[i][0] - name of file, sources[i][1] - sources * @return map where key is className, value is corresponding ClassFile. * @throws IOException + * @throws CompilationException */ - public Map compile(List options, String... sources) throws IOException, - CompilationException { - - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - List src = Stream.of(sources).map(ToolBox.JavaSource::new).collect(toList()); - - try (InMemoryFileManager fileManager = new InMemoryFileManager(compiler.getStandardFileManager(null, null, null))) { - boolean success = compiler.getTask(null, fileManager, null, options, null, src).call(); - if (!success) throw new CompilationException("Compilation Error"); - return fileManager.getClasses(); - } + public InMemoryFileManager compile(List options, String[]...sources) + throws IOException, CompilationException { + return compile(options, src -> new ToolBox.JavaSource(src[0], src[1]), asList(sources)); } public void assertEquals(Object actual, Object expected, String message) { if (!Objects.equals(actual, expected)) - throw new AssertionFailedException(format("%s%nGot: %s, Expected: ", message, actual, expected)); + throw new AssertionFailedException(format("%s%nGot: %s, Expected: %s", message, actual, expected)); } public void assertNull(Object actual, String message) { @@ -80,18 +118,43 @@ public class TestBase { assertEquals(actual, true, message); } + public void assertFalse(boolean actual, String message) { + assertEquals(actual, false, message); + } + + public File getSourceDir() { + return new File(System.getProperty("test.src", ".")); + } + + public File getClassDir() { + return new File(System.getProperty("test.classes", TestBase.class.getResource(".").getPath())); + } + public File getSourceFile(String fileName) { - return new File(System.getProperty("test.src", "."), fileName); + return new File(getSourceDir(), fileName); } public File getClassFile(String fileName) { - return new File(System.getProperty("test.classes", TestBase.class.getResource(".").getPath()), fileName); + return new File(getClassDir(), fileName); } public File getClassFile(Class clazz) { return getClassFile(clazz.getName().replace(".", "/") + ".class"); } + public void echo(String message) { + System.err.println(message.replace("\n", LINE_SEPARATOR)); + } + + public void printf(String template, Object...args) { + System.err.printf(template, Stream.of(args) + .map(Objects::toString) + .map(m -> m.replace("\n", LINE_SEPARATOR)) + .collect(toList()) + .toArray()); + + } + public static class CompilationException extends Exception { public CompilationException(String message) { diff --git a/langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java b/langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java new file mode 100644 index 00000000000..fede897378e --- /dev/null +++ b/langtools/test/tools/javac/classfiles/attributes/lib/TestResult.java @@ -0,0 +1,168 @@ +/* + * 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. + */ + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static java.lang.String.format; +import static java.util.stream.Collectors.joining; + +public class TestResult extends TestBase { + + private final List testCases; + + public TestResult() { + testCases = new ArrayList<>(); + testCases.add(new Info("Global test info")); + } + + public void addTestCase(String src) { + testCases.add(new Info(src)); + } + + public String errorMessage() { + return testCases.stream().filter(Info::isFailed) + .map(tc -> format("Failure in test case:\n%s\n%s", tc.info(), + (tc.asserts.size() > 0 ? tc.getAssertMessage() + "\n" : "") + + tc.getErrorMessage())) + .collect(joining("\n")); + } + + @Override + public void assertEquals(Object actual, Object expected, String message) { + getLastTestCase().assertEquals(actual, expected, message); + } + + @Override + public void assertNull(Object actual, String message) { + getLastTestCase().assertEquals(actual, null, message); + } + + @Override + public void assertNotNull(Object actual, String message) { + getLastTestCase().assertNotNull(actual, message); + } + + @Override + public void assertFalse(boolean actual, String message) { + getLastTestCase().assertEquals(actual, false, message); + } + + @Override + public void assertTrue(boolean actual, String message) { + getLastTestCase().assertEquals(actual, true, message); + } + + public void addFailure(Throwable th) { + getLastTestCase().addFailure(th); + } + + private Info getLastTestCase() { + if (testCases.size() == 1) { + throw new IllegalStateException("Test case should be created"); + } + return testCases.get(testCases.size() - 1); + } + + public void checkStatus() throws TestFailedException { + if (testCases.stream().anyMatch(Info::isFailed)) { + echo(errorMessage()); + throw new TestFailedException("Test failed"); + } + } + + private class Info { + + private final String info; + private final List asserts; + private final List errors; + + private Info(String info) { + this.info = info; + asserts = new ArrayList<>(); + errors = new ArrayList<>(); + } + + public String info() { + return info; + } + + public boolean isFailed() { + return !asserts.isEmpty() || !errors.isEmpty(); + } + + public void addFailure(Throwable th) { + errors.add(th); + printf("[ERROR] : %s\n", getStackTrace(th)); + } + + public void addFailure(String message) { + asserts.add(message); + printf("[ASSERT] : %s\n", message); + } + + public void assertEquals(Object actual, Object expected, String message) { + echo("Testing : " + message); + if (!Objects.equals(actual, expected)) { + addFailure(message + ": Got: " + actual + ", " + "Expected: " + expected); + } + } + + public void assertNotNull(Object actual, String message) { + echo("Testing : " + message); + if (actual == null) { + addFailure(message + " : Expected not null value"); + } + } + + public String getAssertMessage() { + return asserts.stream() + .map(failure -> "[ASSERT] : " + failure) + .collect(joining("\n")); + } + + public String getErrorMessage() { + return errors.stream() + .map(throwable -> + format("[ERROR] : %s", getStackTrace(throwable))) + .collect(joining("\n")); + } + + public String getStackTrace(Throwable throwable) { + StringWriter stringWriter = new StringWriter(); + try (PrintWriter printWriter = new PrintWriter(stringWriter)) { + throwable.printStackTrace(printWriter); + } + return stringWriter.toString(); + } + } + + public static class TestFailedException extends Exception { + public TestFailedException(String message) { + super(message); + } + } +} From 72d5723212922f7516e272939740098bb913bd04 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 4 Jul 2014 16:34:44 +0100 Subject: [PATCH 021/236] 8049075: javac, wildcards and generic vararg method invocation not accepted Reviewed-by: mcimadamore --- .../com/sun/tools/javac/comp/Resolve.java | 21 +++++----- ...rargsAndWildcardParameterizedTypeTest.java | 40 +++++++++++++++++++ 2 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 langtools/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index 40dfa0696dd..bd0da8637e1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -95,7 +95,7 @@ public class Resolve { public final boolean varargsEnabled; public final boolean allowMethodHandles; public final boolean allowFunctionalInterfaceMostSpecific; - public final boolean checkVarargsAccessDuringResolution; + public final boolean checkVarargsAccessAfterResolution; private final boolean debugResolve; private final boolean compactMethodDiags; final EnumSet verboseResolutionMode; @@ -137,7 +137,7 @@ public class Resolve { Target target = Target.instance(context); allowMethodHandles = target.hasMethodHandles(); allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); - checkVarargsAccessDuringResolution = + checkVarargsAccessAfterResolution = source.allowPostApplicabilityVarargsAccessCheck(); polymorphicSignatureScope = new Scope(syms.noSymbol); @@ -836,13 +836,16 @@ public class Resolve { Warner warn) { super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); //should we expand formals? - if ((!checkVarargsAccessDuringResolution || - (checkVarargsAccessDuringResolution && - deferredAttrContext.mode == AttrMode.CHECK)) && - deferredAttrContext.phase.isVarargsRequired()) { - //check varargs element type accessibility - varargsAccessible(env, types.elemtype(formals.last()), - deferredAttrContext.inferenceContext); + if (deferredAttrContext.phase.isVarargsRequired()) { + Type typeToCheck = null; + if (!checkVarargsAccessAfterResolution) { + typeToCheck = types.elemtype(formals.last()); + } else if (deferredAttrContext.mode == AttrMode.CHECK) { + typeToCheck = types.erasure(types.elemtype(formals.last())); + } + if (typeToCheck != null) { + varargsAccessible(env, typeToCheck, deferredAttrContext.inferenceContext); + } } } diff --git a/langtools/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java b/langtools/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java new file mode 100644 index 00000000000..c9618766614 --- /dev/null +++ b/langtools/test/tools/javac/varargs/T8049075/VarargsAndWildcardParameterizedTypeTest.java @@ -0,0 +1,40 @@ +/* + * 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 8049075 + * @summary javac, wildcards and generic vararg method invocation not accepted + * @compile VarargsAndWildcardParameterizedTypeTest.java + */ + +class VarargsAndWildcardParameterizedTypeTest { + interface I { + String m(T... t); + } + + void m() { + I i = null; + i.m(Integer.valueOf(1), Integer.valueOf(1)); + } +} From 0718a280b0b78159e81742830559d35122d681ff Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Mon, 7 Jul 2014 12:36:45 -0700 Subject: [PATCH 022/236] 8046635: .out files for enum tests in tools/javac/dir Reviewed-by: jjg --- .../test/tools/javac/enum/FauxEnum1.java | 27 ++----------------- langtools/test/tools/javac/enum/FauxEnum1.out | 2 ++ .../test/tools/javac/enum/FauxEnum3.java | 27 ++----------------- langtools/test/tools/javac/enum/FauxEnum3.out | 2 ++ .../tools/javac/enum/FauxSpecialEnum1.java | 27 ++----------------- .../tools/javac/enum/FauxSpecialEnum1.out | 2 ++ .../tools/javac/enum/FauxSpecialEnum2.java | 27 ++----------------- .../tools/javac/enum/FauxSpecialEnum2.out | 2 ++ .../javac/enum/forwardRef/TestEnum1.java | 27 ++----------------- .../tools/javac/enum/forwardRef/TestEnum1.out | 3 +++ .../javac/enum/forwardRef/TestEnum2.java | 27 ++----------------- .../tools/javac/enum/forwardRef/TestEnum2.out | 3 +++ .../javac/enum/forwardRef/TestEnum3.java | 27 ++----------------- .../tools/javac/enum/forwardRef/TestEnum3.out | 2 ++ .../javac/enum/forwardRef/TestEnum4.java | 27 ++----------------- .../tools/javac/enum/forwardRef/TestEnum4.out | 2 ++ .../javac/enum/forwardRef/TestEnum5.java | 27 ++----------------- .../tools/javac/enum/forwardRef/TestEnum5.out | 2 ++ .../javac/enum/forwardRef/TestEnum6.java | 27 ++----------------- .../tools/javac/enum/forwardRef/TestEnum6.out | 2 ++ 20 files changed, 42 insertions(+), 250 deletions(-) create mode 100644 langtools/test/tools/javac/enum/FauxEnum1.out create mode 100644 langtools/test/tools/javac/enum/FauxEnum3.out create mode 100644 langtools/test/tools/javac/enum/FauxSpecialEnum1.out create mode 100644 langtools/test/tools/javac/enum/FauxSpecialEnum2.out create mode 100644 langtools/test/tools/javac/enum/forwardRef/TestEnum1.out create mode 100644 langtools/test/tools/javac/enum/forwardRef/TestEnum2.out create mode 100644 langtools/test/tools/javac/enum/forwardRef/TestEnum3.out create mode 100644 langtools/test/tools/javac/enum/forwardRef/TestEnum4.out create mode 100644 langtools/test/tools/javac/enum/forwardRef/TestEnum5.out create mode 100644 langtools/test/tools/javac/enum/forwardRef/TestEnum6.out diff --git a/langtools/test/tools/javac/enum/FauxEnum1.java b/langtools/test/tools/javac/enum/FauxEnum1.java index 4369a7e43b7..5ae6a8b090c 100644 --- a/langtools/test/tools/javac/enum/FauxEnum1.java +++ b/langtools/test/tools/javac/enum/FauxEnum1.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5009574 * @summary verify java.lang.Enum can't be directly subclassed * @author Joseph D. Darcy * - * @compile/fail FauxEnum1.java + * @compile/fail/ref=FauxEnum1.out -XDrawDiagnostics FauxEnum1.java */ public class FauxEnum1 extends java.lang.Enum { diff --git a/langtools/test/tools/javac/enum/FauxEnum1.out b/langtools/test/tools/javac/enum/FauxEnum1.out new file mode 100644 index 00000000000..64bf94f7747 --- /dev/null +++ b/langtools/test/tools/javac/enum/FauxEnum1.out @@ -0,0 +1,2 @@ +FauxEnum1.java:10:8: compiler.err.enum.no.subclassing +1 error diff --git a/langtools/test/tools/javac/enum/FauxEnum3.java b/langtools/test/tools/javac/enum/FauxEnum3.java index a0c0f66827e..659fb0b4d20 100644 --- a/langtools/test/tools/javac/enum/FauxEnum3.java +++ b/langtools/test/tools/javac/enum/FauxEnum3.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5009574 * @summary verify an enum type can't be directly subclassed * @author Joseph D. Darcy * - * @compile/fail FauxEnum3.java + * @compile/fail/ref=FauxEnum3.out -XDrawDiagnostics FauxEnum3.java */ public class FauxEnum3 extends SpecializedEnum { diff --git a/langtools/test/tools/javac/enum/FauxEnum3.out b/langtools/test/tools/javac/enum/FauxEnum3.out new file mode 100644 index 00000000000..e9d23b4185e --- /dev/null +++ b/langtools/test/tools/javac/enum/FauxEnum3.out @@ -0,0 +1,2 @@ +FauxEnum3.java:10:8: compiler.err.enum.types.not.extensible +1 error diff --git a/langtools/test/tools/javac/enum/FauxSpecialEnum1.java b/langtools/test/tools/javac/enum/FauxSpecialEnum1.java index b4518682c5c..5b427bb110d 100644 --- a/langtools/test/tools/javac/enum/FauxSpecialEnum1.java +++ b/langtools/test/tools/javac/enum/FauxSpecialEnum1.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5009601 * @summary verify specialized enum classes can't be abstract * @author Joseph D. Darcy * - * @compile/fail FauxSpecialEnum1.java + * @compile/fail/ref=FauxSpecialEnum1.out -XDrawDiagnostics FauxSpecialEnum1.java */ public enum FauxSpecialEnum1 { diff --git a/langtools/test/tools/javac/enum/FauxSpecialEnum1.out b/langtools/test/tools/javac/enum/FauxSpecialEnum1.out new file mode 100644 index 00000000000..4530bf40a88 --- /dev/null +++ b/langtools/test/tools/javac/enum/FauxSpecialEnum1.out @@ -0,0 +1,2 @@ +FauxSpecialEnum1.java:14:5: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: FauxSpecialEnum1$2, test(), compiler.misc.anonymous.class: FauxSpecialEnum1$2 +1 error diff --git a/langtools/test/tools/javac/enum/FauxSpecialEnum2.java b/langtools/test/tools/javac/enum/FauxSpecialEnum2.java index 028d446aab4..5c0cc610fa2 100644 --- a/langtools/test/tools/javac/enum/FauxSpecialEnum2.java +++ b/langtools/test/tools/javac/enum/FauxSpecialEnum2.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5009601 * @summary verify specialized enum classes can't be abstract * @author Joseph D. Darcy * - * @compile/fail FauxSpecialEnum2.java + * @compile/fail/ref=FauxSpecialEnum2.out -XDrawDiagnostics FauxSpecialEnum2.java */ public enum FauxSpecialEnum2 { diff --git a/langtools/test/tools/javac/enum/FauxSpecialEnum2.out b/langtools/test/tools/javac/enum/FauxSpecialEnum2.out new file mode 100644 index 00000000000..81de8f41726 --- /dev/null +++ b/langtools/test/tools/javac/enum/FauxSpecialEnum2.out @@ -0,0 +1,2 @@ +FauxSpecialEnum2.java:12:5: compiler.err.does.not.override.abstract: compiler.misc.anonymous.class: FauxSpecialEnum2$1, test(), compiler.misc.anonymous.class: FauxSpecialEnum2$1 +1 error diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum1.java b/langtools/test/tools/javac/enum/forwardRef/TestEnum1.java index e0b5cdf1df2..737ed620eff 100644 --- a/langtools/test/tools/javac/enum/forwardRef/TestEnum1.java +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum1.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, 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 + * @test /nodynamiccopyright/ * @bug 6209839 * @summary Illegal forward reference to enum constants allowed by javac * @author Peter von der Ah\u00e9 - * @compile/fail TestEnum1.java + * @compile/fail/ref=TestEnum1.out -XDrawDiagnostics TestEnum1.java */ enum TestEnum { diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum1.out b/langtools/test/tools/javac/enum/forwardRef/TestEnum1.out new file mode 100644 index 00000000000..1d6ccc41c0a --- /dev/null +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum1.out @@ -0,0 +1,3 @@ +TestEnum1.java:11:39: compiler.err.illegal.enum.static.ref +TestEnum1.java:12:40: compiler.err.illegal.enum.static.ref +2 errors diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum2.java b/langtools/test/tools/javac/enum/forwardRef/TestEnum2.java index 148ea2f52d2..cae8d1e8286 100644 --- a/langtools/test/tools/javac/enum/forwardRef/TestEnum2.java +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum2.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, 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 + * @test /nodynamiccopyright/ * @bug 6209839 * @summary Illegal forward reference to enum constants allowed by javac * @author Peter von der Ah\u00e9 - * @compile/fail TestEnum2.java + * @compile/fail/ref=TestEnum2.out -XDrawDiagnostics TestEnum2.java */ enum TestEnum { diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum2.out b/langtools/test/tools/javac/enum/forwardRef/TestEnum2.out new file mode 100644 index 00000000000..3601cbf9435 --- /dev/null +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum2.out @@ -0,0 +1,3 @@ +TestEnum2.java:13:36: compiler.err.illegal.enum.static.ref +TestEnum2.java:14:36: compiler.err.illegal.enum.static.ref +2 errors diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum3.java b/langtools/test/tools/javac/enum/forwardRef/TestEnum3.java index d636a27a9ba..2e22fd5552b 100644 --- a/langtools/test/tools/javac/enum/forwardRef/TestEnum3.java +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum3.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, 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 + * @test /nodynamiccopyright/ * @bug 6209839 * @summary Illegal forward reference to enum constants allowed by javac * @author Peter von der Ah\u00e9 - * @compile/fail TestEnum3.java + * @compile/fail/ref=TestEnum3.out -XDrawDiagnostics TestEnum3.java */ enum TestEnum { diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum3.out b/langtools/test/tools/javac/enum/forwardRef/TestEnum3.out new file mode 100644 index 00000000000..81a014b8791 --- /dev/null +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum3.out @@ -0,0 +1,2 @@ +TestEnum3.java:13:34: compiler.err.illegal.enum.static.ref +1 error diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum4.java b/langtools/test/tools/javac/enum/forwardRef/TestEnum4.java index aff24479388..5b863302db0 100644 --- a/langtools/test/tools/javac/enum/forwardRef/TestEnum4.java +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum4.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, 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 + * @test /nodynamiccopyright/ * @bug 6209839 * @summary Illegal forward reference to enum constants allowed by javac * @author Peter von der Ah\u00e9 - * @compile/fail TestEnum4.java + * @compile/fail/ref=TestEnum4.out -XDrawDiagnostics TestEnum4.java */ enum TestEnum { diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum4.out b/langtools/test/tools/javac/enum/forwardRef/TestEnum4.out new file mode 100644 index 00000000000..56f1bb12d80 --- /dev/null +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum4.out @@ -0,0 +1,2 @@ +TestEnum4.java:14:24: compiler.err.illegal.enum.static.ref +1 error diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum5.java b/langtools/test/tools/javac/enum/forwardRef/TestEnum5.java index ce977f3f1dd..36928c1ef5f 100644 --- a/langtools/test/tools/javac/enum/forwardRef/TestEnum5.java +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum5.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2005, 2006, 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 + * @test /nodynamiccopyright/ * @bug 6209839 * @summary Illegal forward reference to enum constants allowed by javac * @author Peter von der Ah\u00e9 - * @compile/fail TestEnum5.java + * @compile/fail/ref=TestEnum5.out -XDrawDiagnostics TestEnum5.java */ enum TestEnum { diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum5.out b/langtools/test/tools/javac/enum/forwardRef/TestEnum5.out new file mode 100644 index 00000000000..5176c1880ed --- /dev/null +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum5.out @@ -0,0 +1,2 @@ +TestEnum5.java:15:20: compiler.err.illegal.enum.static.ref +1 error diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum6.java b/langtools/test/tools/javac/enum/forwardRef/TestEnum6.java index 32fbddc62a3..ccf003d1694 100644 --- a/langtools/test/tools/javac/enum/forwardRef/TestEnum6.java +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum6.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2006, 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 + * @test /nodynamiccopyright/ * @bug 6424491 * @summary Cannot initialise nested enums * @author Peter von der Ah\u00e9 - * @compile/fail TestEnum6.java + * @compile/fail/ref=TestEnum6.out -XDrawDiagnostics TestEnum6.java */ public enum TestEnum6 { diff --git a/langtools/test/tools/javac/enum/forwardRef/TestEnum6.out b/langtools/test/tools/javac/enum/forwardRef/TestEnum6.out new file mode 100644 index 00000000000..f8da0a3acd3 --- /dev/null +++ b/langtools/test/tools/javac/enum/forwardRef/TestEnum6.out @@ -0,0 +1,2 @@ +TestEnum6.java:10:18: compiler.err.illegal.self.ref +1 error From 3ecb57ccc071a9130f7b280bacd3f5ae56cfffc9 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Mon, 7 Jul 2014 12:44:20 -0700 Subject: [PATCH 023/236] 8046618: .out files for enum tests in tools/javac/dir Reviewed-by: jjg --- .../tools/javac/enum/AbstractEmptyEnum.java | 27 +--------- .../tools/javac/enum/AbstractEmptyEnum.out | 2 + langtools/test/tools/javac/enum/Enum2.java | 28 +---------- langtools/test/tools/javac/enum/Enum2.out | 3 ++ .../test/tools/javac/enum/LocalEnum.java | 28 +---------- langtools/test/tools/javac/enum/LocalEnum.out | 2 + .../test/tools/javac/enum/NestedEnum.java | 27 +--------- .../test/tools/javac/enum/NestedEnum.out | 2 + langtools/test/tools/javac/enum/NoFinal.java | 27 +--------- langtools/test/tools/javac/enum/NoFinal.out | 2 + langtools/test/tools/javac/enum/NoFinal2.java | 27 +--------- langtools/test/tools/javac/enum/NoFinal2.out | 2 + langtools/test/tools/javac/enum/NoFinal3.java | 27 +--------- langtools/test/tools/javac/enum/NoFinal3.out | 2 + langtools/test/tools/javac/enum/NoFinal4.java | 27 +--------- langtools/test/tools/javac/enum/NoFinal4.out | 2 + langtools/test/tools/javac/enum/NoFinal5.java | 27 +--------- langtools/test/tools/javac/enum/NoFinal5.out | 2 + langtools/test/tools/javac/enum/T5081785.java | 50 +++++++------------ langtools/test/tools/javac/enum/T5081785.out | 5 ++ 20 files changed, 61 insertions(+), 258 deletions(-) create mode 100644 langtools/test/tools/javac/enum/AbstractEmptyEnum.out create mode 100644 langtools/test/tools/javac/enum/Enum2.out create mode 100644 langtools/test/tools/javac/enum/LocalEnum.out create mode 100644 langtools/test/tools/javac/enum/NestedEnum.out create mode 100644 langtools/test/tools/javac/enum/NoFinal.out create mode 100644 langtools/test/tools/javac/enum/NoFinal2.out create mode 100644 langtools/test/tools/javac/enum/NoFinal3.out create mode 100644 langtools/test/tools/javac/enum/NoFinal4.out create mode 100644 langtools/test/tools/javac/enum/NoFinal5.out create mode 100644 langtools/test/tools/javac/enum/T5081785.out diff --git a/langtools/test/tools/javac/enum/AbstractEmptyEnum.java b/langtools/test/tools/javac/enum/AbstractEmptyEnum.java index 49f11662653..38c13bde828 100644 --- a/langtools/test/tools/javac/enum/AbstractEmptyEnum.java +++ b/langtools/test/tools/javac/enum/AbstractEmptyEnum.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5009601 * @summary empty enum cannot be abstract * @author Joseph D. Darcy * - * @compile/fail AbstractEmptyEnum.java + * @compile/fail/ref=AbstractEmptyEnum.out -XDrawDiagnostics AbstractEmptyEnum.java */ public enum AbstractEmptyEnum { diff --git a/langtools/test/tools/javac/enum/AbstractEmptyEnum.out b/langtools/test/tools/javac/enum/AbstractEmptyEnum.out new file mode 100644 index 00000000000..933363a3fe6 --- /dev/null +++ b/langtools/test/tools/javac/enum/AbstractEmptyEnum.out @@ -0,0 +1,2 @@ +AbstractEmptyEnum.java:10:8: compiler.err.does.not.override.abstract: AbstractEmptyEnum, m(), AbstractEmptyEnum +1 error diff --git a/langtools/test/tools/javac/enum/Enum2.java b/langtools/test/tools/javac/enum/Enum2.java index 921039daf53..f5e2a7493eb 100644 --- a/langtools/test/tools/javac/enum/Enum2.java +++ b/langtools/test/tools/javac/enum/Enum2.java @@ -1,32 +1,8 @@ /* - * Copyright (c) 2003, 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 + * @test /nodynamiccopyright/ * @summary enums: an enumeration type may not be extended * @author gafter - * - * @compile/fail Enum2.java + * @compile/fail/ref=Enum2.out -XDrawDiagnostics Enum2.java */ public class Enum2 { diff --git a/langtools/test/tools/javac/enum/Enum2.out b/langtools/test/tools/javac/enum/Enum2.out new file mode 100644 index 00000000000..c1fcf5800b3 --- /dev/null +++ b/langtools/test/tools/javac/enum/Enum2.out @@ -0,0 +1,3 @@ +Enum2.java:10:29: compiler.err.cant.inherit.from.final: Enum2.e1 +Enum2.java:10:12: compiler.err.enum.types.not.extensible +2 errors diff --git a/langtools/test/tools/javac/enum/LocalEnum.java b/langtools/test/tools/javac/enum/LocalEnum.java index 9c5d7228690..f415aee15d8 100644 --- a/langtools/test/tools/javac/enum/LocalEnum.java +++ b/langtools/test/tools/javac/enum/LocalEnum.java @@ -1,33 +1,9 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5019609 * @summary javac fails to reject local enums * @author gafter - * - * @compile/fail LocalEnum.java + * @compile/fail/ref=LocalEnum.out -XDrawDiagnostics LocalEnum.java */ public class LocalEnum { diff --git a/langtools/test/tools/javac/enum/LocalEnum.out b/langtools/test/tools/javac/enum/LocalEnum.out new file mode 100644 index 00000000000..20e4e4269aa --- /dev/null +++ b/langtools/test/tools/javac/enum/LocalEnum.out @@ -0,0 +1,2 @@ +LocalEnum.java:11:9: compiler.err.local.enum +1 error diff --git a/langtools/test/tools/javac/enum/NestedEnum.java b/langtools/test/tools/javac/enum/NestedEnum.java index d58df0a59b5..446dd5110ea 100644 --- a/langtools/test/tools/javac/enum/NestedEnum.java +++ b/langtools/test/tools/javac/enum/NestedEnum.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5071831 * @summary javac allows enum in an inner class * @author gafter * - * @compile/fail NestedEnum.java + * @compile/fail/ref=NestedEnum.out -XDrawDiagnostics NestedEnum.java */ class NestedEnum { diff --git a/langtools/test/tools/javac/enum/NestedEnum.out b/langtools/test/tools/javac/enum/NestedEnum.out new file mode 100644 index 00000000000..c2f9e143b3f --- /dev/null +++ b/langtools/test/tools/javac/enum/NestedEnum.out @@ -0,0 +1,2 @@ +NestedEnum.java:12:9: compiler.err.enums.must.be.static +1 error diff --git a/langtools/test/tools/javac/enum/NoFinal.java b/langtools/test/tools/javac/enum/NoFinal.java index 8661f44507b..e48008e803f 100644 --- a/langtools/test/tools/javac/enum/NoFinal.java +++ b/langtools/test/tools/javac/enum/NoFinal.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2004, 2006, 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 + * @test /nodynamiccopyright/ * @bug 5097250 5087624 * @summary Finalize methods on enums must be compile time error * @author Peter von der Ah\u00e9 - * @compile/fail NoFinal.java + * @compile/fail/ref=NoFinal.out -XDrawDiagnostics NoFinal.java */ enum NoFinal { diff --git a/langtools/test/tools/javac/enum/NoFinal.out b/langtools/test/tools/javac/enum/NoFinal.out new file mode 100644 index 00000000000..c31c41acadd --- /dev/null +++ b/langtools/test/tools/javac/enum/NoFinal.out @@ -0,0 +1,2 @@ +NoFinal.java:11:24: compiler.err.enum.no.finalize +1 error diff --git a/langtools/test/tools/javac/enum/NoFinal2.java b/langtools/test/tools/javac/enum/NoFinal2.java index eb9cb2ef232..1c69e0c1e51 100644 --- a/langtools/test/tools/javac/enum/NoFinal2.java +++ b/langtools/test/tools/javac/enum/NoFinal2.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2004, 2006, 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 + * @test /nodynamiccopyright/ * @bug 5097250 5087624 * @summary Finalize methods on enums must be compile time error * @author Peter von der Ah\u00e9 - * @compile/fail NoFinal2.java + * @compile/fail/ref=NoFinal2.out -XDrawDiagnostics NoFinal2.java */ enum NoFinal2 { diff --git a/langtools/test/tools/javac/enum/NoFinal2.out b/langtools/test/tools/javac/enum/NoFinal2.out new file mode 100644 index 00000000000..235d051d8a8 --- /dev/null +++ b/langtools/test/tools/javac/enum/NoFinal2.out @@ -0,0 +1,2 @@ +NoFinal2.java:11:20: compiler.err.enum.no.finalize +1 error diff --git a/langtools/test/tools/javac/enum/NoFinal3.java b/langtools/test/tools/javac/enum/NoFinal3.java index 98d2aa28ff2..742ad4276f7 100644 --- a/langtools/test/tools/javac/enum/NoFinal3.java +++ b/langtools/test/tools/javac/enum/NoFinal3.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2004, 2006, 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 + * @test /nodynamiccopyright/ * @bug 5097250 5087624 * @summary Finalize methods on enums must be compile time error * @author Peter von der Ah\u00e9 - * @compile/fail NoFinal3.java + * @compile/fail/ref=NoFinal3.out -XDrawDiagnostics NoFinal3.java */ enum NoFinal3 { diff --git a/langtools/test/tools/javac/enum/NoFinal3.out b/langtools/test/tools/javac/enum/NoFinal3.out new file mode 100644 index 00000000000..3f11490905f --- /dev/null +++ b/langtools/test/tools/javac/enum/NoFinal3.out @@ -0,0 +1,2 @@ +NoFinal3.java:11:17: compiler.err.enum.no.finalize +1 error diff --git a/langtools/test/tools/javac/enum/NoFinal4.java b/langtools/test/tools/javac/enum/NoFinal4.java index 662972ffb90..ee382d3b78e 100644 --- a/langtools/test/tools/javac/enum/NoFinal4.java +++ b/langtools/test/tools/javac/enum/NoFinal4.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2004, 2006, 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 + * @test /nodynamiccopyright/ * @bug 5097250 5087624 * @summary Finalize methods on enums must be compile time error * @author Peter von der Ah\u00e9 - * @compile/fail NoFinal4.java + * @compile/fail/ref=NoFinal4.out -XDrawDiagnostics NoFinal4.java */ enum NoFinal4 { diff --git a/langtools/test/tools/javac/enum/NoFinal4.out b/langtools/test/tools/javac/enum/NoFinal4.out new file mode 100644 index 00000000000..7820ec65e42 --- /dev/null +++ b/langtools/test/tools/javac/enum/NoFinal4.out @@ -0,0 +1,2 @@ +NoFinal4.java:11:18: compiler.err.enum.no.finalize +1 error diff --git a/langtools/test/tools/javac/enum/NoFinal5.java b/langtools/test/tools/javac/enum/NoFinal5.java index 9b593a7cf6c..6ec5e7c0fcc 100644 --- a/langtools/test/tools/javac/enum/NoFinal5.java +++ b/langtools/test/tools/javac/enum/NoFinal5.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2004, 2006, 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 + * @test /nodynamiccopyright/ * @bug 5097250 5087624 * @summary Finalize methods on enums must be compile time error * @author Peter von der Ah\u00e9 - * @compile/fail NoFinal5.java + * @compile/fail/ref=NoFinal5.out -XDrawDiagnostics NoFinal5.java */ enum NoFinal5 { diff --git a/langtools/test/tools/javac/enum/NoFinal5.out b/langtools/test/tools/javac/enum/NoFinal5.out new file mode 100644 index 00000000000..cd85caf9ec1 --- /dev/null +++ b/langtools/test/tools/javac/enum/NoFinal5.out @@ -0,0 +1,2 @@ +NoFinal5.java:11:10: compiler.err.enum.no.finalize +1 error diff --git a/langtools/test/tools/javac/enum/T5081785.java b/langtools/test/tools/javac/enum/T5081785.java index 3dbcce73af2..0359619f670 100644 --- a/langtools/test/tools/javac/enum/T5081785.java +++ b/langtools/test/tools/javac/enum/T5081785.java @@ -1,43 +1,31 @@ /* - * Copyright (c) 2004, 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 + * @test /nodynamiccopyright/ * @bug 5081785 - * * @summary Empty Enums allowed in non-static contexts * @author Peter von der Ah\u00e9 - * - * @compile/fail T5081785.java - * @compile/fail T5081785a.java - * @compile/fail T5081785b.java - * @compile/fail T5081785c.java + * @compile/fail/ref=T5081785.out -XDrawDiagnostics T5081785.java */ -class A { +class A1 { public void check() { class Foo { enum STRENGTH{}; }; } } + +class A2 { + public A2 check() { + return new A2() { enum STRENGTH{}; }; + } +} + +class A3 { + Object o = new Object() { enum STRENGTH{}; }; +} + +class A4 { + class B { + enum C { X, Y, Z } + } +} diff --git a/langtools/test/tools/javac/enum/T5081785.out b/langtools/test/tools/javac/enum/T5081785.out new file mode 100644 index 00000000000..ef9963304ec --- /dev/null +++ b/langtools/test/tools/javac/enum/T5081785.out @@ -0,0 +1,5 @@ +T5081785.java:29:9: compiler.err.enums.must.be.static +T5081785.java:12:13: compiler.err.enums.must.be.static +T5081785.java:19:27: compiler.err.enums.must.be.static +T5081785.java:24:31: compiler.err.enums.must.be.static +4 errors From 9c09973b5a9f93ca086f6e9d464bd37e541242f6 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Mon, 7 Jul 2014 12:55:00 -0700 Subject: [PATCH 024/236] 8049491: Remove three auxilary files in tools/javac/enum dir Reviewed-by: jjg --- .../test/tools/javac/enum/T5081785a.java | 28 ------------------- .../test/tools/javac/enum/T5081785b.java | 26 ----------------- .../test/tools/javac/enum/T5081785c.java | 28 ------------------- 3 files changed, 82 deletions(-) delete mode 100644 langtools/test/tools/javac/enum/T5081785a.java delete mode 100644 langtools/test/tools/javac/enum/T5081785b.java delete mode 100644 langtools/test/tools/javac/enum/T5081785c.java diff --git a/langtools/test/tools/javac/enum/T5081785a.java b/langtools/test/tools/javac/enum/T5081785a.java deleted file mode 100644 index 4c16d6a49c5..00000000000 --- a/langtools/test/tools/javac/enum/T5081785a.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 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. - */ - -class A { - public A check() { - return new A() { enum STRENGTH{}; }; - } -} diff --git a/langtools/test/tools/javac/enum/T5081785b.java b/langtools/test/tools/javac/enum/T5081785b.java deleted file mode 100644 index 8df48936ea1..00000000000 --- a/langtools/test/tools/javac/enum/T5081785b.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2004, 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. - */ - -class A { - Object o = new Object() { enum STRENGTH{}; }; -} diff --git a/langtools/test/tools/javac/enum/T5081785c.java b/langtools/test/tools/javac/enum/T5081785c.java deleted file mode 100644 index ca8b8f5f927..00000000000 --- a/langtools/test/tools/javac/enum/T5081785c.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2004, 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. - */ - -class A { - class B { - enum C { X, Y, Z } - } -} From 5437ec7e743c4868bd95d39cd1f7df2f39b69030 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Mon, 7 Jul 2014 13:39:31 -0700 Subject: [PATCH 025/236] 8044080: .out files for unicode, implicitThis and importChecks tests in tools/javac dir Reviewed-by: jjg --- .../NewBeforeOuterConstructed.java | 27 ++---------------- .../NewBeforeOuterConstructed.out | 2 ++ .../NewBeforeOuterConstructed2.java | 27 ++---------------- .../NewBeforeOuterConstructed2.out | 2 ++ .../javac/importChecks/ImportCanonical1.java | 27 ++---------------- .../javac/importChecks/ImportCanonical1.out | 2 ++ .../importChecks/ImportIsFullyQualified.java | 27 ++---------------- .../importChecks/ImportIsFullyQualified.out | 2 ++ .../importChecks/InvalidImportsNoClasses.java | 27 ++---------------- .../importChecks/InvalidImportsNoClasses.out | 2 ++ .../tools/javac/unicode/NonasciiDigit.java | 27 ++---------------- .../tools/javac/unicode/NonasciiDigit.out | 2 ++ .../tools/javac/unicode/NonasciiDigit2.java | 27 ++---------------- .../tools/javac/unicode/NonasciiDigit2.out | 2 ++ .../javac/unicode/SupplementaryJavaID2.java | 27 ++---------------- .../javac/unicode/SupplementaryJavaID2.out | 3 ++ .../javac/unicode/SupplementaryJavaID3.java | 27 ++---------------- .../javac/unicode/SupplementaryJavaID3.out | 2 ++ .../test/tools/javac/unicode/TripleQuote.java | 28 ++----------------- .../test/tools/javac/unicode/TripleQuote.out | 7 +++++ 20 files changed, 47 insertions(+), 250 deletions(-) create mode 100644 langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.out create mode 100644 langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.out create mode 100644 langtools/test/tools/javac/importChecks/ImportCanonical1.out create mode 100644 langtools/test/tools/javac/importChecks/ImportIsFullyQualified.out create mode 100644 langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.out create mode 100644 langtools/test/tools/javac/unicode/NonasciiDigit.out create mode 100644 langtools/test/tools/javac/unicode/NonasciiDigit2.out create mode 100644 langtools/test/tools/javac/unicode/SupplementaryJavaID2.out create mode 100644 langtools/test/tools/javac/unicode/SupplementaryJavaID3.out create mode 100644 langtools/test/tools/javac/unicode/TripleQuote.out diff --git a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.java b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.java index d7b1fed6b2d..f9a368f3768 100644 --- a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.java +++ b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 1999, 2002, 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 + * @test /nodynamiccopyright/ * @bug 4249111 * @summary 'new' of inner class should not be allowed unless outer is constructed * - * @compile/fail NewBeforeOuterConstructed.java + * @compile/fail/ref=NewBeforeOuterConstructed.out -XDrawDiagnostics NewBeforeOuterConstructed.java */ import java.io.*; diff --git a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.out b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.out new file mode 100644 index 00000000000..a938776a8cb --- /dev/null +++ b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed.out @@ -0,0 +1,2 @@ +NewBeforeOuterConstructed.java:27:21: compiler.err.cant.ref.before.ctor.called: this +1 error diff --git a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.java b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.java index 442eb02373b..1c9a299e266 100644 --- a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.java +++ b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.java @@ -1,32 +1,9 @@ /* - * Copyright (c) 2002, 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 + * @test /nodynamiccopyright/ * @bug 4689058 * @summary unverifiable code for implicit outer in super constructor call * - * @compile/fail NewBeforeOuterConstructed2.java + * @compile/fail/ref=NewBeforeOuterConstructed2.out -XDrawDiagnostics NewBeforeOuterConstructed2.java */ public class NewBeforeOuterConstructed2 { diff --git a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.out b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.out new file mode 100644 index 00000000000..68e957aacf5 --- /dev/null +++ b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed2.out @@ -0,0 +1,2 @@ +NewBeforeOuterConstructed2.java:20:35: compiler.err.cant.ref.before.ctor.called: this +1 error diff --git a/langtools/test/tools/javac/importChecks/ImportCanonical1.java b/langtools/test/tools/javac/importChecks/ImportCanonical1.java index b7f5e751ddd..64639be8a5a 100644 --- a/langtools/test/tools/javac/importChecks/ImportCanonical1.java +++ b/langtools/test/tools/javac/importChecks/ImportCanonical1.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, 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 + * @test /nodynamiccopyright/ * @bug 4462745 * @summary compiler permits to import class given by its non-canonical name * @author gafter * - * @compile/fail ImportCanonical1.java ImportCanonical2.java + * @compile/fail/ref=ImportCanonical1.out -XDrawDiagnostics ImportCanonical1.java ImportCanonical2.java */ package p1; diff --git a/langtools/test/tools/javac/importChecks/ImportCanonical1.out b/langtools/test/tools/javac/importChecks/ImportCanonical1.out new file mode 100644 index 00000000000..1e69e6ba9c5 --- /dev/null +++ b/langtools/test/tools/javac/importChecks/ImportCanonical1.out @@ -0,0 +1,2 @@ +ImportCanonical2.java:25:13: compiler.err.import.requires.canonical: p1.A1.I +1 error diff --git a/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.java b/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.java index 45af06e9ff5..42d5e2fad1f 100644 --- a/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.java +++ b/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2000, 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 + * @test /nodynamiccopyright/ * @bug 4335264 * @summary Verify that import-on-demand must be fully qualified. * @author maddox * - * @compile/fail ImportIsFullyQualified.java + * @compile/fail/ref=ImportIsFullyQualified.out -XDrawDiagnostics ImportIsFullyQualified.java */ import java.awt.*; diff --git a/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.out b/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.out new file mode 100644 index 00000000000..33e7d2f71c3 --- /dev/null +++ b/langtools/test/tools/javac/importChecks/ImportIsFullyQualified.out @@ -0,0 +1,2 @@ +ImportIsFullyQualified.java:11:1: compiler.err.doesnt.exist: JobAttributes +1 error diff --git a/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.java b/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.java index d5f9075c380..706487971ae 100644 --- a/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.java +++ b/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2000, 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 + * @test /nodynamiccopyright/ * @bug 4312063 * @summary Verify that nonexistent imports detected when no classes declared in compilation unit. * @author maddox * - * @compile/fail InvalidImportsNoClasses.java + * @compile/fail/ref=InvalidImportsNoClasses.out -XDrawDiagnostics InvalidImportsNoClasses.java */ import nonexistent.pack.cls; diff --git a/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.out b/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.out new file mode 100644 index 00000000000..eaaa444e472 --- /dev/null +++ b/langtools/test/tools/javac/importChecks/InvalidImportsNoClasses.out @@ -0,0 +1,2 @@ +InvalidImportsNoClasses.java:10:24: compiler.err.doesnt.exist: nonexistent.pack +1 error diff --git a/langtools/test/tools/javac/unicode/NonasciiDigit.java b/langtools/test/tools/javac/unicode/NonasciiDigit.java index 03f1d73ec1b..dce613d793c 100644 --- a/langtools/test/tools/javac/unicode/NonasciiDigit.java +++ b/langtools/test/tools/javac/unicode/NonasciiDigit.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2002, 2005, 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 + * @test /nodynamiccopyright/ * @bug 4707960 6183529 * @summary javac accepts unicode digits - sometimes crashing * @author gafter * - * @compile/fail NonasciiDigit.java + * @compile/fail/ref=NonasciiDigit.out -XDrawDiagnostics NonasciiDigit.java */ public class NonasciiDigit { public static void main(String[] args) { diff --git a/langtools/test/tools/javac/unicode/NonasciiDigit.out b/langtools/test/tools/javac/unicode/NonasciiDigit.out new file mode 100644 index 00000000000..b2bb88edf0e --- /dev/null +++ b/langtools/test/tools/javac/unicode/NonasciiDigit.out @@ -0,0 +1,2 @@ +NonasciiDigit.java:12:26: compiler.err.illegal.char: \uff11 +1 error diff --git a/langtools/test/tools/javac/unicode/NonasciiDigit2.java b/langtools/test/tools/javac/unicode/NonasciiDigit2.java index 6c29997142d..a732f2de5a1 100644 --- a/langtools/test/tools/javac/unicode/NonasciiDigit2.java +++ b/langtools/test/tools/javac/unicode/NonasciiDigit2.java @@ -1,33 +1,10 @@ /* - * Copyright (c) 2005, 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 + * @test /nodynamiccopyright/ * @bug 4707960 6183529 * @summary javac accepts unicode digits - sometimes crashing * @author gafter * - * @compile/fail NonasciiDigit2.java + * @compile/fail/ref=NonasciiDigit2.out -XDrawDiagnostics NonasciiDigit2.java */ public class NonasciiDigit2 { public static void main(String[] args) { diff --git a/langtools/test/tools/javac/unicode/NonasciiDigit2.out b/langtools/test/tools/javac/unicode/NonasciiDigit2.out new file mode 100644 index 00000000000..27d8882fd27 --- /dev/null +++ b/langtools/test/tools/javac/unicode/NonasciiDigit2.out @@ -0,0 +1,2 @@ +NonasciiDigit2.java:12:18: compiler.err.illegal.nonascii.digit +1 error diff --git a/langtools/test/tools/javac/unicode/SupplementaryJavaID2.java b/langtools/test/tools/javac/unicode/SupplementaryJavaID2.java index 034c7f1cf34..8c1c43a1352 100644 --- a/langtools/test/tools/javac/unicode/SupplementaryJavaID2.java +++ b/langtools/test/tools/javac/unicode/SupplementaryJavaID2.java @@ -1,34 +1,11 @@ /* - * Copyright (c) 2003, 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 + * @test /nodynamiccopyright/ * @bug 4914724 * @summary Ensure that the invalid surrogate sequence, as the start of an identifier, * causes a compilation failure * @author Naoto Sato * - * @compile/fail SupplementaryJavaID2.java + * @compile/fail/ref=SupplementaryJavaID2.out -XDrawDiagnostics SupplementaryJavaID2.java */ public class SupplementaryJavaID2 { diff --git a/langtools/test/tools/javac/unicode/SupplementaryJavaID2.out b/langtools/test/tools/javac/unicode/SupplementaryJavaID2.out new file mode 100644 index 00000000000..f783575f7e2 --- /dev/null +++ b/langtools/test/tools/javac/unicode/SupplementaryJavaID2.out @@ -0,0 +1,3 @@ +SupplementaryJavaID2.java:12:14: compiler.err.illegal.char: \ud801 +SupplementaryJavaID2.java:12:24: compiler.err.expected: token.identifier +2 errors diff --git a/langtools/test/tools/javac/unicode/SupplementaryJavaID3.java b/langtools/test/tools/javac/unicode/SupplementaryJavaID3.java index 765274f4976..c4fe4afc0a5 100644 --- a/langtools/test/tools/javac/unicode/SupplementaryJavaID3.java +++ b/langtools/test/tools/javac/unicode/SupplementaryJavaID3.java @@ -1,34 +1,11 @@ /* - * Copyright (c) 2003, 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 + * @test /nodynamiccopyright/ * @bug 4914724 * @summary Ensure that the invalid surrogate sequence, as the part of an identifier, * causes a compilation failure * @author Naoto Sato * - * @compile/fail SupplementaryJavaID3.java + * @compile/fail/ref=SupplementaryJavaID3.out -XDrawDiagnostics SupplementaryJavaID3.java */ public class SupplementaryJavaID3 { diff --git a/langtools/test/tools/javac/unicode/SupplementaryJavaID3.out b/langtools/test/tools/javac/unicode/SupplementaryJavaID3.out new file mode 100644 index 00000000000..bc2cf5e57b5 --- /dev/null +++ b/langtools/test/tools/javac/unicode/SupplementaryJavaID3.out @@ -0,0 +1,2 @@ +SupplementaryJavaID3.java:12:23: compiler.err.illegal.char: \ud801 +1 error diff --git a/langtools/test/tools/javac/unicode/TripleQuote.java b/langtools/test/tools/javac/unicode/TripleQuote.java index 9ee5e1fcad7..1e4fa5d6809 100644 --- a/langtools/test/tools/javac/unicode/TripleQuote.java +++ b/langtools/test/tools/javac/unicode/TripleQuote.java @@ -1,36 +1,14 @@ /* - * Copyright (c) 1997, 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 + * @test /nodynamiccopyright/ * @bug 1265387 * @summary ''' and '\u0027' are not legal char literals. * @author turnidge * - * @compile/fail TripleQuote.java + * @compile/fail/ref=TripleQuote.out -XDrawDiagnostics TripleQuote.java */ public class TripleQuote { char c = '\u0027'; + char d = '''; } diff --git a/langtools/test/tools/javac/unicode/TripleQuote.out b/langtools/test/tools/javac/unicode/TripleQuote.out new file mode 100644 index 00000000000..8bd658911b9 --- /dev/null +++ b/langtools/test/tools/javac/unicode/TripleQuote.out @@ -0,0 +1,7 @@ +TripleQuote.java:12:14: compiler.err.empty.char.lit +TripleQuote.java:12:20: compiler.err.empty.char.lit +TripleQuote.java:12:21: compiler.err.unclosed.char.lit +TripleQuote.java:13:14: compiler.err.empty.char.lit +TripleQuote.java:13:15: compiler.err.empty.char.lit +TripleQuote.java:13:16: compiler.err.unclosed.char.lit +6 errors From 3c5b32658bd9695a10a3e8f6856221f83a1972a4 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 8 Jul 2014 15:13:16 +0200 Subject: [PATCH 026/236] 8042239: javac: TreeMaker.Type(Type t) does not handle UnionClassType Enhancing TreeMaker.Type(Type t) with support for UnionClassType and IntersectionClassType. Co-authored-by: Robert Field Reviewed-by: vromero, rfield --- .../com/sun/tools/javac/code/Type.java | 4 + .../com/sun/tools/javac/tree/TreeMaker.java | 39 +++- .../test/tools/javac/tree/MakeTypeTest.java | 199 ++++++++++++++++++ .../test/tools/javac/tree/MakeTypeTest.out | 1 + 4 files changed, 235 insertions(+), 8 deletions(-) create mode 100644 langtools/test/tools/javac/tree/MakeTypeTest.java create mode 100644 langtools/test/tools/javac/tree/MakeTypeTest.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java index b89542a162f..6ba524e9bda 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java @@ -1050,6 +1050,10 @@ public abstract class Type extends AnnoConstruct implements TypeMirror { public R accept(TypeVisitor v, P p) { return v.visitUnion(this, p); } + + public Iterable getAlternativeTypes() { + return alternatives_field; + } } // a clone of a ClassType that knows about the bounds of an intersection type. diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java index 9178af72973..a4f9923400c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -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 @@ -692,13 +692,36 @@ public class TreeMaker implements JCTree.Factory { break; } case CLASS: - Type outer = t.getEnclosingType(); - JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP - ? Select(Type(outer), t.tsym) - : QualIdent(t.tsym); - tp = t.getTypeArguments().isEmpty() - ? clazz - : TypeApply(clazz, Types(t.getTypeArguments())); + switch (t.getKind()) { + case UNION: { + UnionClassType tu = (UnionClassType)t; + ListBuffer la = new ListBuffer<>(); + for (Type ta : tu.getAlternativeTypes()) { + la.add(Type(ta)); + } + tp = TypeUnion(la.toList()); + break; + } + case INTERSECTION: { + IntersectionClassType it = (IntersectionClassType)t; + ListBuffer la = new ListBuffer<>(); + for (Type ta : it.getExplicitComponents()) { + la.add(Type(ta)); + } + tp = TypeIntersection(la.toList()); + break; + } + default: { + Type outer = t.getEnclosingType(); + JCExpression clazz = outer.hasTag(CLASS) && t.tsym.owner.kind == TYP + ? Select(Type(outer), t.tsym) + : QualIdent(t.tsym); + tp = t.getTypeArguments().isEmpty() + ? clazz + : TypeApply(clazz, Types(t.getTypeArguments())); + break; + } + } break; case ARRAY: tp = TypeArray(Type(types.elemtype(t))); diff --git a/langtools/test/tools/javac/tree/MakeTypeTest.java b/langtools/test/tools/javac/tree/MakeTypeTest.java new file mode 100644 index 00000000000..c3a1de673c3 --- /dev/null +++ b/langtools/test/tools/javac/tree/MakeTypeTest.java @@ -0,0 +1,199 @@ +/* + * 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 8042239 + * @summary Verify that TreeMaker.Type(Type) can handle all reasonable types + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor MakeTypeTest + * @compile/process/ref=MakeTypeTest.out -processor MakeTypeTest MakeTypeTest.java + */ + +import java.lang.annotation.*; +import java.util.*; + +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.element.*; +import javax.lang.model.type.*; + +import com.sun.source.tree.*; +import com.sun.source.util.*; +import com.sun.tools.javac.api.JavacTrees; +import com.sun.tools.javac.code.Type; +import com.sun.tools.javac.code.Type.ClassType; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.tree.JCTree.JCExpression; +import com.sun.tools.javac.tree.TreeMaker; +import com.sun.tools.javac.util.*; +import com.sun.tools.javac.util.List; + +public class MakeTypeTest extends JavacTestingAbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) + return false; + + JavacTask.instance(processingEnv).addTaskListener(new TaskListener() { + @Override + public void started(TaskEvent e) { + } + @Override + public void finished(TaskEvent e) { + if (e.getKind() == TaskEvent.Kind.ANALYZE && + e.getTypeElement().getQualifiedName().contentEquals("MakeTypeTest")) { + doTest(); + } + } + }); + + return false; + } + + void doTest() { + //go through this file, look for @TestType and verify TreeMaker.Type behavior: + Context ctx = ((JavacProcessingEnvironment) processingEnv).getContext(); + JavacTrees trees = JavacTrees.instance(ctx); + TypeElement testType = processingEnv.getElementUtils().getTypeElement("MakeTypeTest"); + TreePath path = trees.getPath(testType); + + Set unseenTypeKinds = EnumSet.allOf(TypeKind.class); + + new TreePathScanner() { + @Override + public Void visitVariable(VariableTree node, Void p) { + handleDecl(new TreePath(getCurrentPath(), node.getType())); + return super.visitVariable(node, p); + } + + @Override + public Void visitMethod(MethodTree node, Void p) { + if (node.getReturnType() != null) + handleDecl(new TreePath(getCurrentPath(), node.getReturnType())); + return super.visitMethod(node, p); + } + + @Override + public Void visitTypeParameter(TypeParameterTree node, Void p) { + TypeVariable type = (TypeVariable) trees.getTypeMirror(getCurrentPath()); + TreePath aBoundPath = new TreePath(getCurrentPath(), node.getBounds().get(0)); + handleDecl(aBoundPath, (Type) type.getUpperBound()); + return super.visitTypeParameter(node, p); + } + + void handleDecl(TreePath typePath) { + handleDecl(typePath, (Type) trees.getTypeMirror(typePath)); + } + + void handleDecl(TreePath typePath, Type type) { + Element decl = trees.getElement(typePath.getParentPath()); + TestType testType = decl.getAnnotation(TestType.class); + + if (testType == null) return ; + + if (testType.nested() >= 0) { + ClassType ct = (ClassType) type; + type = ct.getTypeArguments().get(testType.nested()); + } + + JCExpression typeExpr = TreeMaker.instance(ctx).Type(type); + + if (!typeExpr.getKind().equals(testType.expectedKind())) { + throw new IllegalStateException("was=" + typeExpr + ", kind=" + + typeExpr.getKind() + "; expected kind: " + + testType.expectedKind() + "; type=" + type); + } + unseenTypeKinds.remove(type.getKind()); + } + + }.scan(path, null); + + unseenTypeKinds.removeAll(Arrays.asList(TypeKind.NONE, TypeKind.NULL, TypeKind.ERROR, + TypeKind.PACKAGE, TypeKind.EXECUTABLE, TypeKind.OTHER)); + + if (!unseenTypeKinds.isEmpty()) + throw new IllegalStateException("Unhandled types=" + unseenTypeKinds); + + System.err.println("done."); + } + + //the following defines the Types that should be passed into TreeMaker.Type and + //the expected resulting Tree kind: + + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + boolean f1; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + byte f2; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + char f3; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + double f4; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + float f5; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + int f6; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + long f7; + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + short f8; + @TestType(expectedKind=Tree.Kind.PARAMETERIZED_TYPE) + List f9; + @TestType(expectedKind=Tree.Kind.ARRAY_TYPE) + int[] fa; + @TestType(expectedKind=Tree.Kind.EXTENDS_WILDCARD, nested = 0) + List fb; + @TestType(expectedKind=Tree.Kind.SUPER_WILDCARD, nested = 0) + List fc; + @TestType(expectedKind=Tree.Kind.UNBOUNDED_WILDCARD, nested = 0) + List fd; + + @TestType(expectedKind=Tree.Kind.PRIMITIVE_TYPE) + void voidMethod() { + try { + voidMethod(); + } catch (@TestType(expectedKind=Tree.Kind.UNION_TYPE) NullPointerException | + IllegalStateException ex) { + } + } + + class WithTypeParam<@TestType(expectedKind=Tree.Kind.INTERSECTION_TYPE) + T extends CharSequence & Runnable> { + @TestType(expectedKind=Tree.Kind.IDENTIFIER) + T voidMethod() { + return null; + } + } + +} + +//TreeMaker.Type will be tested for the type the element annotated by this annotation +@Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, + ElementType.PARAMETER, ElementType.TYPE_PARAMETER}) +@interface TestType { + //the expected Tree kind of the Tree that will be returned from TreeMaker.Type for the type + public Tree.Kind expectedKind(); + //if >=0, the current type will be interpreted as a ClassType and the type to test will be + //the given type argument: + public int nested() default -1; +} diff --git a/langtools/test/tools/javac/tree/MakeTypeTest.out b/langtools/test/tools/javac/tree/MakeTypeTest.out new file mode 100644 index 00000000000..70ff8e5af89 --- /dev/null +++ b/langtools/test/tools/javac/tree/MakeTypeTest.out @@ -0,0 +1 @@ +done. From 15cfa4aac96e2e45d2ec055a8b0b57fac4780a2d Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 8 Jul 2014 15:42:04 +0100 Subject: [PATCH 027/236] 8043926: javac, code valid in 7 is not compiling for 8 Type-containment doesn't handle inference variables correctly Reviewed-by: vromero, dlsmith --- .../com/sun/tools/javac/code/Types.java | 3 +- .../generics/inference/8043926/T8043926.java | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/generics/inference/8043926/T8043926.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index e1831b284db..bdda834d6a7 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -1312,7 +1312,8 @@ public class Types { UndetVar undetvar = (UndetVar)t; WildcardType wt = (WildcardType)s; switch(wt.kind) { - case UNBOUND: //similar to ? extends Object + case UNBOUND: + break; case EXTENDS: { Type bound = wildUpperBound(s); undetvar.addBound(InferenceBound.UPPER, bound, this); diff --git a/langtools/test/tools/javac/generics/inference/8043926/T8043926.java b/langtools/test/tools/javac/generics/inference/8043926/T8043926.java new file mode 100644 index 00000000000..88f0f1b83b2 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/8043926/T8043926.java @@ -0,0 +1,43 @@ +/* + * 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 8043926 + * @summary javac, code valid in 7 is not compiling for 8 + * @compile T8043926.java + */ +class T8043926 { + interface Iface {} + + static class Impl implements Iface {} + + static class Acceptor> { + public Acceptor(T2 obj) {} + } + + void test(Impl impl) { + Acceptor acceptor1 = new Acceptor<>(impl); + Acceptor acceptor2 = new Acceptor<>(impl); + } +} From c2f98fba15b049605810f8619a1380ed0c56acc5 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 8 Jul 2014 18:26:34 -0700 Subject: [PATCH 028/236] 8029548: (jdeps) use @jdk.Exported to determine supported vs JDK internal API 8031092: jdeps does not recognize --help option 8048063: (jdeps) Add filtering capability Reviewed-by: alanb, dfuchs --- .../classes/com/sun/tools/jdeps/Analyzer.java | 324 +++++----- .../classes/com/sun/tools/jdeps/Archive.java | 22 +- .../com/sun/tools/jdeps/ClassFileReader.java | 120 ++-- .../com/sun/tools/jdeps/JdepsTask.java | 584 +++++++++--------- .../classes/com/sun/tools/jdeps/Main.java | 3 +- .../sun/tools/jdeps/PlatformClassPath.java | 116 +++- .../classes/com/sun/tools/jdeps/Profile.java | 8 +- .../tools/jdeps/resources/jdeps.properties | 27 +- langtools/test/tools/jdeps/APIDeps.java | 30 +- langtools/test/tools/jdeps/Basic.java | 21 +- langtools/test/tools/jdeps/DotFileTest.java | 272 ++++++++ langtools/test/tools/jdeps/m/Gee.java | 6 +- langtools/test/tools/jdeps/p/Bar.java | 6 +- 13 files changed, 1015 insertions(+), 524 deletions(-) create mode 100644 langtools/test/tools/jdeps/DotFileTest.java diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java index 8a7806934dc..2833d1258dc 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Analyzer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,16 +26,13 @@ package com.sun.tools.jdeps; import com.sun.tools.classfile.Dependency.Location; import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; -import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; /** * Dependency Analyzer. @@ -52,7 +49,16 @@ public class Analyzer { VERBOSE } + /** + * Filter to be applied when analyzing the dependencies from the given archives. + * Only the accepted dependencies are recorded. + */ + interface Filter { + boolean accepts(Location origin, Archive originArchive, Location target, Archive targetArchive); + } + private final Type type; + private final Filter filter; private final Map results = new HashMap<>(); private final Map map = new HashMap<>(); private final Archive NOT_FOUND @@ -62,15 +68,29 @@ public class Analyzer { * Constructs an Analyzer instance. * * @param type Type of the dependency analysis + * @param filter */ - public Analyzer(Type type) { + public Analyzer(Type type, Filter filter) { this.type = type; + this.filter = filter; } /** * Performs the dependency analysis on the given archives. */ public void run(List archives) { + // build a map from Location to Archive + buildLocationArchiveMap(archives); + + // traverse and analyze all dependencies + for (Archive archive : archives) { + ArchiveDeps deps = new ArchiveDeps(archive, type); + archive.visitDependences(deps); + results.put(archive, deps); + } + } + + private void buildLocationArchiveMap(List archives) { // build a map from Location to Archive for (Archive archive: archives) { for (Location l: archive.getClasses()) { @@ -81,190 +101,202 @@ public class Analyzer { } } } - // traverse and analyze all dependencies - for (Archive archive : archives) { - ArchiveDeps deps; - if (type == Type.CLASS || type == Type.VERBOSE) { - deps = new ClassVisitor(archive); - } else { - deps = new PackageVisitor(archive); - } - archive.visitDependences(deps); - results.put(archive, deps); - } } public boolean hasDependences(Archive archive) { if (results.containsKey(archive)) { - return results.get(archive).deps.size() > 0; + return results.get(archive).dependencies().size() > 0; } return false; } public interface Visitor { - /** - * Visits the source archive to its destination archive of - * a recorded dependency. - */ - void visitArchiveDependence(Archive origin, Archive target, Profile profile); /** * Visits a recorded dependency from origin to target which can be - * a fully-qualified classname, a package name, a profile or + * a fully-qualified classname, a package name, a module or * archive name depending on the Analyzer's type. */ - void visitDependence(String origin, Archive source, String target, Archive archive, Profile profile); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive); } - public void visitArchiveDependences(Archive source, Visitor v) { - ArchiveDeps r = results.get(source); - for (ArchiveDeps.Dep d: r.requireArchives()) { - v.visitArchiveDependence(r.archive, d.archive, d.profile); + /** + * Visit the dependencies of the given source. + * If the requested level is SUMMARY, it will visit the required archives list. + */ + public void visitDependences(Archive source, Visitor v, Type level) { + if (level == Type.SUMMARY) { + final ArchiveDeps result = results.get(source); + result.requires().stream() + .sorted(Comparator.comparing(Archive::getName)) + .forEach(archive -> { + Profile profile = result.getTargetProfile(archive); + v.visitDependence(source.getName(), source, + profile != null ? profile.profileName() : archive.getName(), archive); + }); + } else { + ArchiveDeps result = results.get(source); + if (level != type) { + // requesting different level of analysis + result = new ArchiveDeps(source, level); + source.visitDependences(result); + } + result.dependencies().stream() + .sorted(Comparator.comparing(Dep::origin) + .thenComparing(Dep::target)) + .forEach(d -> v.visitDependence(d.origin(), d.originArchive(), d.target(), d.targetArchive())); } } public void visitDependences(Archive source, Visitor v) { - ArchiveDeps r = results.get(source); - for (Map.Entry> e: r.deps.entrySet()) { - String origin = e.getKey(); - for (ArchiveDeps.Dep d: e.getValue()) { - // filter intra-dependency unless in verbose mode - if (type == Type.VERBOSE || d.archive != source) { - v.visitDependence(origin, source, d.target, d.archive, d.profile); - } - } - } + visitDependences(source, v, type); } /** - * ArchiveDeps contains the dependencies for an Archive that - * can have one or more classes. + * ArchiveDeps contains the dependencies for an Archive that can have one or + * more classes. */ - private abstract class ArchiveDeps implements Archive.Visitor { - final Archive archive; - final SortedMap> deps; - ArchiveDeps(Archive archive) { + class ArchiveDeps implements Archive.Visitor { + protected final Archive archive; + protected final Set requires; + protected final Set deps; + protected final Type level; + private Profile profile; + ArchiveDeps(Archive archive, Type level) { this.archive = archive; - this.deps = new TreeMap<>(); + this.deps = new HashSet<>(); + this.requires = new HashSet<>(); + this.level = level; } - void add(String origin, String target, Archive targetArchive, String pkgName) { - SortedSet set = deps.get(origin); - if (set == null) { - deps.put(origin, set = new TreeSet<>()); - } - Profile p = targetArchive instanceof JDKArchive - ? Profile.getProfile(pkgName) : null; - set.add(new Dep(target, targetArchive, p)); + Set dependencies() { + return deps; } - /** - * Returns the list of Archive dependences. The returned - * list contains one {@code Dep} instance per one archive - * and with the minimum profile this archive depends on. - */ - List requireArchives() { - Map map = new HashMap<>(); - for (Set set: deps.values()) { - for (Dep d: set) { - if (this.archive != d.archive) { - Profile p = map.get(d.archive); - if (p == null || (d.profile != null && p.profile < d.profile.profile)) { - map.put(d.archive, d.profile); - } - } - } - } - List list = new ArrayList<>(); - for (Map.Entry e: map.entrySet()) { - list.add(new Dep("", e.getKey(), e.getValue())); - } - return list; + Set requires() { + return requires; } - /** - * Dep represents a dependence where the target can be - * a classname or packagename and the archive and profile - * the target belongs to. - */ - class Dep implements Comparable { - final String target; - final Archive archive; - final Profile profile; - Dep(String target, Archive archive, Profile p) { - this.target = target; - this.archive = archive; - this.profile = p; - } + Profile getTargetProfile(Archive target) { + return JDKArchive.isProfileArchive(target) ? profile : null; + } - @Override - public boolean equals(Object o) { - if (o instanceof Dep) { - Dep d = (Dep)o; - return this.archive == d.archive && this.target.equals(d.target); - } - return false; + Archive findArchive(Location t) { + Archive target = archive.getClasses().contains(t) ? archive : map.get(t); + if (target == null) { + map.put(t, target = NOT_FOUND); } + return target; + } - @Override - public int hashCode() { - int hash = 3; - hash = 17 * hash + Objects.hashCode(this.archive); - hash = 17 * hash + Objects.hashCode(this.target); - return hash; - } - - @Override - public int compareTo(Dep o) { - if (this.target.equals(o.target)) { - if (this.archive == o.archive) { - return 0; - } else { - return this.archive.getFileName().compareTo(o.archive.getFileName()); - } - } - return this.target.compareTo(o.target); + // return classname or package name depedning on the level + private String getLocationName(Location o) { + if (level == Type.CLASS || level == Type.VERBOSE) { + return o.getClassName(); + } else { + String pkg = o.getPackageName(); + return pkg.isEmpty() ? "" : pkg; } } - public abstract void visit(Location o, Location t); - } - private class ClassVisitor extends ArchiveDeps { - ClassVisitor(Archive archive) { - super(archive); - } @Override public void visit(Location o, Location t) { - Archive targetArchive = - this.archive.getClasses().contains(t) ? this.archive : map.get(t); - if (targetArchive == null) { - map.put(t, targetArchive = NOT_FOUND); + Archive targetArchive = findArchive(t); + if (filter.accepts(o, archive, t, targetArchive)) { + addDep(o, t); + if (!requires.contains(targetArchive)) { + requires.add(targetArchive); + } + } + if (targetArchive instanceof JDKArchive) { + Profile p = Profile.getProfile(t.getPackageName()); + if (profile == null || (p != null && p.compareTo(profile) > 0)) { + profile = p; + } + } + } + + private Dep curDep; + protected Dep addDep(Location o, Location t) { + String origin = getLocationName(o); + String target = getLocationName(t); + Archive targetArchive = findArchive(t); + if (curDep != null && + curDep.origin().equals(origin) && + curDep.originArchive() == archive && + curDep.target().equals(target) && + curDep.targetArchive() == targetArchive) { + return curDep; } - String origin = o.getClassName(); - String target = t.getClassName(); - add(origin, target, targetArchive, t.getPackageName()); + Dep e = new Dep(origin, archive, target, targetArchive); + if (deps.contains(e)) { + for (Dep e1 : deps) { + if (e.equals(e1)) { + curDep = e1; + } + } + } else { + deps.add(e); + curDep = e; + } + return curDep; } } - private class PackageVisitor extends ArchiveDeps { - PackageVisitor(Archive archive) { - super(archive); - } - @Override - public void visit(Location o, Location t) { - Archive targetArchive = - this.archive.getClasses().contains(t) ? this.archive : map.get(t); - if (targetArchive == null) { - map.put(t, targetArchive = NOT_FOUND); - } + /* + * Class-level or package-level dependency + */ + class Dep { + final String origin; + final Archive originArchive; + final String target; + final Archive targetArchive; - String origin = packageOf(o); - String target = packageOf(t); - add(origin, target, targetArchive, t.getPackageName()); + Dep(String origin, Archive originArchive, String target, Archive targetArchive) { + this.origin = origin; + this.originArchive = originArchive; + this.target = target; + this.targetArchive = targetArchive; } - public String packageOf(Location o) { - String pkg = o.getPackageName(); - return pkg.isEmpty() ? "" : pkg; + + String origin() { + return origin; + } + + Archive originArchive() { + return originArchive; + } + + String target() { + return target; + } + + Archive targetArchive() { + return targetArchive; + } + + @Override + @SuppressWarnings("unchecked") + public boolean equals(Object o) { + if (o instanceof Dep) { + Dep d = (Dep) o; + return this.origin.equals(d.origin) && + this.originArchive == d.originArchive && + this.target.equals(d.target) && + this.targetArchive == d.targetArchive; + } + return false; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 67*hash + Objects.hashCode(this.origin) + + Objects.hashCode(this.originArchive) + + Objects.hashCode(this.target) + + Objects.hashCode(this.targetArchive); + return hash; } } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Archive.java b/langtools/src/share/classes/com/sun/tools/jdeps/Archive.java index cc2963bb469..669575d106c 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/Archive.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Archive.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -25,28 +25,34 @@ package com.sun.tools.jdeps; import com.sun.tools.classfile.Dependency.Location; + +import java.io.IOException; import java.nio.file.Path; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * Represents the source of the class files. */ public class Archive { + public static Archive getInstance(Path p) throws IOException { + return new Archive(p, ClassFileReader.newInstance(p)); + } + private final Path path; private final String filename; private final ClassFileReader reader; - private final Map> deps = new HashMap<>(); + protected Map> deps = new ConcurrentHashMap<>(); - public Archive(String name) { + protected Archive(String name) { this.path = null; this.filename = name; this.reader = null; } - public Archive(Path p, ClassFileReader reader) { + protected Archive(Path p, ClassFileReader reader) { this.path = p; this.filename = path.getFileName().toString(); this.reader = reader; @@ -56,7 +62,7 @@ public class Archive { return reader; } - public String getFileName() { + public String getName() { return filename; } @@ -89,6 +95,10 @@ public class Archive { } } + public boolean isEmpty() { + return getClasses().isEmpty(); + } + public String getPathName() { return path != null ? path.toString() : filename; } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java b/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java index 8be91aed091..11ce3e2f954 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/ClassFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -68,7 +68,8 @@ public class ClassFileReader { protected final Path path; protected final String baseFileName; - private ClassFileReader(Path path) { + protected final List skippedEntries = new ArrayList<>(); + protected ClassFileReader(Path path) { this.path = path; this.baseFileName = path.getFileName() != null ? path.getFileName().toString() @@ -79,6 +80,10 @@ public class ClassFileReader { return baseFileName; } + public List skippedEntries() { + return skippedEntries; + } + /** * Returns the ClassFile matching the given binary name * or a fully-qualified class name. @@ -232,11 +237,12 @@ public class ClassFileReader { } } - private static class JarFileReader extends ClassFileReader { - final JarFile jarfile; + static class JarFileReader extends ClassFileReader { + private final JarFile jarfile; JarFileReader(Path path) throws IOException { - this(path, new JarFile(path.toFile())); + this(path, new JarFile(path.toFile(), false)); } + JarFileReader(Path path, JarFile jf) throws IOException { super(path); this.jarfile = jf; @@ -252,18 +258,18 @@ public class ClassFileReader { + entryName.substring(i + 1, entryName.length())); } if (e != null) { - return readClassFile(e); + return readClassFile(jarfile, e); } } else { JarEntry e = jarfile.getJarEntry(name + ".class"); if (e != null) { - return readClassFile(e); + return readClassFile(jarfile, e); } } return null; } - private ClassFile readClassFile(JarEntry e) throws IOException { + protected ClassFile readClassFile(JarFile jarfile, JarEntry e) throws IOException { InputStream is = null; try { is = jarfile.getInputStream(e); @@ -277,60 +283,76 @@ public class ClassFileReader { } public Iterable getClassFiles() throws IOException { - final Iterator iter = new JarFileIterator(); + final Iterator iter = new JarFileIterator(this, jarfile); return new Iterable() { public Iterator iterator() { return iter; } }; } + } - class JarFileIterator implements Iterator { - private Enumeration entries; - private JarEntry nextEntry; - JarFileIterator() { - this.entries = jarfile.entries(); - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - String name = e.getName(); - if (name.endsWith(".class")) { - this.nextEntry = e; - break; - } - } + class JarFileIterator implements Iterator { + protected final JarFileReader reader; + protected Enumeration entries; + protected JarFile jf; + protected JarEntry nextEntry; + protected ClassFile cf; + JarFileIterator(JarFileReader reader) { + this(reader, null); + } + JarFileIterator(JarFileReader reader, JarFile jarfile) { + this.reader = reader; + setJarFile(jarfile); + } + + void setJarFile(JarFile jarfile) { + if (jarfile == null) return; + + this.jf = jarfile; + this.entries = jf.entries(); + this.nextEntry = nextEntry(); + } + + public boolean hasNext() { + if (nextEntry != null && cf != null) { + return true; } - - public boolean hasNext() { - return nextEntry != null; - } - - public ClassFile next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - - ClassFile cf; + while (nextEntry != null) { try { - cf = readClassFile(nextEntry); - } catch (IOException ex) { - throw new ClassFileError(ex); + cf = reader.readClassFile(jf, nextEntry); + return true; + } catch (ClassFileError | IOException ex) { + skippedEntries.add(nextEntry.getName()); } - JarEntry entry = nextEntry; - nextEntry = null; - while (entries.hasMoreElements()) { - JarEntry e = entries.nextElement(); - String name = e.getName(); - if (name.endsWith(".class")) { - nextEntry = e; - break; - } - } - return cf; + nextEntry = nextEntry(); } + return false; + } - public void remove() { - throw new UnsupportedOperationException("Not supported yet."); + public ClassFile next() { + if (!hasNext()) { + throw new NoSuchElementException(); } + ClassFile classFile = cf; + cf = null; + nextEntry = nextEntry(); + return classFile; + } + + protected JarEntry nextEntry() { + while (entries.hasMoreElements()) { + JarEntry e = entries.nextElement(); + String name = e.getName(); + if (name.endsWith(".class")) { + return e; + } + } + return null; + } + + public void remove() { + throw new UnsupportedOperationException("Not supported yet."); } } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java index 63ebc5f271b..091703d2a23 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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,7 +30,9 @@ import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Dependencies; import com.sun.tools.classfile.Dependencies.ClassFileError; import com.sun.tools.classfile.Dependency; +import com.sun.tools.classfile.Dependency.Location; import com.sun.tools.jdeps.PlatformClassPath.JDKArchive; +import static com.sun.tools.jdeps.Analyzer.Type.*; import java.io.*; import java.nio.file.DirectoryStream; import java.nio.file.Files; @@ -110,7 +112,7 @@ class JdepsTask { void process(JdepsTask task, String opt, String arg) throws BadArgs { Path p = Paths.get(arg); if (Files.exists(p) && (!Files.isDirectory(p) || !Files.isWritable(p))) { - throw new BadArgs("err.dot.output.path", arg); + throw new BadArgs("err.invalid.path", arg); } task.options.dotOutputDir = arg; } @@ -118,25 +120,26 @@ class JdepsTask { new Option(false, "-s", "-summary") { void process(JdepsTask task, String opt, String arg) { task.options.showSummary = true; - task.options.verbose = Analyzer.Type.SUMMARY; + task.options.verbose = SUMMARY; } }, new Option(false, "-v", "-verbose", "-verbose:package", - "-verbose:class") - { + "-verbose:class") { void process(JdepsTask task, String opt, String arg) throws BadArgs { switch (opt) { case "-v": case "-verbose": - task.options.verbose = Analyzer.Type.VERBOSE; + task.options.verbose = VERBOSE; + task.options.filterSameArchive = false; + task.options.filterSamePackage = false; break; case "-verbose:package": - task.options.verbose = Analyzer.Type.PACKAGE; - break; + task.options.verbose = PACKAGE; + break; case "-verbose:class": - task.options.verbose = Analyzer.Type.CLASS; - break; + task.options.verbose = CLASS; + break; default: throw new BadArgs("err.invalid.arg.for.option", opt); } @@ -157,6 +160,32 @@ class JdepsTask { task.options.regex = arg; } }, + + new Option(true, "-f", "-filter") { + void process(JdepsTask task, String opt, String arg) { + task.options.filterRegex = arg; + } + }, + new Option(false, "-filter:package", + "-filter:archive", + "-filter:none") { + void process(JdepsTask task, String opt, String arg) { + switch (opt) { + case "-filter:package": + task.options.filterSamePackage = true; + task.options.filterSameArchive = false; + break; + case "-filter:archive": + task.options.filterSameArchive = true; + task.options.filterSamePackage = false; + break; + case "-filter:none": + task.options.filterSameArchive = false; + task.options.filterSamePackage = false; + break; + } + } + }, new Option(true, "-include") { void process(JdepsTask task, String opt, String arg) throws BadArgs { task.options.includePattern = Pattern.compile(arg); @@ -178,12 +207,15 @@ class JdepsTask { new Option(false, "-R", "-recursive") { void process(JdepsTask task, String opt, String arg) { task.options.depth = 0; + // turn off filtering + task.options.filterSameArchive = false; + task.options.filterSamePackage = false; } }, new Option(false, "-jdkinternals") { void process(JdepsTask task, String opt, String arg) { task.options.findJDKInternals = true; - task.options.verbose = Analyzer.Type.CLASS; + task.options.verbose = CLASS; if (task.options.includePattern == null) { task.options.includePattern = Pattern.compile(".*"); } @@ -262,7 +294,7 @@ class JdepsTask { showHelp(); return EXIT_CMDERR; } - if (options.showSummary && options.verbose != Analyzer.Type.SUMMARY) { + if (options.showSummary && options.verbose != SUMMARY) { showHelp(); return EXIT_CMDERR; } @@ -283,9 +315,28 @@ class JdepsTask { private final List sourceLocations = new ArrayList<>(); private boolean run() throws IOException { + // parse classfiles and find all dependencies findDependencies(); - Analyzer analyzer = new Analyzer(options.verbose); + + Analyzer analyzer = new Analyzer(options.verbose, new Analyzer.Filter() { + @Override + public boolean accepts(Location origin, Archive originArchive, Location target, Archive targetArchive) { + if (options.findJDKInternals) { + // accepts target that is JDK class but not exported + return isJDKArchive(targetArchive) && + !((JDKArchive) targetArchive).isExported(target.getClassName()); + } else if (options.filterSameArchive) { + // accepts origin and target that from different archive + return originArchive != targetArchive; + } + return true; + } + }); + + // analyze the dependencies analyzer.run(sourceLocations); + + // output result if (options.dotOutputDir != null) { Path dir = Paths.get(options.dotOutputDir); Files.createDirectories(dir); @@ -296,27 +347,34 @@ class JdepsTask { return true; } - private void generateDotFiles(Path dir, Analyzer analyzer) throws IOException { + private void generateSummaryDotFile(Path dir, Analyzer analyzer) throws IOException { + // If verbose mode (-v or -verbose option), + // the summary.dot file shows package-level dependencies. + Analyzer.Type summaryType = + (options.verbose == PACKAGE || options.verbose == SUMMARY) ? SUMMARY : PACKAGE; Path summary = dir.resolve("summary.dot"); - boolean verbose = options.verbose == Analyzer.Type.VERBOSE; - DotGraph graph = verbose ? new DotSummaryForPackage() - : new DotSummaryForArchive(); - for (Archive archive : sourceLocations) { - analyzer.visitArchiveDependences(archive, graph); - if (verbose || options.showLabel) { - // traverse detailed dependences to generate package-level - // summary or build labels for edges - analyzer.visitDependences(archive, graph); + try (PrintWriter sw = new PrintWriter(Files.newOutputStream(summary)); + SummaryDotFile dotfile = new SummaryDotFile(sw, summaryType)) { + for (Archive archive : sourceLocations) { + if (!archive.isEmpty()) { + if (options.verbose == PACKAGE || options.verbose == SUMMARY) { + if (options.showLabel) { + // build labels listing package-level dependencies + analyzer.visitDependences(archive, dotfile.labelBuilder(), PACKAGE); + } + } + analyzer.visitDependences(archive, dotfile, summaryType); + } } } - try (PrintWriter sw = new PrintWriter(Files.newOutputStream(summary))) { - graph.writeTo(sw); - } + } + + private void generateDotFiles(Path dir, Analyzer analyzer) throws IOException { // output individual .dot file for each archive - if (options.verbose != Analyzer.Type.SUMMARY) { + if (options.verbose != SUMMARY) { for (Archive archive : sourceLocations) { if (analyzer.hasDependences(archive)) { - Path dotfile = dir.resolve(archive.getFileName() + ".dot"); + Path dotfile = dir.resolve(archive.getName() + ".dot"); try (PrintWriter pw = new PrintWriter(Files.newOutputStream(dotfile)); DotFileFormatter formatter = new DotFileFormatter(pw, archive)) { analyzer.visitDependences(archive, formatter); @@ -324,17 +382,23 @@ class JdepsTask { } } } + // generate summary dot file + generateSummaryDotFile(dir, analyzer); } private void printRawOutput(PrintWriter writer, Analyzer analyzer) { + RawOutputFormatter depFormatter = new RawOutputFormatter(writer); + RawSummaryFormatter summaryFormatter = new RawSummaryFormatter(writer); for (Archive archive : sourceLocations) { - RawOutputFormatter formatter = new RawOutputFormatter(writer); - analyzer.visitArchiveDependences(archive, formatter); - if (options.verbose != Analyzer.Type.SUMMARY) { - analyzer.visitDependences(archive, formatter); + if (!archive.isEmpty()) { + analyzer.visitDependences(archive, summaryFormatter, SUMMARY); + if (analyzer.hasDependences(archive) && options.verbose != SUMMARY) { + analyzer.visitDependences(archive, depFormatter); + } } } } + private boolean isValidClassName(String name) { if (!Character.isJavaIdentifierStart(name.charAt(0))) { return false; @@ -348,21 +412,54 @@ class JdepsTask { return true; } - private Dependency.Filter getDependencyFilter() { - if (options.regex != null) { - return Dependencies.getRegexFilter(Pattern.compile(options.regex)); - } else if (options.packageNames.size() > 0) { - return Dependencies.getPackageFilter(options.packageNames, false); - } else { - return new Dependency.Filter() { - @Override - public boolean accepts(Dependency dependency) { - return !dependency.getOrigin().equals(dependency.getTarget()); - } - }; + /* + * Dep Filter configured based on the input jdeps option + * 1. -p and -regex to match target dependencies + * 2. -filter:package to filter out same-package dependencies + * + * This filter is applied when jdeps parses the class files + * and filtered dependencies are not stored in the Analyzer. + * + * -filter:archive is applied later in the Analyzer as the + * containing archive of a target class may not be known until + * the entire archive + */ + class DependencyFilter implements Dependency.Filter { + final Dependency.Filter filter; + final Pattern filterPattern; + DependencyFilter() { + if (options.regex != null) { + this.filter = Dependencies.getRegexFilter(Pattern.compile(options.regex)); + } else if (options.packageNames.size() > 0) { + this.filter = Dependencies.getPackageFilter(options.packageNames, false); + } else { + this.filter = null; + } + + this.filterPattern = + options.filterRegex != null ? Pattern.compile(options.filterRegex) : null; + } + @Override + public boolean accepts(Dependency d) { + if (d.getOrigin().equals(d.getTarget())) { + return false; + } + String pn = d.getTarget().getPackageName(); + if (options.filterSamePackage && d.getOrigin().getPackageName().equals(pn)) { + return false; + } + + if (filterPattern != null && filterPattern.matcher(pn).matches()) { + return false; + } + return filter != null ? filter.accepts(d) : true; } } + /** + * Tests if the given class matches the pattern given in the -include option + * or if it's a public class if -apionly option is specified + */ private boolean matches(String classname, AccessFlags flags) { if (options.apiOnly && !flags.is(AccessFlags.ACC_PUBLIC)) { return false; @@ -377,14 +474,14 @@ class JdepsTask { Dependency.Finder finder = options.apiOnly ? Dependencies.getAPIFinder(AccessFlags.ACC_PROTECTED) : Dependencies.getClassDependencyFinder(); - Dependency.Filter filter = getDependencyFilter(); + Dependency.Filter filter = new DependencyFilter(); List archives = new ArrayList<>(); Deque roots = new LinkedList<>(); for (String s : classes) { Path p = Paths.get(s); if (Files.exists(p)) { - archives.add(new Archive(p, ClassFileReader.newInstance(p))); + archives.add(Archive.getInstance(p)); } else { if (isValidClassName(s)) { roots.add(s); @@ -421,20 +518,27 @@ class JdepsTask { throw new ClassFileError(e); } - if (matches(classFileName, cf.access_flags)) { - if (!doneClasses.contains(classFileName)) { - doneClasses.add(classFileName); - } - for (Dependency d : finder.findDependencies(cf)) { - if (filter.accepts(d)) { - String cn = d.getTarget().getName(); - if (!doneClasses.contains(cn) && !deque.contains(cn)) { - deque.add(cn); - } - a.addClass(d.getOrigin(), d.getTarget()); + // tests if this class matches the -include or -apiOnly option if specified + if (!matches(classFileName, cf.access_flags)) { + continue; + } + + if (!doneClasses.contains(classFileName)) { + doneClasses.add(classFileName); + } + + for (Dependency d : finder.findDependencies(cf)) { + if (filter.accepts(d)) { + String cn = d.getTarget().getName(); + if (!doneClasses.contains(cn) && !deque.contains(cn)) { + deque.add(cn); } + a.addClass(d.getOrigin(), d.getTarget()); } } + for (String name : a.reader().skippedEntries()) { + warning("warn.skipped.entry", name, a.getPathName()); + } } } @@ -462,6 +566,10 @@ class JdepsTask { // if name is a fully-qualified class name specified // from command-line, this class might already be parsed doneClasses.add(classFileName); + // process @jdk.Exported for JDK classes + if (isJDKArchive(a)) { + ((JDKArchive)a).processJdkExported(cf); + } for (Dependency d : finder.findDependencies(cf)) { if (depth == 0) { // ignore the dependency @@ -544,7 +652,7 @@ class JdepsTask { for (Option o : recognizedOptions) { String name = o.aliases[0].substring(1); // there must always be at least one name name = name.charAt(0) == '-' ? name.substring(1) : name; - if (o.isHidden() || name.equals("h")) { + if (o.isHidden() || name.equals("h") || name.startsWith("filter:")) { continue; } log.println(getMessage("main.opt." + name)); @@ -582,14 +690,18 @@ class JdepsTask { boolean fullVersion; boolean showProfile; boolean showSummary; - boolean wildcard; boolean apiOnly; boolean showLabel; boolean findJDKInternals; + // default is to show package-level dependencies + // and filter references from same package + Analyzer.Type verbose = PACKAGE; + boolean filterSamePackage = true; + boolean filterSameArchive = false; + String filterRegex; String dotOutputDir; String classpath = ""; int depth = 1; - Analyzer.Type verbose = Analyzer.Type.PACKAGE; Set packageNames = new HashSet<>(); String regex; // apply to the dependences Pattern includePattern; // apply to classes @@ -613,19 +725,6 @@ class JdepsTask { } } - private List getArchives(List filenames) throws IOException { - List result = new ArrayList<>(); - for (String s : filenames) { - Path p = Paths.get(s); - if (Files.exists(p)) { - result.add(new Archive(p, ClassFileReader.newInstance(p))); - } else { - warning("warn.file.not.exist", s); - } - } - return result; - } - private List getClassPathArchives(String paths) throws IOException { List result = new ArrayList<>(); if (paths.isEmpty()) { @@ -648,7 +747,7 @@ class JdepsTask { } for (Path f : files) { if (Files.exists(f)) { - result.add(new Archive(f, ClassFileReader.newInstance(f))); + result.add(Archive.getInstance(f)); } } } @@ -656,81 +755,50 @@ class JdepsTask { return result; } - /** - * If the given archive is JDK archive and non-null Profile, - * this method returns the profile name only if -profile option is specified; - * a null profile indicates it accesses a private JDK API and this method - * will return "JDK internal API". - * - * For non-JDK archives, this method returns the file name of the archive. - */ - private String getProfileArchiveInfo(Archive source, Profile profile) { - if (options.showProfile && profile != null) - return profile.toString(); - - if (source instanceof JDKArchive) { - return profile == null ? "JDK internal API (" + source.getFileName() + ")" : ""; - } - return source.getFileName(); - } - - /** - * Returns the profile name or "JDK internal API" for JDK archive; - * otherwise empty string. - */ - private String profileName(Archive archive, Profile profile) { - if (archive instanceof JDKArchive) { - return Objects.toString(profile, "JDK internal API"); - } else { - return ""; - } - } - class RawOutputFormatter implements Analyzer.Visitor { private final PrintWriter writer; + private String pkg = ""; RawOutputFormatter(PrintWriter writer) { this.writer = writer; } - - private String pkg = ""; @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - if (options.findJDKInternals && - !(archive instanceof JDKArchive && profile == null)) { - // filter dependences other than JDK internal APIs - return; - } - if (options.verbose == Analyzer.Type.VERBOSE) { - writer.format(" %-50s -> %-50s %s%n", - origin, target, getProfileArchiveInfo(archive, profile)); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + String tag = toTag(target, targetArchive); + if (options.verbose == VERBOSE) { + writer.format(" %-50s -> %-50s %s%n", origin, target, tag); } else { if (!origin.equals(pkg)) { pkg = origin; - writer.format(" %s (%s)%n", origin, source.getFileName()); + writer.format(" %s (%s)%n", origin, originArchive.getName()); } - writer.format(" -> %-50s %s%n", - target, getProfileArchiveInfo(archive, profile)); - } - } - - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - writer.format("%s -> %s", origin.getPathName(), target.getPathName()); - if (options.showProfile && profile != null) { - writer.format(" (%s)%n", profile); - } else { - writer.format("%n"); + writer.format(" -> %-50s %s%n", target, tag); } } } - class DotFileFormatter extends DotGraph implements AutoCloseable { + class RawSummaryFormatter implements Analyzer.Visitor { + private final PrintWriter writer; + RawSummaryFormatter(PrintWriter writer) { + this.writer = writer; + } + @Override + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + writer.format("%s -> %s", originArchive.getName(), targetArchive.getPathName()); + if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) { + writer.format(" (%s)", target); + } + writer.format("%n"); + } + } + + class DotFileFormatter implements Analyzer.Visitor, AutoCloseable { private final PrintWriter writer; private final String name; DotFileFormatter(PrintWriter writer, Archive archive) { this.writer = writer; - this.name = archive.getFileName(); + this.name = archive.getName(); writer.format("digraph \"%s\" {%n", name); writer.format(" // Path: %s%n", archive.getPathName()); } @@ -741,173 +809,123 @@ class JdepsTask { } @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - if (options.findJDKInternals && - !(archive instanceof JDKArchive && profile == null)) { - // filter dependences other than JDK internal APIs - return; - } - // if -P option is specified, package name -> profile will - // be shown and filter out multiple same edges. - String name = getProfileArchiveInfo(archive, profile); - writeEdge(writer, new Edge(origin, target, getProfileArchiveInfo(archive, profile))); - } - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - throw new UnsupportedOperationException(); + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + String tag = toTag(target, targetArchive); + writer.format(" %-50s -> \"%s\";%n", + String.format("\"%s\"", origin), + tag.isEmpty() ? target + : String.format("%s (%s)", target, tag)); } } - class DotSummaryForArchive extends DotGraph { - @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - Edge e = findEdge(source, archive); - assert e != null; - // add the dependency to the label if enabled and not compact1 - if (profile == Profile.COMPACT1) { - return; - } - e.addLabel(origin, target, profileName(archive, profile)); - } - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - // add an edge with the archive's name with no tag - // so that there is only one node for each JDK archive - // while there may be edges to different profiles - Edge e = addEdge(origin, target, ""); - if (target instanceof JDKArchive) { - // add a label to print the profile - if (profile == null) { - e.addLabel("JDK internal API"); - } else if (options.showProfile && !options.showLabel) { - e.addLabel(profile.toString()); - } - } - } - } - - // DotSummaryForPackage generates the summary.dot file for verbose mode - // (-v or -verbose option) that includes all class dependencies. - // The summary.dot file shows package-level dependencies. - class DotSummaryForPackage extends DotGraph { - private String packageOf(String cn) { - int i = cn.lastIndexOf('.'); - return i > 0 ? cn.substring(0, i) : ""; - } - @Override - public void visitDependence(String origin, Archive source, - String target, Archive archive, Profile profile) { - // add a package dependency edge - String from = packageOf(origin); - String to = packageOf(target); - Edge e = addEdge(from, to, getProfileArchiveInfo(archive, profile)); - - // add the dependency to the label if enabled and not compact1 - if (!options.showLabel || profile == Profile.COMPACT1) { - return; - } - - // trim the package name of origin to shorten the label - int i = origin.lastIndexOf('.'); - String n1 = i < 0 ? origin : origin.substring(i+1); - e.addLabel(n1, target, profileName(archive, profile)); - } - @Override - public void visitArchiveDependence(Archive origin, Archive target, Profile profile) { - // nop - } - } - abstract class DotGraph implements Analyzer.Visitor { - private final Set edges = new LinkedHashSet<>(); - private Edge curEdge; - public void writeTo(PrintWriter writer) { + class SummaryDotFile implements Analyzer.Visitor, AutoCloseable { + private final PrintWriter writer; + private final Analyzer.Type type; + private final Map> edges = new HashMap<>(); + SummaryDotFile(PrintWriter writer, Analyzer.Type type) { + this.writer = writer; + this.type = type; writer.format("digraph \"summary\" {%n"); - for (Edge e: edges) { - writeEdge(writer, e); - } + } + + @Override + public void close() { writer.println("}"); } - void writeEdge(PrintWriter writer, Edge e) { - writer.format(" %-50s -> \"%s\"%s;%n", - String.format("\"%s\"", e.from.toString()), - e.tag.isEmpty() ? e.to - : String.format("%s (%s)", e.to, e.tag), - getLabel(e)); + @Override + public void visitDependence(String origin, Archive originArchive, + String target, Archive targetArchive) { + String targetName = type == PACKAGE ? target : targetArchive.getName(); + if (type == PACKAGE) { + String tag = toTag(target, targetArchive, type); + if (!tag.isEmpty()) + targetName += " (" + tag + ")"; + } else if (options.showProfile && JDKArchive.isProfileArchive(targetArchive)) { + targetName += " (" + target + ")"; + } + String label = getLabel(originArchive, targetArchive); + writer.format(" %-50s -> \"%s\"%s;%n", + String.format("\"%s\"", origin), targetName, label); } - Edge addEdge(T origin, T target, String tag) { - Edge e = new Edge(origin, target, tag); - if (e.equals(curEdge)) { - return curEdge; - } + String getLabel(Archive origin, Archive target) { + if (edges.isEmpty()) + return ""; - if (edges.contains(e)) { - for (Edge e1 : edges) { - if (e.equals(e1)) { - curEdge = e1; - } - } - } else { - edges.add(e); - curEdge = e; - } - return curEdge; + StringBuilder label = edges.get(origin).get(target); + return label == null ? "" : String.format(" [label=\"%s\",fontsize=9]", label.toString()); } - Edge findEdge(T origin, T target) { - for (Edge e : edges) { - if (e.from.equals(origin) && e.to.equals(target)) { - return e; + Analyzer.Visitor labelBuilder() { + // show the package-level dependencies as labels in the dot graph + return new Analyzer.Visitor() { + @Override + public void visitDependence(String origin, Archive originArchive, String target, Archive targetArchive) { + edges.putIfAbsent(originArchive, new HashMap<>()); + edges.get(originArchive).putIfAbsent(targetArchive, new StringBuilder()); + StringBuilder sb = edges.get(originArchive).get(targetArchive); + String tag = toTag(target, targetArchive, PACKAGE); + addLabel(sb, origin, target, tag); } - } - return null; - } - String getLabel(Edge e) { - String label = e.label.toString(); - return label.isEmpty() ? "" : String.format("[label=\"%s\",fontsize=9]", label); - } - - class Edge { - final T from; - final T to; - final String tag; // optional tag - final StringBuilder label = new StringBuilder(); - Edge(T from, T to, String tag) { - this.from = from; - this.to = to; - this.tag = tag; - } - void addLabel(String s) { - label.append(s).append("\\n"); - } - void addLabel(String origin, String target, String profile) { - label.append(origin).append(" -> ").append(target); - if (!profile.isEmpty()) { - label.append(" (" + profile + ")"); + void addLabel(StringBuilder label, String origin, String target, String tag) { + label.append(origin).append(" -> ").append(target); + if (!tag.isEmpty()) { + label.append(" (" + tag + ")"); + } + label.append("\\n"); } - label.append("\\n"); - } - @Override @SuppressWarnings("unchecked") - public boolean equals(Object o) { - if (o instanceof DotGraph.Edge) { - DotGraph.Edge e = (DotGraph.Edge)o; - return this.from.equals(e.from) && - this.to.equals(e.to) && - this.tag.equals(e.tag); - } - return false; - } - @Override - public int hashCode() { - int hash = 7; - hash = 67 * hash + Objects.hashCode(this.from) + - Objects.hashCode(this.to) + Objects.hashCode(this.tag); - return hash; - } + }; } } + + /** + * Test if the given archive is part of the JDK + */ + private boolean isJDKArchive(Archive archive) { + return JDKArchive.class.isInstance(archive); + } + + /** + * If the given archive is JDK archive, this method returns the profile name + * only if -profile option is specified; it accesses a private JDK API and + * the returned value will have "JDK internal API" prefix + * + * For non-JDK archives, this method returns the file name of the archive. + */ + private String toTag(String name, Archive source, Analyzer.Type type) { + if (!isJDKArchive(source)) { + return source.getName(); + } + + JDKArchive jdk = (JDKArchive)source; + boolean isExported = false; + if (type == CLASS || type == VERBOSE) { + isExported = jdk.isExported(name); + } else { + isExported = jdk.isExportedPackage(name); + } + Profile p = getProfile(name, type); + if (isExported) { + // exported API + return options.showProfile && p != null ? p.profileName() : ""; + } else { + return "JDK internal API (" + source.getName() + ")"; + } + } + + private String toTag(String name, Archive source) { + return toTag(name, source, options.verbose); + } + + private Profile getProfile(String name, Analyzer.Type type) { + String pn = name; + if (type == CLASS || type == VERBOSE) { + int i = name.lastIndexOf('.'); + pn = i > 0 ? name.substring(0, i) : ""; + } + return Profile.getProfile(pn); + } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Main.java b/langtools/src/share/classes/com/sun/tools/jdeps/Main.java index 863815ff24a..a693062206a 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/Main.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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,4 +63,3 @@ public class Main { return t.run(args); } } - diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java b/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java index 3c1950a7bb9..55b9e8ab393 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/PlatformClassPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -24,6 +24,12 @@ */ package com.sun.tools.jdeps; +import com.sun.tools.classfile.Annotation; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPool; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.RuntimeAnnotations_attribute; +import com.sun.tools.classfile.Dependencies.ClassFileError; import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.Files; @@ -33,11 +39,15 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.*; +import static com.sun.tools.classfile.Attribute.*; + /** * ClassPath for Java SE and JDK */ class PlatformClassPath { - private final static List javaHomeArchives = init(); + private static final List NON_PLATFORM_JARFILES = + Arrays.asList("alt-rt.jar", "jfxrt.jar", "ant-javafx.jar", "javafx-mx.jar"); + private static final List javaHomeArchives = init(); static List getArchives() { return javaHomeArchives; @@ -50,12 +60,19 @@ class PlatformClassPath { if (home.endsWith("jre")) { // jar files in /jre/lib result.addAll(addJarFiles(home.resolve("lib"))); + if (home.getParent() != null) { + // add tools.jar and other JDK jar files + Path lib = home.getParent().resolve("lib"); + if (Files.exists(lib)) { + result.addAll(addJarFiles(lib)); + } + } } else if (Files.exists(home.resolve("lib"))) { // either a JRE or a jdk build image Path classes = home.resolve("classes"); if (Files.isDirectory(classes)) { // jdk build outputdir - result.add(new JDKArchive(classes, ClassFileReader.newInstance(classes))); + result.add(new JDKArchive(classes)); } // add other JAR files result.addAll(addJarFiles(home.resolve("lib"))); @@ -91,9 +108,9 @@ class PlatformClassPath { if (fn.endsWith(".jar")) { // JDK may cobundle with JavaFX that doesn't belong to any profile // Treat jfxrt.jar as regular Archive - result.add(fn.equals("jfxrt.jar") - ? new Archive(p, ClassFileReader.newInstance(p)) - : new JDKArchive(p, ClassFileReader.newInstance(p))); + result.add(NON_PLATFORM_JARFILES.contains(fn) + ? Archive.getInstance(p) + : new JDKArchive(p)); } return FileVisitResult.CONTINUE; } @@ -106,8 +123,91 @@ class PlatformClassPath { * or implementation classes (i.e. JDK internal API) */ static class JDKArchive extends Archive { - JDKArchive(Path p, ClassFileReader reader) { - super(p, reader); + private static List PROFILE_JARS = Arrays.asList("rt.jar", "jce.jar"); + public static boolean isProfileArchive(Archive archive) { + if (archive instanceof JDKArchive) { + return PROFILE_JARS.contains(archive.getName()); + } + return false; + } + + private final Map exportedPackages = new HashMap<>(); + private final Map exportedTypes = new HashMap<>(); + JDKArchive(Path p) throws IOException { + super(p, ClassFileReader.newInstance(p)); + } + + /** + * Tests if a given fully-qualified name is an exported type. + */ + public boolean isExported(String cn) { + int i = cn.lastIndexOf('.'); + String pn = i > 0 ? cn.substring(0, i) : ""; + + boolean isJdkExported = isExportedPackage(pn); + if (exportedTypes.containsKey(cn)) { + return exportedTypes.get(cn); + } + return isJdkExported; + } + + /** + * Tests if a given package name is exported. + */ + public boolean isExportedPackage(String pn) { + if (Profile.getProfile(pn) != null) { + return true; + } + return exportedPackages.containsKey(pn) ? exportedPackages.get(pn) : false; + } + + private static final String JDK_EXPORTED_ANNOTATION = "Ljdk/Exported;"; + private Boolean isJdkExported(ClassFile cf) throws ConstantPoolException { + RuntimeAnnotations_attribute attr = (RuntimeAnnotations_attribute) + cf.attributes.get(RuntimeVisibleAnnotations); + if (attr != null) { + for (int i = 0; i < attr.annotations.length; i++) { + Annotation ann = attr.annotations[i]; + String annType = cf.constant_pool.getUTF8Value(ann.type_index); + if (JDK_EXPORTED_ANNOTATION.equals(annType)) { + boolean isJdkExported = true; + for (int j = 0; j < ann.num_element_value_pairs; j++) { + Annotation.element_value_pair pair = ann.element_value_pairs[j]; + Annotation.Primitive_element_value ev = (Annotation.Primitive_element_value) pair.value; + ConstantPool.CONSTANT_Integer_info info = (ConstantPool.CONSTANT_Integer_info) + cf.constant_pool.get(ev.const_value_index); + isJdkExported = info.value != 0; + } + return Boolean.valueOf(isJdkExported); + } + } + } + return null; + } + + void processJdkExported(ClassFile cf) throws IOException { + try { + String cn = cf.getName(); + String pn = cn.substring(0, cn.lastIndexOf('/')).replace('/', '.'); + + Boolean b = isJdkExported(cf); + if (b != null) { + exportedTypes.put(cn.replace('/', '.'), b); + } + if (!exportedPackages.containsKey(pn)) { + // check if package-info.class has @jdk.Exported + Boolean isJdkExported = null; + ClassFile pcf = reader().getClassFile(cn.substring(0, cn.lastIndexOf('/')+1) + "package-info"); + if (pcf != null) { + isJdkExported = isJdkExported(pcf); + } + if (isJdkExported != null) { + exportedPackages.put(pn, isJdkExported); + } + } + } catch (ConstantPoolException e) { + throw new ClassFileError(e); + } } } } diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/Profile.java b/langtools/src/share/classes/com/sun/tools/jdeps/Profile.java index 4d358553afe..d78b5c45e1b 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/Profile.java +++ b/langtools/src/share/classes/com/sun/tools/jdeps/Profile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -43,7 +43,6 @@ import java.util.jar.JarFile; * Build the profile information from ct.sym if exists. */ enum Profile { - COMPACT1("compact1", 1), COMPACT2("compact2", 2), COMPACT3("compact3", 3), @@ -61,8 +60,7 @@ enum Profile { this.proprietaryPkgs = new HashSet<>(); } - @Override - public String toString() { + public String profileName() { return name; } @@ -77,7 +75,7 @@ enum Profile { public static Profile getProfile(String pn) { Profile profile = PackageToProfile.map.get(pn); return (profile != null && profile.packages.contains(pn)) - ? profile : null; + ? profile : null; } static class PackageToProfile { diff --git a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties index ca7493e7928..7cc433e1f0e 100644 --- a/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties +++ b/langtools/src/share/classes/com/sun/tools/jdeps/resources/jdeps.properties @@ -1,6 +1,6 @@ main.usage.summary=\ Usage: {0} \n\ -use -h, -? or --help for a list of possible options +use -h, -? or -help for a list of possible options main.usage=\ Usage: {0} \n\ @@ -18,20 +18,29 @@ main.opt.version=\ main.opt.v=\ \ -v -verbose Print all class level dependencies\n\ +\ Equivalent to -verbose:class -filter:none.\n\ \ -verbose:package Print package-level dependencies excluding\n\ -\ dependencies within the same archive\n\ +\ dependencies within the same package by default\n\ \ -verbose:class Print class-level dependencies excluding\n\ -\ dependencies within the same archive +\ dependencies within the same package by default + +main.opt.f=\ +\ -f -filter Filter dependences matching the given pattern\n\ +\ If given multiple times, the last one will be used.\n\ +\ -filter:package Filter dependences within the same package (default)\n\ +\ -filter:archive Filter dependences within the same archive\n\ +\ -filter:none No -filter:package and -filter:archive filtering\n\ +\ Filtering specified via the -filter option still applies. main.opt.s=\ \ -s -summary Print dependency summary only main.opt.p=\ -\ -p -package Finds dependences in the given package\n\ +\ -p -package Finds dependences matching the given package name\n\ \ (may be given multiple times) main.opt.e=\ -\ -e -regex Finds dependences in packages matching pattern\n\ +\ -e -regex Finds dependences matching the given pattern\n\ \ (-p and -e are exclusive) main.opt.include=\ @@ -47,7 +56,10 @@ main.opt.cp=\ \ -cp -classpath Specify where to find class files main.opt.R=\ -\ -R -recursive Recursively traverse all dependencies +\ -R -recursive Recursively traverse all dependencies.\n\ +\ The -R option implies -filter:none. If -p, -e, -f\n\ +\ option is specified, only the matching dependences\n\ +\ are analyzed. main.opt.apionly=\ \ -apionly Restrict analysis to APIs i.e. dependences\n\ @@ -74,12 +86,11 @@ main.opt.depth=\ err.unknown.option=unknown option: {0} err.missing.arg=no value given for {0} -err.internal.error=internal error: {0} {1} {2} err.invalid.arg.for.option=invalid argument for option: {0} err.option.after.class=option must be specified before classes: {0} err.option.unsupported={0} not supported: {1} err.profiles.msg=No profile information -err.dot.output.path=invalid path: {0} +err.invalid.path=invalid path: {0} warn.invalid.arg=Invalid classname or pathname not exist: {0} warn.split.package=package {0} defined in {1} {2} diff --git a/langtools/test/tools/jdeps/APIDeps.java b/langtools/test/tools/jdeps/APIDeps.java index 0e0e59d50b9..bf01a77ba8c 100644 --- a/langtools/test/tools/jdeps/APIDeps.java +++ b/langtools/test/tools/jdeps/APIDeps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8015912 8029216 + * @bug 8015912 8029216 8048063 * @summary Test -apionly and -jdkinternals options * @build m.Bar m.Foo m.Gee b.B c.C c.I d.D e.E f.F g.G * @run main APIDeps @@ -80,28 +80,40 @@ public class APIDeps { "b.B", "c.C", "d.D", "f.F", "g.G"}, new String[] {"compact1", "compact3", testDirBasename}, new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); + test(new File(mDir, "Foo.class"), + new String[] {"c.I", "e.E", "f.F"}, + new String[] {testDirBasename}, + new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P"}); test(new File(mDir, "Foo.class"), new String[] {"c.I", "e.E", "f.F", "m.Bar"}, new String[] {testDirBasename}, - new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); + new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-filter:none", "-P"}); test(new File(mDir, "Gee.class"), - new String[] {"g.G", "sun.misc.Lock"}, - new String[] {testDirBasename, "JDK internal API"}, - new String[] {"-classpath", testDir.getPath(), "-verbose"}); + new String[] {"g.G", "sun.misc.Lock", "com.sun.tools.classfile.ClassFile", + "com.sun.management.ThreadMXBean", "com.sun.source.tree.BinaryTree"}, + new String[] {testDirBasename, "JDK internal API", "compact3", ""}, + new String[] {"-classpath", testDir.getPath(), "-verbose", "-P"}); // -jdkinternals test(new File(mDir, "Gee.class"), - new String[] {"sun.misc.Lock"}, + new String[] {"sun.misc.Lock", "com.sun.tools.classfile.ClassFile"}, new String[] {"JDK internal API"}, new String[] {"-jdkinternals"}); // -jdkinternals parses all classes on -classpath and the input arguments test(new File(mDir, "Gee.class"), - new String[] {"sun.misc.Lock", "sun.misc.Unsafe"}, + new String[] {"com.sun.tools.jdeps.Main", "com.sun.tools.classfile.ClassFile", + "sun.misc.Lock", "sun.misc.Unsafe"}, new String[] {"JDK internal API"}, new String[] {"-classpath", testDir.getPath(), "-jdkinternals"}); // parse only APIs - // parse only APIs + test(mDir, + new String[] {"java.lang.Object", "java.lang.String", + "java.util.Set", + "c.C", "d.D", "c.I", "e.E"}, + new String[] {"compact1", testDirBasename}, + new String[] {"-classpath", testDir.getPath(), "-verbose:class", "-P", "-apionly"}); + test(mDir, new String[] {"java.lang.Object", "java.lang.String", "java.util.Set", diff --git a/langtools/test/tools/jdeps/Basic.java b/langtools/test/tools/jdeps/Basic.java index 34999aa04be..046a047fcc6 100644 --- a/langtools/test/tools/jdeps/Basic.java +++ b/langtools/test/tools/jdeps/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8003562 8005428 8015912 8027481 + * @bug 8003562 8005428 8015912 8027481 8048063 * @summary Basic tests for jdeps tool * @build Test p.Foo p.Bar javax.activity.NotCompactProfile * @run main Basic @@ -86,6 +86,16 @@ public class Basic { new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, new String[] {"compact1", "compact1", "not found", "not found"}, new String[] {"-verbose:class"}); + // test -filter:none option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto", "p"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1", "p"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:none"}); + // test -filter:archive option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:archive"}); // test -p option test(new File(testDir, "Test.class"), new String[] {"p.Foo", "p.Bar"}, @@ -100,11 +110,12 @@ public class Basic { new String[] {"java.lang"}, new String[] {"compact1"}, new String[] {"-verbose:package", "-e", "java\\.lang\\..*"}); + // test -classpath and -include options test(null, - new String[] {"java.lang", "java.util", - "java.lang.management", "javax.crypto"}, - new String[] {"compact1", "compact1", "compact3", "compact1"}, + new String[] {"java.lang", "java.util", "java.lang.management", + "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, new String[] {"-classpath", testDir.getPath(), "-include", "p.+|Test.class"}); test(new File(testDir, "Test.class"), new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, diff --git a/langtools/test/tools/jdeps/DotFileTest.java b/langtools/test/tools/jdeps/DotFileTest.java new file mode 100644 index 00000000000..63e283f43ea --- /dev/null +++ b/langtools/test/tools/jdeps/DotFileTest.java @@ -0,0 +1,272 @@ +/* + * 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 8003562 + * @summary Basic tests for jdeps -dotoutput option + * @build Test p.Foo p.Bar javax.activity.NotCompactProfile + * @run main DotFileTest + */ + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.*; +import java.util.regex.*; + +public class DotFileTest { + private static boolean symbolFileExist = initProfiles(); + private static boolean initProfiles() { + // check if ct.sym exists; if not use the profiles.properties file + Path home = Paths.get(System.getProperty("java.home")); + if (home.endsWith("jre")) { + home = home.getParent(); + } + Path ctsym = home.resolve("lib").resolve("ct.sym"); + boolean symbolExists = ctsym.toFile().exists(); + if (!symbolExists) { + Path testSrcProfiles = + Paths.get(System.getProperty("test.src", "."), "profiles.properties"); + if (!testSrcProfiles.toFile().exists()) + throw new Error(testSrcProfiles + " does not exist"); + System.out.format("%s doesn't exist.%nUse %s to initialize profiles info%n", + ctsym, testSrcProfiles); + System.setProperty("jdeps.profiles", testSrcProfiles.toString()); + } + return symbolExists; + } + + public static void main(String... args) throws Exception { + int errors = 0; + errors += new DotFileTest().run(); + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + final Path dir; + final Path dotoutput; + DotFileTest() { + this.dir = Paths.get(System.getProperty("test.classes", ".")); + this.dotoutput = dir.resolve("dots"); + } + + int run() throws IOException { + File testDir = dir.toFile(); + // test a .class file + test(new File(testDir, "Test.class"), + new String[] {"java.lang", "p"}, + new String[] {"compact1", "not found"}); + // test a directory + // also test non-SE javax.activity class dependency + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, + new String[] {"-classpath", testDir.getPath()}); + // test class-level dependency output + test(new File(testDir, "Test.class"), + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, + new String[] {"compact1", "compact1", "not found", "not found"}, + new String[] {"-verbose:class"}); + // test -filter:none option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto", "p"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1", "p"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:none"}); + // test -filter:archive option + test(new File(testDir, "p"), + new String[] {"java.lang", "java.util", "java.lang.management", "javax.activity", "javax.crypto"}, + new String[] {"compact1", "compact1", "compact3", testDir.getName(), "compact1"}, + new String[] {"-classpath", testDir.getPath(), "-verbose:package", "-filter:archive"}); + // test -p option + test(new File(testDir, "Test.class"), + new String[] {"p.Foo", "p.Bar"}, + new String[] {"not found", "not found"}, + new String[] {"-verbose:class", "-p", "p"}); + // test -e option + test(new File(testDir, "Test.class"), + new String[] {"p.Foo", "p.Bar"}, + new String[] {"not found", "not found"}, + new String[] {"-verbose:class", "-e", "p\\..*"}); + test(new File(testDir, "Test.class"), + new String[] {"java.lang"}, + new String[] {"compact1"}, + new String[] {"-verbose:package", "-e", "java\\.lang\\..*"}); + // test -classpath options + test(new File(testDir, "Test.class"), + new String[] {"java.lang.Object", "java.lang.String", "p.Foo", "p.Bar"}, + new String[] {"compact1", "compact1", testDir.getName(), testDir.getName()}, + new String[] {"-v", "-classpath", testDir.getPath()}); + + testSummary(new File(testDir, "Test.class"), + new String[] {"rt.jar", testDir.getName()}, + new String[] {"compact1", ""}, + new String[] {"-classpath", testDir.getPath()}); + testSummary(new File(testDir, "Test.class"), + new String[] {"java.lang", "p"}, + new String[] {"compact1", testDir.getName()}, + new String[] {"-v", "-classpath", testDir.getPath()}); + return errors; + } + + void test(File file, String[] expect, String[] profiles) throws IOException { + test(file, expect, profiles, new String[0]); + } + + void test(File file, String[] expect, String[] profiles, String[] options) + throws IOException + { + Path dotfile = dotoutput.resolve(file.toPath().getFileName().toString() + ".dot"); + + List args = new ArrayList<>(Arrays.asList(options)); + args.add("-dotoutput"); + args.add(dotoutput.toString()); + if (file != null) { + args.add(file.getPath()); + } + + Map result = jdeps(args, dotfile); + checkResult("dependencies", expect, result.keySet()); + + // with -P option + List argsWithDashP = new ArrayList<>(); + argsWithDashP.add("-dotoutput"); + argsWithDashP.add(dotoutput.toString()); + argsWithDashP.add("-P"); + argsWithDashP.addAll(args); + + result = jdeps(argsWithDashP, dotfile); + checkResult("profiles", expect, profiles, result); + } + + void testSummary(File file, String[] expect, String[] profiles, String[] options) + throws IOException + { + Path dotfile = dotoutput.resolve("summary.dot"); + + List args = new ArrayList<>(Arrays.asList(options)); + args.add("-dotoutput"); + args.add(dotoutput.toString()); + if (file != null) { + args.add(file.getPath()); + } + + Map result = jdeps(args, dotfile); + checkResult("dependencies", expect, result.keySet()); + + // with -P option + List argsWithDashP = new ArrayList<>(); + argsWithDashP.add("-dotoutput"); + argsWithDashP.add(dotoutput.toString()); + argsWithDashP.add("-P"); + argsWithDashP.addAll(args); + + result = jdeps(argsWithDashP, dotfile); + checkResult("profiles", expect, profiles, result); + } + + Map jdeps(List args, Path dotfile) throws IOException { + if (Files.exists(dotoutput)) { + try (DirectoryStream stream = Files.newDirectoryStream(dotoutput)) { + for (Path p : stream) { + Files.delete(p); + } + } + Files.delete(dotoutput); + } + // invoke jdeps + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + System.err.println("jdeps " + args); + int rc = com.sun.tools.jdeps.Main.run(args.toArray(new String[0]), pw); + pw.close(); + String out = sw.toString(); + if (!out.isEmpty()) + System.err.println(out); + if (rc != 0) + throw new Error("jdeps failed: rc=" + rc); + + // check output files + if (Files.notExists(dotfile)) { + throw new RuntimeException(dotfile + " doesn't exist"); + } + return parse(dotfile); + } + private static Pattern pattern = Pattern.compile("(.*) -> +([^ ]*) (.*)"); + private Map parse(Path outfile) throws IOException { + Map result = new LinkedHashMap<>(); + for (String line : Files.readAllLines(outfile)) { + line = line.replace('"', ' ').replace(';', ' '); + Matcher pm = pattern.matcher(line); + if (pm.find()) { + String origin = pm.group(1).trim(); + String target = pm.group(2).trim(); + String module = pm.group(3).replace('(', ' ').replace(')', ' ').trim(); + result.put(target, module); + } + } + return result; + } + + void checkResult(String label, String[] expect, Collection found) { + List list = Arrays.asList(expect); + if (!isEqual(list, found)) + error("Unexpected " + label + " found: '" + found + "', expected: '" + list + "'"); + } + + void checkResult(String label, String[] expect, String[] profiles, Map result) { + if (expect.length != profiles.length) + error("Invalid expected names and profiles"); + + // check the dependencies + checkResult(label, expect, result.keySet()); + // check profile information + checkResult(label, profiles, result.values()); + for (int i=0; i < expect.length; i++) { + String profile = result.get(expect[i]); + if (!profile.equals(profiles[i])) + error("Unexpected profile: '" + profile + "', expected: '" + profiles[i] + "'"); + } + } + + boolean isEqual(List expected, Collection found) { + if (expected.size() != found.size()) + return false; + + List list = new ArrayList<>(found); + list.removeAll(expected); + return list.isEmpty(); + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors; +} diff --git a/langtools/test/tools/jdeps/m/Gee.java b/langtools/test/tools/jdeps/m/Gee.java index 749847e72a0..0020b18da6b 100644 --- a/langtools/test/tools/jdeps/m/Gee.java +++ b/langtools/test/tools/jdeps/m/Gee.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,5 +26,7 @@ package m; class Gee extends g.G { public sun.misc.Lock lock; + public com.sun.tools.classfile.ClassFile cf; // @jdk.Exported(false) + public com.sun.source.tree.BinaryTree tree; // @jdk.Exported + public com.sun.management.ThreadMXBean mxbean; // @jdk.Exported on package-info } - diff --git a/langtools/test/tools/jdeps/p/Bar.java b/langtools/test/tools/jdeps/p/Bar.java index 9a99a769070..77e20e6391c 100644 --- a/langtools/test/tools/jdeps/p/Bar.java +++ b/langtools/test/tools/jdeps/p/Bar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,4 +30,8 @@ public class Bar extends javax.activity.NotCompactProfile { public javax.crypto.Cipher getCiper() { return null; } + + public Foo foo() { + return new Foo(); + } } From 0067b707258923c5664593543f4c44ce350289d1 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 9 Jul 2014 16:32:05 +0200 Subject: [PATCH 029/236] 8031569: Refactor javac scope implementation to enable lazy imports Introducing an internal API for Scope; rewriting ImportScopes to extend CompoundScopes. Co-authored-by: Maurizio Cimadamore Reviewed-by: mcimadamore, jjg, jfranck --- .../com/sun/tools/javac/api/JavacScope.java | 29 +- .../com/sun/tools/javac/api/JavacTrees.java | 37 +- .../com/sun/tools/javac/code/ClassFinder.java | 7 +- .../com/sun/tools/javac/code/Scope.java | 1179 ++++++++++------- .../com/sun/tools/javac/code/Symbol.java | 54 +- .../com/sun/tools/javac/code/Symtab.java | 7 +- .../com/sun/tools/javac/code/Types.java | 30 +- .../com/sun/tools/javac/comp/Annotate.java | 2 +- .../com/sun/tools/javac/comp/Attr.java | 53 +- .../com/sun/tools/javac/comp/AttrContext.java | 7 +- .../com/sun/tools/javac/comp/Check.java | 280 ++-- .../sun/tools/javac/comp/DeferredAttr.java | 3 +- .../com/sun/tools/javac/comp/Enter.java | 19 +- .../com/sun/tools/javac/comp/Flow.java | 5 +- .../sun/tools/javac/comp/LambdaToMethod.java | 6 +- .../com/sun/tools/javac/comp/Lower.java | 53 +- .../com/sun/tools/javac/comp/MemberEnter.java | 241 ++-- .../com/sun/tools/javac/comp/Resolve.java | 183 +-- .../com/sun/tools/javac/comp/TransTypes.java | 15 +- .../com/sun/tools/javac/jvm/ClassReader.java | 33 +- .../com/sun/tools/javac/jvm/ClassWriter.java | 29 +- .../classes/com/sun/tools/javac/jvm/Gen.java | 12 +- .../com/sun/tools/javac/jvm/JNIWriter.java | 8 +- .../javac/model/AnnotationProxyMaker.java | 9 +- .../tools/javac/model/FilteredMemberList.java | 51 +- .../sun/tools/javac/model/JavacElements.java | 28 +- .../com/sun/tools/javac/model/JavacTypes.java | 6 +- .../sun/tools/javac/sym/CreateSymbols.java | 12 +- .../com/sun/tools/javac/tree/JCTree.java | 6 +- .../com/sun/tools/javac/tree/TreeMaker.java | 30 +- .../tools/javadoc/AnnotationTypeDocImpl.java | 12 +- .../com/sun/tools/javadoc/ClassDocImpl.java | 85 +- .../com/sun/tools/javadoc/MethodDocImpl.java | 12 +- .../com/sun/tools/javadoc/PackageDocImpl.java | 12 +- .../com/sun/tools/javadoc/SerializedForm.java | 37 +- .../javac/6402516/CheckLocalElements.java | 23 +- .../test/tools/javac/6402516/Checker.java | 6 +- .../javac/6402516/TestLocalElements.java | 4 +- .../test/tools/javac/6889255/T6889255.java | 14 +- .../ImportOnDemandConflicts.java | 3 + .../ImportOnDemandConflicts.out | 2 + .../tools/javac/importOnDemand/p1/Object.java | 5 + .../tools/javac/importOnDemand/p1/String.java | 15 + .../javac/importOnDemand/p2/Boolean.java | 7 + langtools/test/tools/javac/lib/DPrinter.java | 102 +- .../scope/7017664/CompoundScopeTest.java | 14 +- .../7017664/ImplementationCacheTest.java | 4 +- .../tools/javac/scope/HashCollisionTest.java | 122 +- .../tools/javac/scope/StarImportTest.java | 82 +- .../javac/staticImport/6537020/T6537020.out | 2 +- 50 files changed, 1614 insertions(+), 1383 deletions(-) create mode 100644 langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.java create mode 100644 langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.out create mode 100644 langtools/test/tools/javac/importOnDemand/p1/Object.java create mode 100644 langtools/test/tools/javac/importOnDemand/p1/String.java create mode 100644 langtools/test/tools/javac/importOnDemand/p2/Boolean.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacScope.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacScope.java index 5aa4c0cc1da..51df082e28d 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacScope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacScope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 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 @@ -46,18 +46,33 @@ import com.sun.tools.javac.comp.Env; * @author Jonathan Gibbons; */ public class JavacScope implements com.sun.source.tree.Scope { + + static JavacScope create(Env env) { + if (env.outer == null || env.outer == env) { + //the "top-level" scope needs to return both imported and defined elements + //see test CheckLocalElements + return new JavacScope(env) { + @Override + public Iterable getLocalElements() { + return env.toplevel.namedImportScope.getSymbols(); + } + }; + } else { + return new JavacScope(env); + } + } + protected final Env env; - /** Creates a new instance of JavacScope */ - JavacScope(Env env) { + private JavacScope(Env env) { env.getClass(); // null-check this.env = env; } public JavacScope getEnclosingScope() { - if (env.outer != null && env.outer != env) - return new JavacScope(env.outer); - else { + if (env.outer != null && env.outer != env) { + return create(env.outer); + } else { // synthesize an outermost "star-import" scope return new JavacScope(env) { public boolean isStarImportScope() { @@ -67,7 +82,7 @@ public class JavacScope implements com.sun.source.tree.Scope { return null; } public Iterable getLocalElements() { - return env.toplevel.starImportScope.getElements(); + return env.toplevel.starImportScope.getSymbols(); } }; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index d9c2c248bcb..da75e39dd43 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -456,10 +456,9 @@ public class JavacTrees extends DocTrees { } searched.add(tsym); - for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(fieldName); - e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.VAR) { - return (VarSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbolsByName(fieldName)) { + if (sym.kind == Kinds.VAR) { + return (VarSymbol)sym; } } @@ -499,11 +498,10 @@ public class JavacTrees extends DocTrees { /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */ MethodSymbol findConstructor(ClassSymbol tsym, List paramTypes) { - for (com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(names.init); - e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.MTH) { - if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) { - return (MethodSymbol) e.sym; + for (Symbol sym : tsym.members().getSymbolsByName(names.init)) { + if (sym.kind == Kinds.MTH) { + if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { + return (MethodSymbol) sym; } } } @@ -529,7 +527,6 @@ public class JavacTrees extends DocTrees { searched.add(tsym); // search current class - com.sun.tools.javac.code.Scope.Entry e = tsym.members().lookup(methodName); //### Using modifier filter here isn't really correct, //### but emulates the old behavior. Instead, we should @@ -542,10 +539,10 @@ public class JavacTrees extends DocTrees { // In order to provide textually identical results, we // attempt to emulate the old behavior. MethodSymbol lastFound = null; - for (; e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.MTH) { - if (e.sym.name == methodName) { - lastFound = (MethodSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { + if (sym.kind == Kinds.MTH) { + if (sym.name == methodName) { + lastFound = (MethodSymbol)sym; } } } @@ -553,11 +550,11 @@ public class JavacTrees extends DocTrees { return lastFound; } } else { - for (; e.scope != null; e = e.next()) { - if (e.sym != null && - e.sym.kind == Kinds.MTH) { - if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) { - return (MethodSymbol) e.sym; + for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { + if (sym != null && + sym.kind == Kinds.MTH) { + if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { + return (MethodSymbol) sym; } } } @@ -684,7 +681,7 @@ public class JavacTrees extends DocTrees { } public JavacScope getScope(TreePath path) { - return new JavacScope(getAttrContext(path)); + return JavacScope.create(getAttrContext(path)); } public String getDocComment(TreePath path) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/ClassFinder.java b/langtools/src/share/classes/com/sun/tools/javac/code/ClassFinder.java index 4c19370386d..ea17e00f657 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/ClassFinder.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/ClassFinder.java @@ -37,6 +37,7 @@ import javax.tools.StandardJavaFileManager; import static javax.tools.StandardLocation.*; import com.sun.tools.javac.comp.Annotate; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.jvm.ClassReader; import com.sun.tools.javac.util.*; @@ -218,7 +219,7 @@ public class ClassFinder { if (c.owner.kind == PCK) { Symbol owner = c.owner; for (Name name : Convert.enclosingCandidates(Convert.shortName(c.name))) { - Symbol encl = owner.members().lookup(name).sym; + Symbol encl = owner.members().findFirst(name); if (encl == null) encl = syms.classes.get(TypeSymbol.formFlatName(name, owner)); if (encl != null) @@ -335,7 +336,7 @@ public class ClassFinder { boolean isPkgInfo = classname == names.package_info; ClassSymbol c = isPkgInfo ? p.package_info - : (ClassSymbol) p.members_field.lookup(classname).sym; + : (ClassSymbol) p.members_field.findFirst(classname); if (c == null) { c = syms.enterClass(classname, p); if (c.classfile == null) // only update the file if's it's newly created @@ -399,7 +400,7 @@ public class ClassFinder { */ private void fillIn(PackageSymbol p) throws IOException { if (p.members_field == null) - p.members_field = new Scope(p); + p.members_field = WriteableScope.create(p); preferCurrent = false; if (userPathsFirst) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java index dee7c42ff9a..dec8ef65739 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java @@ -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 @@ -25,440 +25,588 @@ package com.sun.tools.javac.code; -import java.util.Iterator; +import java.util.*; import com.sun.tools.javac.util.*; +import com.sun.tools.javac.util.List; + +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; +import static com.sun.tools.javac.code.Scope.LookupKind.RECURSIVE; /** A scope represents an area of visibility in a Java program. The * Scope class is a container for symbols which provides * efficient access to symbols given their names. Scopes are implemented * as hash tables with "open addressing" and "double hashing". - * Scopes can be nested; the next field of a scope points - * to its next outer scope. Nested scopes can share their hash tables. + * Scopes can be nested. Nested scopes can share their hash tables. * *

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. * This code and its internal interfaces are subject to change or * deletion without notice. */ -public class Scope { - - /** The number of scopes that share this scope's hash table. - */ - private int shared; - - /** Next enclosing scope (with whom this scope may share a hashtable) - */ - public Scope next; +public abstract class Scope { /** The scope's owner. */ - public Symbol owner; + public final Symbol owner; - /** A hash table for the scope's entries. - */ - Entry[] table; + protected Scope(Symbol owner) { + this.owner = owner; + } - /** Mask for hash codes, always equal to (table.length - 1). + /**Returns all Symbols in this Scope. Symbols from outward Scopes are included. */ - int hashMask; + public final Iterable getSymbols() { + return getSymbols(noFilter); + } - /** A linear list that also contains all entries in - * reverse order of appearance (i.e later entries are pushed on top). + /**Returns Symbols that match the given filter. Symbols from outward Scopes are included. */ - public Entry elems; + public final Iterable getSymbols(Filter sf) { + return getSymbols(sf, RECURSIVE); + } - /** The number of elements in this scope. - * This includes deleted elements, whose value is the sentinel. + /**Returns all Symbols in this Scope. Symbols from outward Scopes are included + * iff lookupKind == RECURSIVE. */ - int nelems = 0; + public final Iterable getSymbols(LookupKind lookupKind) { + return getSymbols(noFilter, lookupKind); + } + + /**Returns Symbols that match the given filter. Symbols from outward Scopes are included + * iff lookupKind == RECURSIVE. + */ + public abstract Iterable getSymbols(Filter sf, LookupKind lookupKind); + + /**Returns Symbols with the given name. Symbols from outward Scopes are included. + */ + public final Iterable getSymbolsByName(Name name) { + return getSymbolsByName(name, RECURSIVE); + } + + /**Returns Symbols with the given name that match the given filter. + * Symbols from outward Scopes are included. + */ + public final Iterable getSymbolsByName(final Name name, final Filter sf) { + return getSymbolsByName(name, sf, RECURSIVE); + } + + /**Returns Symbols with the given name. Symbols from outward Scopes are included + * iff lookupKind == RECURSIVE. + */ + public final Iterable getSymbolsByName(Name name, LookupKind lookupKind) { + return getSymbolsByName(name, noFilter, lookupKind); + } + + /**Returns Symbols with the given name that match the given filter. + * Symbols from outward Scopes are included iff lookupKind == RECURSIVE. + */ + public abstract Iterable getSymbolsByName(final Name name, final Filter sf, + final LookupKind lookupKind); + + /** Return the first Symbol from this or outward scopes with the given name. + * Returns null if none. + */ + public final Symbol findFirst(Name name) { + return findFirst(name, noFilter); + } + + /** Return the first Symbol from this or outward scopes with the given name that matches the + * given filter. Returns null if none. + */ + public Symbol findFirst(Name name, Filter sf) { + Iterator it = getSymbolsByName(name, sf).iterator(); + return it.hasNext() ? it.next() : null; + } + + /** Returns true iff there are is at least one Symbol in this scope matching the given filter. + * Does not inspect outward scopes. + */ + public boolean anyMatch(Filter filter) { + return getSymbols(filter, NON_RECURSIVE).iterator().hasNext(); + } + + /** Returns true iff the given Symbol is in this scope or any outward scope. + */ + public boolean includes(final Symbol sym) { + return getSymbolsByName(sym.name, new Filter() { + @Override + public boolean accepts(Symbol t) { + return t == sym; + } + }).iterator().hasNext(); + } + + /** Returns true iff this scope does not contain any Symbol. Does not inspect outward scopes. + */ + public boolean isEmpty() { + return !getSymbols(NON_RECURSIVE).iterator().hasNext(); + } + + /** Returns the Scope from which the givins Symbol originates in this scope. + */ + public abstract Scope getOrigin(Symbol byName); + + /** Returns true iff the given Symbol is part of this scope due to a static import. + */ + public abstract boolean isStaticallyImported(Symbol byName); + + private static final Filter noFilter = null; /** A list of scopes to be notified if items are to be removed from this scope. */ List listeners = List.nil(); - /** Use as a "not-found" result for lookup. - * Also used to mark deleted entries in the table. - */ - private static final Entry sentinel = new Entry(null, null, null, null); - - /** The hash table's initial size. - */ - private static final int INITIAL_SIZE = 0x10; - - /** A value for the empty scope. - */ - public static final Scope emptyScope = new Scope(null, null, new Entry[]{}); - - /** Construct a new scope, within scope next, with given owner, using - * given table. The table's length must be an exponent of 2. - */ - private Scope(Scope next, Symbol owner, Entry[] table) { - this.next = next; - Assert.check(emptyScope == null || owner != null); - this.owner = owner; - this.table = table; - this.hashMask = table.length - 1; + public void addScopeListener(ScopeListener sl) { + listeners = listeners.prepend(sl); } - /** Convenience constructor used for dup and dupUnshared. */ - private Scope(Scope next, Symbol owner, Entry[] table, int nelems) { - this(next, owner, table); - this.nelems = nelems; - } - - /** Construct a new scope, within scope next, with given owner, - * using a fresh table of length INITIAL_SIZE. - */ - public Scope(Symbol owner) { - this(null, owner, new Entry[INITIAL_SIZE]); - } - - /** Construct a fresh scope within this scope, with same owner, - * which shares its table with the outer scope. Used in connection with - * method leave if scope access is stack-like in order to avoid allocation - * of fresh tables. - */ - public Scope dup() { - return dup(this.owner); - } - - /** Construct a fresh scope within this scope, with new owner, - * which shares its table with the outer scope. Used in connection with - * method leave if scope access is stack-like in order to avoid allocation - * of fresh tables. - */ - public Scope dup(Symbol newOwner) { - Scope result = new Scope(this, newOwner, this.table, this.nelems); - shared++; - // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); - // new Error().printStackTrace(System.out); - return result; - } - - /** Construct a fresh scope within this scope, with same owner, - * with a new hash table, whose contents initially are those of - * the table of its outer scope. - */ - public Scope dupUnshared() { - return new Scope(this, this.owner, this.table.clone(), this.nelems); - } - - /** Remove all entries of this scope from its table, if shared - * with next. - */ - public Scope leave() { - Assert.check(shared == 0); - if (table != next.table) return next; - while (elems != null) { - int hash = getIndex(elems.sym.name); - Entry e = table[hash]; - Assert.check(e == elems, elems.sym); - table[hash] = elems.shadowed; - elems = elems.sibling; - } - Assert.check(next.shared > 0); - next.shared--; - next.nelems = nelems; - // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); - // new Error().printStackTrace(System.out); - return next; - } - - /** Double size of hash table. - */ - private void dble() { - Assert.check(shared == 0); - Entry[] oldtable = table; - Entry[] newtable = new Entry[oldtable.length * 2]; - for (Scope s = this; s != null; s = s.next) { - if (s.table == oldtable) { - Assert.check(s == this || s.shared != 0); - s.table = newtable; - s.hashMask = newtable.length - 1; - } - } - int n = 0; - for (int i = oldtable.length; --i >= 0; ) { - Entry e = oldtable[i]; - if (e != null && e != sentinel) { - table[getIndex(e.sym.name)] = e; - n++; - } - } - // We don't need to update nelems for shared inherited scopes, - // since that gets handled by leave(). - nelems = n; - } - - /** Enter symbol sym in this scope. - */ - public void enter(Symbol sym) { - Assert.check(shared == 0); - enter(sym, this); - } - - public void enter(Symbol sym, Scope s) { - enter(sym, s, s, false); - } - - /** - * Enter symbol sym in this scope, but mark that it comes from - * given scope `s' accessed through `origin'. The last two - * arguments are only used in import scopes. - */ - public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { - Assert.check(shared == 0); - if (nelems * 3 >= hashMask * 2) - dble(); - int hash = getIndex(sym.name); - Entry old = table[hash]; - if (old == null) { - old = sentinel; - nelems++; - } - Entry e = makeEntry(sym, old, elems, s, origin, staticallyImported); - table[hash] = e; - elems = e; - - //notify listeners - for (List l = listeners; l.nonEmpty(); l = l.tail) { - l.head.symbolAdded(sym, this); - } - } - - Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin, boolean staticallyImported) { - return new Entry(sym, shadowed, sibling, scope); - } - - public interface ScopeListener { public void symbolAdded(Symbol sym, Scope s); public void symbolRemoved(Symbol sym, Scope s); } - public void addScopeListener(ScopeListener sl) { - listeners = listeners.prepend(sl); + public enum LookupKind { + RECURSIVE, + NON_RECURSIVE; } - /** Remove symbol from this scope. Used when an inner class - * attribute tells us that the class isn't a package member. - */ - public void remove(Symbol sym) { - Assert.check(shared == 0); - Entry e = lookup(sym.name); - if (e.scope == null) return; + /**A scope into which Symbols can be added.*/ + public abstract static class WriteableScope extends Scope { - // remove e from table and shadowed list; - int i = getIndex(sym.name); - Entry te = table[i]; - if (te == e) - table[i] = e.shadowed; - else while (true) { - if (te.shadowed == e) { - te.shadowed = e.shadowed; - break; + public WriteableScope(Symbol owner) { + super(owner); + } + + /** Enter the given Symbol into this scope. + */ + public abstract void enter(Symbol c); + /** Enter symbol sym in this scope if not already there. + */ + public abstract void enterIfAbsent(Symbol c); + + public abstract void remove(Symbol c); + + /** Construct a fresh scope within this scope, with same owner. The new scope may + * shares internal structures with the this scope. Used in connection with + * method leave if scope access is stack-like in order to avoid allocation + * of fresh tables. + */ + public final WriteableScope dup() { + return dup(this.owner); + } + + /** Construct a fresh scope within this scope, with new owner. The new scope may + * shares internal structures with the this scope. Used in connection with + * method leave if scope access is stack-like in order to avoid allocation + * of fresh tables. + */ + public abstract WriteableScope dup(Symbol newOwner); + + /** Must be called on dup-ed scopes to be able to work with the outward scope again. + */ + public abstract WriteableScope leave(); + + /** Construct a fresh scope within this scope, with same owner. The new scope + * will not share internal structures with this scope. + */ + public final WriteableScope dupUnshared() { + return dupUnshared(owner); + } + + /** Construct a fresh scope within this scope, with new owner. The new scope + * will not share internal structures with this scope. + */ + public abstract WriteableScope dupUnshared(Symbol newOwner); + + /** Create a new WriteableScope. + */ + public static WriteableScope create(Symbol owner) { + return new ScopeImpl(owner); + } + + } + + private static class ScopeImpl extends WriteableScope { + /** The number of scopes that share this scope's hash table. + */ + private int shared; + + /** Next enclosing scope (with whom this scope may share a hashtable) + */ + public ScopeImpl next; + + /** A hash table for the scope's entries. + */ + Entry[] table; + + /** Mask for hash codes, always equal to (table.length - 1). + */ + int hashMask; + + /** A linear list that also contains all entries in + * reverse order of appearance (i.e later entries are pushed on top). + */ + public Entry elems; + + /** The number of elements in this scope. + * This includes deleted elements, whose value is the sentinel. + */ + int nelems = 0; + + /** Use as a "not-found" result for lookup. + * Also used to mark deleted entries in the table. + */ + private static final Entry sentinel = new Entry(null, null, null, null); + + /** The hash table's initial size. + */ + private static final int INITIAL_SIZE = 0x10; + + /** Construct a new scope, within scope next, with given owner, using + * given table. The table's length must be an exponent of 2. + */ + private ScopeImpl(ScopeImpl next, Symbol owner, Entry[] table) { + super(owner); + this.next = next; + Assert.check(owner != null); + this.table = table; + this.hashMask = table.length - 1; + } + + /** Convenience constructor used for dup and dupUnshared. */ + private ScopeImpl(ScopeImpl next, Symbol owner, Entry[] table, int nelems) { + this(next, owner, table); + this.nelems = nelems; + } + + /** Construct a new scope, within scope next, with given owner, + * using a fresh table of length INITIAL_SIZE. + */ + public ScopeImpl(Symbol owner) { + this(null, owner, new Entry[INITIAL_SIZE]); + } + + /** Construct a fresh scope within this scope, with new owner, + * which shares its table with the outer scope. Used in connection with + * method leave if scope access is stack-like in order to avoid allocation + * of fresh tables. + */ + public WriteableScope dup(Symbol newOwner) { + ScopeImpl result = new ScopeImpl(this, newOwner, this.table, this.nelems); + shared++; + // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode()); + // new Error().printStackTrace(System.out); + return result; + } + + /** Construct a fresh scope within this scope, with new owner, + * with a new hash table, whose contents initially are those of + * the table of its outer scope. + */ + public WriteableScope dupUnshared(Symbol newOwner) { + return new ScopeImpl(this, newOwner, this.table.clone(), this.nelems); + } + + /** Remove all entries of this scope from its table, if shared + * with next. + */ + public WriteableScope leave() { + Assert.check(shared == 0); + if (table != next.table) return next; + while (elems != null) { + int hash = getIndex(elems.sym.name); + Entry e = table[hash]; + Assert.check(e == elems, elems.sym); + table[hash] = elems.shadowed; + elems = elems.sibling; } - te = te.shadowed; + Assert.check(next.shared > 0); + next.shared--; + next.nelems = nelems; + // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); + // new Error().printStackTrace(System.out); + return next; } - // remove e from elems and sibling list - te = elems; - if (te == e) - elems = e.sibling; - else while (true) { - if (te.sibling == e) { - te.sibling = e.sibling; - break; + /** Double size of hash table. + */ + private void dble() { + Assert.check(shared == 0); + Entry[] oldtable = table; + Entry[] newtable = new Entry[oldtable.length * 2]; + for (ScopeImpl s = this; s != null; s = s.next) { + if (s.table == oldtable) { + Assert.check(s == this || s.shared != 0); + s.table = newtable; + s.hashMask = newtable.length - 1; + } } - te = te.sibling; + int n = 0; + for (int i = oldtable.length; --i >= 0; ) { + Entry e = oldtable[i]; + if (e != null && e != sentinel) { + table[getIndex(e.sym.name)] = e; + n++; + } + } + // We don't need to update nelems for shared inherited scopes, + // since that gets handled by leave(). + nelems = n; } - //notify listeners - for (List l = listeners; l.nonEmpty(); l = l.tail) { - l.head.symbolRemoved(sym, this); + /** Enter symbol sym in this scope. + */ + public void enter(Symbol sym) { + Assert.check(shared == 0); + if (nelems * 3 >= hashMask * 2) + dble(); + int hash = getIndex(sym.name); + Entry old = table[hash]; + if (old == null) { + old = sentinel; + nelems++; + } + Entry e = new Entry(sym, old, elems, this); + table[hash] = e; + elems = e; + + //notify listeners + for (List l = listeners; l.nonEmpty(); l = l.tail) { + l.head.symbolAdded(sym, this); + } } - } - /** Enter symbol sym in this scope if not already there. - */ - public void enterIfAbsent(Symbol sym) { - Assert.check(shared == 0); - Entry e = lookup(sym.name); - while (e.scope == this && e.sym.kind != sym.kind) e = e.next(); - if (e.scope != this) enter(sym); - } + /** Remove symbol from this scope. Used when an inner class + * attribute tells us that the class isn't a package member. + */ + public void remove(Symbol sym) { + Assert.check(shared == 0); + Entry e = lookup(sym.name); + if (e.scope == null) return; - /** Given a class, is there already a class with same fully - * qualified name in this (import) scope? - */ - public boolean includes(Symbol c) { - for (Scope.Entry e = lookup(c.name); - e.scope == this; - e = e.next()) { - if (e.sym == c) return true; + // remove e from table and shadowed list; + int i = getIndex(sym.name); + Entry te = table[i]; + if (te == e) + table[i] = e.shadowed; + else while (true) { + if (te.shadowed == e) { + te.shadowed = e.shadowed; + break; + } + te = te.shadowed; + } + + // remove e from elems and sibling list + te = elems; + if (te == e) + elems = e.sibling; + else while (true) { + if (te.sibling == e) { + te.sibling = e.sibling; + break; + } + te = te.sibling; + } + + //notify listeners + for (List l = listeners; l.nonEmpty(); l = l.tail) { + l.head.symbolRemoved(sym, this); + } } - return false; - } - static final Filter noFilter = new Filter() { - public boolean accepts(Symbol s) { - return true; + /** Enter symbol sym in this scope if not already there. + */ + public void enterIfAbsent(Symbol sym) { + Assert.check(shared == 0); + Entry e = lookup(sym.name); + while (e.scope == this && e.sym.kind != sym.kind) e = e.next(); + if (e.scope != this) enter(sym); } - }; - /** Return the entry associated with given name, starting in - * this scope and proceeding outwards. If no entry was found, - * return the sentinel, which is characterized by having a null in - * both its scope and sym fields, whereas both fields are non-null - * for regular entries. - */ - public Entry lookup(Name name) { - return lookup(name, noFilter); - } - - public Entry lookup(Name name, Filter sf) { - Entry e = table[getIndex(name)]; - if (e == null || e == sentinel) - return sentinel; - while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym))) - e = e.shadowed; - return e; - } - - /*void dump (java.io.PrintStream out) { - out.println(this); - for (int l=0; l < table.length; l++) { - Entry le = table[l]; - out.print("#"+l+": "); - if (le==sentinel) out.println("sentinel"); - else if(le == null) out.println("null"); - else out.println(""+le+" s:"+le.sym); + /** Given a class, is there already a class with same fully + * qualified name in this (import) scope? + */ + public boolean includes(Symbol c) { + for (Scope.Entry e = lookup(c.name); + e.scope == this; + e = e.next()) { + if (e.sym == c) return true; + } + return false; } - }*/ - /** Look for slot in the table. - * We use open addressing with double hashing. - */ - int getIndex (Name name) { - int h = name.hashCode(); - int i = h & hashMask; - // The expression below is always odd, so it is guaranteed - // to be mutually prime with table.length, a power of 2. - int x = hashMask - ((h + (h >> 16)) << 1); - int d = -1; // Index of a deleted item. - for (;;) { - Entry e = table[i]; - if (e == null) - return d >= 0 ? d : i; - if (e == sentinel) { - // We have to keep searching even if we see a deleted item. - // However, remember the index in case we fail to find the name. - if (d < 0) - d = i; - } else if (e.sym.name == name) - return i; - i = (i + x) & hashMask; + /** Return the entry associated with given name, starting in + * this scope and proceeding outwards. If no entry was found, + * return the sentinel, which is characterized by having a null in + * both its scope and sym fields, whereas both fields are non-null + * for regular entries. + */ + protected Entry lookup(Name name) { + return lookup(name, noFilter); } - } - public boolean anyMatch(Filter sf) { - return getElements(sf).iterator().hasNext(); - } + protected Entry lookup(Name name, Filter sf) { + Entry e = table[getIndex(name)]; + if (e == null || e == sentinel) + return sentinel; + while (e.scope != null && (e.sym.name != name || (sf != null && !sf.accepts(e.sym)))) + e = e.shadowed; + return e; + } - public Iterable getElements() { - return getElements(noFilter); - } + public Symbol findFirst(Name name, Filter sf) { + return lookup(name, sf).sym; + } - public Iterable getElements(final Filter sf) { - return new Iterable() { - public Iterator iterator() { - return new Iterator() { - private Scope currScope = Scope.this; - private Scope.Entry currEntry = elems; - { - update(); - } + /*void dump (java.io.PrintStream out) { + out.println(this); + for (int l=0; l < table.length; l++) { + Entry le = table[l]; + out.print("#"+l+": "); + if (le==sentinel) out.println("sentinel"); + else if(le == null) out.println("null"); + else out.println(""+le+" s:"+le.sym); + } + }*/ - public boolean hasNext() { - return currEntry != null; - } + /** Look for slot in the table. + * We use open addressing with double hashing. + */ + int getIndex (Name name) { + int h = name.hashCode(); + int i = h & hashMask; + // The expression below is always odd, so it is guaranteed + // to be mutually prime with table.length, a power of 2. + int x = hashMask - ((h + (h >> 16)) << 1); + int d = -1; // Index of a deleted item. + for (;;) { + Entry e = table[i]; + if (e == null) + return d >= 0 ? d : i; + if (e == sentinel) { + // We have to keep searching even if we see a deleted item. + // However, remember the index in case we fail to find the name. + if (d < 0) + d = i; + } else if (e.sym.name == name) + return i; + i = (i + x) & hashMask; + } + } - public Symbol next() { - Symbol sym = (currEntry == null ? null : currEntry.sym); - if (currEntry != null) { - currEntry = currEntry.sibling; + public boolean anyMatch(Filter sf) { + return getSymbols(sf, NON_RECURSIVE).iterator().hasNext(); + } + + public Iterable getSymbols(final Filter sf, + final LookupKind lookupKind) { + return new Iterable() { + public Iterator iterator() { + return new Iterator() { + private ScopeImpl currScope = ScopeImpl.this; + private Scope.Entry currEntry = elems; + { + update(); } - update(); - return sym; - } - public void remove() { - throw new UnsupportedOperationException(); - } + public boolean hasNext() { + return currEntry != null; + } - private void update() { - skipToNextMatchingEntry(); - while (currEntry == null && currScope.next != null) { - currScope = currScope.next; - currEntry = currScope.elems; + public Symbol next() { + Symbol sym = (currEntry == null ? null : currEntry.sym); + if (currEntry != null) { + currEntry = currEntry.sibling; + } + update(); + return sym; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + private void update() { skipToNextMatchingEntry(); + if (lookupKind == RECURSIVE) { + while (currEntry == null && currScope.next != null) { + currScope = currScope.next; + currEntry = currScope.elems; + skipToNextMatchingEntry(); + } + } } - } - void skipToNextMatchingEntry() { - while (currEntry != null && !sf.accepts(currEntry.sym)) { - currEntry = currEntry.sibling; + void skipToNextMatchingEntry() { + while (currEntry != null && sf != null && !sf.accepts(currEntry.sym)) { + currEntry = currEntry.sibling; + } } - } - }; - } - }; - } - - public Iterable getElementsByName(Name name) { - return getElementsByName(name, noFilter); - } - - public Iterable getElementsByName(final Name name, final Filter sf) { - return new Iterable() { - public Iterator iterator() { - return new Iterator() { - Scope.Entry currentEntry = lookup(name, sf); - - public boolean hasNext() { - return currentEntry.scope != null; - } - public Symbol next() { - Scope.Entry prevEntry = currentEntry; - currentEntry = currentEntry.next(sf); - return prevEntry.sym; - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - public String toString() { - StringBuilder result = new StringBuilder(); - result.append("Scope["); - for (Scope s = this; s != null ; s = s.next) { - if (s != this) result.append(" | "); - for (Entry e = s.elems; e != null; e = e.sibling) { - if (e != s.elems) result.append(", "); - result.append(e.sym); - } + }; + } + }; + } + + public Iterable getSymbolsByName(final Name name, + final Filter sf, + final LookupKind lookupKind) { + return new Iterable() { + public Iterator iterator() { + return new Iterator() { + Scope.Entry currentEntry = lookup(name, sf); + + public boolean hasNext() { + return currentEntry.scope != null && + (lookupKind == RECURSIVE || + currentEntry.scope == ScopeImpl.this); + } + public Symbol next() { + Scope.Entry prevEntry = currentEntry; + currentEntry = currentEntry.next(sf); + return prevEntry.sym; + } + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; + } + + public Scope getOrigin(Symbol s) { + for (Scope.Entry e = lookup(s.name); e.scope != null ; e = e.next()) { + if (e.sym == s) { + return this; + } + } + return null; + } + + @Override + public boolean isStaticallyImported(Symbol s) { + return false; + } + + public String toString() { + StringBuilder result = new StringBuilder(); + result.append("Scope["); + for (ScopeImpl s = this; s != null ; s = s.next) { + if (s != this) result.append(" | "); + for (Entry e = s.elems; e != null; e = e.sibling) { + if (e != s.elems) result.append(", "); + result.append(e.sym); + } + } + result.append("]"); + return result.toString(); } - result.append("]"); - return result.toString(); } /** A class for scope entries. */ - public static class Entry { + private static class Entry { /** The referenced symbol. * sym == null iff this == sentinel @@ -475,8 +623,6 @@ public class Scope { /** The entry's scope. * scope == null iff this == sentinel - * for an entry in an import scope, this is the scope - * where the entry came from (i.e. was imported from). */ public Scope scope; @@ -495,101 +641,201 @@ public class Scope { } public Entry next(Filter sf) { - if (shadowed.sym == null || sf.accepts(shadowed.sym)) return shadowed; + if (shadowed.sym == null || sf == null || sf.accepts(shadowed.sym)) return shadowed; else return shadowed.next(sf); } - public boolean isStaticallyImported() { - return false; - } - - public Scope getOrigin() { - // The origin is only recorded for import scopes. For all - // other scope entries, the "enclosing" type is available - // from other sources. See Attr.visitSelect and - // Attr.visitIdent. Rather than throwing an assertion - // error, we return scope which will be the same as origin - // in many cases. - return scope; - } } - public static class ImportScope extends Scope { + public static class NamedImportScope extends CompoundScope { - public ImportScope(Symbol owner) { + public NamedImportScope(Symbol owner, Scope currentFileScope) { super(owner); + prependSubScope(currentFileScope); } - @Override - Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, - final Scope origin, final boolean staticallyImported) { - return new Entry(sym, shadowed, sibling, scope) { - @Override - public Scope getOrigin() { - return origin; - } + public void importByName(Scope delegate, Scope origin, Name name, ImportFilter filter) { + appendScope(new FilterImportScope(delegate, origin, name, filter, true)); + } + + public void importType(Scope delegate, Scope origin, Symbol sym) { + appendScope(new SingleEntryScope(delegate.owner, sym, origin)); + } + + private void appendScope(Scope newScope) { + List existingScopes = this.subScopes.reverse(); + subScopes = List.of(existingScopes.head); + subScopes = subScopes.prepend(newScope); + for (Scope s : existingScopes.tail) { + subScopes = subScopes.prepend(s); + } + } + + private static class SingleEntryScope extends Scope { + + private final Symbol sym; + private final List content; + private final Scope origin; + + public SingleEntryScope(Symbol owner, Symbol sym, Scope origin) { + super(owner); + this.sym = sym; + this.content = List.of(sym); + this.origin = origin; + } + + @Override + public Iterable getSymbols(Filter sf, LookupKind lookupKind) { + return sf == null || sf.accepts(sym) ? content : Collections.emptyList(); + } + + @Override + public Iterable getSymbolsByName(Name name, + Filter sf, + LookupKind lookupKind) { + return sym.name == name && + (sf == null || sf.accepts(sym)) ? content : Collections.emptyList(); + } + + @Override + public Scope getOrigin(Symbol byName) { + return sym == byName ? origin : null; + } + + @Override + public boolean isStaticallyImported(Symbol byName) { + return false; + } - @Override - public boolean isStaticallyImported() { - return staticallyImported; - } - }; } } - public static class StarImportScope extends ImportScope implements ScopeListener { + public static class StarImportScope extends CompoundScope { public StarImportScope(Symbol owner) { super(owner); } - public void importAll (Scope fromScope) { - for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { - if (e.sym.kind == Kinds.TYP && !includes(e.sym)) - enter(e.sym, fromScope); + public void importAll(Scope delegate, + Scope origin, + ImportFilter filter, + boolean staticImport) { + for (Scope existing : subScopes) { + Assert.check(existing instanceof FilterImportScope); + FilterImportScope fis = (FilterImportScope) existing; + if (fis.delegate == delegate && fis.origin == origin && + fis.filter == filter && fis.staticImport == staticImport) + return ; //avoid entering the same scope twice } - // Register to be notified when imported items are removed - fromScope.addScopeListener(this); + prependSubScope(new FilterImportScope(delegate, origin, null, filter, staticImport)); } - public void symbolRemoved(Symbol sym, Scope s) { - remove(sym); - } - public void symbolAdded(Symbol sym, Scope s) { } } - /** An empty scope, into which you can't place anything. Used for - * the scope for a variable initializer. - */ - public static class DelegatedScope extends Scope { - Scope delegatee; - public static final Entry[] emptyTable = new Entry[0]; + public interface ImportFilter { + public boolean accepts(Scope origin, Symbol sym); + } - public DelegatedScope(Scope outer) { - super(outer, outer.owner, emptyTable); - delegatee = outer; + private static class FilterImportScope extends Scope { + + private final Scope delegate; + private final Scope origin; + private final Name filterName; + private final ImportFilter filter; + private final boolean staticImport; + + public FilterImportScope(Scope delegate, + Scope origin, + Name filterName, + ImportFilter filter, + boolean staticImport) { + super(delegate.owner); + this.delegate = delegate; + this.origin = origin; + this.filterName = filterName; + this.filter = filter; + this.staticImport = staticImport; } - public Scope dup() { - return new DelegatedScope(next); + + @Override + public Iterable getSymbols(Filter sf, LookupKind lookupKind) { + if (filterName != null) + return getSymbolsByName(filterName, sf, lookupKind); + return new FilteredIterable(delegate.getSymbols(sf, lookupKind)); } - public Scope dupUnshared() { - return new DelegatedScope(next); + + @Override + public Iterable getSymbolsByName(Name name, + Filter sf, + LookupKind lookupKind) { + if (filterName != null && filterName != name) + return Collections.emptyList(); + return new FilteredIterable(delegate.getSymbolsByName(name, sf, lookupKind)); } - public Scope leave() { - return next; + + @Override + public Scope getOrigin(Symbol byName) { + return origin; } - public void enter(Symbol sym) { - // only anonymous classes could be put here + + @Override + public boolean isStaticallyImported(Symbol byName) { + return staticImport; } - public void enter(Symbol sym, Scope s) { - // only anonymous classes could be put here + + private class FilteredIterator implements Iterator { + private final Iterator delegate; + private Symbol next; + + public FilteredIterator(Iterator delegate) { + this.delegate = delegate; + update(); + } + + void update() { + while (delegate.hasNext()) { + if (filter.accepts(origin, next = delegate.next())) + return; + } + + next = null; + } + + @Override + public boolean hasNext() { + return next != null; + } + + @Override + public Symbol next() { + Symbol result = next; + + update(); + + return result; + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Not supported."); + } + } - public void remove(Symbol sym) { - throw new AssertionError(sym); - } - public Entry lookup(Name name) { - return delegatee.lookup(name); + + private class FilteredIterable implements Iterable { + + private final Iterable unfiltered; + + public FilteredIterable(Iterable unfiltered) { + this.unfiltered = unfiltered; + } + + @Override + public Iterator iterator() { + return new FilteredIterator(unfiltered.iterator()); + } } + } /** A class scope adds capabilities to keep track of changes in related @@ -600,16 +846,14 @@ public class Scope { */ public static class CompoundScope extends Scope implements ScopeListener { - public static final Entry[] emptyTable = new Entry[0]; - - private List subScopes = List.nil(); + List subScopes = List.nil(); private int mark = 0; public CompoundScope(Symbol owner) { - super(null, owner, emptyTable); + super(owner); } - public void addSubScope(Scope that) { + public void prependSubScope(Scope that) { if (that != null) { subScopes = subScopes.prepend(that); that.addScopeListener(this); @@ -618,7 +862,7 @@ public class Scope { sl.symbolAdded(null, this); //propagate upwards in case of nested CompoundScopes } } - } + } public void symbolAdded(Symbol sym, Scope s) { mark++; @@ -653,12 +897,13 @@ public class Scope { } @Override - public Iterable getElements(final Filter sf) { + public Iterable getSymbols(final Filter sf, + final LookupKind lookupKind) { return new Iterable() { public Iterator iterator() { return new CompoundScopeIterator(subScopes) { Iterator nextIterator(Scope s) { - return s.getElements(sf).iterator(); + return s.getSymbols(sf, lookupKind).iterator(); } }; } @@ -666,18 +911,40 @@ public class Scope { } @Override - public Iterable getElementsByName(final Name name, final Filter sf) { + public Iterable getSymbolsByName(final Name name, + final Filter sf, + final LookupKind lookupKind) { return new Iterable() { public Iterator iterator() { return new CompoundScopeIterator(subScopes) { Iterator nextIterator(Scope s) { - return s.getElementsByName(name, sf).iterator(); + return s.getSymbolsByName(name, sf, lookupKind).iterator(); } }; } }; } + @Override + public Scope getOrigin(Symbol sym) { + for (Scope delegate : subScopes) { + if (delegate.includes(sym)) + return delegate.getOrigin(sym); + } + + return null; + } + + @Override + public boolean isStaticallyImported(Symbol sym) { + for (Scope delegate : subScopes) { + if (delegate.includes(sym)) + return delegate.isStaticallyImported(sym); + } + + return false; + } + abstract class CompoundScopeIterator implements Iterator { private Iterator currentIterator; @@ -715,41 +982,21 @@ public class Scope { currentIterator = null; } } - - @Override - public Entry lookup(Name name, Filter sf) { - throw new UnsupportedOperationException(); - } - - @Override - public Scope dup(Symbol newOwner) { - throw new UnsupportedOperationException(); - } - - @Override - public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { - throw new UnsupportedOperationException(); - } - - @Override - public void remove(Symbol sym) { - throw new UnsupportedOperationException(); - } } /** An error scope, for which the owner should be an error symbol. */ - public static class ErrorScope extends Scope { - ErrorScope(Scope next, Symbol errSymbol, Entry[] table) { + public static class ErrorScope extends ScopeImpl { + ErrorScope(ScopeImpl next, Symbol errSymbol, Entry[] table) { super(next, /*owner=*/errSymbol, table); } public ErrorScope(Symbol errSymbol) { super(errSymbol); } - public Scope dup() { - return new ErrorScope(this, owner, table); + public WriteableScope dup(Symbol newOwner) { + return new ErrorScope(this, newOwner, table); } - public Scope dupUnshared() { - return new ErrorScope(this, owner, table.clone()); + public WriteableScope dupUnshared(Symbol newOwner) { + return new ErrorScope(this, newOwner, table.clone()); } public Entry lookup(Name name) { Entry e = super.lookup(name); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index c6565f27b16..85dcf930a94 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -33,19 +33,21 @@ import java.util.concurrent.Callable; import javax.lang.model.element.*; import javax.tools.JavaFileObject; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.comp.Attr; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Env; import com.sun.tools.javac.jvm.*; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.Name; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.FORALL; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; -import com.sun.tools.javac.tree.JCTree.JCVariableDecl; /** Root class for Java symbols. It contains subclasses * for specific sorts of symbols, such as variables, methods and operators, @@ -376,7 +378,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { /** If this is a class or package, its members, otherwise null. */ - public Scope members() { + public WriteableScope members() { return null; } @@ -475,15 +477,13 @@ public abstract class Symbol extends AnnoConstruct implements Element { if (currentClass == owner) { return this; } - Scope.Entry e = currentClass.members().lookup(name); - while (e.scope != null) { - if (e.sym.kind == kind && + for (Symbol sym : currentClass.members().getSymbolsByName(name)) { + if (sym.kind == kind && (kind != MTH || - (e.sym.flags() & STATIC) != 0 && - types.isSubSignature(e.sym.type, type))) { - return e.sym; + (sym.flags() & STATIC) != 0 && + types.isSubSignature(sym.type, type))) { + return sym; } - e = e.next(); } Symbol hiddenSym = null; for (Type st : types.interfaces(currentClass.type) @@ -632,7 +632,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { public boolean isConstructor() { return other.isConstructor(); } public Name getQualifiedName() { return other.getQualifiedName(); } public Name flatName() { return other.flatName(); } - public Scope members() { return other.members(); } + public WriteableScope members() { return other.members(); } public boolean isInner() { return other.isInner(); } public boolean hasOuterInstance() { return other.hasOuterInstance(); } public ClassSymbol enclClass() { return other.enclClass(); } @@ -721,9 +721,9 @@ public abstract class Symbol extends AnnoConstruct implements Element { if (kind == TYP && type.hasTag(TYPEVAR)) { return list; } - for (Scope.Entry e = members().elems; e != null; e = e.sibling) { - if (e.sym != null && (e.sym.flags() & SYNTHETIC) == 0 && e.sym.owner == this) - list = list.prepend(e.sym); + for (Symbol sym : members().getSymbols(NON_RECURSIVE)) { + if (sym != null && (sym.flags() & SYNTHETIC) == 0 && sym.owner == this) + list = list.prepend(sym); } return list; } @@ -818,7 +818,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { public static class PackageSymbol extends TypeSymbol implements PackageElement { - public Scope members_field; + public WriteableScope members_field; public Name fullname; public ClassSymbol package_info; // see bug 6443073 @@ -845,7 +845,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { return name.isEmpty() && owner != null; } - public Scope members() { + public WriteableScope members() { if (completer != null) complete(); return members_field; } @@ -910,7 +910,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { /** a scope for all class members; variables, methods and inner classes * type parameters are not part of this scope */ - public Scope members_field; + public WriteableScope members_field; /** the fully qualified name of the class, i.e. pck.outer.inner. * null for anonymous classes @@ -971,7 +971,7 @@ public abstract class Symbol extends AnnoConstruct implements Element { return flags_field; } - public Scope members() { + public WriteableScope members() { if (completer != null) complete(); return members_field; } @@ -1397,15 +1397,13 @@ public abstract class Symbol extends AnnoConstruct implements Element { public Symbol implementedIn(TypeSymbol c, Types types) { Symbol impl = null; - for (Scope.Entry e = c.members().lookup(name); - impl == null && e.scope != null; - e = e.next()) { - if (this.overrides(e.sym, (TypeSymbol)owner, types, true) && + for (Symbol sym : c.members().getSymbolsByName(name)) { + if (this.overrides(sym, (TypeSymbol)owner, types, true) && // FIXME: I suspect the following requires a // subst() for a parametric return type. types.isSameType(type.getReturnType(), - types.memberType(owner.type, e.sym).getReturnType())) { - impl = e.sym; + types.memberType(owner.type, sym).getReturnType())) { + impl = sym; } } return impl; @@ -1441,12 +1439,10 @@ public abstract class Symbol extends AnnoConstruct implements Element { */ public MethodSymbol binaryImplementation(ClassSymbol origin, Types types) { for (TypeSymbol c = origin; c != null; c = types.supertype(c.type).tsym) { - for (Scope.Entry e = c.members().lookup(name); - e.scope != null; - e = e.next()) { - if (e.sym.kind == MTH && - ((MethodSymbol)e.sym).binaryOverrides(this, origin, types)) - return (MethodSymbol)e.sym; + for (Symbol sym : c.members().getSymbolsByName(name)) { + if (sym.kind == MTH && + ((MethodSymbol)sym).binaryOverrides(this, origin, types)) + return (MethodSymbol)sym; } } return null; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java index 9ced8f07d83..be66abaa130 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java @@ -34,6 +34,7 @@ import javax.lang.model.element.ElementVisitor; import javax.tools.JavaFileObject; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.Completer; import com.sun.tools.javac.code.Symbol.CompletionFailure; @@ -396,7 +397,7 @@ public class Symtab { sym.completer = null; sym.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE; sym.erasure_field = type; - sym.members_field = new Scope(sym); + sym.members_field = WriteableScope.create(sym); type.typarams_field = List.nil(); type.allparams_field = List.nil(); type.supertype_field = annotationType; @@ -466,7 +467,7 @@ public class Symtab { // Create class to hold all predefined constants and operations. predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage); - Scope scope = new Scope(predefClass); + WriteableScope scope = WriteableScope.create(predefClass); predefClass.members_field = scope; // Get the initial completer for Symbols from the ClassFinder @@ -578,7 +579,7 @@ public class Symtab { ClassType arrayClassType = (ClassType)arrayClass.type; arrayClassType.supertype_field = objectType; arrayClassType.interfaces_field = List.of(cloneableType, serializableType); - arrayClass.members_field = new Scope(arrayClass); + arrayClass.members_field = WriteableScope.create(arrayClass); lengthVar = new VarSymbol( PUBLIC | FINAL, names.length, diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index bdda834d6a7..71e9745de86 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -403,7 +403,7 @@ public class Types { } final ListBuffer abstracts = new ListBuffer<>(); - for (Symbol sym : membersCache.getElements(new DescriptorFilter(origin))) { + for (Symbol sym : membersCache.getSymbols(new DescriptorFilter(origin))) { Type mtype = memberType(origin.type, sym); if (abstracts.isEmpty() || (sym.name == abstracts.first().name && @@ -633,7 +633,7 @@ public class Types { Type descType = findDescriptorType(targets.head); ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass()); csym.completer = null; - csym.members_field = new Scope(csym); + csym.members_field = WriteableScope.create(csym); MethodSymbol instDescSym = new MethodSymbol(descSym.flags(), descSym.name, descType, csym); csym.members_field.enter(instDescSym); Type.ClassType ctype = new Type.ClassType(Type.noType, List.nil(), csym, @@ -655,7 +655,7 @@ public class Types { Symbol descSym = findDescriptorSymbol(origin); CompoundScope members = membersClosure(origin.type, false); ListBuffer overridden = new ListBuffer<>(); - outer: for (Symbol m2 : members.getElementsByName(descSym.name, bridgeFilter)) { + outer: for (Symbol m2 : members.getSymbolsByName(descSym.name, bridgeFilter)) { if (m2 == descSym) continue; else if (descSym.overrides(m2, origin, Types.this, false)) { for (Symbol m3 : overridden) { @@ -2290,7 +2290,7 @@ public class Types { bc.erasure_field = (bounds.head.hasTag(TYPEVAR)) ? syms.objectType : // error condition, recover erasure(firstExplicitBound); - bc.members_field = new Scope(bc); + bc.members_field = WriteableScope.create(bc); return bc.type; } @@ -2619,8 +2619,8 @@ public class Types { } public boolean overridesObjectMethod(TypeSymbol origin, Symbol msym) { - for (Scope.Entry e = syms.objectType.tsym.members().lookup(msym.name) ; e.scope != null ; e = e.next()) { - if (msym.overrides(e.sym, origin, Types.this, true)) { + for (Symbol sym : syms.objectType.tsym.members().getSymbolsByName(msym.name)) { + if (msym.overrides(sym, origin, Types.this, true)) { return true; } } @@ -2680,12 +2680,10 @@ public class Types { while (t.hasTag(TYPEVAR)) t = t.getUpperBound(); TypeSymbol c = t.tsym; - for (Scope.Entry e = c.members().lookup(ms.name, implFilter); - e.scope != null; - e = e.next(implFilter)) { - if (e.sym != null && - e.sym.overrides(ms, origin, Types.this, checkResult)) - return (MethodSymbol)e.sym; + for (Symbol sym : c.members().getSymbolsByName(ms.name, implFilter)) { + if (sym != null && + sym.overrides(ms, origin, Types.this, checkResult)) + return (MethodSymbol)sym; } } return null; @@ -2742,11 +2740,11 @@ public class Types { CompoundScope membersClosure = new CompoundScope(csym); if (!skipInterface) { for (Type i : interfaces(t)) { - membersClosure.addSubScope(visit(i, skipInterface)); + membersClosure.prependSubScope(visit(i, skipInterface)); } } - membersClosure.addSubScope(visit(supertype(t), skipInterface)); - membersClosure.addSubScope(csym.members()); + membersClosure.prependSubScope(visit(supertype(t), skipInterface)); + membersClosure.prependSubScope(csym.members()); e = new Entry(skipInterface, membersClosure); _map.put(csym, e); } @@ -2775,7 +2773,7 @@ public class Types { public List interfaceCandidates(Type site, MethodSymbol ms) { Filter filter = new MethodFilter(ms, site); List candidates = List.nil(); - for (Symbol s : membersClosure(site, false).getElements(filter)) { + for (Symbol s : membersClosure(site, false).getSymbols(filter)) { if (!site.tsym.isInterface() && !s.owner.isInterface()) { return List.of((MethodSymbol)s); } else if (!candidates.contains(s)) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java index 296c98a913f..bbe532f0c2f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -690,7 +690,7 @@ public class Annotate { Scope scope = targetContainerType.tsym.members(); int nr_value_elems = 0; boolean error = false; - for(Symbol elm : scope.getElementsByName(names.value)) { + for(Symbol elm : scope.getSymbolsByName(names.value)) { nr_value_elems++; if (nr_value_elems == 1 && diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index fb17574a987..383dc806a77 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -37,6 +37,7 @@ import com.sun.source.tree.TreeVisitor; import com.sun.source.util.SimpleTreeVisitor; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Lint.LintCategory; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.comp.Check.CheckContext; @@ -618,14 +619,11 @@ public class Attr extends JCTree.Visitor { return newEnv; } - Scope copyScope(Scope sc) { - Scope newScope = new Scope(sc.owner); + WriteableScope copyScope(WriteableScope sc) { + WriteableScope newScope = WriteableScope.create(sc.owner); List elemsList = List.nil(); - while (sc != null) { - for (Scope.Entry e = sc.elems ; e != null ; e = e.sibling) { - elemsList = elemsList.prepend(e.sym); - } - sc = sc.next; + for (Symbol sym : sc.getSymbols()) { + elemsList = elemsList.prepend(sym); } for (Symbol s : elemsList) { newScope.enter(s); @@ -1140,12 +1138,12 @@ public class Attr extends JCTree.Visitor { // Block is a static or instance initializer; // let the owner of the environment be a freshly // created BLOCK-method. - final Env localEnv = - env.dup(tree, env.info.dup(env.info.scope.dupUnshared())); - localEnv.info.scope.owner = + Symbol fakeOwner = new MethodSymbol(tree.flags | BLOCK | env.info.scope.owner.flags() & STRICTFP, names.empty, null, env.info.scope.owner); + final Env localEnv = + env.dup(tree, env.info.dup(env.info.scope.dupUnshared(fakeOwner))); if ((tree.flags & STATIC) != 0) localEnv.info.staticLevel++; attribStats(tree.stats, localEnv); @@ -1328,7 +1326,7 @@ public class Attr extends JCTree.Visitor { } // where /** Add any variables defined in stats to the switch scope. */ - private static void addVars(List stats, Scope switchScope) { + private static void addVars(List stats, WriteableScope switchScope) { for (;stats.nonEmpty(); stats = stats.tail) { JCTree stat = stats.head; if (stat.hasTag(VARDEF)) @@ -1344,10 +1342,9 @@ public class Attr extends JCTree.Visitor { } JCIdent ident = (JCIdent)tree; Name name = ident.name; - for (Scope.Entry e = enumType.tsym.members().lookup(name); - e.scope != null; e = e.next()) { - if (e.sym.kind == VAR) { - Symbol s = ident.sym = e.sym; + for (Symbol sym : enumType.tsym.members().getSymbolsByName(name)) { + if (sym.kind == VAR) { + Symbol s = ident.sym = sym; ((VarSymbol)s).getConstValue(); // ensure initializer is evaluated ident.type = s.type; return ((s.flags_field & Flags.ENUM) == 0) @@ -2343,7 +2340,7 @@ public class Attr extends JCTree.Visitor { Symbol descriptor = types.findDescriptorSymbol(clazztype.tsym); int count = 0; boolean found = false; - for (Symbol sym : csym.members().getElements()) { + for (Symbol sym : csym.members().getSymbols()) { if ((sym.flags() & SYNTHETIC) != 0 || sym.isConstructor()) continue; count++; @@ -2774,15 +2771,15 @@ public class Attr extends JCTree.Visitor { Symbol owner = env.info.scope.owner; if (owner.kind == VAR && owner.owner.kind == TYP) { //field initializer - lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared())); ClassSymbol enclClass = owner.enclClass(); + Symbol newScopeOwner = env.info.scope.owner; /* if the field isn't static, then we can get the first constructor * and use it as the owner of the environment. This is what * LTM code is doing to look for type annotations so we are fine. */ if ((owner.flags() & STATIC) == 0) { - for (Symbol s : enclClass.members_field.getElementsByName(names.init)) { - lambdaEnv.info.scope.owner = s; + for (Symbol s : enclClass.members_field.getSymbolsByName(names.init)) { + newScopeOwner = s; break; } } else { @@ -2798,8 +2795,9 @@ public class Attr extends JCTree.Visitor { clinit.params = List.nil(); clinits.put(enclClass, clinit); } - lambdaEnv.info.scope.owner = clinit; + newScopeOwner = clinit; } + lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dupUnshared(newScopeOwner))); } else { lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup())); } @@ -4515,7 +4513,7 @@ public class Attr extends JCTree.Visitor { for (List l = tree.typarams; l.nonEmpty(); l = l.tail) { - Assert.checkNonNull(env.info.scope.lookup(l.head.name).scope); + Assert.checkNonNull(env.info.scope.findFirst(l.head.name)); } // Check that a generic class doesn't extend Throwable @@ -4602,16 +4600,21 @@ public class Attr extends JCTree.Visitor { private void checkSerialVersionUID(JCClassDecl tree, ClassSymbol c) { // check for presence of serialVersionUID - Scope.Entry e = c.members().lookup(names.serialVersionUID); - while (e.scope != null && e.sym.kind != VAR) e = e.next(); - if (e.scope == null) { + VarSymbol svuid = null; + for (Symbol sym : c.members().getSymbolsByName(names.serialVersionUID)) { + if (sym.kind == VAR) { + svuid = (VarSymbol)sym; + break; + } + } + + if (svuid == null) { log.warning(LintCategory.SERIAL, tree.pos(), "missing.SVUID", c); return; } // check that it is static final - VarSymbol svuid = (VarSymbol)e.sym; if ((svuid.flags() & (STATIC | FINAL)) != (STATIC | FINAL)) log.warning(LintCategory.SERIAL, diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java index 3ffda2453d8..b752075f113 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/AttrContext.java @@ -27,6 +27,7 @@ package com.sun.tools.javac.comp; import com.sun.tools.javac.util.*; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.WriteableScope; /** Contains information specific to the attribute and enter * passes, to be used in place of the generic field in environments. @@ -40,7 +41,7 @@ public class AttrContext { /** The scope of local symbols. */ - Scope scope = null; + WriteableScope scope = null; /** The number of enclosing `static' modifiers. */ @@ -87,7 +88,7 @@ public class AttrContext { /** Duplicate this context, replacing scope field and copying all others. */ - AttrContext dup(Scope scope) { + AttrContext dup(WriteableScope scope) { AttrContext info = new AttrContext(); info.scope = scope; info.staticLevel = staticLevel; @@ -112,7 +113,7 @@ public class AttrContext { public Iterable getLocalElements() { if (scope == null) return List.nil(); - return scope.getElements(); + return scope.getSymbols(); } boolean lastResolveVarargs() { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 44275993165..3bd195ae5bb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -28,6 +28,7 @@ package com.sun.tools.javac.comp; import java.util.*; import javax.tools.JavaFileManager; +import javax.tools.JavaFileObject; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Attribute.Compound; @@ -39,6 +40,8 @@ import com.sun.tools.javac.util.List; import com.sun.tools.javac.code.Lint; import com.sun.tools.javac.code.Lint.LintCategory; +import com.sun.tools.javac.code.Scope.NamedImportScope; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext; @@ -51,6 +54,7 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.ANNOTATION; import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.code.TypeTag.WILDCARD; @@ -362,16 +366,13 @@ public class Check { * @param s The scope. */ void checkTransparentVar(DiagnosticPosition pos, VarSymbol v, Scope s) { - if (s.next != null) { - for (Scope.Entry e = s.next.lookup(v.name); - e.scope != null && e.sym.owner == v.owner; - e = e.next()) { - if (e.sym.kind == VAR && - (e.sym.owner.kind & (VAR | MTH)) != 0 && - v.name != names.error) { - duplicateError(pos, e.sym); - return; - } + for (Symbol sym : s.getSymbolsByName(v.name)) { + if (sym.owner != v.owner) break; + if (sym.kind == VAR && + (sym.owner.kind & (VAR | MTH)) != 0 && + v.name != names.error) { + duplicateError(pos, sym); + return; } } } @@ -383,16 +384,13 @@ public class Check { * @param s The scope. */ void checkTransparentClass(DiagnosticPosition pos, ClassSymbol c, Scope s) { - if (s.next != null) { - for (Scope.Entry e = s.next.lookup(c.name); - e.scope != null && e.sym.owner == c.owner; - e = e.next()) { - if (e.sym.kind == TYP && !e.sym.type.hasTag(TYPEVAR) && - (e.sym.owner.kind & (VAR | MTH)) != 0 && - c.name != names.error) { - duplicateError(pos, e.sym); - return; - } + for (Symbol sym : s.getSymbolsByName(c.name)) { + if (sym.owner != c.owner) break; + if (sym.kind == TYP && !sym.type.hasTag(TYPEVAR) && + (sym.owner.kind & (VAR | MTH)) != 0 && + c.name != names.error) { + duplicateError(pos, sym); + return; } } } @@ -405,9 +403,9 @@ public class Check { * @param s The enclosing scope. */ boolean checkUniqueClassName(DiagnosticPosition pos, Name name, Scope s) { - for (Scope.Entry e = s.lookup(name); e.scope == s; e = e.next()) { - if (e.sym.kind == TYP && e.sym.name != names.error) { - duplicateError(pos, e.sym); + for (Symbol sym : s.getSymbolsByName(name, NON_RECURSIVE)) { + if (sym.kind == TYP && sym.name != names.error) { + duplicateError(pos, sym); return false; } } @@ -1778,10 +1776,7 @@ public class Check { for (Type t1 = sup; t1.hasTag(CLASS) && t1.tsym.type.isParameterized(); t1 = types.supertype(t1)) { - for (Scope.Entry e1 = t1.tsym.members().elems; - e1 != null; - e1 = e1.sibling) { - Symbol s1 = e1.sym; + for (Symbol s1 : t1.tsym.members().getSymbols(NON_RECURSIVE)) { if (s1.kind != MTH || (s1.flags() & (STATIC|SYNTHETIC|BRIDGE)) != 0 || !s1.isInheritedIn(site.tsym, types) || @@ -1796,10 +1791,7 @@ public class Check { for (Type t2 = sup; t2.hasTag(CLASS); t2 = types.supertype(t2)) { - for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); - e2.scope != null; - e2 = e2.next()) { - Symbol s2 = e2.sym; + for (Symbol s2 : t2.tsym.members().getSymbolsByName(s1.name)) { if (s2 == s1 || s2.kind != MTH || (s2.flags() & (STATIC|SYNTHETIC|BRIDGE)) != 0 || @@ -1893,15 +1885,13 @@ public class Check { /** Return the first method in t2 that conflicts with a method from t1. */ private Symbol firstDirectIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) { - for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; e1 = e1.sibling) { - Symbol s1 = e1.sym; + for (Symbol s1 : t1.tsym.members().getSymbols(NON_RECURSIVE)) { Type st1 = null; if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types) || (s1.flags() & SYNTHETIC) != 0) continue; Symbol impl = ((MethodSymbol)s1).implementation(site.tsym, types, false); if (impl != null && (impl.flags() & ABSTRACT) == 0) continue; - for (Scope.Entry e2 = t2.tsym.members().lookup(s1.name); e2.scope != null; e2 = e2.next()) { - Symbol s2 = e2.sym; + for (Symbol s2 : t2.tsym.members().getSymbolsByName(s1.name)) { if (s1 == s2) continue; if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types) || (s2.flags() & SYNTHETIC) != 0) continue; @@ -1944,8 +1934,7 @@ public class Check { Type st2 = types.memberType(site, s2); closure(site, supertypes); for (Type t : supertypes.values()) { - for (Scope.Entry e = t.tsym.members().lookup(s1.name); e.scope != null; e = e.next()) { - Symbol s3 = e.sym; + for (Symbol s3 : t.tsym.members().getSymbolsByName(s1.name)) { if (s3 == s1 || s3 == s2 || s3.kind != MTH || (s3.flags() & (BRIDGE|SYNTHETIC)) != 0) continue; Type st3 = types.memberType(site,s3); if (types.overrideEquivalent(st3, st1) && @@ -1995,14 +1984,12 @@ public class Check { void checkOverride(JCTree tree, Type site, ClassSymbol origin, MethodSymbol m) { TypeSymbol c = site.tsym; - Scope.Entry e = c.members().lookup(m.name); - while (e.scope != null) { - if (m.overrides(e.sym, origin, types, false)) { - if ((e.sym.flags() & ABSTRACT) == 0) { - checkOverride(tree, m, (MethodSymbol)e.sym, origin); + for (Symbol sym : c.members().getSymbolsByName(m.name)) { + if (m.overrides(sym, origin, types, false)) { + if ((sym.flags() & ABSTRACT) == 0) { + checkOverride(tree, m, (MethodSymbol)sym, origin); } } - e = e.next(); } } @@ -2037,9 +2024,9 @@ public class Check { ClassSymbol someClass) { if (lint.isEnabled(LintCategory.OVERRIDES)) { MethodSymbol equalsAtObject = (MethodSymbol)syms.objectType - .tsym.members().lookup(names.equals).sym; + .tsym.members().findFirst(names.equals); MethodSymbol hashCodeAtObject = (MethodSymbol)syms.objectType - .tsym.members().lookup(names.hashCode).sym; + .tsym.members().findFirst(names.hashCode); boolean overridesEquals = types.implementation(equalsAtObject, someClass, false, equalsHasCodeFilter).owner == someClass; boolean overridesHashCode = types.implementation(hashCodeAtObject, @@ -2095,12 +2082,10 @@ public class Check { // since they cannot have abstract members. if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) { Scope s = c.members(); - for (Scope.Entry e = s.elems; - undef == null && e != null; - e = e.sibling) { - if (e.sym.kind == MTH && - (e.sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) { - MethodSymbol absmeth = (MethodSymbol)e.sym; + for (Symbol sym : s.getSymbols(NON_RECURSIVE)) { + if (sym.kind == MTH && + (sym.flags() & (ABSTRACT|IPROXY|DEFAULT)) == ABSTRACT) { + MethodSymbol absmeth = (MethodSymbol)sym; MethodSymbol implmeth = absmeth.implementation(impl, types, true); if (implmeth == null || implmeth == absmeth) { //look for default implementations @@ -2113,6 +2098,7 @@ public class Check { } if (implmeth == null || implmeth == absmeth) { undef = absmeth; + break; } } } @@ -2336,10 +2322,10 @@ public class Check { for (List l = types.closure(ic.type); l.nonEmpty(); l = l.tail) { ClassSymbol lc = (ClassSymbol)l.head.tsym; if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) { - for (Scope.Entry e=lc.members().elems; e != null; e=e.sibling) { - if (e.sym.kind == MTH && - (e.sym.flags() & (STATIC|ABSTRACT)) == ABSTRACT) { - MethodSymbol absmeth = (MethodSymbol)e.sym; + for (Symbol sym : lc.members().getSymbols(NON_RECURSIVE)) { + if (sym.kind == MTH && + (sym.flags() & (STATIC|ABSTRACT)) == ABSTRACT) { + MethodSymbol absmeth = (MethodSymbol)sym; MethodSymbol implmeth = absmeth.implementation(origin, types, false); if (implmeth != null && implmeth != absmeth && (implmeth.owner.flags() & INTERFACE) == @@ -2382,15 +2368,15 @@ public class Check { void checkConflicts(DiagnosticPosition pos, Symbol sym, TypeSymbol c) { for (Type ct = c.type; ct != Type.noType ; ct = types.supertype(ct)) { - for (Scope.Entry e = ct.tsym.members().lookup(sym.name); e.scope == ct.tsym.members(); e = e.next()) { + for (Symbol sym2 : ct.tsym.members().getSymbolsByName(sym.name, NON_RECURSIVE)) { // VM allows methods and variables with differing types - if (sym.kind == e.sym.kind && - types.isSameType(types.erasure(sym.type), types.erasure(e.sym.type)) && - sym != e.sym && - (sym.flags() & Flags.SYNTHETIC) != (e.sym.flags() & Flags.SYNTHETIC) && - (sym.flags() & IPROXY) == 0 && (e.sym.flags() & IPROXY) == 0 && - (sym.flags() & BRIDGE) == 0 && (e.sym.flags() & BRIDGE) == 0) { - syntheticError(pos, (e.sym.flags() & SYNTHETIC) == 0 ? e.sym : sym); + if (sym.kind == sym2.kind && + types.isSameType(types.erasure(sym.type), types.erasure(sym2.type)) && + sym != sym2 && + (sym.flags() & Flags.SYNTHETIC) != (sym2.flags() & Flags.SYNTHETIC) && + (sym.flags() & IPROXY) == 0 && (sym2.flags() & IPROXY) == 0 && + (sym.flags() & BRIDGE) == 0 && (sym2.flags() & BRIDGE) == 0) { + syntheticError(pos, (sym2.flags() & SYNTHETIC) == 0 ? sym2 : sym); return; } } @@ -2411,7 +2397,7 @@ public class Check { List potentiallyAmbiguousList = List.nil(); boolean overridesAny = false; - for (Symbol m1 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { + for (Symbol m1 : types.membersClosure(site, false).getSymbolsByName(sym.name, cf)) { if (!sym.overrides(m1, site.tsym, types, false)) { if (m1 == sym) { continue; @@ -2429,7 +2415,7 @@ public class Check { } //...check each method m2 that is a member of 'site' - for (Symbol m2 : types.membersClosure(site, false).getElementsByName(sym.name, cf)) { + for (Symbol m2 : types.membersClosure(site, false).getSymbolsByName(sym.name, cf)) { if (m2 == m1) continue; //if (i) the signature of 'sym' is not a subsignature of m1 (seen as //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error @@ -2466,7 +2452,7 @@ public class Check { void checkHideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { ClashFilter cf = new ClashFilter(site); //for each method m1 that is a member of 'site'... - for (Symbol s : types.membersClosure(site, true).getElementsByName(sym.name, cf)) { + for (Symbol s : types.membersClosure(site, true).getSymbolsByName(sym.name, cf)) { //if (i) the signature of 'sym' is not a subsignature of m1 (seen as //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error if (!types.isSubSignature(sym.type, types.memberType(site, s), allowStrictMethodClashCheck)) { @@ -2508,7 +2494,7 @@ public class Check { void checkDefaultMethodClashes(DiagnosticPosition pos, Type site) { DefaultMethodClashFilter dcf = new DefaultMethodClashFilter(site); - for (Symbol m : types.membersClosure(site, false).getElements(dcf)) { + for (Symbol m : types.membersClosure(site, false).getSymbols(dcf)) { Assert.check(m.kind == MTH); List prov = types.interfaceCandidates(site, (MethodSymbol)m); if (prov.size() > 1) { @@ -2772,11 +2758,11 @@ public class Check { void validateAnnotationMethod(DiagnosticPosition pos, MethodSymbol m) { for (Type sup = syms.annotationType; sup.hasTag(CLASS); sup = types.supertype(sup)) { Scope s = sup.tsym.members(); - for (Scope.Entry e = s.lookup(m.name); e.scope != null; e = e.next()) { - if (e.sym.kind == MTH && - (e.sym.flags() & (PUBLIC | PROTECTED)) != 0 && - types.overrideEquivalent(m.type, e.sym.type)) - log.error(pos, "intf.annotation.member.clash", e.sym, sup); + for (Symbol sym : s.getSymbolsByName(m.name)) { + if (sym.kind == MTH && + (sym.flags() & (PUBLIC | PROTECTED)) != 0 && + types.overrideEquivalent(m.type, sym.type)) + log.error(pos, "intf.annotation.member.clash", sym, sup); } } } @@ -2856,9 +2842,9 @@ public class Check { } private void validateValue(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) { - Scope.Entry e = container.members().lookup(names.value); - if (e.scope != null && e.sym.kind == MTH) { - MethodSymbol m = (MethodSymbol) e.sym; + Symbol sym = container.members().findFirst(names.value); + if (sym != null && sym.kind == MTH) { + MethodSymbol m = (MethodSymbol) sym; Type ret = m.getReturnType(); if (!(ret.hasTag(ARRAY) && types.isSameType(((ArrayType)ret).elemtype, contained.type))) { log.error(pos, "invalid.repeatable.annotation.value.return", @@ -3003,7 +2989,7 @@ public class Check { private void validateDefault(Symbol container, DiagnosticPosition pos) { // validate that all other elements of containing type has defaults Scope scope = container.members(); - for(Symbol elm : scope.getElements()) { + for(Symbol elm : scope.getSymbols()) { if (elm.name != names.value && elm.kind == Kinds.MTH && ((MethodSymbol)elm).defaultValue == null) { @@ -3025,8 +3011,8 @@ public class Check { if (sup == owner.type) continue; // skip "this" Scope scope = sup.tsym.members(); - for (Scope.Entry e = scope.lookup(m.name); e.scope != null; e = e.next()) { - if (!e.sym.isStatic() && m.overrides(e.sym, owner, types, true)) + for (Symbol sym : scope.getSymbolsByName(m.name)) { + if (!sym.isStatic() && m.overrides(sym, owner, types, true)) return true; } } @@ -3160,12 +3146,10 @@ public class Check { boolean isValid = true; // collect an inventory of the annotation elements Set members = new LinkedHashSet<>(); - for (Scope.Entry e = a.annotationType.type.tsym.members().elems; - e != null; - e = e.sibling) - if (e.sym.kind == MTH && e.sym.name != names.clinit && - (e.sym.flags() & SYNTHETIC) == 0) - members.add((MethodSymbol) e.sym); + for (Symbol sym : a.annotationType.type.tsym.members().getSymbols(NON_RECURSIVE)) + if (sym.kind == MTH && sym.name != names.clinit && + (sym.flags() & SYNTHETIC) == 0) + members.add((MethodSymbol) sym); // remove the ones that are assigned values for (JCTree arg : a.args) { @@ -3293,8 +3277,7 @@ public class Check { } try { tsym.flags_field |= LOCKED; - for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { - Symbol s = e.sym; + for (Symbol s : tsym.members().getSymbols(NON_RECURSIVE)) { if (s.kind != Kinds.MTH) continue; checkAnnotationResType(pos, ((MethodSymbol)s).type.getReturnType()); @@ -3436,23 +3419,23 @@ public class Check { if (sym.type.isErroneous()) return true; if (sym.owner.name == names.any) return false; - for (Scope.Entry e = s.lookup(sym.name); e.scope == s; e = e.next()) { - if (sym != e.sym && - (e.sym.flags() & CLASH) == 0 && - sym.kind == e.sym.kind && + for (Symbol byName : s.getSymbolsByName(sym.name, NON_RECURSIVE)) { + if (sym != byName && + (byName.flags() & CLASH) == 0 && + sym.kind == byName.kind && sym.name != names.error && (sym.kind != MTH || - types.hasSameArgs(sym.type, e.sym.type) || - types.hasSameArgs(types.erasure(sym.type), types.erasure(e.sym.type)))) { - if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) { - varargsDuplicateError(pos, sym, e.sym); + types.hasSameArgs(sym.type, byName.type) || + types.hasSameArgs(types.erasure(sym.type), types.erasure(byName.type)))) { + if ((sym.flags() & VARARGS) != (byName.flags() & VARARGS)) { + varargsDuplicateError(pos, sym, byName); return true; - } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, e.sym.type, false)) { - duplicateErasureError(pos, sym, e.sym); + } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, byName.type, false)) { + duplicateErasureError(pos, sym, byName); sym.flags_field |= CLASH; return true; } else { - duplicateError(pos, e.sym); + duplicateError(pos, byName); return false; } } @@ -3471,47 +3454,50 @@ public class Check { /** Check that single-type import is not already imported or top-level defined, * but make an exception for two single-type imports which denote the same type. * @param pos Position for error reporting. + * @param toplevel The file in which in the check is performed. * @param sym The symbol. - * @param s The scope */ - boolean checkUniqueImport(DiagnosticPosition pos, Symbol sym, Scope s) { - return checkUniqueImport(pos, sym, s, false); + boolean checkUniqueImport(DiagnosticPosition pos, JCCompilationUnit toplevel, Symbol sym) { + return checkUniqueImport(pos, toplevel, sym, false); } /** Check that static single-type import is not already imported or top-level defined, * but make an exception for two single-type imports which denote the same type. * @param pos Position for error reporting. + * @param toplevel The file in which in the check is performed. * @param sym The symbol. - * @param s The scope */ - boolean checkUniqueStaticImport(DiagnosticPosition pos, Symbol sym, Scope s) { - return checkUniqueImport(pos, sym, s, true); + boolean checkUniqueStaticImport(DiagnosticPosition pos, JCCompilationUnit toplevel, Symbol sym) { + return checkUniqueImport(pos, toplevel, sym, true); } /** Check that single-type import is not already imported or top-level defined, * but make an exception for two single-type imports which denote the same type. * @param pos Position for error reporting. + * @param toplevel The file in which in the check is performed. * @param sym The symbol. - * @param s The scope. * @param staticImport Whether or not this was a static import */ - private boolean checkUniqueImport(DiagnosticPosition pos, Symbol sym, Scope s, boolean staticImport) { - for (Scope.Entry e = s.lookup(sym.name); e.scope != null; e = e.next()) { + private boolean checkUniqueImport(DiagnosticPosition pos, JCCompilationUnit toplevel, Symbol sym, boolean staticImport) { + NamedImportScope namedImportScope = toplevel.namedImportScope; + WriteableScope topLevelScope = toplevel.toplevelScope; + + for (Symbol byName : namedImportScope.getSymbolsByName(sym.name)) { // is encountered class entered via a class declaration? - boolean isClassDecl = e.scope == s; - if ((isClassDecl || sym != e.sym) && - sym.kind == e.sym.kind && + boolean isClassDecl = namedImportScope.getOrigin(byName) == topLevelScope; + if ((isClassDecl || sym != byName) && + sym.kind == byName.kind && sym.name != names.error && - (!staticImport || !e.isStaticallyImported())) { - if (!e.sym.type.isErroneous()) { + (!staticImport || !namedImportScope.isStaticallyImported(byName))) { + if (!byName.type.isErroneous()) { if (!isClassDecl) { if (staticImport) - log.error(pos, "already.defined.static.single.import", e.sym); + log.error(pos, "already.defined.static.single.import", byName); else - log.error(pos, "already.defined.single.import", e.sym); + log.error(pos, "already.defined.single.import", byName); } - else if (sym != e.sym) - log.error(pos, "already.defined.this.unit", e.sym); + else if (sym != byName) + log.error(pos, "already.defined.this.unit", byName); } return false; } @@ -3610,4 +3596,68 @@ public class Check { } } } + + public void checkImportsResolvable(final JCCompilationUnit toplevel) { + for (final JCImport imp : toplevel.getImports()) { + if (!imp.staticImport || !imp.qualid.hasTag(SELECT)) + continue; + final JCFieldAccess select = (JCFieldAccess) imp.qualid; + final Symbol origin; + if (select.name == names.asterisk || (origin = TreeInfo.symbol(select.selected)) == null || origin.kind != TYP) + continue; + + JavaFileObject prev = log.useSource(toplevel.sourcefile); + try { + TypeSymbol site = (TypeSymbol) TreeInfo.symbol(select.selected); + if (!checkTypeContainsImportableElement(site, site, toplevel.packge, select.name, new HashSet())) { + log.error(imp.pos(), "cant.resolve.location", + KindName.STATIC, + select.name, List.nil(), List.nil(), + Kinds.typeKindName(TreeInfo.symbol(select.selected).type), + TreeInfo.symbol(select.selected).type); + } + } finally { + log.useSource(prev); + } + } + } + + private boolean checkTypeContainsImportableElement(TypeSymbol tsym, TypeSymbol origin, PackageSymbol packge, Name name, Set processed) { + if (tsym == null || !processed.add(tsym)) + return false; + + // also search through inherited names + if (checkTypeContainsImportableElement(types.supertype(tsym.type).tsym, origin, packge, name, processed)) + return true; + + for (Type t : types.interfaces(tsym.type)) + if (checkTypeContainsImportableElement(t.tsym, origin, packge, name, processed)) + return true; + + for (Symbol sym : tsym.members().getSymbolsByName(name)) { + if (sym.isStatic() && + staticImportAccessible(sym, packge) && + sym.isMemberOf(origin, types)) { + return true; + } + } + + return false; + } + + // is the sym accessible everywhere in packge? + public boolean staticImportAccessible(Symbol sym, PackageSymbol packge) { + int flags = (int)(sym.flags() & AccessFlags); + switch (flags) { + default: + case PUBLIC: + return true; + case PRIVATE: + return false; + case 0: + case PROTECTED: + return sym.packge() == packge; + } + } + } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 9275ea4429b..4aec32a7ea0 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -376,9 +376,8 @@ public class DeferredAttr extends JCTree.Visitor { ResultInfo resultInfo, Annotate.PositionCreator creator) { final JCTree newTree = new TreeCopier<>(make).copy(tree); - Env speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared())); + Env speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared(env.info.scope.owner))); speculativeEnv.info.isSpeculative = true; - speculativeEnv.info.scope.owner = env.info.scope.owner; Log.DeferredDiagnosticHandler deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log, new Filter() { public boolean accepts(final JCDiagnostic d) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java index 03448a80a9b..69d37f7b7c9 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java @@ -191,7 +191,7 @@ public class Enter extends JCTree.Visitor { */ public Env classEnv(JCClassDecl tree, Env env) { Env localEnv = - env.dup(tree, env.info.dup(new Scope(tree.sym))); + env.dup(tree, env.info.dup(WriteableScope.create(tree.sym))); localEnv.enclClass = tree; localEnv.outer = env; localEnv.info.isSelfCall = false; @@ -207,9 +207,10 @@ public class Enter extends JCTree.Visitor { Env localEnv = new Env<>(tree, new AttrContext()); localEnv.toplevel = tree; localEnv.enclClass = predefClassDef; - tree.namedImportScope = new ImportScope(tree.packge); + tree.toplevelScope = WriteableScope.create(tree.packge); + tree.namedImportScope = new NamedImportScope(tree.packge, tree.toplevelScope); tree.starImportScope = new StarImportScope(tree.packge); - localEnv.info.scope = tree.namedImportScope; + localEnv.info.scope = tree.toplevelScope; localEnv.info.lint = lint; return localEnv; } @@ -218,7 +219,7 @@ public class Enter extends JCTree.Visitor { Env localEnv = new Env<>(tree, new AttrContext()); localEnv.toplevel = tree; localEnv.enclClass = predefClassDef; - localEnv.info.scope = tree.namedImportScope; + localEnv.info.scope = tree.toplevelScope; localEnv.info.lint = lint; return localEnv; } @@ -228,7 +229,7 @@ public class Enter extends JCTree.Visitor { * where the local scope is for type variables, and the this and super symbol * only, and members go into the class member scope. */ - Scope enterScope(Env env) { + WriteableScope enterScope(Env env) { return (env.tree.hasTag(JCTree.Tag.CLASSDEF)) ? ((JCClassDecl) env.tree).sym.members_field : env.info.scope; @@ -324,7 +325,7 @@ public class Enter extends JCTree.Visitor { c.flatname = names.fromString(tree.packge + "." + name); c.sourcefile = tree.sourcefile; c.completer = null; - c.members_field = new Scope(c); + c.members_field = WriteableScope.create(c); tree.packge.package_info = c; } classEnter(tree.defs, topEnv); @@ -338,7 +339,7 @@ public class Enter extends JCTree.Visitor { @Override public void visitClassDef(JCClassDecl tree) { Symbol owner = env.info.scope.owner; - Scope enclScope = enterScope(env); + WriteableScope enclScope = enterScope(env); ClassSymbol c; if (owner.kind == PCK) { // We are seeing a toplevel class. @@ -392,7 +393,7 @@ public class Enter extends JCTree.Visitor { c.completer = memberEnter; c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); c.sourcefile = env.toplevel.sourcefile; - c.members_field = new Scope(c); + c.members_field = WriteableScope.create(c); ClassType ct = (ClassType)c.type; if (owner.kind != PCK && (c.flags_field & STATIC) == 0) { @@ -495,7 +496,7 @@ public class Enter extends JCTree.Visitor { // if there remain any unimported toplevels (these must have // no classes at all), process their import statements as well. for (JCCompilationUnit tree : trees) { - if (tree.starImportScope.elems == null) { + if (tree.starImportScope.isEmpty()) { JavaFileObject prev = log.useSource(tree.sourcefile); Env topEnv = topLevelEnv(tree); memberEnter.memberEnter(tree, topEnv); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index a9e13874512..84f67abcac1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -30,6 +30,7 @@ package com.sun.tools.javac.comp; import java.util.HashMap; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; @@ -1419,7 +1420,7 @@ public class Flow { /** The list of unreferenced automatic resources. */ - Scope unrefdResources; + WriteableScope unrefdResources; /** Set when processing a loop body the second time for DU analysis. */ FlowKind flowKind = FlowKind.NORMAL; @@ -2410,7 +2411,7 @@ public class Flow { nextadr = 0; pendingExits = new ListBuffer<>(); this.classDef = null; - unrefdResources = new Scope(env.enclClass.sym); + unrefdResources = WriteableScope.create(env.enclClass.sym); scan(tree); } finally { // note that recursive invocations of this method fail hard diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index b222285d75a..df9f8b9ba8f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -31,7 +31,7 @@ import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.tree.TreeTranslator; import com.sun.tools.javac.code.Attribute; import com.sun.tools.javac.code.Kinds; -import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.DynamicMethodSymbol; @@ -448,7 +448,7 @@ public class LambdaToMethod extends TreeTranslator { make.at(prevPos); } // Replace the entered symbol for this variable - Scope sc = tree.sym.owner.members(); + WriteableScope sc = tree.sym.owner.members(); if (sc != null) { sc.remove(tree.sym); sc.enter(xsym); @@ -1475,7 +1475,7 @@ public class LambdaToMethod extends TreeTranslator { return clinit; } else { //get the first constructor and treat it as the instance init sym - for (Symbol s : csym.members_field.getElementsByName(names.init)) { + for (Symbol s : csym.members_field.getSymbolsByName(names.init)) { return s; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 933c790e82a..62016b4dcd5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -28,6 +28,7 @@ package com.sun.tools.javac.comp; import java.util.*; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.main.Option.PkgInfo; import com.sun.tools.javac.tree.*; @@ -45,6 +46,7 @@ import com.sun.tools.javac.tree.EndPosTable; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -299,7 +301,7 @@ public class Lower extends TreeTranslator { Symbol sym = _sym; if (sym.kind == VAR || sym.kind == MTH) { while (sym != null && sym.owner != owner) - sym = proxies.lookup(proxyName(sym.name)).sym; + sym = proxies.findFirst(proxyName(sym.name)); if (sym != null && sym.owner == owner) { VarSymbol v = (VarSymbol)sym; if (v.getConstValue() == null) { @@ -644,7 +646,7 @@ public class Lower extends TreeTranslator { } c.sourcefile = owner.sourcefile; c.completer = null; - c.members_field = new Scope(c); + c.members_field = WriteableScope.create(c); c.flags_field = flags; ClassType ctype = (ClassType) c.type; ctype.supertype_field = syms.objectType; @@ -678,7 +680,7 @@ public class Lower extends TreeTranslator { * @param sym The symbol. * @param s The scope. */ - private void enterSynthetic(DiagnosticPosition pos, Symbol sym, Scope s) { + private void enterSynthetic(DiagnosticPosition pos, Symbol sym, WriteableScope s) { s.enter(sym); } @@ -746,7 +748,7 @@ public class Lower extends TreeTranslator { * @param name The name. */ private Symbol lookupSynthetic(Name name, Scope s) { - Symbol sym = s.lookup(name).sym; + Symbol sym = s.findFirst(name); return (sym==null || (sym.flags()&SYNTHETIC)==0) ? null : sym; } @@ -901,11 +903,9 @@ public class Lower extends TreeTranslator { /** Return binary operator that corresponds to given access code. */ private OperatorSymbol binaryAccessOperator(int acode) { - for (Scope.Entry e = syms.predefClass.members().elems; - e != null; - e = e.sibling) { - if (e.sym instanceof OperatorSymbol) { - OperatorSymbol op = (OperatorSymbol)e.sym; + for (Symbol sym : syms.predefClass.members().getSymbols(NON_RECURSIVE)) { + if (sym instanceof OperatorSymbol) { + OperatorSymbol op = (OperatorSymbol)sym; if (accessCode(op.opcode) == acode) return op; } } @@ -1143,7 +1143,7 @@ public class Lower extends TreeTranslator { return makeLit(sym.type, cv); } // Otherwise replace the variable by its proxy. - sym = proxies.lookup(proxyName(sym.name)).sym; + sym = proxies.findFirst(proxyName(sym.name)); Assert.check(sym != null && (sym.flags_field & FINAL) != 0); tree = make.at(tree.pos).Ident(sym); } @@ -1459,12 +1459,12 @@ public class Lower extends TreeTranslator { * in an additional innermost scope, where they represent the constructor * parameters. */ - Scope proxies; + WriteableScope proxies; /** A scope containing all unnamed resource variables/saved * exception variables for translated TWR blocks */ - Scope twrVars; + WriteableScope twrVars; /** A stack containing the this$n field of the currently translated * classes (if needed) in innermost first order. @@ -1519,7 +1519,7 @@ public class Lower extends TreeTranslator { nestingLevel++; } Name result = names.fromString("this" + target.syntheticNameChar() + nestingLevel); - while (owner.kind == TYP && ((ClassSymbol)owner).members().lookup(result).scope != null) + while (owner.kind == TYP && ((ClassSymbol)owner).members().findFirst(result) != null) result = names.fromString(result.toString() + target.syntheticNameChar()); return result; } @@ -1859,10 +1859,10 @@ public class Lower extends TreeTranslator { * name is the name of a free variable. */ JCStatement initField(int pos, Name name) { - Scope.Entry e = proxies.lookup(name); - Symbol rhs = e.sym; + Iterator it = proxies.getSymbolsByName(name).iterator(); + Symbol rhs = it.next(); Assert.check(rhs.owner.kind == MTH); - Symbol lhs = e.next().sym; + Symbol lhs = it.next(); Assert.check(rhs.owner.owner == lhs.owner); make.at(pos); return @@ -1903,10 +1903,10 @@ public class Lower extends TreeTranslator { if ((clazz.flags() & INTERFACE) == 0 && !target.useInnerCacheClass()) return clazz; Scope s = clazz.members(); - for (Scope.Entry e = s.elems; e != null; e = e.sibling) - if (e.sym.kind == TYP && - e.sym.name == names.empty && - (e.sym.flags() & INTERFACE) == 0) return (ClassSymbol) e.sym; + for (Symbol sym : s.getSymbols(NON_RECURSIVE)) + if (sym.kind == TYP && + sym.name == names.empty && + (sym.flags() & INTERFACE) == 0) return (ClassSymbol) sym; return makeEmptyClass(STATIC | SYNTHETIC, clazz).sym; } @@ -2574,7 +2574,7 @@ public class Lower extends TreeTranslator { // private static final T[] #VALUES = { a, b, c }; Name valuesName = names.fromString(target.syntheticNameChar() + "VALUES"); - while (tree.sym.members().lookup(valuesName).scope != null) // avoid name clash + while (tree.sym.members().findFirst(valuesName) != null) // avoid name clash valuesName = names.fromString(valuesName + "" + target.syntheticNameChar()); Type arrayType = new ArrayType(types.erasure(tree.type), syms.arrayClass, Type.noAnnotations); @@ -2602,7 +2602,7 @@ public class Lower extends TreeTranslator { } else { // template: T[] $result = new T[$values.length]; Name resultName = names.fromString(target.syntheticNameChar() + "result"); - while (tree.sym.members().lookup(resultName).scope != null) // avoid name clash + while (tree.sym.members().findFirst(resultName) != null) // avoid name clash resultName = names.fromString(resultName + "" + target.syntheticNameChar()); VarSymbol resultVar = new VarSymbol(FINAL|SYNTHETIC, resultName, @@ -2683,8 +2683,7 @@ public class Lower extends TreeTranslator { private MethodSymbol systemArraycopyMethod; private boolean useClone() { try { - Scope.Entry e = syms.objectType.tsym.members().lookup(names.clone); - return (e.sym != null); + return syms.objectType.tsym.members().findFirst(names.clone) != null; } catch (CompletionFailure e) { return false; @@ -2786,7 +2785,7 @@ public class Lower extends TreeTranslator { final Name pName = proxyName(l.head.name); m.capturedLocals = m.capturedLocals.append((VarSymbol) - (proxies.lookup(pName).sym)); + (proxies.findFirst(pName))); added = added.prepend( initField(tree.body.pos, pName)); } @@ -3969,8 +3968,8 @@ public class Lower extends TreeTranslator { classdefs = new HashMap<>(); actualSymbols = new HashMap<>(); freevarCache = new HashMap<>(); - proxies = new Scope(syms.noSymbol); - twrVars = new Scope(syms.noSymbol); + proxies = WriteableScope.create(syms.noSymbol); + twrVars = WriteableScope.create(syms.noSymbol); outerThisStack = List.nil(); accessNums = new HashMap<>(); accessSyms = new HashMap<>(); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index dfdcaee0acc..9e7037cf4f3 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -25,12 +25,18 @@ package com.sun.tools.javac.comp; +import java.util.Collections; import java.util.HashSet; +import java.util.IdentityHashMap; import java.util.Set; import javax.tools.JavaFileObject; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.ImportFilter; +import com.sun.tools.javac.code.Scope.NamedImportScope; +import com.sun.tools.javac.code.Scope.StarImportScope; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.util.*; @@ -43,6 +49,7 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.ANNOTATION; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.ERROR; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; @@ -151,7 +158,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { final TypeSymbol tsym, Env env) { // Check that packages imported from exist (JLS ???). - if (tsym.kind == PCK && tsym.members().elems == null && !tsym.exists()) { + if (tsym.kind == PCK && tsym.members().isEmpty() && !tsym.exists()) { // If we can't find java.lang, exit immediately. if (((PackageSymbol)tsym).fullname.equals(names.java_lang)) { JCDiagnostic msg = diags.fragment("fatal.err.no.java.lang"); @@ -160,7 +167,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { log.error(DiagnosticFlag.RESOLVE_ERROR, pos, "doesnt.exist", tsym); } } - env.toplevel.starImportScope.importAll(tsym.members()); + env.toplevel.starImportScope.importAll(tsym.members(), tsym.members(), typeImportFilter, false); } /** Import all static members of a class or package on demand. @@ -171,82 +178,16 @@ public class MemberEnter extends JCTree.Visitor implements Completer { private void importStaticAll(int pos, final TypeSymbol tsym, Env env) { - final JavaFileObject sourcefile = env.toplevel.sourcefile; - final Scope toScope = env.toplevel.starImportScope; + final StarImportScope toScope = env.toplevel.starImportScope; final PackageSymbol packge = env.toplevel.packge; final TypeSymbol origin = tsym; // enter imported types immediately - new Object() { - Set processed = new HashSet<>(); - void importFrom(TypeSymbol tsym) { - if (tsym == null || !processed.add(tsym)) - return; - - // also import inherited names - importFrom(types.supertype(tsym.type).tsym); - for (Type t : types.interfaces(tsym.type)) - importFrom(t.tsym); - - final Scope fromScope = tsym.members(); - for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { - Symbol sym = e.sym; - if (sym.kind == TYP && - (sym.flags() & STATIC) != 0 && - staticImportAccessible(sym, packge) && - sym.isMemberOf(origin, types) && - !toScope.includes(sym)) - toScope.enter(sym, fromScope, origin.members(), true); - } + new SymbolImporter() { + void doImport(TypeSymbol tsym) { + toScope.importAll(tsym.members(), origin.members(), staticImportFilter, true); } }.importFrom(tsym); - - // enter non-types before annotations that might use them - annotate.earlier(new Annotate.Worker() { - Set processed = new HashSet<>(); - - public String toString() { - return "import static " + tsym + ".*" + " in " + sourcefile; - } - void importFrom(TypeSymbol tsym) { - if (tsym == null || !processed.add(tsym)) - return; - - // also import inherited names - importFrom(types.supertype(tsym.type).tsym); - for (Type t : types.interfaces(tsym.type)) - importFrom(t.tsym); - - final Scope fromScope = tsym.members(); - for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { - Symbol sym = e.sym; - if (sym.isStatic() && sym.kind != TYP && - staticImportAccessible(sym, packge) && - !toScope.includes(sym) && - sym.isMemberOf(origin, types)) { - toScope.enter(sym, fromScope, origin.members(), true); - } - } - } - public void run() { - importFrom(tsym); - } - }); - } - - // is the sym accessible everywhere in packge? - boolean staticImportAccessible(Symbol sym, PackageSymbol packge) { - int flags = (int)(sym.flags() & AccessFlags); - switch (flags) { - default: - case PUBLIC: - return true; - case PRIVATE: - return false; - case 0: - case PROTECTED: - return sym.packge() == packge; - } } /** Import statics types of a given name. Non-types are handled in Attr. @@ -265,44 +206,47 @@ public class MemberEnter extends JCTree.Visitor implements Completer { return; } - final Scope toScope = env.toplevel.namedImportScope; - final PackageSymbol packge = env.toplevel.packge; - final TypeSymbol origin = tsym; + final NamedImportScope toScope = env.toplevel.namedImportScope; + final Scope originMembers = tsym.members(); // enter imported types immediately - new Object() { - Set processed = new HashSet<>(); - void importFrom(TypeSymbol tsym) { - if (tsym == null || !processed.add(tsym)) - return; - - // also import inherited names - importFrom(types.supertype(tsym.type).tsym); - for (Type t : types.interfaces(tsym.type)) - importFrom(t.tsym); - - for (Scope.Entry e = tsym.members().lookup(name); - e.scope != null; - e = e.next()) { - Symbol sym = e.sym; - if (sym.isStatic() && - sym.kind == TYP && - staticImportAccessible(sym, packge) && - sym.isMemberOf(origin, types) && - chk.checkUniqueStaticImport(pos, sym, toScope)) - toScope.enter(sym, sym.owner.members(), origin.members(), true); + new SymbolImporter() { + void doImport(TypeSymbol tsym) { + Set maskedOut = null; + for (Symbol sym : tsym.members().getSymbolsByName(name)) { + if (sym.kind == TYP && + staticImportFilter.accepts(originMembers, sym) && + !chk.checkUniqueStaticImport(pos, env.toplevel, sym)) { + if (maskedOut == null) + maskedOut = Collections.newSetFromMap(new IdentityHashMap()); + maskedOut.add(sym); + } } + ImportFilter importFilter = maskedOut != null ? + new MaskedImportFilter(staticImportFilter, maskedOut) : + staticImportFilter; + toScope.importByName(tsym.members(), originMembers, name, importFilter); } }.importFrom(tsym); + } + //where: + class MaskedImportFilter implements ImportFilter { - // enter non-types before annotations that might use them - annotate.earlier(new Annotate.Worker() { - Set processed = new HashSet<>(); - boolean found = false; + private final ImportFilter delegate; + private final Set maskedOut; - public String toString() { - return "import static " + tsym + "." + name; + public MaskedImportFilter(ImportFilter delegate, Set maskedOut) { + this.delegate = delegate; + this.maskedOut = maskedOut; } + + @Override + public boolean accepts(Scope origin, Symbol sym) { + return !maskedOut.contains(sym) && delegate.accepts(origin, sym); + } + } + abstract class SymbolImporter { + Set processed = new HashSet<>(); void importFrom(TypeSymbol tsym) { if (tsym == null || !processed.add(tsym)) return; @@ -312,47 +256,21 @@ public class MemberEnter extends JCTree.Visitor implements Completer { for (Type t : types.interfaces(tsym.type)) importFrom(t.tsym); - for (Scope.Entry e = tsym.members().lookup(name); - e.scope != null; - e = e.next()) { - Symbol sym = e.sym; - if (sym.isStatic() && - staticImportAccessible(sym, packge) && - sym.isMemberOf(origin, types)) { - found = true; - if (sym.kind != TYP) { - toScope.enter(sym, sym.owner.members(), origin.members(), true); - } - } - } + doImport(tsym); } - public void run() { - JavaFileObject prev = log.useSource(env.toplevel.sourcefile); - try { - importFrom(tsym); - if (!found) { - log.error(pos, "cant.resolve.location", - KindName.STATIC, - name, List.nil(), List.nil(), - Kinds.typeKindName(tsym.type), - tsym.type); - } - } finally { - log.useSource(prev); - } - } - }); - } + abstract void doImport(TypeSymbol tsym); + } + /** Import given class. * @param pos Position to be used for error reporting. * @param tsym The class to be imported. * @param env The environment containing the named import * scope to add to. */ - private void importNamed(DiagnosticPosition pos, Symbol tsym, Env env) { + private void importNamed(DiagnosticPosition pos, final Symbol tsym, Env env) { if (tsym.kind == TYP && - chk.checkUniqueImport(pos, tsym, env.toplevel.namedImportScope)) - env.toplevel.namedImportScope.enter(tsym, tsym.owner.members()); + chk.checkUniqueImport(pos, env.toplevel, tsym)) + env.toplevel.namedImportScope.importType(tsym.owner.members(), tsym.owner.members(), tsym); } /** Construct method type from method signature. @@ -482,6 +400,32 @@ public class MemberEnter extends JCTree.Visitor implements Completer { * Visitor methods for member enter *********************************************************************/ + ImportFilter staticImportFilter; + ImportFilter typeImportFilter = new ImportFilter() { + @Override + public boolean accepts(Scope origin, Symbol t) { + return t.kind == Kinds.TYP; + } + }; + + protected void memberEnter(JCCompilationUnit tree, Env env) { + ImportFilter prevStaticImportFilter = staticImportFilter; + try { + final PackageSymbol packge = env.toplevel.packge; + this.staticImportFilter = new ImportFilter() { + @Override + public boolean accepts(Scope origin, Symbol sym) { + return sym.isStatic() && + chk.staticImportAccessible(sym, packge) && + sym.isMemberOf((TypeSymbol) origin.owner, types); + } + }; + memberEnter((JCTree) tree, env); + } finally { + this.staticImportFilter = prevStaticImportFilter; + } + } + /** Visitor argument: the current environment */ protected Env env; @@ -570,7 +514,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } public void visitTopLevel(JCCompilationUnit tree) { - if (tree.starImportScope.elems != null) { + if (!tree.starImportScope.isEmpty()) { // we must have already processed this toplevel return; } @@ -640,7 +584,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { } public void visitMethodDef(JCMethodDecl tree) { - Scope enclScope = enter.enterScope(env); + WriteableScope enclScope = enter.enterScope(env); MethodSymbol m = new MethodSymbol(0, tree.name, null, enclScope.owner); m.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, m, tree); tree.sym = m; @@ -696,9 +640,8 @@ public class MemberEnter extends JCTree.Visitor implements Completer { */ Env methodEnv(JCMethodDecl tree, Env env) { Env localEnv = - env.dup(tree, env.info.dup(env.info.scope.dupUnshared())); + env.dup(tree, env.info.dup(env.info.scope.dupUnshared(tree.sym))); localEnv.enclMethod = tree; - localEnv.info.scope.owner = tree.sym; if (tree.sym.type != null) { //when this is called in the enter stage, there's no type to be set localEnv.info.returnResult = attr.new ResultInfo(VAL, tree.sym.type.getReturnType()); @@ -739,7 +682,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { ArrayType atype = (ArrayType)tree.vartype.type; tree.vartype.type = atype.makeVarargs(); } - Scope enclScope = enter.enterScope(env); + WriteableScope enclScope = enter.enterScope(env); VarSymbol v = new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); @@ -875,8 +818,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { Env initEnv(JCVariableDecl tree, Env env) { Env localEnv = env.dupto(new AttrContextEnv(tree, env.info.dup())); if (tree.sym.owner.kind == TYP) { - localEnv.info.scope = env.info.scope.dupUnshared(); - localEnv.info.scope.owner = tree.sym; + localEnv.info.scope = env.info.scope.dupUnshared(tree.sym); } if ((tree.mods.flags & STATIC) != 0 || ((env.enclClass.sym.flags() & INTERFACE) != 0 && env.enclMethod == null)) @@ -1220,23 +1162,30 @@ public class MemberEnter extends JCTree.Visitor implements Completer { // Enter all member fields and methods of a set of half completed // classes in a second phase. if (wasFirst) { + Set topLevels = new HashSet<>(); try { while (halfcompleted.nonEmpty()) { Env toFinish = halfcompleted.next(); + topLevels.add(toFinish.toplevel); finish(toFinish); } } finally { isFirst = true; } + + for (JCCompilationUnit toplevel : topLevels) { + chk.checkImportsResolvable(toplevel); + } + } } private Env baseEnv(JCClassDecl tree, Env env) { - Scope baseScope = new Scope(tree.sym); + WriteableScope baseScope = WriteableScope.create(tree.sym); //import already entered local classes into base scope - for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) { - if (e.sym.isLocal()) { - baseScope.enter(e.sym); + for (Symbol sym : env.outer.info.scope.getSymbols(NON_RECURSIVE)) { + if (sym.isLocal()) { + baseScope.enter(sym); } } //import current type-parameters into base scope diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index bd0da8637e1..30754afdb33 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -28,6 +28,7 @@ package com.sun.tools.javac.comp; import com.sun.source.tree.MemberReferenceTree.ReferenceMode; import com.sun.tools.javac.api.Formattable.LocalizedString; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.comp.Attr.ResultInfo; @@ -100,7 +101,7 @@ public class Resolve { private final boolean compactMethodDiags; final EnumSet verboseResolutionMode; - Scope polymorphicSignatureScope; + WriteableScope polymorphicSignatureScope; protected Resolve(Context context) { context.put(resolveKey, this); @@ -139,7 +140,7 @@ public class Resolve { allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); checkVarargsAccessAfterResolution = source.allowPostApplicabilityVarargsAccessCheck(); - polymorphicSignatureScope = new Scope(syms.noSymbol); + polymorphicSignatureScope = WriteableScope.create(syms.noSymbol); inapplicableMethodException = new InapplicableMethodException(diags); } @@ -1299,13 +1300,11 @@ public class Resolve { c = c.type.getUpperBound().tsym; Symbol bestSoFar = varNotFound; Symbol sym; - Scope.Entry e = c.members().lookup(name); - while (e.scope != null) { - if (e.sym.kind == VAR && (e.sym.flags_field & SYNTHETIC) == 0) { - return isAccessible(env, site, e.sym) - ? e.sym : new AccessError(env, site, e.sym); + for (Symbol s : c.members().getSymbolsByName(name)) { + if (s.kind == VAR && (s.flags_field & SYNTHETIC) == 0) { + return isAccessible(env, site, s) + ? s : new AccessError(env, site, s); } - e = e.next(); } Type st = types.supertype(c.type); if (st != null && (st.hasTag(CLASS) || st.hasTag(TYPEVAR))) { @@ -1348,20 +1347,20 @@ public class Resolve { */ Symbol findVar(Env env, Name name) { Symbol bestSoFar = varNotFound; - Symbol sym; Env env1 = env; boolean staticOnly = false; while (env1.outer != null) { + Symbol sym = null; if (isStatic(env1)) staticOnly = true; - Scope.Entry e = env1.info.scope.lookup(name); - while (e.scope != null && - (e.sym.kind != VAR || - (e.sym.flags_field & SYNTHETIC) != 0)) - e = e.next(); - sym = (e.scope != null) - ? e.sym - : findField( - env1, env1.enclClass.sym.type, name, env1.enclClass.sym); + for (Symbol s : env1.info.scope.getSymbolsByName(name)) { + if (s.kind == VAR && (s.flags_field & SYNTHETIC) == 0) { + sym = s; + break; + } + } + if (sym == null) { + sym = findField(env1, env1.enclClass.sym.type, name, env1.enclClass.sym); + } if (sym.exists()) { if (staticOnly && sym.kind == VAR && @@ -1378,7 +1377,7 @@ public class Resolve { env1 = env1.outer; } - sym = findField(env, syms.predefClass.type, name, syms.predefClass); + Symbol sym = findField(env, syms.predefClass.type, name, syms.predefClass); if (sym.exists()) return sym; if (bestSoFar.exists()) @@ -1386,18 +1385,16 @@ public class Resolve { Symbol origin = null; for (Scope sc : new Scope[] { env.toplevel.namedImportScope, env.toplevel.starImportScope }) { - Scope.Entry e = sc.lookup(name); - for (; e.scope != null; e = e.next()) { - sym = e.sym; - if (sym.kind != VAR) + for (Symbol currentSymbol : sc.getSymbolsByName(name)) { + if (currentSymbol.kind != VAR) continue; // invariant: sym.kind == VAR - if (bestSoFar.kind < AMBIGUOUS && sym.owner != bestSoFar.owner) - return new AmbiguityError(bestSoFar, sym); + if (bestSoFar.kind < AMBIGUOUS && currentSymbol.owner != bestSoFar.owner) + return new AmbiguityError(bestSoFar, currentSymbol); else if (bestSoFar.kind >= VAR) { - origin = e.getOrigin().owner; - bestSoFar = isAccessible(env, origin.type, sym) - ? sym : new AccessError(env, origin.type, sym); + origin = sc.getOrigin(currentSymbol).owner; + bestSoFar = isAccessible(env, origin.type, currentSymbol) + ? currentSymbol : new AccessError(env, origin.type, currentSymbol); } } if (bestSoFar.exists()) break; @@ -1627,7 +1624,7 @@ public class Resolve { boolean useVarargs, boolean operator, boolean abstractok) { - for (Symbol s : sc.getElementsByName(name, new LookupFilter(abstractok))) { + for (Symbol s : sc.getSymbolsByName(name, new LookupFilter(abstractok))) { bestSoFar = selectBest(env, site, argtypes, typeargtypes, s, bestSoFar, allowBoxing, useVarargs, operator); } @@ -1827,12 +1824,11 @@ public class Resolve { List argtypes, List typeargtypes, boolean allowBoxing, boolean useVarargs) { Symbol bestSoFar = methodNotFound; - Symbol sym; Env env1 = env; boolean staticOnly = false; while (env1.outer != null) { if (isStatic(env1)) staticOnly = true; - sym = findMethod( + Symbol sym = findMethod( env1, env1.enclClass.sym.type, name, argtypes, typeargtypes, allowBoxing, useVarargs, false); if (sym.exists()) { @@ -1848,41 +1844,37 @@ public class Resolve { env1 = env1.outer; } - sym = findMethod(env, syms.predefClass.type, name, argtypes, - typeargtypes, allowBoxing, useVarargs, false); + Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes, + typeargtypes, allowBoxing, useVarargs, false); if (sym.exists()) return sym; - Scope.Entry e = env.toplevel.namedImportScope.lookup(name); - for (; e.scope != null; e = e.next()) { - sym = e.sym; - Type origin = e.getOrigin().owner.type; - if (sym.kind == MTH) { - if (e.sym.owner.type != origin) - sym = sym.clone(e.getOrigin().owner); - if (!isAccessible(env, origin, sym)) - sym = new AccessError(env, origin, sym); - bestSoFar = selectBest(env, origin, + for (Symbol currentSym : env.toplevel.namedImportScope.getSymbolsByName(name)) { + Symbol origin = env.toplevel.namedImportScope.getOrigin(currentSym).owner; + if (currentSym.kind == MTH) { + if (currentSym.owner.type != origin.type) + currentSym = currentSym.clone(origin); + if (!isAccessible(env, origin.type, currentSym)) + currentSym = new AccessError(env, origin.type, currentSym); + bestSoFar = selectBest(env, origin.type, argtypes, typeargtypes, - sym, bestSoFar, + currentSym, bestSoFar, allowBoxing, useVarargs, false); } } if (bestSoFar.exists()) return bestSoFar; - e = env.toplevel.starImportScope.lookup(name); - for (; e.scope != null; e = e.next()) { - sym = e.sym; - Type origin = e.getOrigin().owner.type; - if (sym.kind == MTH) { - if (e.sym.owner.type != origin) - sym = sym.clone(e.getOrigin().owner); - if (!isAccessible(env, origin, sym)) - sym = new AccessError(env, origin, sym); - bestSoFar = selectBest(env, origin, + for (Symbol currentSym : env.toplevel.starImportScope.getSymbolsByName(name)) { + Symbol origin = env.toplevel.starImportScope.getOrigin(currentSym).owner; + if (currentSym.kind == MTH) { + if (currentSym.owner.type != origin.type) + currentSym = currentSym.clone(origin); + if (!isAccessible(env, origin.type, currentSym)) + currentSym = new AccessError(env, origin.type, currentSym); + bestSoFar = selectBest(env, origin.type, argtypes, typeargtypes, - sym, bestSoFar, + currentSym, bestSoFar, allowBoxing, useVarargs, false); } } @@ -1921,14 +1913,12 @@ public class Resolve { Type site, Name name, TypeSymbol c) { - Scope.Entry e = c.members().lookup(name); - while (e.scope != null) { - if (e.sym.kind == TYP) { - return isAccessible(env, site, e.sym) - ? e.sym - : new AccessError(env, site, e.sym); + for (Symbol sym : c.members().getSymbolsByName(name)) { + if (sym.kind == TYP) { + return isAccessible(env, site, sym) + ? sym + : new AccessError(env, site, sym); } - e = e.next(); } return typeNotFound; } @@ -1995,8 +1985,8 @@ public class Resolve { */ Symbol findGlobalType(Env env, Scope scope, Name name) { Symbol bestSoFar = typeNotFound; - for (Scope.Entry e = scope.lookup(name); e.scope != null; e = e.next()) { - Symbol sym = loadClass(env, e.sym.flatName()); + for (Symbol s : scope.getSymbolsByName(name)) { + Symbol sym = loadClass(env, s.flatName()); if (bestSoFar.kind == TYP && sym.kind == TYP && bestSoFar != sym) return new AmbiguityError(bestSoFar, sym); @@ -2007,15 +1997,13 @@ public class Resolve { } Symbol findTypeVar(Env env, Name name, boolean staticOnly) { - for (Scope.Entry e = env.info.scope.lookup(name); - e.scope != null; - e = e.next()) { - if (e.sym.kind == TYP) { + for (Symbol sym : env.info.scope.getSymbolsByName(name)) { + if (sym.kind == TYP) { if (staticOnly && - e.sym.type.hasTag(TYPEVAR) && - e.sym.owner.kind == TYP) - return new StaticError(e.sym); - return e.sym; + sym.type.hasTag(TYPEVAR) && + sym.owner.kind == TYP) + return new StaticError(sym); + return sym; } } return typeNotFound; @@ -2322,42 +2310,6 @@ public class Resolve { kindName(sym), sym, sym.location()); } -/* *************************************************************************** - * Debugging - ****************************************************************************/ - - /** print all scopes starting with scope s and proceeding outwards. - * used for debugging. - */ - public void printscopes(Scope s) { - while (s != null) { - if (s.owner != null) - System.err.print(s.owner + ": "); - for (Scope.Entry e = s.elems; e != null; e = e.sibling) { - if ((e.sym.flags() & ABSTRACT) != 0) - System.err.print("abstract "); - System.err.print(e.sym + " "); - } - System.err.println(); - s = s.next; - } - } - - void printscopes(Env env) { - while (env.outer != null) { - System.err.println("------------------------------"); - printscopes(env.info.scope); - env = env.outer; - } - } - - public void printscopes(Type t) { - while (t.hasTag(CLASS)) { - printscopes(t.tsym.members()); - t = types.supertype(t); - } - } - /* *************************************************************************** * Name resolution * Naming conventions are as for symbol lookup @@ -2456,7 +2408,7 @@ public class Resolve { List argtypes) { Type mtype = infer.instantiatePolymorphicSignatureInstance(env, (MethodSymbol)spMethod, currentResolutionContext, argtypes); - for (Symbol sym : polymorphicSignatureScope.getElementsByName(spMethod.name)) { + for (Symbol sym : polymorphicSignatureScope.getSymbolsByName(spMethod.name)) { if (types.isSameType(mtype, sym.type)) { return sym; } @@ -2629,14 +2581,11 @@ public class Resolve { boolean allowBoxing, boolean useVarargs) { Symbol bestSoFar = methodNotFound; - for (Scope.Entry e = site.tsym.members().lookup(names.init); - e.scope != null; - e = e.next()) { - final Symbol sym = e.sym; + for (final Symbol sym : site.tsym.members().getSymbolsByName(names.init)) { //- System.out.println(" e " + e.sym); if (sym.kind == MTH && (sym.flags_field & SYNTHETIC) == 0) { - List oldParams = e.sym.type.hasTag(FORALL) ? + List oldParams = sym.type.hasTag(FORALL) ? ((ForAll)sym.type).tvars : List.nil(); Type constrType = new ForAll(site.tsym.type.getTypeArguments().appendList(oldParams), @@ -3252,7 +3201,7 @@ public class Resolve { @Override protected Symbol lookup(Env env, MethodResolutionPhase phase) { - Scope sc = new Scope(syms.arrayClass); + WriteableScope sc = WriteableScope.create(syms.arrayClass); MethodSymbol arrayConstr = new MethodSymbol(PUBLIC, name, null, site.tsym); arrayConstr.type = new MethodType(List.of(syms.intType), site, List.nil(), syms.methodClass); sc.enter(arrayConstr); @@ -3362,7 +3311,7 @@ public class Resolve { while (env1.outer != null) { if (isStatic(env1)) staticOnly = true; if (env1.enclClass.sym == c) { - Symbol sym = env1.info.scope.lookup(name).sym; + Symbol sym = env1.info.scope.findFirst(name); if (sym != null) { if (staticOnly) sym = new StaticError(sym); return accessBase(sym, pos, env.enclClass.sym.type, @@ -3449,7 +3398,7 @@ public class Resolve { while (env1 != null && env1.outer != null) { if (isStatic(env1)) staticOnly = true; if (env1.enclClass.sym.isSubClass(member.owner, types)) { - Symbol sym = env1.info.scope.lookup(name).sym; + Symbol sym = env1.info.scope.findFirst(name); if (sym != null) { if (staticOnly) sym = new StaticError(sym); return sym; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index 780c788c4dd..9bc36893cae 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -37,6 +37,7 @@ import com.sun.tools.javac.util.List; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; import static com.sun.tools.javac.code.TypeTag.VOID; @@ -449,8 +450,8 @@ public class TransTypes extends TreeTranslator { TypeSymbol i, ClassSymbol origin, ListBuffer bridges) { - for (Scope.Entry e = i.members().elems; e != null; e = e.sibling) - addBridgeIfNeeded(pos, e.sym, origin, bridges); + for (Symbol sym : i.members().getSymbols(NON_RECURSIVE)) + addBridgeIfNeeded(pos, sym, origin, bridges); for (List l = types.interfaces(i.type); l.nonEmpty(); l = l.tail) addBridges(pos, l.head.tsym, origin, bridges); } @@ -529,14 +530,12 @@ public class TransTypes extends TreeTranslator { } // Check that we do not introduce a name clash by erasing types. - for (Scope.Entry e = tree.sym.owner.members().lookup(tree.name); - e.sym != null; - e = e.next()) { - if (e.sym != tree.sym && - types.isSameType(erasure(e.sym.type), tree.type)) { + for (Symbol sym : tree.sym.owner.members().getSymbolsByName(tree.name)) { + if (sym != tree.sym && + types.isSameType(erasure(sym.type), tree.type)) { log.error(tree.pos(), "name.clash.same.erasure", tree.sym, - e.sym); + sym); return; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index bc610a2b6ee..55a7f199a0b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -42,6 +42,7 @@ import com.sun.tools.javac.comp.Annotate; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Lint.LintCategory; import com.sun.tools.javac.code.Type.*; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.file.BaseFileObject; @@ -141,7 +142,7 @@ public class ClassReader { /** The current scope where type variables are entered. */ - protected Scope typevars; + protected WriteableScope typevars; /** The path name of the class file currently being read. */ @@ -231,7 +232,7 @@ public class ClassReader { profile = Profile.instance(context); - typevars = new Scope(syms.noSymbol); + typevars = WriteableScope.create(syms.noSymbol); lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE); @@ -832,9 +833,9 @@ public class ClassReader { /** Find type variable with given name in `typevars' scope. */ Type findTypeVar(Name name) { - Scope.Entry e = typevars.lookup(name); - if (e.scope != null) { - return e.sym.type; + Symbol s = typevars.findFirst(name); + if (s != null) { + return s.type; } else { if (readingClassAttr) { // While reading the class attribute, the supertypes @@ -1228,9 +1229,10 @@ public class ClassReader { MethodType type = nt.uniqueType.type.asMethodType(); - for (Scope.Entry e = scope.lookup(nt.name); e.scope != null; e = e.next()) - if (e.sym.kind == MTH && isSameBinaryType(e.sym.type.asMethodType(), type)) - return (MethodSymbol)e.sym; + for (Symbol sym : scope.getSymbolsByName(nt.name)) { + if (sym.kind == MTH && isSameBinaryType(sym.type.asMethodType(), type)) + return (MethodSymbol)sym; + } if (nt.name != names.init) // not a constructor @@ -1769,10 +1771,7 @@ public class ClassReader { MethodSymbol findAccessMethod(Type container, Name name) { CompletionFailure failure = null; try { - for (Scope.Entry e = container.tsym.members().lookup(name); - e.scope != null; - e = e.next()) { - Symbol sym = e.sym; + for (Symbol sym : container.tsym.members().getSymbolsByName(name)) { if (sym.kind == MTH && sym.type.getParameterTypes().length() == 0) return (MethodSymbol) sym; } @@ -1852,11 +1851,9 @@ public class ClassReader { VarSymbol enumerator = null; CompletionFailure failure = null; try { - for (Scope.Entry e = enumTypeSym.members().lookup(proxy.enumerator); - e.scope != null; - e = e.next()) { - if (e.sym.kind == VAR) { - enumerator = (VarSymbol)e.sym; + for (Symbol sym : enumTypeSym.members().getSymbolsByName(proxy.enumerator)) { + if (sym.kind == VAR) { + enumerator = (VarSymbol)sym; break; } } @@ -2197,7 +2194,7 @@ public class ClassReader { ClassType ct = (ClassType)c.type; // allocate scope for members - c.members_field = new Scope(c); + c.members_field = WriteableScope.create(c); // prepare type variable table typevars = typevars.dup(currentOwner); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 5eebcc21cc9..51fadaf90c1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -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 @@ -49,6 +49,7 @@ import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.jvm.UninitializedType.*; import static com.sun.tools.javac.main.Option.*; @@ -1563,12 +1564,12 @@ public class ClassWriter extends ClassFile { } } - void writeFields(Scope.Entry e) { + void writeFields(Scope s) { // process them in reverse sibling order; // i.e., process them in declaration order. List vars = List.nil(); - for (Scope.Entry i = e; i != null; i = i.sibling) { - if (i.sym.kind == VAR) vars = vars.prepend((VarSymbol)i.sym); + for (Symbol sym : s.getSymbols(NON_RECURSIVE)) { + if (sym.kind == VAR) vars = vars.prepend((VarSymbol)sym); } while (vars.nonEmpty()) { writeField(vars.head); @@ -1576,11 +1577,11 @@ public class ClassWriter extends ClassFile { } } - void writeMethods(Scope.Entry e) { + void writeMethods(Scope s) { List methods = List.nil(); - for (Scope.Entry i = e; i != null; i = i.sibling) { - if (i.sym.kind == MTH && (i.sym.flags() & HYPOTHETICAL) == 0) - methods = methods.prepend((MethodSymbol)i.sym); + for (Symbol sym : s.getSymbols(NON_RECURSIVE)) { + if (sym.kind == MTH && (sym.flags() & HYPOTHETICAL) == 0) + methods = methods.prepend((MethodSymbol)sym); } while (methods.nonEmpty()) { writeMethod(methods.head); @@ -1654,12 +1655,12 @@ public class ClassWriter extends ClassFile { databuf.appendChar(pool.put(l.head.tsym)); int fieldsCount = 0; int methodsCount = 0; - for (Scope.Entry e = c.members().elems; e != null; e = e.sibling) { - switch (e.sym.kind) { + for (Symbol sym : c.members().getSymbols(NON_RECURSIVE)) { + switch (sym.kind) { case VAR: fieldsCount++; break; - case MTH: if ((e.sym.flags() & HYPOTHETICAL) == 0) methodsCount++; + case MTH: if ((sym.flags() & HYPOTHETICAL) == 0) methodsCount++; break; - case TYP: enterInner((ClassSymbol)e.sym); break; + case TYP: enterInner((ClassSymbol)sym); break; default : Assert.error(); } } @@ -1671,9 +1672,9 @@ public class ClassWriter extends ClassFile { } databuf.appendChar(fieldsCount); - writeFields(c.members().elems); + writeFields(c.members()); databuf.appendChar(methodsCount); - writeMethods(c.members().elems); + writeMethods(c.members()); int acountIdx = beginAttrs(); int acount = 0; diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 1eb989d81ec..56afb51b603 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -45,6 +45,7 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.jvm.CRTFlags.*; @@ -302,7 +303,7 @@ public class Gen extends JCTree.Visitor { if (!target.interfaceObjectOverridesBinaryCompatibility()) { if ((sym.owner.flags() & INTERFACE) != 0 && - syms.objectType.tsym.members().lookup(sym.name).scope != null) + syms.objectType.tsym.members().findFirst(sym.name) != null) return sym; } @@ -651,13 +652,10 @@ public class Gen extends JCTree.Visitor { void implementInterfaceMethods(ClassSymbol c, ClassSymbol site) { for (List l = types.interfaces(c.type); l.nonEmpty(); l = l.tail) { ClassSymbol i = (ClassSymbol)l.head.tsym; - for (Scope.Entry e = i.members().elems; - e != null; - e = e.sibling) - { - if (e.sym.kind == MTH && (e.sym.flags() & STATIC) == 0) + for (Symbol sym : i.members().getSymbols(NON_RECURSIVE)) { + if (sym.kind == MTH && (sym.flags() & STATIC) == 0) { - MethodSymbol absMeth = (MethodSymbol)e.sym; + MethodSymbol absMeth = (MethodSymbol)sym; MethodSymbol implMeth = absMeth.binaryImplementation(site, types); if (implMeth == null) addAbstractMethod(site, absMeth); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java index f91c5c3189b..41fb62138dc 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java @@ -37,7 +37,6 @@ import javax.tools.StandardLocation; import com.sun.tools.javac.code.Attribute; import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Scope; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; @@ -53,6 +52,7 @@ import com.sun.tools.javac.util.Pair; import static com.sun.tools.javac.main.Option.*; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; /** This class provides operations to write native header files for classes. * @@ -146,8 +146,7 @@ public class JNIWriter { if (c.isLocal() || isSynthetic(c)) return false; - for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { - Symbol sym = i.sym; + for (Symbol sym : c.members_field.getSymbols(NON_RECURSIVE)) { if (sym.kind == MTH && isNative(sym)) return true; for (Attribute.Compound a: sym.getDeclarationAttributes()) { @@ -156,8 +155,7 @@ public class JNIWriter { } } if (checkNestedClasses) { - for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { - Symbol sym = i.sym; + for (Symbol sym : c.members_field.getSymbols(NON_RECURSIVE)) { if ((sym.kind == TYP) && needsHeader(((ClassSymbol) sym), true)) return true; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java b/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java index 48e9d9726c2..34f515b4b12 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -43,6 +43,7 @@ import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.ArrayType; import com.sun.tools.javac.util.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; /** * A generator of dynamic proxy implementations of @@ -119,9 +120,9 @@ public class AnnotationProxyMaker { // First find the default values. ClassSymbol sym = (ClassSymbol) anno.type.tsym; - for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { - if (e.sym.kind == Kinds.MTH) { - MethodSymbol m = (MethodSymbol) e.sym; + for (Symbol s : sym.members().getSymbols(NON_RECURSIVE)) { + if (s.kind == Kinds.MTH) { + MethodSymbol m = (MethodSymbol) s; Attribute def = m.getDefaultValue(); if (def != null) res.put(m, def); diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/FilteredMemberList.java b/langtools/src/share/classes/com/sun/tools/javac/model/FilteredMemberList.java index 59b3e607851..eeb7fe70b37 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/FilteredMemberList.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/FilteredMemberList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,11 +27,12 @@ package com.sun.tools.javac.model; import java.util.AbstractList; import java.util.Iterator; -import java.util.NoSuchElementException; import com.sun.tools.javac.code.Scope; import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.util.Filter; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; /** * Utility to construct a view of a symbol's members, @@ -53,56 +54,28 @@ public class FilteredMemberList extends AbstractList { public int size() { int cnt = 0; - for (Scope.Entry e = scope.elems; e != null; e = e.sibling) { - if (!unwanted(e.sym)) + for (Symbol sym : scope.getSymbols(NON_RECURSIVE)) { + if (!unwanted(sym)) cnt++; } return cnt; } public Symbol get(int index) { - for (Scope.Entry e = scope.elems; e != null; e = e.sibling) { - if (!unwanted(e.sym) && (index-- == 0)) - return e.sym; + for (Symbol sym : scope.getSymbols(NON_RECURSIVE)) { + if (!unwanted(sym) && (index-- == 0)) + return sym; } throw new IndexOutOfBoundsException(); } // A more efficient implementation than AbstractList's. public Iterator iterator() { - return new Iterator() { - - /** The next entry to examine, or null if none. */ - private Scope.Entry nextEntry = scope.elems; - - private boolean hasNextForSure = false; - - public boolean hasNext() { - if (hasNextForSure) { - return true; - } - while (nextEntry != null && unwanted(nextEntry.sym)) { - nextEntry = nextEntry.sibling; - } - hasNextForSure = (nextEntry != null); - return hasNextForSure; + return scope.getSymbols(new Filter() { + public boolean accepts(Symbol t) { + return !unwanted(t); } - - public Symbol next() { - if (hasNext()) { - Symbol result = nextEntry.sym; - nextEntry = nextEntry.sibling; - hasNextForSure = false; - return result; - } else { - throw new NoSuchElementException(); - } - } - - public void remove() { - throw new UnsupportedOperationException(); - } - }; + }, NON_RECURSIVE).iterator(); } /** diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java index f04fb38c83d..2e451782674 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java @@ -35,6 +35,7 @@ import javax.tools.JavaFileObject; import static javax.lang.model.util.ElementFilter.methodsIn; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.comp.AttrContext; import com.sun.tools.javac.comp.Enter; @@ -47,6 +48,7 @@ import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.Name; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -356,35 +358,31 @@ public class JavacElements implements Elements { */ public FilteredMemberList getAllMembers(TypeElement element) { Symbol sym = cast(Symbol.class, element); - Scope scope = sym.members().dupUnshared(); + WriteableScope scope = sym.members().dupUnshared(); List closure = types.closure(sym.asType()); for (Type t : closure) addMembers(scope, t); return new FilteredMemberList(scope); } // where - private void addMembers(Scope scope, Type type) { + private void addMembers(WriteableScope scope, Type type) { members: - for (Scope.Entry e = type.asElement().members().elems; e != null; e = e.sibling) { - Scope.Entry overrider = scope.lookup(e.sym.getSimpleName()); - while (overrider.scope != null) { - if (overrider.sym.kind == e.sym.kind - && (overrider.sym.flags() & Flags.SYNTHETIC) == 0) - { - if (overrider.sym.getKind() == ElementKind.METHOD - && overrides((ExecutableElement)overrider.sym, (ExecutableElement)e.sym, (TypeElement)type.asElement())) { + for (Symbol e : type.asElement().members().getSymbols(NON_RECURSIVE)) { + for (Symbol overrider : scope.getSymbolsByName(e.getSimpleName())) { + if (overrider.kind == e.kind && (overrider.flags() & Flags.SYNTHETIC) == 0) { + if (overrider.getKind() == ElementKind.METHOD && + overrides((ExecutableElement)overrider, (ExecutableElement)e, (TypeElement)type.asElement())) { continue members; } } - overrider = overrider.next(); } - boolean derived = e.sym.getEnclosingElement() != scope.owner; - ElementKind kind = e.sym.getKind(); + boolean derived = e.getEnclosingElement() != scope.owner; + ElementKind kind = e.getKind(); boolean initializer = kind == ElementKind.CONSTRUCTOR || kind == ElementKind.INSTANCE_INIT || kind == ElementKind.STATIC_INIT; - if (!derived || (!initializer && e.sym.isInheritedIn(scope.owner, types))) - scope.enter(e.sym); + if (!derived || (!initializer && e.isInheritedIn(scope.owner, types))) + scope.enter(e); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java index f968a903de4..148e9b736ae 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java @@ -310,9 +310,9 @@ public class JavacTypes implements javax.lang.model.util.Types { for (Type t : types.closure(origin.type)) { if (t != origin.type) { ClassSymbol c = (ClassSymbol) t.tsym; - for (Scope.Entry e = c.members().lookup(m.name); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.MTH && m.overrides(e.sym, origin, types, true)) { - results.add((MethodSymbol) e.sym); + for (Symbol sym : c.members().getSymbolsByName(m.name)) { + if (sym.kind == Kinds.MTH && m.overrides(sym, origin, types, true)) { + results.add((MethodSymbol) sym); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java index 589032f06ae..33852a99c0f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java +++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java @@ -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,7 +27,7 @@ package com.sun.tools.javac.sym; import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.code.Kinds; -import com.sun.tools.javac.code.Scope; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Attribute; @@ -189,7 +189,7 @@ public class CreateSymbols extends AbstractProcessor { new Attribute.Compound(syms.proprietaryType, List.>nil()); Attribute.Compound[] profileAnnos = new Attribute.Compound[profiles.getProfileCount() + 1]; - Symbol.MethodSymbol profileValue = (MethodSymbol) syms.profileType.tsym.members().lookup(names.value).sym; + Symbol.MethodSymbol profileValue = (MethodSymbol) syms.profileType.tsym.members().findFirst(names.value); for (int i = 1; i < profileAnnos.length; i++) { profileAnnos[i] = new Attribute.Compound(syms.profileType, List.>of( @@ -259,9 +259,9 @@ public class CreateSymbols extends AbstractProcessor { pool.reset(); cs.pool = pool; writer.writeClass(cs); - for (Scope.Entry e = cs.members().elems; e != null; e = e.sibling) { - if (e.sym.kind == Kinds.TYP) { - ClassSymbol nestedClass = (ClassSymbol)e.sym; + for (Symbol sym : cs.members().getSymbols(NON_RECURSIVE)) { + if (sym.kind == Kinds.TYP) { + ClassSymbol nestedClass = (ClassSymbol)sym; nestedClass.complete(); writeClass(pool, nestedClass, writer); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java index f68a2f061f1..1ec7b2b4c1f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -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 @@ -488,8 +488,10 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { public JavaFileObject sourcefile; /** The package to which this compilation unit belongs. */ public PackageSymbol packge; + /** A scope containing top level classes. */ + public WriteableScope toplevelScope; /** A scope for all named imports. */ - public ImportScope namedImportScope; + public NamedImportScope namedImportScope; /** A scope for all import-on-demands. */ public StarImportScope starImportScope; /** Line starting positions, defined only if option -g is set. */ diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java index a4f9923400c..58e370c3608 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java @@ -25,6 +25,8 @@ package com.sun.tools.javac.tree; +import java.util.Iterator; + import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; @@ -978,24 +980,26 @@ public class TreeMaker implements JCTree.Factory { sym.owner.kind == MTH || sym.owner.kind == VAR) { return true; } else if (sym.kind == TYP && toplevel != null) { - Scope.Entry e; - e = toplevel.namedImportScope.lookup(sym.name); - if (e.scope != null) { + Iterator it = toplevel.namedImportScope.getSymbolsByName(sym.name).iterator(); + if (it.hasNext()) { + Symbol s = it.next(); return - e.sym == sym && - e.next().scope == null; + s == sym && + !it.hasNext(); } - e = toplevel.packge.members().lookup(sym.name); - if (e.scope != null) { + it = toplevel.packge.members().getSymbolsByName(sym.name).iterator(); + if (it.hasNext()) { + Symbol s = it.next(); return - e.sym == sym && - e.next().scope == null; + s == sym && + !it.hasNext(); } - e = toplevel.starImportScope.lookup(sym.name); - if (e.scope != null) { + it = toplevel.starImportScope.getSymbolsByName(sym.name).iterator(); + if (it.hasNext()) { + Symbol s = it.next(); return - e.sym == sym && - e.next().scope == null; + s == sym && + !it.hasNext(); } } return false; diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java index 032b5f70912..0e487b6f1fd 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java @@ -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 @@ -29,10 +29,12 @@ import com.sun.javadoc.*; import com.sun.source.util.TreePath; import com.sun.tools.javac.code.Kinds; -import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.util.List; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; + /** * Represents an annotation type. * @@ -91,9 +93,9 @@ public class AnnotationTypeDocImpl */ public AnnotationTypeElementDoc[] elements() { List elements = List.nil(); - for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { - if (e.sym != null && e.sym.kind == Kinds.MTH) { - MethodSymbol s = (MethodSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { + if (sym != null && sym.kind == Kinds.MTH) { + MethodSymbol s = (MethodSymbol)sym; elements = elements.prepend(env.getAnnotationTypeElementDoc(s)); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java index f9fcaa74864..66ef27e5f7d 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java @@ -59,6 +59,7 @@ import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Position; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -589,9 +590,9 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { */ private FieldDoc[] fields(boolean filter, boolean enumConstants) { List fields = List.nil(); - for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { - if (e.sym != null && e.sym.kind == VAR) { - VarSymbol s = (VarSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { + if (sym != null && sym.kind == VAR) { + VarSymbol s = (VarSymbol)sym; boolean isEnum = ((s.flags() & Flags.ENUM) != 0) && !env.legacyDoclet; if (isEnum == enumConstants && @@ -614,12 +615,12 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { public MethodDoc[] methods(boolean filter) { Names names = tsym.name.table.names; List methods = List.nil(); - for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { - if (e.sym != null - && e.sym.kind == Kinds.MTH - && e.sym.name != names.init - && e.sym.name != names.clinit) { - MethodSymbol s = (MethodSymbol)e.sym; + for (Symbol sym :tsym.members().getSymbols(NON_RECURSIVE)) { + if (sym != null + && sym.kind == Kinds.MTH + && sym.name != names.init + && sym.name != names.clinit) { + MethodSymbol s = (MethodSymbol)sym; if (!filter || env.shouldDocument(s)) { methods = methods.prepend(env.getMethodDoc(s)); } @@ -649,10 +650,10 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { public ConstructorDoc[] constructors(boolean filter) { Names names = tsym.name.table.names; List constructors = List.nil(); - for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { - if (e.sym != null && - e.sym.kind == Kinds.MTH && e.sym.name == names.init) { - MethodSymbol s = (MethodSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { + if (sym != null && + sym.kind == Kinds.MTH && sym.name == names.init) { + MethodSymbol s = (MethodSymbol)sym; if (!filter || env.shouldDocument(s)) { constructors = constructors.prepend(env.getConstructorDoc(s)); } @@ -685,10 +686,9 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { if (l.contains(this)) return; l.append(this); List more = List.nil(); - for (Scope.Entry e = tsym.members().elems; e != null; - e = e.sibling) { - if (e.sym != null && e.sym.kind == Kinds.TYP) { - ClassSymbol s = (ClassSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { + if (sym != null && sym.kind == Kinds.TYP) { + ClassSymbol s = (ClassSymbol)sym; ClassDocImpl c = env.getClassDoc(s); if (c.isSynthetic()) continue; if (c != null) more = more.prepend(c); @@ -713,9 +713,9 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { */ public ClassDoc[] innerClasses(boolean filter) { ListBuffer innerClasses = new ListBuffer<>(); - for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) { - if (e.sym != null && e.sym.kind == Kinds.TYP) { - ClassSymbol s = (ClassSymbol)e.sym; + for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { + if (sym != null && sym.kind == Kinds.TYP) { + ClassSymbol s = (ClassSymbol)sym; if ((s.flags_field & Flags.SYNTHETIC) != 0) continue; if (!filter || env.isVisible(s)) { innerClasses.prepend(env.getClassDoc(s)); @@ -809,17 +809,17 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { if (compenv == null) return null; Scope s = compenv.toplevel.namedImportScope; - for (Scope.Entry e = s.lookup(names.fromString(className)); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.TYP) { - ClassDoc c = env.getClassDoc((ClassSymbol)e.sym); + for (Symbol sym : s.getSymbolsByName(names.fromString(className))) { + if (sym.kind == Kinds.TYP) { + ClassDoc c = env.getClassDoc((ClassSymbol)sym); return c; } } s = compenv.toplevel.starImportScope; - for (Scope.Entry e = s.lookup(names.fromString(className)); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.TYP) { - ClassDoc c = env.getClassDoc((ClassSymbol)e.sym); + for (Symbol sym : s.getSymbolsByName(names.fromString(className))) { + if (sym.kind == Kinds.TYP) { + ClassDoc c = env.getClassDoc((ClassSymbol)sym); return c; } } @@ -918,7 +918,6 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { *---------------------------------*/ // search current class - Scope.Entry e = tsym.members().lookup(names.fromString(methodName)); //### Using modifier filter here isn't really correct, //### but emulates the old behavior. Instead, we should @@ -931,11 +930,11 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { // In order to provide textually identical results, we // attempt to emulate the old behavior. MethodSymbol lastFound = null; - for (; e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.MTH) { + for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(methodName))) { + if (sym.kind == Kinds.MTH) { //### Should intern methodName as Name. - if (e.sym.name.toString().equals(methodName)) { - lastFound = (MethodSymbol)e.sym; + if (sym.name.toString().equals(methodName)) { + lastFound = (MethodSymbol)sym; } } } @@ -943,12 +942,12 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { return env.getMethodDoc(lastFound); } } else { - for (; e.scope != null; e = e.next()) { - if (e.sym != null && - e.sym.kind == Kinds.MTH) { + for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(methodName))) { + if (sym != null && + sym.kind == Kinds.MTH) { //### Should intern methodName as Name. - if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) { - return env.getMethodDoc((MethodSymbol)e.sym); + if (hasParameterTypes((MethodSymbol)sym, paramTypes)) { + return env.getMethodDoc((MethodSymbol)sym); } } } @@ -1005,10 +1004,10 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { public ConstructorDoc findConstructor(String constrName, String[] paramTypes) { Names names = tsym.name.table.names; - for (Scope.Entry e = tsym.members().lookup(names.fromString("")); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.MTH) { - if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) { - return env.getConstructorDoc((MethodSymbol)e.sym); + for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(""))) { + if (sym.kind == Kinds.MTH) { + if (hasParameterTypes((MethodSymbol)sym, paramTypes)) { + return env.getConstructorDoc((MethodSymbol)sym); } } } @@ -1047,10 +1046,10 @@ public class ClassDocImpl extends ProgramElementDocImpl implements ClassDoc { } searched.add(this); - for (Scope.Entry e = tsym.members().lookup(names.fromString(fieldName)); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.VAR) { + for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(fieldName))) { + if (sym.kind == Kinds.VAR) { //### Should intern fieldName as Name. - return env.getFieldDoc((VarSymbol)e.sym); + return env.getFieldDoc((VarSymbol)sym); } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java index 4d5d191b929..b1530228d9b 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/MethodDocImpl.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 @@ -128,8 +128,8 @@ public class MethodDocImpl t.hasTag(CLASS); t = env.types.supertype(t)) { ClassSymbol c = (ClassSymbol)t.tsym; - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { - if (sym.overrides(e.sym, origin, env.types, true)) { + for (Symbol sym2 : c.members().getSymbolsByName(sym.name)) { + if (sym.overrides(sym2, origin, env.types, true)) { return TypeMaker.getType(env, t); } } @@ -160,9 +160,9 @@ public class MethodDocImpl t.hasTag(CLASS); t = env.types.supertype(t)) { ClassSymbol c = (ClassSymbol)t.tsym; - for (Scope.Entry e = c.members().lookup(sym.name); e.scope != null; e = e.next()) { - if (sym.overrides(e.sym, origin, env.types, true)) { - return env.getMethodDoc((MethodSymbol)e.sym); + for (Symbol sym2 : c.members().getSymbolsByName(sym.name)) { + if (sym.overrides(sym2, origin, env.types, true)) { + return env.getMethodDoc((MethodSymbol)sym2); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java b/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java index dd70c02ac23..fcc5efde0e5 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.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 @@ -33,7 +33,7 @@ import javax.tools.FileObject; import com.sun.javadoc.*; import com.sun.source.util.TreePath; import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.PackageSymbol; import com.sun.tools.javac.tree.JCTree; @@ -43,6 +43,8 @@ import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Position; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; + /** * Represents a java package. Provides access to information * about the package, the package's comment and tags, and the @@ -146,9 +148,9 @@ public class PackageDocImpl extends DocImpl implements PackageDoc { return allClassesFiltered; } ListBuffer classes = new ListBuffer<>(); - for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) { - if (e.sym != null) { - ClassSymbol s = (ClassSymbol)e.sym; + for (Symbol enumerated : sym.members().getSymbols(NON_RECURSIVE)) { + if (enumerated != null) { + ClassSymbol s = (ClassSymbol)enumerated; ClassDocImpl c = env.getClassDoc(s); if (c != null && !c.isSynthetic()) c.addAllClasses(classes, filtered); diff --git a/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java b/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java index 932833fdb8f..b74a0f59345 100644 --- a/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java +++ b/langtools/src/share/classes/com/sun/tools/javadoc/SerializedForm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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,15 +26,13 @@ package com.sun.tools.javadoc; import com.sun.javadoc.*; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Kinds; -import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; -import com.sun.tools.javac.util.ListBuffer; -import com.sun.tools.javac.util.Name; -import com.sun.tools.javac.util.Names; +import com.sun.tools.javac.util.*; + +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; /** * The serialized form is the specification of a class' serialization @@ -159,9 +157,9 @@ class SerializedForm { /* SERIALIZABLE_FIELDS can be private, * so must lookup by ClassSymbol, not by ClassDocImpl. */ - for (Scope.Entry e = def.members().lookup(names.fromString(SERIALIZABLE_FIELDS)); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.VAR) { - VarSymbol f = (VarSymbol)e.sym; + for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) { + if (sym.kind == Kinds.VAR) { + VarSymbol f = (VarSymbol)sym; if ((f.flags() & Flags.STATIC) != 0 && (f.flags() & Flags.PRIVATE) != 0) { return f; @@ -180,9 +178,9 @@ class SerializedForm { private void computeDefaultSerializableFields(DocEnv env, ClassSymbol def, ClassDocImpl cd) { - for (Scope.Entry e = def.members().elems; e != null; e = e.sibling) { - if (e.sym != null && e.sym.kind == Kinds.VAR) { - VarSymbol f = (VarSymbol)e.sym; + for (Symbol sym : def.members().getSymbols(NON_RECURSIVE)) { + if (sym != null && sym.kind == Kinds.VAR) { + VarSymbol f = (VarSymbol)sym; if ((f.flags() & Flags.STATIC) == 0 && (f.flags() & Flags.TRANSIENT) == 0) { //### No modifier filtering applied here. @@ -209,9 +207,9 @@ class SerializedForm { private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) { Names names = def.name.table.names; - for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.MTH) { - MethodSymbol md = (MethodSymbol)e.sym; + for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) { + if (sym.kind == Kinds.MTH) { + MethodSymbol md = (MethodSymbol)sym; if ((md.flags() & Flags.STATIC) == 0) { /* * WARNING: not robust if unqualifiedMethodName is overloaded @@ -241,10 +239,9 @@ class SerializedForm { Name fieldName = names.fromString(tag.fieldName()); // Look for a FieldDocImpl that is documented by serialFieldTagImpl. - for (Scope.Entry e = def.members().lookup(fieldName); - e.scope != null; e = e.next()) { - if (e.sym.kind == Kinds.VAR) { - VarSymbol f = (VarSymbol) e.sym; + for (Symbol sym : def.members().getSymbolsByName(fieldName)) { + if (sym.kind == Kinds.VAR) { + VarSymbol f = (VarSymbol) sym; FieldDocImpl fdi = env.getFieldDoc(f); ((SerialFieldTagImpl) (tag)).mapToFieldDocImpl(fdi); break; diff --git a/langtools/test/tools/javac/6402516/CheckLocalElements.java b/langtools/test/tools/javac/6402516/CheckLocalElements.java index 169387361ce..cd2b6a43d02 100644 --- a/langtools/test/tools/javac/6402516/CheckLocalElements.java +++ b/langtools/test/tools/javac/6402516/CheckLocalElements.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2011, 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 @@ -23,19 +23,24 @@ /* * @test - * @bug 6402516 + * @bug 6402516 8031569 * @summary need Trees.getScope(TreePath) * @build Checker CheckLocalElements * @run main CheckLocalElements */ +import java.io.IOException; import java.util.*; -import com.sun.source.tree.*; +import java.util.regex.*; + import javax.lang.model.element.*; import javax.lang.model.util.*; +import com.sun.source.tree.*; +import com.sun.source.util.*; + /* - * Check the local elements of a scope against the contents of string literals. + * Check the local elements of a scope against the contents of string literals and top-level comment. */ public class CheckLocalElements extends Checker { public static void main(String... args) throws Exception { @@ -90,6 +95,16 @@ public class CheckLocalElements extends Checker { return true; } + @Override + void additionalChecks(Trees trees, CompilationUnitTree topLevel) throws IOException { + Matcher m = TOPLEVEL_SCOPE_DEF.matcher(topLevel.getSourceFile().getCharContent(false)); + if (!m.find()) + throw new AssertionError("Should have top-level scope def!"); + check(trees.getScope(new TreePath(topLevel)), m.group(1)); + } + //where: + Pattern TOPLEVEL_SCOPE_DEF = Pattern.compile("TOPLEVEL_SCOPE:(.*)"); + private String getEnclosingName(Element e) { Element encl = e.getEnclosingElement(); return encl == null ? "" : encl.accept(qualNameVisitor, null); diff --git a/langtools/test/tools/javac/6402516/Checker.java b/langtools/test/tools/javac/6402516/Checker.java index 30fc7d05e2a..34f9ead9e9a 100644 --- a/langtools/test/tools/javac/6402516/Checker.java +++ b/langtools/test/tools/javac/6402516/Checker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 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 @@ -67,6 +67,7 @@ abstract class Checker { for (CompilationUnitTree unit: units) { TreePath p = new TreePath(unit); s.scan(p, getTrees()); + additionalChecks(getTrees(), unit); } task = null; @@ -111,6 +112,9 @@ abstract class Checker { throw new IllegalStateException(); } + void additionalChecks(Trees trees, CompilationUnitTree topLevel) throws IOException { + } + void error(Scope s, String ref, String msg) { System.err.println("Error: " + msg); System.err.println("Scope: " + (s == null ? null : asList(s.getLocalElements()))); diff --git a/langtools/test/tools/javac/6402516/TestLocalElements.java b/langtools/test/tools/javac/6402516/TestLocalElements.java index 7e2d64f694d..589d2e993cb 100644 --- a/langtools/test/tools/javac/6402516/TestLocalElements.java +++ b/langtools/test/tools/javac/6402516/TestLocalElements.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 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 @@ -23,7 +23,7 @@ import java.util.List; import java.io.*; - +//TOPLEVEL_SCOPE:List, Test2, Test; java.io.*, java.lang.* class Test { void m1(int m1_arg) { String x = "x, m1_arg, super, this; List, Test2, Test; java.io.*, java.lang.*"; diff --git a/langtools/test/tools/javac/6889255/T6889255.java b/langtools/test/tools/javac/6889255/T6889255.java index cf69632e384..d7e1ac0243e 100644 --- a/langtools/test/tools/javac/6889255/T6889255.java +++ b/langtools/test/tools/javac/6889255/T6889255.java @@ -32,7 +32,7 @@ import java.util.*; import javax.tools.StandardLocation; import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.code.Kinds; -import com.sun.tools.javac.code.Scope; +import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; @@ -43,6 +43,8 @@ import com.sun.tools.javac.jvm.ClassReader; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.Names; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; + public class T6889255 { boolean testInterfaces = true; boolean testSyntheticMethods = true; @@ -380,11 +382,11 @@ public class T6889255 { if ((sym.flags() & Flags.INTERFACE) != 0 && !testInterfaces) continue; - for (Scope.Entry e = sym.members_field.elems; e != null; e = e.sibling) { - System.err.println("Checking member " + e.sym); - switch (e.sym.kind) { + for (Symbol s : sym.members_field.getSymbols(NON_RECURSIVE)) { + System.err.println("Checking member " + s); + switch (s.kind) { case Kinds.TYP: { - String name = e.sym.flatName().toString(); + String name = s.flatName().toString(); if (!classes.contains(name)) { classes.add(name); work.add(name); @@ -392,7 +394,7 @@ public class T6889255 { break; } case Kinds.MTH: - verify((MethodSymbol) e.sym, expectNames); + verify((MethodSymbol) s, expectNames); break; } diff --git a/langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.java b/langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.java new file mode 100644 index 00000000000..8881e4973a7 --- /dev/null +++ b/langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.java @@ -0,0 +1,3 @@ +/* @test /nodynamiccopyright/ + * @compile/fail/ref=ImportOnDemandConflicts.out -XDrawDiagnostics p1/Object.java p1/String.java p2/Boolean.java + */ diff --git a/langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.out b/langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.out new file mode 100644 index 00000000000..612a44dd2bf --- /dev/null +++ b/langtools/test/tools/javac/importOnDemand/ImportOnDemandConflicts.out @@ -0,0 +1,2 @@ +String.java:13:9: compiler.err.ref.ambiguous: Boolean, kindname.class, p2.Boolean, p2, kindname.class, java.lang.Boolean, java.lang +1 error diff --git a/langtools/test/tools/javac/importOnDemand/p1/Object.java b/langtools/test/tools/javac/importOnDemand/p1/Object.java new file mode 100644 index 00000000000..e631c00de07 --- /dev/null +++ b/langtools/test/tools/javac/importOnDemand/p1/Object.java @@ -0,0 +1,5 @@ +package p1; + +public class Object { + public static void test() { } +} diff --git a/langtools/test/tools/javac/importOnDemand/p1/String.java b/langtools/test/tools/javac/importOnDemand/p1/String.java new file mode 100644 index 00000000000..38c79b384c4 --- /dev/null +++ b/langtools/test/tools/javac/importOnDemand/p1/String.java @@ -0,0 +1,15 @@ +package p1; + +import p2.*; + +public class String { + public static void test() { } +} + +class Test1 { + private void test() { + String.test(); + Object.test(); + Boolean.valueOf(true); + } +} diff --git a/langtools/test/tools/javac/importOnDemand/p2/Boolean.java b/langtools/test/tools/javac/importOnDemand/p2/Boolean.java new file mode 100644 index 00000000000..958644a8dfd --- /dev/null +++ b/langtools/test/tools/javac/importOnDemand/p2/Boolean.java @@ -0,0 +1,7 @@ +package p2; + +public class Boolean { + public static Boolean valueOf(boolean b) { + return null; + } +} diff --git a/langtools/test/tools/javac/lib/DPrinter.java b/langtools/test/tools/javac/lib/DPrinter.java index c20b913babe..6418a7f9b03 100644 --- a/langtools/test/tools/javac/lib/DPrinter.java +++ b/langtools/test/tools/javac/lib/DPrinter.java @@ -31,6 +31,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -337,6 +338,8 @@ public class DPrinter { printList(label, (List) item); } else if (item instanceof Name) { printName(label, (Name) item); + } else if (item instanceof Scope) { + printScope(label, (Scope) item); } else { printString(label, String.valueOf(item)); } @@ -356,7 +359,7 @@ public class DPrinter { out.print(label); out.print(": ["); String sep = ""; - for (Symbol sym: scope.getElements()) { + for (Symbol sym: scope.getSymbols()) { out.print(sep); out.print(sym.name); sep = ","; @@ -370,19 +373,7 @@ public class DPrinter { out.println(label); indent(+1); - printImplClass(scope, Scope.class); - printSymbol("owner", scope.owner, Details.SUMMARY); - printScope("next", scope.next, Details.SUMMARY); - printObject("shared", getField(scope, Scope.class, "shared"), Details.SUMMARY); - if (scope instanceof CompoundScope) { - printObject("subScopes", - getField(scope, CompoundScope.class, "subScopes"), - Details.FULL); - } else { - for (Symbol sym : scope.getElements()) { - printSymbol(sym.name.toString(), sym, Details.SUMMARY); - } - } + printFullScopeImpl(scope); indent(-1); break; } @@ -390,6 +381,72 @@ public class DPrinter { } } + void printFullScopeImpl(Scope scope) { + indent(); + out.println(scope.getClass().getName()); + printSymbol("owner", scope.owner, Details.SUMMARY); + if (SCOPE_IMPL_CLASS.equals(scope.getClass().getName())) { + printScope("next", (Scope) getField(scope, scope.getClass(), "next"), Details.SUMMARY); + printObject("shared", getField(scope, scope.getClass(), "shared"), Details.SUMMARY); + Object[] table = (Object[]) getField(scope, scope.getClass(), "table"); + for (int i = 0; i < table.length; i++) { + if (i > 0) + out.print(", "); + else + indent(); + out.print(i + ":" + entryToString(table[i], table, false)); + } + out.println(); + } else if (FILTER_SCOPE_CLASS.equals(scope.getClass().getName())) { + printScope("delegate", + (Scope) getField(scope, scope.getClass(), "delegate"), Details.FULL); + } else if (scope instanceof CompoundScope) { + printList("delegates", (List) getField(scope, CompoundScope.class, "subScopes")); + } else { + for (Symbol sym : scope.getSymbols()) { + printSymbol(sym.name.toString(), sym, Details.SUMMARY); + } + } + } + //where: + static final String SCOPE_IMPL_CLASS = "com.sun.tools.javac.code.Scope$ScopeImpl"; + static final String FILTER_SCOPE_CLASS = "com.sun.tools.javac.code.Scope$FilterImportScope"; + + /** + * Create a string showing the contents of an entry, using the table + * to help identify cross-references to other entries in the table. + * @param e the entry to be shown + * @param table the table containing the other entries + */ + String entryToString(Object e, Object[] table, boolean ref) { + if (e == null) + return "null"; + Symbol sym = (Symbol) getField(e, e.getClass(), "sym"); + if (sym == null) + return "sent"; // sentinel + if (ref) { + int index = indexOf(table, e); + if (index != -1) + return String.valueOf(index); + } + Scope scope = (Scope) getField(e, e.getClass(), "scope"); + return "(" + sym.name + ":" + sym + + ",shdw:" + entryToString(callMethod(e, e.getClass(), "next"), table, true) + + ",sibl:" + entryToString(getField(e, e.getClass(), "sibling"), table, true) + + ((sym.owner != scope.owner) + ? (",BOGUS[" + sym.owner + "," + scope.owner + "]") + : "") + + ")"; + } + + int indexOf(T[] array, T item) { + for (int i = 0; i < array.length; i++) { + if (array[i] == item) + return i; + } + return -1; + } + public void printSource(String label, JCTree tree) { printString(label, Pretty.toSimpleString(tree, maxSrcLength)); } @@ -552,6 +609,23 @@ public class DPrinter { } } + protected Object callMethod(Object o, Class clazz, String name) { + try { + Method m = clazz.getDeclaredMethod(name); + boolean prev = m.isAccessible(); + m.setAccessible(true); + try { + return m.invoke(o); + } finally { + m.setAccessible(prev); + } + } catch (ReflectiveOperationException e) { + return e; + } catch (SecurityException e) { + return e; + } + } + // // diff --git a/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java b/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java index e9d44a84d41..84794e0a86b 100644 --- a/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java +++ b/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -117,13 +117,13 @@ public class CompoundScopeTest { boolean subAdded = false; for (int sc = 0 ; sc < 3 ; sc ++) { if (scopeNesting[sc][i]) { - sub.addSubScope(scopes[sc]); + sub.prependSubScope(scopes[sc]); if (!subAdded) { - root.addSubScope(sub); + root.prependSubScope(sub); subAdded = true; } } else { - root.addSubScope(scopes[sc]); + root.prependSubScope(scopes[sc]); } } log("testing scope: " + root); @@ -145,7 +145,7 @@ public class CompoundScopeTest { * Create a scope containing a given number of synthetic symbols */ Scope createScope(int nelems) { - Scope s = new Scope(symtab.noSymbol); + WriteableScope s = WriteableScope.create(symtab.noSymbol); for (int i = 0 ; i < nelems ; i++) { Symbol sym = new TypeVariableSymbol(0, names.fromString("s" + i), null, null); s.enter(sym); @@ -181,7 +181,7 @@ public class CompoundScopeTest { elems : filter(elems, sf); int expectedCount = allSymbols.length(); - for (Symbol s : sf == null ? cs.getElements() : cs.getElements(sf)) { + for (Symbol s : sf == null ? cs.getSymbols() : cs.getSymbols(sf)) { checkSameSymbols(s, allSymbols.head); allSymbols = allSymbols.tail; found.append(s); @@ -204,7 +204,7 @@ public class CompoundScopeTest { filter(shadowedEntry.getValue(), sf); int expectedCount = shadowed.length(); Name name = shadowedEntry.getKey(); - for (Symbol s : sf == null ? cs.getElementsByName(name) : cs.getElementsByName(name, sf)) { + for (Symbol s : sf == null ? cs.getSymbolsByName(name) : cs.getSymbolsByName(name, sf)) { checkSameSymbols(s, shadowed.head); shadowed = shadowed.tail; count++; diff --git a/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java b/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java index 3654ad3dcab..f1c15c1fa7e 100644 --- a/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java +++ b/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -98,7 +98,7 @@ public class ImplementationCacheTest { MethodSymbol I_m = null; - for (Symbol sym : i.members().getElements()) { + for (Symbol sym : i.members().getSymbols()) { if (sym.name.contentEquals("m")) { I_m = (MethodSymbol)sym; } diff --git a/langtools/test/tools/javac/scope/HashCollisionTest.java b/langtools/test/tools/javac/scope/HashCollisionTest.java index 6fbc6e8b17e..a0015ce65b6 100644 --- a/langtools/test/tools/javac/scope/HashCollisionTest.java +++ b/langtools/test/tools/javac/scope/HashCollisionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 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 @@ -25,16 +25,21 @@ * @test * @bug 7004029 * @summary Ensure Scope impl can cope with hash collisions + * @library /tools/javac/lib + * @build DPrinter HashCollisionTest + * @run main HashCollisionTest */ import java.lang.reflect.*; import java.io.*; + +import com.sun.source.util.Trees; +import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.util.*; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Scope.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.file.JavacFileManager; -import static com.sun.tools.javac.code.Kinds.*; public class HashCollisionTest { public static void main(String... args) throws Exception { @@ -47,12 +52,13 @@ public class HashCollisionTest { JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab names = Names.instance(context); // Name.Table impls tied to an instance of Names symtab = Symtab.instance(context); + trees = JavacTrees.instance(context); // determine hashMask for an empty scope - Scope emptyScope = new Scope(symtab.unnamedPackage); // any owner will do - Field sHashMask = Scope.class.getDeclaredField("hashMask"); - sHashMask.setAccessible(true); - scopeHashMask = sHashMask.getInt(emptyScope); + Scope emptyScope = WriteableScope.create(symtab.unnamedPackage); // any owner will do + Field field = emptyScope.getClass().getDeclaredField("hashMask"); + field.setAccessible(true); + scopeHashMask = field.getInt(emptyScope); log("scopeHashMask: " + scopeHashMask); // 1. determine the Name.hashCode of "Entry", and therefore the index of @@ -92,7 +98,7 @@ public class HashCollisionTest { // 4. Create a package containing a nested class using the name from 2 PackageSymbol p = new PackageSymbol(names.fromString("p"), symtab.rootPackage); - p.members_field = new Scope(p); + p.members_field = WriteableScope.create(p); ClassSymbol inner = createClass(innerName, p); // we'll need this later when we "rename" cn ClassSymbol outer = createClass(outerName, p); @@ -100,42 +106,25 @@ public class HashCollisionTest { // 5. Create a star-import scope log ("createStarImportScope"); - // if StarImportScope exists, use it, otherwise, for testing legacy code, - // fall back on ImportScope - Scope starImportScope; - Method importAll; PackageSymbol pkg = new PackageSymbol(names.fromString("pkg"), symtab.rootPackage); - try { - Class c = Class.forName("com.sun.tools.javac.code.Scope$StarImportScope"); - Constructor ctor = c.getDeclaredConstructor(new Class[] { Symbol.class }); - importAll = c.getDeclaredMethod("importAll", new Class[] { Scope.class }); - starImportScope = (Scope) ctor.newInstance(new Object[] { pkg }); - } catch (ClassNotFoundException e) { - starImportScope = new ImportScope(pkg); - importAll = null; - } + StarImportScope starImportScope = new StarImportScope(pkg); dump("initial", starImportScope); // 6. Insert the contents of the package from 4. - Scope p_members = p.members(); - if (importAll != null) { - importAll.invoke(starImportScope, p_members); - } else { - Scope fromScope = p_members; - Scope toScope = starImportScope; - // The following lines are taken from MemberEnter.importAll, - // before the use of StarImportScope.importAll. - for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { - if (e.sym.kind == TYP && !toScope.includes(e.sym)) - toScope.enter(e.sym, fromScope); + Scope fromScope = p.members(); + ImportFilter typeFilter = new ImportFilter() { + @Override + public boolean accepts(Scope origin, Symbol sym) { + return sym.kind == Kinds.TYP; } - } + }; + starImportScope.importAll(fromScope, fromScope, typeFilter, false); dump("imported p", starImportScope); // 7. Insert the class from 3. - starImportScope.enter(ce, cc.members_field); + starImportScope.importAll(cc.members_field, cc.members_field, typeFilter, false); dump("imported ce", starImportScope); /* @@ -149,11 +138,11 @@ public class HashCollisionTest { outer.members_field.enter(inner); // 9. Lookup Entry - Scope.Entry e = starImportScope.lookup(entry); - dump("final", starImportScope); + Symbol found = starImportScope.findFirst(entry); + if (found != ce) + throw new Exception("correct symbol not found: " + entry + "; found=" + found); - if (e.sym == null) - throw new Exception("symbol not found: " + entry); + dump("final", starImportScope); } /* @@ -170,7 +159,7 @@ public class HashCollisionTest { */ ClassSymbol createClass(Name name, Symbol owner) { ClassSymbol sym = new ClassSymbol(0, name, owner); - sym.members_field = new Scope(sym); + sym.members_field = WriteableScope.create(sym); if (owner != symtab.unnamedPackage) owner.members().enter(sym); return sym; @@ -180,58 +169,16 @@ public class HashCollisionTest { * Dump the contents of a scope to System.err. */ void dump(String label, Scope s) throws Exception { - dump(label, s, System.err); + PrintWriter pw = new PrintWriter(System.err); + new DPrinter(pw, trees).printScope(label, s); + pw.flush(); } - /** - * Dump the contents of a scope to a stream. - */ - void dump(String label, Scope s, PrintStream out) throws Exception { - out.println(label); - Field sTable = Scope.class.getDeclaredField("table"); - sTable.setAccessible(true); + Object readField(Object scope, String fieldName) throws Exception { + Field field = scope.getClass().getDeclaredField(fieldName); + field.setAccessible(true); - out.println("owner:" + s.owner); - Scope.Entry[] table = (Scope.Entry[]) sTable.get(s); - for (int i = 0; i < table.length; i++) { - if (i > 0) - out.print(", "); - out.print(i + ":" + toString(table[i], table, false)); - } - out.println(); - } - - /** - * Create a string showing the contents of an entry, using the table - * to help identify cross-references to other entries in the table. - * @param e the entry to be shown - * @param table the table containing the other entries - */ - String toString(Scope.Entry e, Scope.Entry[] table, boolean ref) { - if (e == null) - return "null"; - if (e.sym == null) - return "sent"; // sentinel - if (ref) { - int index = indexOf(table, e); - if (index != -1) - return String.valueOf(index); - } - return "(" + e.sym.name + ":" + e.sym - + ",shdw:" + toString(e.next(), table, true) - + ",sibl:" + toString(e.sibling, table, true) - + ((e.sym.owner != e.scope.owner) - ? (",BOGUS[" + e.sym.owner + "," + e.scope.owner + "]") - : "") - + ")"; - } - - int indexOf(T[] array, T item) { - for (int i = 0; i < array.length; i++) { - if (array[i] == item) - return i; - } - return -1; + return field.get(scope); } /** @@ -246,4 +193,5 @@ public class HashCollisionTest { Names names; Symtab symtab; + Trees trees; } diff --git a/langtools/test/tools/javac/scope/StarImportTest.java b/langtools/test/tools/javac/scope/StarImportTest.java index 805dc66fb77..eab98398813 100644 --- a/langtools/test/tools/javac/scope/StarImportTest.java +++ b/langtools/test/tools/javac/scope/StarImportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 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 @@ -27,14 +27,17 @@ * @summary Basher for star-import scopes */ -import java.lang.reflect.*; import java.util.*; import java.util.List; -import com.sun.tools.javac.util.*; + import com.sun.tools.javac.code.*; -import com.sun.tools.javac.code.Scope.*; +import com.sun.tools.javac.code.Scope.ImportFilter; +import com.sun.tools.javac.code.Scope.StarImportScope; +import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.*; + import static com.sun.tools.javac.code.Kinds.*; public class StarImportTest { @@ -87,13 +90,9 @@ public class StarImportTest { System.err.print(msg); System.err.print(": "); String sep = "("; - for (Scope.Entry se = s.elems; se != null; se = se.sibling) { - for (Scope.Entry e = se; e.sym != null; e = e.next()) { - System.err.print(sep + e.sym.name + ":" + e.sym); - sep = ","; - } - System.err.print(")"); - sep = ", ("; + for (Symbol sym : s.getSymbols()) { + System.err.print(sep + sym.name + ":" + sym); + sep = ","; } System.err.println(); } @@ -171,7 +170,7 @@ public class StarImportTest { int count = rgen.nextInt(MAX_SETUP_PACKAGE_COUNT); log("setup: creating package " + name + " with " + count + " entries"); PackageSymbol p = new PackageSymbol(name, symtab.rootPackage); - p.members_field = new Scope(p); + p.members_field = WriteableScope.create(p); for (int i = 0; i < count; i++) { String outer = name + "c" + i; String suffix = random(null, "$Entry", "$Entry2"); @@ -213,38 +212,21 @@ public class StarImportTest { log ("createStarImportScope"); PackageSymbol pkg = new PackageSymbol(names.fromString("pkg"), symtab.rootPackage); - // if StarImportScope exists, use it, otherwise, for testing legacy code, - // fall back on ImportScope - Method importAll; - try { - Class c = Class.forName("com.sun.tools.javac.code.Scope$StarImportScope"); - Constructor ctor = c.getDeclaredConstructor(new Class[] { Symbol.class }); - importAll = c.getDeclaredMethod("importAll", new Class[] { Scope.class }); - starImportScope = (Scope) ctor.newInstance(new Object[] { pkg }); - } catch (ClassNotFoundException e) { - starImportScope = new ImportScope(pkg); - importAll = null; - } + starImportScope = new StarImportScope(pkg); starImportModel = new Model(); for (Symbol imp: imports) { Scope members = imp.members(); - if (importAll != null) { // log("importAll", members); - importAll.invoke(starImportScope, members); - } else { - Scope fromScope = members; - Scope toScope = starImportScope; - // The following lines are taken from MemberEnter.importAll, - // before the use of StarImportScope.importAll. - for (Scope.Entry e = fromScope.elems; e != null; e = e.sibling) { - if (e.sym.kind == TYP && !toScope.includes(e.sym)) - toScope.enter(e.sym, fromScope); + starImportScope.importAll(members, members, new ImportFilter() { + @Override + public boolean accepts(Scope origin, Symbol t) { + return t.kind == TYP; } - } + }, false); - for (Scope.Entry e = members.elems; e != null; e = e.sibling) { - starImportModel.enter(e.sym); + for (Symbol sym : members.getSymbols()) { + starImportModel.enter(sym); } } @@ -260,9 +242,9 @@ public class StarImportTest { log ("test"); List nestedClasses = new LinkedList(); for (PackageSymbol p: packages) { - for (Scope.Entry se = p.members_field.elems; se != null; se = se.sibling) { - if (se.sym.name.toString().contains("$")) - nestedClasses.add((ClassSymbol) se.sym); + for (Symbol sym : p.members_field.getSymbols()) { + if (sym.name.toString().contains("$")) + nestedClasses.add((ClassSymbol) sym); } } @@ -283,8 +265,7 @@ public class StarImportTest { // determine new owner Name outerName = names.fromString(s.substring(0, dollar)); // log(sym + " owner: " + sym.owner, sym.owner.members()); - Scope.Entry outerEntry = sym.owner.members().lookup(outerName); - ClassSymbol outer = (ClassSymbol) outerEntry.sym; + ClassSymbol outer = (ClassSymbol)sym.owner.members().findFirst(outerName); // log("outer: " + outerName + " " + outer); // remove from package @@ -302,7 +283,7 @@ public class StarImportTest { ClassSymbol createClass(Name name, Symbol owner) { ClassSymbol sym = new ClassSymbol(0, name, owner); - sym.members_field = new Scope(sym); + sym.members_field = WriteableScope.create(sym); if (owner != symtab.unnamedPackage) owner.members().enter(sym); return sym; @@ -318,7 +299,7 @@ public class StarImportTest { List imports = new ArrayList(); int nextClassSerial; - Scope starImportScope; + StarImportScope starImportScope; Model starImportModel; } @@ -355,9 +336,8 @@ public class StarImportTest { void check(Scope scope) { // First, check all entries in scope are in map int bogusCount = 0; - for (Scope.Entry se = scope.elems; se != null; se = se.sibling) { - Symbol sym = se.sym; - if (sym.owner != se.scope.owner) { + for (Symbol sym : scope.getSymbols()) { + if (sym.owner != scope.getOrigin(sym).owner) { if (bogus.contains(sym)) { bogusCount++; } else { @@ -380,16 +360,14 @@ public class StarImportTest { // Second, check all entries in map are in scope for (Map.Entry> me: map.entrySet()) { Name name = me.getKey(); - Scope.Entry se = scope.lookup(name); - assert (se != null); - if (se.sym == null) { + if (scope.findFirst(name) == null) { error("check: no entries found for " + name + " in scope"); continue; } nextSym: for (Symbol sym: me.getValue()) { - for (Scope.Entry e = se; e.sym != null; e = e.next()) { - if (sym == e.sym) + for (Symbol s : scope.getSymbolsByName(name)) { + if (sym == s) continue nextSym; } error("check: symbol " + sym + " not found in scope"); diff --git a/langtools/test/tools/javac/staticImport/6537020/T6537020.out b/langtools/test/tools/javac/staticImport/6537020/T6537020.out index 5fd1d0c9796..6286afedd2f 100644 --- a/langtools/test/tools/javac/staticImport/6537020/T6537020.out +++ b/langtools/test/tools/javac/staticImport/6537020/T6537020.out @@ -1,2 +1,2 @@ -T6537020.java:25:16: compiler.err.ref.ambiguous: s, kindname.variable, s, p.T6537020.B, kindname.variable, s, p.T6537020.A +T6537020.java:25:16: compiler.err.ref.ambiguous: s, kindname.variable, s, p.T6537020.A, kindname.variable, s, p.T6537020.B 1 error From 5916a0adfaa27b08821e1e580909c6857744ed75 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 9 Jul 2014 10:49:32 -0400 Subject: [PATCH 030/236] 8033483: Should ignore nested lambda bodies during overload resolution Reviewed-by: mcimadamore, dlsmith --- .../sun/tools/javac/comp/DeferredAttr.java | 23 +++++++++---- ...IgnoreLambdaBodyDuringResolutionTest1.java | 31 +++++++++++++++++ .../IgnoreLambdaBodyDuringResolutionTest1.out | 2 ++ ...IgnoreLambdaBodyDuringResolutionTest2.java | 34 +++++++++++++++++++ .../IgnoreLambdaBodyDuringResolutionTest2.out | 6 ++++ 5 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java create mode 100644 langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out create mode 100644 langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java create mode 100644 langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 4aec32a7ea0..95bc47542b3 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -516,13 +516,11 @@ public class DeferredAttr extends JCTree.Visitor { } } if (!progress) { - DeferredAttrContext dac = this; - while (dac != emptyDeferredAttrContext) { - if (dac.mode == AttrMode.SPECULATIVE) { - //unsticking does not take place during overload - break; + if (insideOverloadPhase()) { + for (DeferredAttrNode deferredNode: deferredAttrNodes) { + deferredNode.dt.tree.type = Type.noType; } - dac = dac.parent; + return; } //remove all variables that have already been instantiated //from the list of stuck variables @@ -538,6 +536,17 @@ public class DeferredAttr extends JCTree.Visitor { } } } + + private boolean insideOverloadPhase() { + DeferredAttrContext dac = this; + if (dac == emptyDeferredAttrContext) { + return false; + } + if (dac.mode == AttrMode.SPECULATIVE) { + return true; + } + return dac.parent.insideOverloadPhase(); + } } /** @@ -598,6 +607,8 @@ public class DeferredAttr extends JCTree.Visitor { return false; } } else { + Assert.check(!deferredAttrContext.insideOverloadPhase(), + "attribution shouldn't be happening here"); ResultInfo instResultInfo = resultInfo.dup(deferredAttrContext.inferenceContext.asInstType(resultInfo.pt)); dt.check(instResultInfo, dummyStuckPolicy, basicCompleter); diff --git a/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java new file mode 100644 index 00000000000..77e6d8569ec --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.java @@ -0,0 +1,31 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8033483 + * @summary Should ignore nested lambda bodies during overload resolution + * @compile/fail/ref=IgnoreLambdaBodyDuringResolutionTest1.out -XDrawDiagnostics IgnoreLambdaBodyDuringResolutionTest1.java + */ + +class IgnoreLambdaBodyDuringResolutionTest1 { + interface SAM { + T action(T t); + } + + T m(SAM op) { + return null; + } + + class B { + B x() { + return this; + } + } + + class C {} + + void foo(B arg) {} + void foo(C arg) {} + + void bar() { + foo(m(arg -> new B())); + } +} diff --git a/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out new file mode 100644 index 00000000000..4bd68f59727 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest1.out @@ -0,0 +1,2 @@ +IgnoreLambdaBodyDuringResolutionTest1.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(IgnoreLambdaBodyDuringResolutionTest1.B), IgnoreLambdaBodyDuringResolutionTest1, kindname.method, foo(IgnoreLambdaBodyDuringResolutionTest1.C), IgnoreLambdaBodyDuringResolutionTest1 +1 error diff --git a/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java new file mode 100644 index 00000000000..aee1bcddf34 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.java @@ -0,0 +1,34 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8033483 + * @summary Should ignore nested lambda bodies during overload resolution + * @compile/fail/ref=IgnoreLambdaBodyDuringResolutionTest2.out -XDrawDiagnostics IgnoreLambdaBodyDuringResolutionTest2.java + */ + +class IgnoreLambdaBodyDuringResolutionTest2 { + interface SAM { + boolean test(S t); + } + + I bar(final T l) { + return null; + } + + class D { + void foo() { + m(bar(e -> false)); + } + + void m(Class arg) {} + void m(SAM arg) {} + } + + class F { + void foo() { + m(bar((String e) -> false)); + } + + void m(Class arg) {} + void m(SAM arg) {} + } +} diff --git a/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out new file mode 100644 index 00000000000..5c294d0a793 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8033483/IgnoreLambdaBodyDuringResolutionTest2.out @@ -0,0 +1,6 @@ +IgnoreLambdaBodyDuringResolutionTest2.java:19:13: compiler.err.ref.ambiguous: m, kindname.method, m(java.lang.Class), IgnoreLambdaBodyDuringResolutionTest2.D, kindname.method, m(IgnoreLambdaBodyDuringResolutionTest2.SAM), IgnoreLambdaBodyDuringResolutionTest2.D +IgnoreLambdaBodyDuringResolutionTest2.java:19:18: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Object)) +IgnoreLambdaBodyDuringResolutionTest2.java:19:14: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Class, , kindname.class, IgnoreLambdaBodyDuringResolutionTest2.D, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Class))) +IgnoreLambdaBodyDuringResolutionTest2.java:28:13: compiler.err.ref.ambiguous: m, kindname.method, m(java.lang.Class), IgnoreLambdaBodyDuringResolutionTest2.F, kindname.method, m(IgnoreLambdaBodyDuringResolutionTest2.SAM), IgnoreLambdaBodyDuringResolutionTest2.F +IgnoreLambdaBodyDuringResolutionTest2.java:28:14: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: I,T, (compiler.misc.not.a.functional.intf: java.lang.Class)) +5 errors From de072ba28fcee94493c55bfff3dd915d9ff3a89d Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 10 Jul 2014 12:13:35 -0700 Subject: [PATCH 031/236] Added tag jdk9-b22 for changeset cf09dddb6caf --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 6096220d5a8..69efa79b43b 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -264,3 +264,4 @@ fd8da51c5df4546995c360fc49f0b985cbf8fbd3 jdk9-b18 a9accd7c44159f191ad09740d54493e563c39f95 jdk9-b19 31acbc476a5251824f919df0b82bca9cbb19cf7c jdk9-b20 fa0d1059a26f82f95620b7dc8bbfbe302bce8883 jdk9-b21 +aca19c52b24627a6b085cfeb433051a3e420cd81 jdk9-b22 From b4b2f994caed090af60656918ba8af7d40bd3662 Mon Sep 17 00:00:00 2001 From: Neil Toda Date: Thu, 10 Jul 2014 13:57:27 -0700 Subject: [PATCH 032/236] 8011044: Remove support for 1.5 and earlier source and target options Co-authored-by: Brian Goetz Reviewed-by: darcy, jjg --- .../com/sun/tools/javac/code/Source.java | 50 +---- .../com/sun/tools/javac/code/Symtab.java | 10 +- .../com/sun/tools/javac/code/Types.java | 31 +-- .../com/sun/tools/javac/comp/Attr.java | 80 ++----- .../com/sun/tools/javac/comp/Check.java | 57 +---- .../com/sun/tools/javac/comp/Lower.java | 206 ++++++------------ .../com/sun/tools/javac/comp/Resolve.java | 15 +- .../com/sun/tools/javac/comp/TransTypes.java | 24 +- .../com/sun/tools/javac/jvm/ClassReader.java | 34 +-- .../com/sun/tools/javac/jvm/ClassWriter.java | 52 +---- .../classes/com/sun/tools/javac/jvm/Gen.java | 135 +----------- .../com/sun/tools/javac/jvm/Target.java | 173 +-------------- .../sun/tools/javac/main/JavaCompiler.java | 36 ++- .../com/sun/tools/javac/main/Main.java | 11 +- .../sun/tools/javac/parser/JavaTokenizer.java | 13 +- .../sun/tools/javac/parser/JavacParser.java | 172 +++------------ .../tools/javac/resources/compiler.properties | 58 +---- .../sun/tools/javac/util/BaseFileManager.java | 13 +- .../crossCompile/CrossCompile.java | 4 +- ...thodsNotVisibleForSourceLessThan8Test.java | 4 - .../examples/AnnotationsNotSupported.java | 28 --- .../diags/examples/AssertAsIdentifier.java | 29 --- .../diags/examples/EnumAsIdentifier.java | 29 --- .../diags/examples/EnumsNotSupported.java | 27 --- .../tools/javac/diags/examples/Expected2.java | 12 +- .../diags/examples/GenericsNotSupported.java | 27 --- .../examples/NeitherConditionalSubtype.java | 13 +- .../examples/ObsoleteSourceAndTarget.java | 4 +- ...tedFpLit.java => OptionRemovedSource.java} | 11 +- ...upported.java => OptionRemovedTarget.java} | 16 +- .../diags/examples/SourceNoBootclasspath.java | 4 +- .../examples/StaticImportNotSupported.java | 29 --- .../examples/TypeAnnotationsNotSupported.java | 4 +- .../diags/examples/VarargsNotSupported.java | 29 --- .../_super/NonDirectSuper/Base.java | 45 ---- .../_super/NonDirectSuper/NonDirectSuper.java | 179 --------------- .../_super/NonDirectSuper/Target11.java | 76 ------- .../tools/javac/miranda/6964669/T6964669.java | 29 --- .../tools/javac/miranda/6964669/pkg/A.java | 26 --- .../tools/javac/miranda/6964669/pkg/B.java | 28 --- .../tools/javac/miranda/6964669/pkg/C.java | 28 --- .../mixedTarget/CompatibleAbstracts1.java | 55 ----- .../mixedTarget/CompatibleAbstracts2.java | 32 --- .../javac/mixedTarget/ExtendCovariant1.java | 9 +- .../javac/mixedTarget/ExtendCovariant2.java | 10 +- .../test/tools/javac/options/T6900037.java | 8 +- .../test/tools/javac/options/T6900037.out | 2 +- .../test/tools/javac/options/T7022337.java | 4 +- .../processing/messager/MessagerDiags.java | 10 +- langtools/test/tools/javac/versions/check.sh | 26 +-- 50 files changed, 264 insertions(+), 1743 deletions(-) delete mode 100644 langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java delete mode 100644 langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java delete mode 100644 langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java delete mode 100644 langtools/test/tools/javac/diags/examples/EnumsNotSupported.java delete mode 100644 langtools/test/tools/javac/diags/examples/GenericsNotSupported.java rename langtools/test/tools/javac/diags/examples/{UnsupportedFpLit.java => OptionRemovedSource.java} (79%) rename langtools/test/tools/javac/diags/examples/{ForeachNotSupported.java => OptionRemovedTarget.java} (75%) delete mode 100644 langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java delete mode 100644 langtools/test/tools/javac/diags/examples/VarargsNotSupported.java delete mode 100644 langtools/test/tools/javac/expression/_super/NonDirectSuper/Base.java delete mode 100644 langtools/test/tools/javac/expression/_super/NonDirectSuper/NonDirectSuper.java delete mode 100644 langtools/test/tools/javac/expression/_super/NonDirectSuper/Target11.java delete mode 100644 langtools/test/tools/javac/miranda/6964669/T6964669.java delete mode 100644 langtools/test/tools/javac/miranda/6964669/pkg/A.java delete mode 100644 langtools/test/tools/javac/miranda/6964669/pkg/B.java delete mode 100644 langtools/test/tools/javac/miranda/6964669/pkg/C.java delete mode 100644 langtools/test/tools/javac/mixedTarget/CompatibleAbstracts1.java delete mode 100644 langtools/test/tools/javac/mixedTarget/CompatibleAbstracts2.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java index 6621805c6a5..26a1e5df541 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java @@ -105,7 +105,11 @@ public enum Source { this.name = name; } - public static final Source DEFAULT = JDK1_9; + public static final Source MIN = Source.JDK1_6; + + private static final Source MAX = values()[values().length - 1]; + + public static final Source DEFAULT = MAX; public static Source lookup(String name) { return tab.get(name); @@ -121,19 +125,6 @@ public enum Source { return Target.JDK1_1; } - /** Allow encoding errors, giving only warnings. */ - public boolean allowEncodingErrors() { - return compareTo(JDK1_6) < 0; - } - public boolean allowAsserts() { - return compareTo(JDK1_4) >= 0; - } - public boolean allowCovariantReturns() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowGenerics() { - return compareTo(JDK1_5) >= 0; - } public boolean allowDiamond() { return compareTo(JDK1_7) >= 0; } @@ -146,37 +137,6 @@ public enum Source { public boolean allowImprovedCatchAnalysis() { return compareTo(JDK1_7) >= 0; } - public boolean allowEnums() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowForeach() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowStaticImport() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowBoxing() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowVarargs() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowAnnotations() { - return compareTo(JDK1_5) >= 0; - } - // hex floating-point literals supported? - public boolean allowHexFloats() { - return compareTo(JDK1_5) >= 0; - } - public boolean allowAnonOuterThis() { - return compareTo(JDK1_5) >= 0; - } - public boolean addBridges() { - return compareTo(JDK1_5) >= 0; - } - public boolean enforceMandatoryWarnings() { - return compareTo(JDK1_5) >= 0; - } public boolean allowTryWithResources() { return compareTo(JDK1_7) >= 0; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java index be66abaa130..06fdfca54f2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java @@ -367,11 +367,9 @@ public class Symtab { } catch (CompletionFailure e) { sym.flags_field |= PUBLIC; ((ClassType) sym.type).supertype_field = objectType; - Name n = target.boxWithConstructors() ? names.init : names.valueOf; MethodSymbol boxMethod = - new MethodSymbol(PUBLIC | STATIC, - n, - new MethodType(List.of(type), sym.type, + new MethodSymbol(PUBLIC | STATIC, names.valueOf, + new MethodType(List.of(type), sym.type, List.nil(), methodClass), sym); sym.members().enter(boxMethod); @@ -528,9 +526,7 @@ public class Symtab { comparableType = enterClass("java.lang.Comparable"); comparatorType = enterClass("java.util.Comparator"); arraysType = enterClass("java.util.Arrays"); - iterableType = target.hasIterable() - ? enterClass("java.lang.Iterable") - : enterClass("java.util.Collection"); + iterableType = enterClass("java.lang.Iterable"); iteratorType = enterClass("java.util.Iterator"); annotationTargetType = enterClass("java.lang.annotation.Target"); overrideType = enterClass("java.lang.Override"); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index 71e9745de86..2147b19cc54 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -80,8 +80,6 @@ public class Types { final Symtab syms; final JavacMessages messages; final Names names; - final boolean allowBoxing; - final boolean allowCovariantReturns; final boolean allowObjectToPrimitiveCast; final Check chk; final Enter enter; @@ -105,8 +103,6 @@ public class Types { syms = Symtab.instance(context); names = Names.instance(context); Source source = Source.instance(context); - allowBoxing = source.allowBoxing(); - allowCovariantReturns = source.allowCovariantReturns(); allowObjectToPrimitiveCast = source.allowObjectToPrimitiveCast(); chk = Check.instance(context); enter = Enter.instance(context); @@ -292,7 +288,6 @@ public class Types { if (tPrimitive == sPrimitive) { return isSubtypeUnchecked(t, s, warn); } - if (!allowBoxing) return false; return tPrimitive ? isSubtype(boxedClass(t).type, s) : isSubtype(unboxedType(t), s); @@ -1484,8 +1479,7 @@ public class Types { return true; if (t.isPrimitive() != s.isPrimitive()) - return allowBoxing && ( - isConvertible(t, s, warn) + return (isConvertible(t, s, warn) || (allowObjectToPrimitiveCast && s.isPrimitive() && isSubtype(boxedClass(s).type, t))); @@ -3844,8 +3838,6 @@ public class Types { if (hasSameArgs(r1, r2)) return covariantReturnType(r1.getReturnType(), r2res, warner); - if (!allowCovariantReturns) - return false; if (isSubtypeUnchecked(r1.getReturnType(), r2res, warner)) return true; if (!isSubtype(r1.getReturnType(), erasure(r2res))) @@ -3861,7 +3853,6 @@ public class Types { public boolean covariantReturnType(Type t, Type s, Warner warner) { return isSameType(t, s) || - allowCovariantReturns && !t.isPrimitive() && !s.isPrimitive() && isAssignable(t, s, warner); @@ -3889,13 +3880,11 @@ public class Types { * Return the primitive type corresponding to a boxed type. */ public Type unboxedType(Type t) { - if (allowBoxing) { - for (int i=0; i argtypes, Type restype) { - if (allowCovariantReturns && - methodName == names.clone && - types.isArray(qualifierType)) { + if (methodName == names.clone && types.isArray(qualifierType)) { // as a special case, array.clone() has a result that is // the same as static type of the array being cloned return qualifierType; - } else if (allowGenerics && - methodName == names.getClass && - argtypes.isEmpty()) { + } else if (methodName == names.getClass && argtypes.isEmpty()) { // as a special case, x.getClass() has type Class return new ClassType(restype.getEnclosingType(), List.of(new WildcardType(types.erasure(qualifierType), @@ -2133,10 +2094,9 @@ public class Attr extends JCTree.Visitor { // If we have made no mistakes in the class type... if (clazztype.hasTag(CLASS)) { // Enums may not be instantiated except implicitly - if (allowEnums && - (clazztype.tsym.flags_field&Flags.ENUM) != 0 && + if ((clazztype.tsym.flags_field & Flags.ENUM) != 0 && (!env.tree.hasTag(VARDEF) || - (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 || + (((JCVariableDecl) env.tree).mods.flags & Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); // Check that class is not abstract @@ -3370,7 +3330,7 @@ public class Attr extends JCTree.Visitor { while (symEnv.outer != null && !sym.isMemberOf(symEnv.enclClass.sym, types)) { if ((symEnv.enclClass.sym.flags() & NOOUTERTHIS) != 0) - noOuterThisPath = !allowAnonOuterThis; + noOuterThisPath = false; symEnv = symEnv.outer; } } @@ -3592,9 +3552,7 @@ public class Attr extends JCTree.Visitor { // In this case, we have already made sure in // visitSelect that qualifier expression is a type. Type t = syms.classType; - List typeargs = allowGenerics - ? List.of(types.erasure(site)) - : List.nil(); + List typeargs = List.of(types.erasure(site)); t = new ClassType(t.getEnclosingType(), typeargs, t.tsym); return new VarSymbol( STATIC | PUBLIC | FINAL, names._class, t, site.tsym); @@ -3774,8 +3732,7 @@ public class Attr extends JCTree.Visitor { // Test (4): if symbol is an instance field of a raw type, // which is being assigned to, issue an unchecked warning if // its type changes under erasure. - if (allowGenerics && - resultInfo.pkind == VAR && + if (resultInfo.pkind == VAR && v.owner.kind == TYP && (v.flags() & STATIC) == 0 && (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) { @@ -3955,8 +3912,7 @@ public class Attr extends JCTree.Visitor { List typeargtypes) { // Test (5): if symbol is an instance method of a raw type, issue // an unchecked warning if its argument types change under erasure. - if (allowGenerics && - (sym.flags() & STATIC) == 0 && + if ((sym.flags() & STATIC) == 0 && (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) { Type s = types.asOuterSuper(site, sym.owner); if (s != null && s.isRaw() && diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 3bd195ae5bb..196169ae441 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -124,10 +124,6 @@ public class Check { fileManager = context.get(JavaFileManager.class); Source source = Source.instance(context); - allowGenerics = source.allowGenerics(); - allowVarargs = source.allowVarargs(); - allowAnnotations = source.allowAnnotations(); - allowCovariantReturns = source.allowCovariantReturns(); allowSimplifiedVarargs = source.allowSimplifiedVarargs(); allowDefaultMethods = source.allowDefaultMethods(); allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); @@ -146,7 +142,7 @@ public class Check { boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION); boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED); boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI); - boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings(); + boolean enforceMandatoryWarnings = true; deprecationHandler = new MandatoryWarningHandler(log, verboseDeprecated, enforceMandatoryWarnings, "deprecated", LintCategory.DEPRECATION); @@ -158,22 +154,6 @@ public class Check { deferredLintHandler = DeferredLintHandler.instance(context); } - /** Switch: generics enabled? - */ - boolean allowGenerics; - - /** Switch: varargs enabled? - */ - boolean allowVarargs; - - /** Switch: annotations enabled? - */ - boolean allowAnnotations; - - /** Switch: covariant returns enabled? - */ - boolean allowCovariantReturns; - /** Switch: simplified varargs enabled? */ boolean allowSimplifiedVarargs; @@ -903,8 +883,7 @@ public class Check { assertConvertible(arg, arg.type, varArg, warn); args = args.tail; } - } else if ((sym.flags() & (VARARGS | SIGNATURE_POLYMORPHIC)) == VARARGS && - allowVarargs) { + } else if ((sym.flags() & (VARARGS | SIGNATURE_POLYMORPHIC)) == VARARGS) { // non-varargs call to varargs method Type varParam = owntype.getParameterTypes().last(); Type lastArg = argtypes.last(); @@ -1671,18 +1650,12 @@ public class Check { boolean resultTypesOK = types.returnTypeSubstitutable(mt, ot, otres, overrideWarner); if (!resultTypesOK) { - if (!allowCovariantReturns && - m.owner != origin && - m.owner.isSubClass(other.owner, types)) { - // allow limited interoperability with covariant returns - } else { - log.error(TreeInfo.diagnosticPositionFor(m, tree), - "override.incompatible.ret", - cannotOverride(m, other), - mtres, otres); - m.flags_field |= BAD_OVERRIDE; - return; - } + log.error(TreeInfo.diagnosticPositionFor(m, tree), + "override.incompatible.ret", + cannotOverride(m, other), + mtres, otres); + m.flags_field |= BAD_OVERRIDE; + return; } else if (overrideWarner.hasNonSilentLint(LintCategory.UNCHECKED)) { warnUnchecked(TreeInfo.diagnosticPositionFor(m, tree), "override.unchecked.ret", @@ -1817,13 +1790,6 @@ public class Check { * @param t1 The first argument type. * @param t2 The second argument type. */ - public boolean checkCompatibleAbstracts(DiagnosticPosition pos, - Type t1, - Type t2) { - return checkCompatibleAbstracts(pos, t1, t2, - types.makeCompoundType(t1, t2)); - } - public boolean checkCompatibleAbstracts(DiagnosticPosition pos, Type t1, Type t2, @@ -2321,7 +2287,7 @@ public class Check { void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) { for (List l = types.closure(ic.type); l.nonEmpty(); l = l.tail) { ClassSymbol lc = (ClassSymbol)l.head.tsym; - if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) { + if ((lc.flags() & ABSTRACT) != 0) { for (Symbol sym : lc.members().getSymbols(NON_RECURSIVE)) { if (sym.kind == MTH && (sym.flags() & (STATIC|ABSTRACT)) == ABSTRACT) { @@ -2356,7 +2322,7 @@ public class Check { (supertype.tsym.flags() & ABSTRACT) != 0) supertypes = supertypes.prepend(supertype); for (List l = supertypes; l.nonEmpty(); l = l.tail) { - if (allowGenerics && !l.head.getTypeArguments().isEmpty() && + if (!l.head.getTypeArguments().isEmpty() && !checkCompatibleAbstracts(pos, l.head, l.head, c)) return; for (List m = supertypes; m != l; m = m.tail) @@ -3204,8 +3170,7 @@ public class Check { } void checkDeprecatedAnnotation(DiagnosticPosition pos, Symbol s) { - if (allowAnnotations && - lint.isEnabled(LintCategory.DEP_ANN) && + if (lint.isEnabled(LintCategory.DEP_ANN) && (s.flags() & DEPRECATED) != 0 && !syms.deprecatedType.isErroneous() && s.attribute(syms.deprecatedType.tsym) == null) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 62016b4dcd5..0ce025945ed 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -82,7 +82,6 @@ public class Lower extends TreeTranslator { private final Target target; private final Source source; private final TypeEnvs typeEnvs; - private final boolean allowEnums; private final Name dollarAssertionsDisabled; private final Name classDollar; private final Types types; @@ -103,7 +102,6 @@ public class Lower extends TreeTranslator { target = Target.instance(context); source = Source.instance(context); typeEnvs = TypeEnvs.instance(context); - allowEnums = source.allowEnums(); dollarAssertionsDisabled = names. fromString(target.syntheticNameChar() + "assertionsDisabled"); classDollar = names. @@ -1492,9 +1490,6 @@ public class Lower extends TreeTranslator { List freevarDefs(int pos, List freevars, Symbol owner, long additionalFlags) { long flags = FINAL | SYNTHETIC | additionalFlags; - if (owner.kind == TYP && - target.usePrivateSyntheticFields()) - flags |= PRIVATE; List defs = List.nil(); for (List l = freevars; l.nonEmpty(); l = l.tail) { VarSymbol v = l.head; @@ -1525,9 +1520,6 @@ public class Lower extends TreeTranslator { } private VarSymbol makeOuterThisVarSymbol(Symbol owner, long flags) { - if (owner.kind == TYP && - target.usePrivateSyntheticFields()) - flags |= PRIVATE; Type target = types.erasure(owner.enclClass().type.getEnclosingType()); VarSymbol outerThis = new VarSymbol(flags, outerThisName(target, owner), target, owner); @@ -1900,8 +1892,6 @@ public class Lower extends TreeTranslator { */ private ClassSymbol outerCacheClass() { ClassSymbol clazz = outermostClassDef.sym; - if ((clazz.flags() & INTERFACE) == 0 && - !target.useInnerCacheClass()) return clazz; Scope s = clazz.members(); for (Symbol sym : s.getSymbols(NON_RECURSIVE)) if (sym.kind == TYP && @@ -1958,79 +1948,54 @@ public class Lower extends TreeTranslator { JCBlock returnResult; - // in 1.4.2 and above, we use - // Class.forName(String name, boolean init, ClassLoader loader); - // which requires we cache the current loader in cl$ - if (target.classLiteralsNoInit()) { - // clsym = "private static ClassLoader cl$" - VarSymbol clsym = new VarSymbol(STATIC|SYNTHETIC, - names.fromString("cl" + target.syntheticNameChar()), - syms.classLoaderType, - outerCacheClass); - enterSynthetic(pos, clsym, outerCacheClass.members()); + // cache the current loader in cl$ + // clsym = "private static ClassLoader cl$" + VarSymbol clsym = new VarSymbol(STATIC | SYNTHETIC, + names.fromString("cl" + target.syntheticNameChar()), + syms.classLoaderType, + outerCacheClass); + enterSynthetic(pos, clsym, outerCacheClass.members()); - // emit "private static ClassLoader cl$;" - JCVariableDecl cldef = make.VarDef(clsym, null); - JCClassDecl outerCacheClassDef = classDef(outerCacheClass); - outerCacheClassDef.defs = outerCacheClassDef.defs.prepend(cldef); + // emit "private static ClassLoader cl$;" + JCVariableDecl cldef = make.VarDef(clsym, null); + JCClassDecl outerCacheClassDef = classDef(outerCacheClass); + outerCacheClassDef.defs = outerCacheClassDef.defs.prepend(cldef); - // newcache := "new cache$1[0]" - JCNewArray newcache = make. - NewArray(make.Type(outerCacheClass.type), - List.of(make.Literal(INT, 0).setType(syms.intType)), - null); - newcache.type = new ArrayType(types.erasure(outerCacheClass.type), - syms.arrayClass, Type.noAnnotations); + // newcache := "new cache$1[0]" + JCNewArray newcache = make.NewArray(make.Type(outerCacheClass.type), + List.of(make.Literal(INT, 0).setType(syms.intType)), + null); + newcache.type = new ArrayType(types.erasure(outerCacheClass.type), + syms.arrayClass, Type.noAnnotations); - // forNameSym := java.lang.Class.forName( - // String s,boolean init,ClassLoader loader) - Symbol forNameSym = lookupMethod(make_pos, names.forName, - types.erasure(syms.classType), - List.of(syms.stringType, - syms.booleanType, - syms.classLoaderType)); - // clvalue := "(cl$ == null) ? - // $newcache.getClass().getComponentType().getClassLoader() : cl$" - JCExpression clvalue = + // forNameSym := java.lang.Class.forName( + // String s,boolean init,ClassLoader loader) + Symbol forNameSym = lookupMethod(make_pos, names.forName, + types.erasure(syms.classType), + List.of(syms.stringType, + syms.booleanType, + syms.classLoaderType)); + // clvalue := "(cl$ == null) ? + // $newcache.getClass().getComponentType().getClassLoader() : cl$" + JCExpression clvalue = make.Conditional( - makeBinary(EQ, make.Ident(clsym), makeNull()), - make.Assign( - make.Ident(clsym), - makeCall( - makeCall(makeCall(newcache, - names.getClass, - List.nil()), - names.getComponentType, - List.nil()), - names.getClassLoader, - List.nil())).setType(syms.classLoaderType), - make.Ident(clsym)).setType(syms.classLoaderType); + makeBinary(EQ, make.Ident(clsym), makeNull()), + make.Assign(make.Ident(clsym), + makeCall( + makeCall(makeCall(newcache, + names.getClass, + List.nil()), + names.getComponentType, + List.nil()), + names.getClassLoader, + List.nil())).setType(syms.classLoaderType), + make.Ident(clsym)).setType(syms.classLoaderType); - // returnResult := "{ return Class.forName(param1, false, cl$); }" - List args = List.of(make.Ident(md.params.head.sym), - makeLit(syms.booleanType, 0), - clvalue); - returnResult = make. - Block(0, List.of(make. - Call(make. // return - App(make. - Ident(forNameSym), args)))); - } else { - // forNameSym := java.lang.Class.forName(String s) - Symbol forNameSym = lookupMethod(make_pos, - names.forName, - types.erasure(syms.classType), - List.of(syms.stringType)); - // returnResult := "{ return Class.forName(param1); }" - returnResult = make. - Block(0, List.of(make. - Call(make. // return - App(make. - QualIdent(forNameSym), - List.of(make. - Ident(md.params. - head.sym)))))); - } + // returnResult := "{ return Class.forName(param1, false, cl$); }" + List args = List.of(make.Ident(md.params.head.sym), + makeLit(syms.booleanType, 0), + clvalue); + returnResult = make.Block(0, List.of(make.Call(make.App(make.Ident(forNameSym), args)))); // catchParam := ClassNotFoundException e1 VarSymbol catchParam = @@ -2039,27 +2004,13 @@ public class Lower extends TreeTranslator { classDollarSym); JCStatement rethrow; - if (target.hasInitCause()) { - // rethrow = "throw new NoClassDefFoundError().initCause(e); - JCExpression throwExpr = - makeCall(makeNewClass(syms.noClassDefFoundErrorType, - List.nil()), - names.initCause, - List.of(make.Ident(catchParam))); - rethrow = make.Throw(throwExpr); - } else { - // getMessageSym := ClassNotFoundException.getMessage() - Symbol getMessageSym = lookupMethod(make_pos, - names.getMessage, - syms.classNotFoundExceptionType, - List.nil()); - // rethrow = "throw new NoClassDefFoundError(e.getMessage());" - rethrow = make. - Throw(makeNewClass(syms.noClassDefFoundErrorType, - List.of(make.App(make.Select(make.Ident(catchParam), - getMessageSym), - List.nil())))); - } + // rethrow = "throw new NoClassDefFoundError().initCause(e); + JCExpression throwExpr = + makeCall(makeNewClass(syms.noClassDefFoundErrorType, + List.nil()), + names.initCause, + List.of(make.Ident(catchParam))); + rethrow = make.Throw(throwExpr); // rethrowStmt := "( $rethrow )" JCBlock rethrowStmt = make.Block(0, List.of(rethrow)); @@ -2147,29 +2098,10 @@ public class Lower extends TreeTranslator { ((VarSymbol)typeSym).getConstValue(); // ensure initializer is evaluated return make.QualIdent(typeSym); case CLASS: case ARRAY: - if (target.hasClassLiterals()) { VarSymbol sym = new VarSymbol( STATIC | PUBLIC | FINAL, names._class, syms.classType, type.tsym); return make_at(pos).Select(make.Type(type), sym); - } - // replace with - // where - // - is the type signature of T, - // - is the cache variable for tsig. - String sig = - writer.xClassName(type).toString().replace('/', '.'); - Symbol cs = cacheSym(pos, sig); - return make_at(pos).Conditional( - makeBinary(EQ, make.Ident(cs), makeNull()), - make.Assign( - make.Ident(cs), - make.App( - make.Ident(classDollarSym(pos)), - List.of(make.Literal(CLASS, sig) - .setType(syms.stringType)))) - .setType(types.erasure(syms.classType)), - make.Ident(cs)).setType(types.erasure(syms.classType)); default: throw new AssertionError(); } @@ -2415,9 +2347,8 @@ public class Lower extends TreeTranslator { Name name = names.package_info; long flags = Flags.ABSTRACT | Flags.INTERFACE; - if (target.isPackageInfoSynthetic()) - // package-info is marked SYNTHETIC in JDK 1.6 and later releases - flags = flags | Flags.SYNTHETIC; + // package-info is marked SYNTHETIC in JDK 1.6 and later releases + flags = flags | Flags.SYNTHETIC; JCClassDecl packageAnnotationsClass = make.ClassDef(make.Modifiers(flags, tree.getAnnotations()), name, List.nil(), @@ -2549,8 +2480,7 @@ public class Lower extends TreeTranslator { if (tree.extending == null) tree.extending = make.Type(types.supertype(tree.type)); - // classOfType adds a cache field to tree.defs unless - // target.hasClassLiterals(). + // classOfType adds a cache field to tree.defs JCExpression e_class = classOfType(tree.sym.type, tree.pos()). setType(types.erasure(syms.classType)); @@ -2810,11 +2740,7 @@ public class Lower extends TreeTranslator { // recursively translate following local statements and // combine with this- or super-call List stats = translate(tree.body.stats.tail); - if (target.initializeFieldsBeforeSuper()) - tree.body.stats = stats.prepend(selfCall).prependList(added); - else - tree.body.stats = stats.prependList(added).prepend(selfCall); - + tree.body.stats = stats.prepend(selfCall).prependList(added); outerThisStack = prevOuterThisStack; } else { Map prevLambdaTranslationMap = @@ -3056,9 +2982,7 @@ public class Lower extends TreeTranslator { public void visitApply(JCMethodInvocation tree) { Symbol meth = TreeInfo.symbol(tree.meth); List argtypes = meth.type.getParameterTypes(); - if (allowEnums && - meth.name==names.init && - meth.owner == syms.enumSym) + if (meth.name == names.init && meth.owner == syms.enumSym) argtypes = argtypes.tail.tail; tree.args = boxArgs(argtypes, tree.args, tree.varargsElement); tree.varargsElement = null; @@ -3195,20 +3119,12 @@ public class Lower extends TreeTranslator { /** Box up a single primitive expression. */ JCExpression boxPrimitive(JCExpression tree, Type box) { make_at(tree.pos()); - if (target.boxWithConstructors()) { - Symbol ctor = lookupConstructor(tree.pos(), - box, - List.nil() - .prepend(tree.type)); - return make.Create(ctor, List.of(tree)); - } else { - Symbol valueOfSym = lookupMethod(tree.pos(), - names.valueOf, - box, - List.nil() - .prepend(tree.type)); - return make.App(make.QualIdent(valueOfSym), List.of(tree)); - } + Symbol valueOfSym = lookupMethod(tree.pos(), + names.valueOf, + box, + List.nil() + .prepend(tree.type)); + return make.App(make.QualIdent(valueOfSym), List.of(tree)); } /** Unbox an object to a primitive value. */ diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index 30754afdb33..de3914c71c4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -54,11 +54,9 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; import java.util.Arrays; import java.util.Collection; -import java.util.EnumMap; import java.util.EnumSet; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.Map; import javax.lang.model.element.ElementVisitor; @@ -92,8 +90,6 @@ public class Resolve { TreeInfo treeinfo; Types types; JCDiagnostic.Factory diags; - public final boolean boxingEnabled; - public final boolean varargsEnabled; public final boolean allowMethodHandles; public final boolean allowFunctionalInterfaceMostSpecific; public final boolean checkVarargsAccessAfterResolution; @@ -128,8 +124,6 @@ public class Resolve { types = Types.instance(context); diags = JCDiagnostic.Factory.instance(context); Source source = Source.instance(context); - boxingEnabled = source.allowBoxing(); - varargsEnabled = source.allowVarargs(); Options options = Options.instance(context); debugResolve = options.isSet("debugresolve"); compactMethodDiags = options.isSet(Option.XDIAGS, "compact") || @@ -3279,8 +3273,8 @@ public class Resolve { Symbol bestSoFar = methodNotFound; currentResolutionContext = resolveContext; for (MethodResolutionPhase phase : methodResolutionSteps) { - if (!phase.isApplicable(boxingEnabled, varargsEnabled) || - lookupHelper.shouldStop(bestSoFar, phase)) break; + if (lookupHelper.shouldStop(bestSoFar, phase)) + break; MethodResolutionPhase prevPhase = currentResolutionContext.step; Symbol prevBest = bestSoFar; currentResolutionContext.step = phase; @@ -4208,11 +4202,6 @@ public class Resolve { return isVarargsRequired; } - public boolean isApplicable(boolean boxingEnabled, boolean varargsEnabled) { - return (varargsEnabled || !isVarargsRequired) && - (boxingEnabled || !isBoxingRequired); - } - public Symbol mergeResults(Symbol prev, Symbol sym) { return sym; } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index 9bc36893cae..9b7a6c6784a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -67,18 +67,10 @@ public class TransTypes extends TreeTranslator { private Symtab syms; private TreeMaker make; private Enter enter; - private boolean allowEnums; private boolean allowInterfaceBridges; private Types types; private final Resolve resolve; - /** - * Flag to indicate whether or not to generate bridge methods. - * For pre-Tiger source there is no need for bridge methods, so it - * can be skipped to get better performance for -source 1.4 etc. - */ - private final boolean addBridges; - private final CompileStates compileStates; protected TransTypes(Context context) { @@ -90,8 +82,6 @@ public class TransTypes extends TreeTranslator { enter = Enter.instance(context); overridden = new HashMap<>(); Source source = Source.instance(context); - allowEnums = source.allowEnums(); - addBridges = source.addBridges(); allowInterfaceBridges = source.allowDefaultMethods(); types = Types.instance(context); make = TreeMaker.instance(context); @@ -665,9 +655,7 @@ public class TransTypes extends TreeTranslator { Symbol meth = TreeInfo.symbol(tree.meth); Type mt = meth.erasure(types); List argtypes = mt.getParameterTypes(); - if (allowEnums && - meth.name==names.init && - meth.owner == syms.enumSym) + if (meth.name == names.init && meth.owner == syms.enumSym) argtypes = argtypes.tail.tail; if (tree.varargsElement != null) tree.varargsElement = types.erasure(tree.varargsElement); @@ -920,13 +908,11 @@ public class TransTypes extends TreeTranslator { tree.typarams = List.nil(); super.visitClassDef(tree); make.at(tree.pos); - if (addBridges) { - ListBuffer bridges = new ListBuffer<>(); - if (allowInterfaceBridges || (tree.sym.flags() & INTERFACE) == 0) { - addBridges(tree.pos(), c, bridges); - } - tree.defs = bridges.toList().prependList(tree.defs); + ListBuffer bridges = new ListBuffer<>(); + if (allowInterfaceBridges || (tree.sym.flags() & INTERFACE) == 0) { + addBridges(tree.pos(), c, bridges); } + tree.defs = bridges.toList().prependList(tree.defs); tree.type = erasure(tree.type); } finally { make = savedMake; diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 55a7f199a0b..dc9c6389729 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -91,18 +91,6 @@ public class ClassReader { */ public boolean readAllOfClassFile = false; - /** Switch: read GJ signature information. - */ - boolean allowGenerics; - - /** Switch: read varargs attribute. - */ - boolean allowVarargs; - - /** Switch: allow annotations. - */ - boolean allowAnnotations; - /** Switch: allow simplified varargs. */ boolean allowSimplifiedVarargs; @@ -223,9 +211,6 @@ public class ClassReader { checkClassFile = options.isSet("-checkclassfile"); Source source = Source.instance(context); - allowGenerics = source.allowGenerics(); - allowVarargs = source.allowVarargs(); - allowAnnotations = source.allowAnnotations(); allowSimplifiedVarargs = source.allowSimplifiedVarargs(); saveParameterNames = options.isSet("save-parameter-names"); @@ -1026,9 +1011,7 @@ public class ClassReader { new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { - // bridge methods are visible when generics not enabled - if (allowGenerics || (sym.flags_field & BRIDGE) == 0) - sym.flags_field |= SYNTHETIC; + sym.flags_field |= SYNTHETIC; } }, @@ -1043,11 +1026,6 @@ public class ClassReader { }, new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) { - @Override - protected boolean accepts(AttributeKind kind) { - return super.accepts(kind) && allowGenerics; - } - protected void read(Symbol sym, int attrLen) { if (sym.kind == TYP) { ClassSymbol c = (ClassSymbol) sym; @@ -1110,16 +1088,13 @@ public class ClassReader { new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { - if (allowAnnotations) - sym.flags_field |= ANNOTATION; + sym.flags_field |= ANNOTATION; } }, new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { sym.flags_field |= BRIDGE; - if (!allowGenerics) - sym.flags_field &= ~SYNTHETIC; } }, @@ -1131,8 +1106,7 @@ public class ClassReader { new AttributeReader(names.Varargs, V49, CLASS_OR_MEMBER_ATTRIBUTE) { protected void read(Symbol sym, int attrLen) { - if (allowVarargs) - sym.flags_field |= VARARGS; + sym.flags_field |= VARARGS; } }, @@ -2413,8 +2387,6 @@ public class ClassReader { if ((flags & ACC_BRIDGE) != 0) { flags &= ~ACC_BRIDGE; flags |= BRIDGE; - if (!allowGenerics) - flags &= ~SYNTHETIC; } if ((flags & ACC_VARARGS) != 0) { flags &= ~ACC_VARARGS; diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java index 51fadaf90c1..0aca7ad5fae 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java @@ -51,7 +51,6 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; -import static com.sun.tools.javac.jvm.UninitializedType.*; import static com.sun.tools.javac.main.Option.*; import static javax.tools.StandardLocation.CLASS_OUTPUT; @@ -543,8 +542,6 @@ public class ClassWriter extends ClassFile { * Returns the number of attributes written (0 or 1). */ int writeEnclosingMethodAttribute(ClassSymbol c) { - if (!target.hasEnclosingMethodAttribute()) - return 0; return writeEnclosingMethodAttribute(names.EnclosingMethod, c); } @@ -578,31 +575,6 @@ public class ClassWriter extends ClassFile { endAttr(alenIdx); acount++; } - if ((flags & ENUM) != 0 && !target.useEnumFlag()) { - int alenIdx = writeAttr(names.Enum); - endAttr(alenIdx); - acount++; - } - if ((flags & SYNTHETIC) != 0 && !target.useSyntheticFlag()) { - int alenIdx = writeAttr(names.Synthetic); - endAttr(alenIdx); - acount++; - } - if ((flags & BRIDGE) != 0 && !target.useBridgeFlag()) { - int alenIdx = writeAttr(names.Bridge); - endAttr(alenIdx); - acount++; - } - if ((flags & VARARGS) != 0 && !target.useVarargsFlag()) { - int alenIdx = writeAttr(names.Varargs); - endAttr(alenIdx); - acount++; - } - if ((flags & ANNOTATION) != 0 && !target.useAnnotationFlag()) { - int alenIdx = writeAttr(names.Annotation); - endAttr(alenIdx); - acount++; - } return acount; } @@ -612,11 +584,10 @@ public class ClassWriter extends ClassFile { int writeMemberAttrs(Symbol sym) { int acount = writeFlagAttrs(sym.flags()); long flags = sym.flags(); - if (source.allowGenerics() && - (flags & (SYNTHETIC|BRIDGE)) != SYNTHETIC && + if ((flags & (SYNTHETIC | BRIDGE)) != SYNTHETIC && (flags & ANONCONSTR) == 0 && (!types.isSameType(sym.type, sym.erasure(types)) || - signatureGen.hasTypeVar(sym.type.getThrownTypes()))) { + signatureGen.hasTypeVar(sym.type.getThrownTypes()))) { // note that a local class with captured variables // will get a signature attribute int alenIdx = writeAttr(names.Signature); @@ -1252,14 +1223,14 @@ public class ClassWriter extends ClassFile { // output locals int localCount = 0; for (int j=0; j l = types.interfaces(c.type); l.nonEmpty(); l = l.tail) { - ClassSymbol i = (ClassSymbol)l.head.tsym; - for (Symbol sym : i.members().getSymbols(NON_RECURSIVE)) { - if (sym.kind == MTH && (sym.flags() & STATIC) == 0) - { - MethodSymbol absMeth = (MethodSymbol)sym; - MethodSymbol implMeth = absMeth.binaryImplementation(site, types); - if (implMeth == null) - addAbstractMethod(site, absMeth); - else if ((implMeth.flags() & IPROXY) != 0) - adjustAbstractMethod(site, implMeth, absMeth); - } - } - implementInterfaceMethods(i, site); - } - } - - /** Add an abstract methods to a class - * which implicitly implements a method defined in some interface - * implemented by the class. These methods are called "Miranda methods". - * Enter the newly created method into its enclosing class scope. - * Note that it is not entered into the class tree, as the emitter - * doesn't need to see it there to emit an abstract method. - * - * @param c The class to which the Miranda method is added. - * @param m The interface method symbol for which a Miranda method - * is added. - */ - private void addAbstractMethod(ClassSymbol c, - MethodSymbol m) { - MethodSymbol absMeth = new MethodSymbol( - m.flags() | IPROXY | SYNTHETIC, m.name, - m.type, // was c.type.memberType(m), but now only !generics supported - c); - c.members().enter(absMeth); // add to symbol table - } - - private void adjustAbstractMethod(ClassSymbol c, - MethodSymbol pm, - MethodSymbol im) { - MethodType pmt = (MethodType)pm.type; - Type imt = types.memberType(c.type, im); - pmt.thrown = chk.intersect(pmt.getThrownTypes(), imt.getThrownTypes()); - } - /* ************************************************************************ * Traversal methods *************************************************************************/ @@ -1689,13 +1581,8 @@ public class Gen extends JCTree.Visitor { code.addCatch(startpc1, endpc1, handler_pc1, (char)catch_type); } else { - if (!useJsrLocally && !target.generateStackMapTable()) { - useJsrLocally = true; - throw new CodeSizeOverflow(); - } else { - log.error(pos, "limit.code.too.large.for.try.stmt"); - nerrs++; - } + log.error(pos, "limit.code.too.large.for.try.stmt"); + nerrs++; } } @@ -2361,7 +2248,6 @@ public class Gen extends JCTree.Visitor { Symbol sym = tree.sym; if (tree.name == names._class) { - Assert.check(target.hasClassLiterals()); code.emitLdc(makeRef(tree.pos(), tree.selected.type)); result = items.makeStackItem(pt); return; @@ -2472,13 +2358,6 @@ public class Gen extends JCTree.Visitor { ClassSymbol c = cdef.sym; this.toplevel = env.toplevel; this.endPosTable = toplevel.endPositions; - // If this is a class definition requiring Miranda methods, - // add them. - if (generateIproxies && - (c.flags() & (INTERFACE|ABSTRACT)) == ABSTRACT - && !allowGenerics // no Miranda methods available with generics - ) - implementInterfaceMethods(c); cdef.defs = normalizeDefs(cdef.defs, c); c.pool = pool; pool.reset(); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java index dec23681525..8300c1fa9a5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -77,11 +77,9 @@ public enum Target { return instance; } - private static final Target MIN = values()[0]; - public static Target MIN() { return MIN; } + public static final Target MIN = Target.JDK1_6; private static final Target MAX = values()[values().length - 1]; - public static Target MAX() { return MAX; } private static final Map tab = new HashMap<>(); static { @@ -110,132 +108,6 @@ public enum Target { return tab.get(name); } - /** In -target 1.1 and earlier, the compiler is required to emit - * synthetic method definitions in abstract classes for interface - * methods that are not overridden. We call them "Miranda" methods. - */ - public boolean requiresIproxy() { - return compareTo(JDK1_1) <= 0; - } - - /** Beginning in 1.4, we take advantage of the possibility of emitting - * code to initialize fields before calling the superclass constructor. - * This is allowed by the VM spec, but the verifier refused to allow - * it until 1.4. This is necesary to translate some code involving - * inner classes. See, for example, 4030374. - */ - public boolean initializeFieldsBeforeSuper() { - return compareTo(JDK1_4) >= 0; - } - - /** Beginning with -target 1.2 we obey the JLS rules for binary - * compatibility, emitting as the qualifying type of a reference - * to a method or field the type of the qualifier. In earlier - * targets we use as the qualifying type the class in which the - * member was found. The following methods named - * *binaryCompatibility() indicate places where we vary from this - * general rule. */ - public boolean obeyBinaryCompatibility() { - return compareTo(JDK1_2) >= 0; - } - - /** Starting in 1.5, the compiler uses an array type as - * the qualifier for method calls (such as clone) where required by - * the language and VM spec. Earlier versions of the compiler - * qualified them by Object. - */ - public boolean arrayBinaryCompatibility() { - return compareTo(JDK1_5) >= 0; - } - - /** Beginning after 1.2, we follow the binary compatibility rules for - * interface fields. The 1.2 VMs had bugs handling interface fields - * when compiled using binary compatibility (see 4400598), so this is - * an accommodation to them. - */ - public boolean interfaceFieldsBinaryCompatibility() { - return compareTo(JDK1_2) > 0; - } - - /** Beginning in -target 1.5, we follow the binary compatibility - * rules for interface methods that redefine Object methods. - * Earlier VMs had bugs handling such methods compiled using binary - * compatibility (see 4392595, 4398791, 4392595, 4400415). - * The VMs were fixed during or soon after 1.4. See 4392595. - */ - public boolean interfaceObjectOverridesBinaryCompatibility() { - return compareTo(JDK1_5) >= 0; - } - - /** Beginning in -target 1.5, we make synthetic variables - * package-private instead of private. This is to prevent the - * necessity of access methods, which effectively relax the - * protection of the field but bloat the class files and affect - * execution. - */ - public boolean usePrivateSyntheticFields() { - return compareTo(JDK1_5) < 0; - } - - /** Sometimes we need to create a field to cache a value like a - * class literal of the assertions flag. In -target 1.5 and - * later we create a new synthetic class for this instead of - * using the outermost class. See 4401576. - */ - public boolean useInnerCacheClass() { - return compareTo(JDK1_5) >= 0; - } - - /** Return true if cldc-style stack maps need to be generated. */ - public boolean generateCLDCStackmap() { - return false; - } - - /** Beginning in -target 6, we generate stackmap attribute in - * compact format. */ - public boolean generateStackMapTable() { - return compareTo(JDK1_6) >= 0; - } - - /** Beginning in -target 6, package-info classes are marked synthetic. - */ - public boolean isPackageInfoSynthetic() { - return compareTo(JDK1_6) >= 0; - } - - /** Do we generate "empty" stackmap slots after double and long? - */ - public boolean generateEmptyAfterBig() { - return false; - } - - /** Beginning in 1.5, we have an unsynchronized version of - * StringBuffer called StringBuilder that can be used by the - * compiler for string concatenation. - */ - public boolean useStringBuilder() { - return compareTo(JDK1_5) >= 0; - } - - /** Beginning in 1.5, we have flag bits we can use instead of - * marker attributes. - */ - public boolean useSyntheticFlag() { - return compareTo(JDK1_5) >= 0; - } - public boolean useEnumFlag() { - return compareTo(JDK1_5) >= 0; - } - public boolean useAnnotationFlag() { - return compareTo(JDK1_5) >= 0; - } - public boolean useVarargsFlag() { - return compareTo(JDK1_5) >= 0; - } - public boolean useBridgeFlag() { - return compareTo(JDK1_5) >= 0; - } - /** Return the character to be used in constructing synthetic * identifiers, where not specified by the JLS. */ @@ -243,12 +115,6 @@ public enum Target { return '$'; } - /** Does the VM have direct support for class literals? - */ - public boolean hasClassLiterals() { - return compareTo(JDK1_5) >= 0; - } - /** Does the VM support an invokedynamic instruction? */ public boolean hasInvokedynamic() { @@ -263,39 +129,4 @@ public enum Target { return hasInvokedynamic(); } - /** Although we may not have support for class literals, should we - * avoid initializing the class that the literal refers to? - * See 4468823 - */ - public boolean classLiteralsNoInit() { - return compareTo(JDK1_5) >= 0; - } - - /** Although we may not have support for class literals, when we - * throw a NoClassDefFoundError, should we initialize its cause? - */ - public boolean hasInitCause() { - return compareTo(JDK1_4) >= 0; - } - - /** For bootstrapping, we use J2SE1.4's wrapper class constructors - * to implement boxing. - */ - public boolean boxWithConstructors() { - return compareTo(JDK1_5) < 0; - } - - /** For bootstrapping, we use J2SE1.4's java.util.Collection - * instead of java.lang.Iterable. - */ - public boolean hasIterable() { - return compareTo(JDK1_5) >= 0; - } - - /** In J2SE1.5.0, we introduced the "EnclosingMethod" attribute - * for improved reflection support. - */ - public boolean hasEnclosingMethodAttribute() { - return compareTo(JDK1_5) >= 0; - } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 97dfb97e1bb..19f8a72c63e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -441,20 +441,36 @@ public class JavaCompiler { // Unless lint checking on options is disabled, check for // obsolete source and target options. boolean obsoleteOptionFound = false; - if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) { - if (source.compareTo(Source.JDK1_5) <= 0) { - log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); - obsoleteOptionFound = true; - } - if (target.compareTo(Target.JDK1_5) <= 0) { - log.warning(LintCategory.OPTIONS, "option.obsolete.target", target.name); - obsoleteOptionFound = true; - } + boolean lintOptions = + options.isUnset(XLINT_CUSTOM, "-"+LintCategory.OPTIONS.option); + + switch (source.compareTo(Source.MIN)) { + case -1: + log.error("option.removed.source", source.name, Source.MIN.name); + break; + case 0: + if (lintOptions) { + log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); + obsoleteOptionFound = true; + } + break; + } + // check target version request + switch (target.compareTo(Target.MIN)) { + case -1: + log.error("option.removed.target", target.name, Target.MIN.name); + break; + case 0: + if (lintOptions) { + log.warning(LintCategory.OPTIONS, "option.obsolete.target", target.name); + obsoleteOptionFound = true; + } + break; + } if (obsoleteOptionFound) log.warning(LintCategory.OPTIONS, "option.obsolete.suppression"); - } } /* Switches: diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java index ec95d298964..2428644f3ca 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java @@ -295,11 +295,7 @@ public class Main { Target target = (targetString != null) ? Target.lookup(targetString) : Target.DEFAULT; - // We don't check source/target consistency for CLDC, as J2ME - // profiles are not aligned with J2SE targets; moreover, a - // single CLDC target may have many profiles. In addition, - // this is needed for the continued functioning of the JSR14 - // prototype. + if (Character.isDigit(target.name.charAt(0))) { if (target.compareTo(source.requiredTarget()) < 0) { if (targetString != null) { @@ -317,11 +313,6 @@ public class Main { target = source.requiredTarget(); options.put("-target", target.name); } - } else { - if (targetString == null && !source.allowGenerics()) { - target = Target.JDK1_4; - options.put("-target", target.name); - } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java index b24684776aa..762c03149de 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java @@ -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 @@ -46,10 +46,6 @@ public class JavaTokenizer { private static final boolean scannerDebug = false; - /** Allow hex floating-point literals. - */ - private boolean allowHexFloats; - /** Allow binary literals. */ private boolean allowBinaryLiterals; @@ -126,7 +122,6 @@ public class JavaTokenizer { this.source = fac.source; this.reader = reader; this.allowBinaryLiterals = source.allowBinaryLiterals(); - this.allowHexFloats = source.allowHexFloats(); this.allowUnderscoresInLiterals = source.allowUnderscoresInLiterals(); } @@ -220,11 +215,7 @@ public class JavaTokenizer { skipIllegalUnderscores(); if ('0' <= reader.ch && reader.ch <= '9') { scanDigits(pos, 10); - if (!allowHexFloats) { - lexError(pos, "unsupported.fp.lit", source.name); - allowHexFloats = true; - } - else if (!hexFloatsWork) + if (!hexFloatsWork) lexError(pos, "unsupported.cross.fp.lit"); } else lexError(pos, "malformed.fp.lit"); diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index 25bbf6dfdf4..41f024a1baf 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -144,13 +144,6 @@ public class JavacParser implements Parser { this.log = fac.log; this.names = fac.names; this.source = fac.source; - this.allowGenerics = source.allowGenerics(); - this.allowVarargs = source.allowVarargs(); - this.allowAsserts = source.allowAsserts(); - this.allowEnums = source.allowEnums(); - this.allowForeach = source.allowForeach(); - this.allowStaticImport = source.allowStaticImport(); - this.allowAnnotations = source.allowAnnotations(); this.allowTWR = source.allowTryWithResources(); this.allowDiamond = source.allowDiamond(); this.allowMulticatch = source.allowMulticatch(); @@ -179,10 +172,6 @@ public class JavacParser implements Parser { return keepDocComments ? new LazyDocCommentTable(fac) : null; } - /** Switch: Should generics be recognized? - */ - boolean allowGenerics; - /** Switch: Should diamond operator be recognized? */ boolean allowDiamond; @@ -191,30 +180,6 @@ public class JavacParser implements Parser { */ boolean allowMulticatch; - /** Switch: Should varargs be recognized? - */ - boolean allowVarargs; - - /** Switch: should we recognize assert statements, or just give a warning? - */ - boolean allowAsserts; - - /** Switch: should we recognize enums, or just give a warning? - */ - boolean allowEnums; - - /** Switch: should we recognize foreach? - */ - boolean allowForeach; - - /** Switch: should we recognize foreach? - */ - boolean allowStaticImport; - - /** Switch: should we recognize annotations? - */ - boolean allowAnnotations; - /** Switch: should we recognize try-with-resources? */ boolean allowTWR; @@ -419,8 +384,8 @@ public class JavacParser implements Parser { return; break; case ASSERT: - if (stopAtStatement && allowAsserts) - return ; + if (stopAtStatement) + return; break; } nextToken(); @@ -604,27 +569,13 @@ public class JavacParser implements Parser { nextToken(); return name; } else if (token.kind == ASSERT) { - if (allowAsserts) { - error(token.pos, "assert.as.identifier"); - nextToken(); - return names.error; - } else { - warning(token.pos, "assert.as.identifier"); - Name name = token.name(); - nextToken(); - return name; - } + error(token.pos, "assert.as.identifier"); + nextToken(); + return names.error; } else if (token.kind == ENUM) { - if (allowEnums) { - error(token.pos, "enum.as.identifier"); - nextToken(); - return names.error; - } else { - warning(token.pos, "enum.as.identifier"); - Name name = token.name(); - nextToken(); - return name; - } + error(token.pos, "enum.as.identifier"); + nextToken(); + return names.error; } else if (token.kind == THIS) { if (allowThisIdent) { // Make sure we're using a supported source version. @@ -1340,7 +1291,6 @@ public class JavacParser implements Parser { } accept(GT); t = toP(F.at(pos1).TypeApply(t, args.toList())); - checkGenerics(); while (token.kind == DOT) { nextToken(); mode = TYPE; @@ -1815,7 +1765,6 @@ public class JavacParser implements Parser { (mode & TYPE) != 0 && (mode & NOPARAMS) == 0) { mode = TYPE; - checkGenerics(); return typeArguments(t, false); } else { return t; @@ -1827,7 +1776,6 @@ public class JavacParser implements Parser { List typeArgumentsOpt(int useMode) { if (token.kind == LT) { - checkGenerics(); if ((mode & useMode) == 0 || (mode & NOPARAMS) != 0) { illegal(); @@ -2060,7 +2008,6 @@ public class JavacParser implements Parser { boolean diamondFound = false; int lastTypeargsPos = -1; if (token.kind == LT) { - checkGenerics(); lastTypeargsPos = token.pos; t = typeArguments(t, true); diamondFound = (mode & DIAMOND) != 0; @@ -2081,7 +2028,6 @@ public class JavacParser implements Parser { if (token.kind == LT) { lastTypeargsPos = token.pos; - checkGenerics(); t = typeArguments(t, true); diamondFound = (mode & DIAMOND) != 0; } @@ -2153,7 +2099,6 @@ public class JavacParser implements Parser { if (token.kind == LT) { int oldmode = mode; - checkGenerics(); t = typeArguments(t, true); mode = oldmode; } @@ -2357,7 +2302,6 @@ public class JavacParser implements Parser { } } - @SuppressWarnings("fallthrough") List blockStatement() { //todo: skip to anchor on error(?) int pos = token.pos; @@ -2374,7 +2318,7 @@ public class JavacParser implements Parser { JCModifiers mods = modifiersOpt(); if (token.kind == INTERFACE || token.kind == CLASS || - allowEnums && token.kind == ENUM) { + token.kind == ENUM) { return List.of(classOrInterfaceOrEnumDeclaration(mods, dc)); } else { JCExpression t = parseType(); @@ -2396,15 +2340,11 @@ public class JavacParser implements Parser { Comment dc = token.comment(CommentStyle.JAVADOC); return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc)); case ENUM: + error(token.pos, "local.enum"); + dc = token.comment(CommentStyle.JAVADOC); + return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc)); case ASSERT: - if (allowEnums && token.kind == ENUM) { - error(token.pos, "local.enum"); - dc = token.comment(CommentStyle.JAVADOC); - return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc)); - } else if (allowAsserts && token.kind == ASSERT) { - return List.of(parseStatement()); - } - /* fall through to default */ + return List.of(parseStatement()); default: Token prevToken = token; JCExpression t = term(EXPR | TYPE); @@ -2452,7 +2392,6 @@ public class JavacParser implements Parser { * | ExpressionStatement * | Ident ":" Statement */ - @SuppressWarnings("fallthrough") public JCStatement parseStatement() { int pos = token.pos; switch (token.kind) { @@ -2477,7 +2416,6 @@ public class JavacParser implements Parser { inits.head.hasTag(VARDEF) && ((JCVariableDecl) inits.head).init == null && token.kind == COLON) { - checkForeach(); JCVariableDecl var = (JCVariableDecl)inits.head; accept(COLON); JCExpression expr = parseExpression(); @@ -2593,19 +2531,16 @@ public class JavacParser implements Parser { case CATCH: return doRecover(token.pos, BasicErrorRecoveryAction.CATCH_CLAUSE, "catch.without.try"); case ASSERT: { - if (allowAsserts && token.kind == ASSERT) { + nextToken(); + JCExpression assertion = parseExpression(); + JCExpression message = null; + if (token.kind == COLON) { nextToken(); - JCExpression assertion = parseExpression(); - JCExpression message = null; - if (token.kind == COLON) { - nextToken(); - message = parseExpression(); - } - accept(SEMI); - JCAssert t = toP(F.at(pos).Assert(assertion, message)); - return t; + message = parseExpression(); } - /* else fall through to default case */ + accept(SEMI); + JCAssert t = toP(F.at(pos).Assert(assertion, message)); + return t; } case ENUM: default: @@ -2831,7 +2766,6 @@ public class JavacParser implements Parser { lastPos = token.pos; nextToken(); if (flag == Flags.ANNOTATION) { - checkAnnotations(); if (token.kind != INTERFACE) { JCAnnotation ann = annotation(lastPos, Tag.ANNOTATION); // if first modifier is an annotation, set pos to annotation's. @@ -2867,7 +2801,6 @@ public class JavacParser implements Parser { */ JCAnnotation annotation(int pos, Tag kind) { // accept(AT); // AT consumed by caller - checkAnnotations(); if (kind == Tag.TYPE_ANNOTATION) { checkTypeAnnotations(); } @@ -3166,7 +3099,6 @@ public class JavacParser implements Parser { nextToken(); boolean importStatic = false; if (token.kind == STATIC) { - checkStaticImports(); importStatic = true; nextToken(); } @@ -3209,27 +3141,9 @@ public class JavacParser implements Parser { return classDeclaration(mods, dc); } else if (token.kind == INTERFACE) { return interfaceDeclaration(mods, dc); - } else if (allowEnums) { - if (token.kind == ENUM) { - return enumDeclaration(mods, dc); - } else { - int pos = token.pos; - List errs; - if (LAX_IDENTIFIER.accepts(token.kind)) { - errs = List.of(mods, toP(F.at(pos).Ident(ident()))); - setErrorEndPos(token.pos); - } else { - errs = List.of(mods); - } - return toP(F.Exec(syntaxError(pos, errs, "expected3", - CLASS, INTERFACE, ENUM))); - } + } else if (token.kind == ENUM) { + return enumDeclaration(mods, dc); } else { - if (token.kind == ENUM) { - error(token.pos, "enums.not.supported.in.source", source.name); - allowEnums = true; - return enumDeclaration(mods, dc); - } int pos = token.pos; List errs; if (LAX_IDENTIFIER.accepts(token.kind)) { @@ -3238,8 +3152,8 @@ public class JavacParser implements Parser { } else { errs = List.of(mods); } - return toP(F.Exec(syntaxError(pos, errs, "expected2", - CLASS, INTERFACE))); + return toP(F.Exec(syntaxError(pos, errs, "expected3", + CLASS, INTERFACE, ENUM))); } } @@ -3315,7 +3229,7 @@ public class JavacParser implements Parser { mods.flags |= Flags.ENUM; JCClassDecl result = toP(F.at(pos). ClassDef(mods, name, List.nil(), - null, implementing, defs)); + null, implementing, defs)); attach(result, dc); return result; } @@ -3465,7 +3379,7 @@ public class JavacParser implements Parser { JCModifiers mods = modifiersOpt(); if (token.kind == CLASS || token.kind == INTERFACE || - allowEnums && token.kind == ENUM) { + token.kind == ENUM) { return List.of(classOrInterfaceOrEnumDeclaration(mods, dc)); } else if (token.kind == LBRACE && (mods.flags & Flags.StandardFlags & ~Flags.STATIC) == 0 && @@ -3634,7 +3548,6 @@ public class JavacParser implements Parser { */ List typeParametersOpt() { if (token.kind == LT) { - checkGenerics(); ListBuffer typarams = new ListBuffer<>(); nextToken(); typarams.append(typeParameter()); @@ -3822,7 +3735,6 @@ public class JavacParser implements Parser { if (token.kind == ELLIPSIS) { List varargsAnnos = typeAnnotationsPushedBack; typeAnnotationsPushedBack = List.nil(); - checkVarargs(); mods.flags |= Flags.VARARGS; // insert var arg type annotations type = insertAnnotationsToMostInner(type, varargsAnnos, true); @@ -4009,36 +3921,6 @@ public class JavacParser implements Parser { } } - void checkGenerics() { - if (!allowGenerics) { - error(token.pos, "generics.not.supported.in.source", source.name); - allowGenerics = true; - } - } - void checkVarargs() { - if (!allowVarargs) { - error(token.pos, "varargs.not.supported.in.source", source.name); - allowVarargs = true; - } - } - void checkForeach() { - if (!allowForeach) { - error(token.pos, "foreach.not.supported.in.source", source.name); - allowForeach = true; - } - } - void checkStaticImports() { - if (!allowStaticImport) { - error(token.pos, "static.import.not.supported.in.source", source.name); - allowStaticImport = true; - } - } - void checkAnnotations() { - if (!allowAnnotations) { - error(token.pos, "annotations.not.supported.in.source", source.name); - allowAnnotations = true; - } - } void checkDiamond() { if (!allowDiamond) { error(token.pos, "diamond.not.supported.in.source", source.name); diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 5df19716849..6bd6b57d87b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -720,6 +720,7 @@ compiler.err.neither.conditional.subtype=\ second operand: {0}\n\ third operand : {1} + # 0: message segment compiler.misc.incompatible.type.in.conditional=\ bad type in conditional expression\n\ @@ -1467,6 +1468,14 @@ compiler.warn.option.obsolete.source=\ compiler.warn.option.obsolete.target=\ target value {0} is obsolete and will be removed in a future release +# 0: string, 1: string +compiler.err.option.removed.source=\ + Source option {0} is no longer supported. Use {1} or later. + +# 0: string, 1: string +compiler.err.option.removed.target=\ + Target option {0} is no longer supported. Use {1} or later. + compiler.warn.option.obsolete.suppression=\ To suppress warnings about obsolete options, use -Xlint:-options. @@ -2234,11 +2243,6 @@ compiler.misc.inapplicable.method=\ ######################################## # Diagnostics for language feature changes ######################################## -# 0: string -compiler.err.unsupported.fp.lit=\ - hexadecimal floating point literals are not supported in -source {0}\n\ - (use -source 5 or higher to enable hexadecimal floating point literals) - # 0: string compiler.err.unsupported.binary.lit=\ binary literals are not supported in -source {0}\n\ @@ -2254,14 +2258,6 @@ compiler.err.try.with.resources.not.supported.in.source=\ try-with-resources is not supported in -source {0}\n\ (use -source 7 or higher to enable try-with-resources) -compiler.warn.enum.as.identifier=\ - as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\ - (use -source 5 or higher to use ''enum'' as a keyword) - -compiler.warn.assert.as.identifier=\ - as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier\n\ - (use -source 1.4 or higher to use ''assert'' as a keyword) - compiler.warn.underscore.as.identifier=\ ''_'' used as an identifier\n\ (use of ''_'' as an identifier might not be supported in releases after Java SE 8) @@ -2271,12 +2267,10 @@ compiler.err.underscore.as.identifier.in.lambda=\ (use of ''_'' as an identifier is forbidden for lambda parameters) compiler.err.enum.as.identifier=\ - as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\ - (use -source 1.4 or lower to use ''enum'' as an identifier) + as of release 5, ''enum'' is a keyword, and may not be used as an identifier compiler.err.assert.as.identifier=\ - as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier\n\ - (use -source 1.3 or lower to use ''assert'' as an identifier) + as of release 1.4, ''assert'' is a keyword, and may not be used as an identifier # TODO 308: make a better error message compiler.err.this.as.identifier=\ @@ -2323,21 +2317,6 @@ compiler.err.incorrect.constructor.receiver.name=\ compiler.err.no.annotations.on.dot.class=\ no annotations are allowed in the type of a class literal -# 0: string -compiler.err.generics.not.supported.in.source=\ - generics are not supported in -source {0}\n\ - (use -source 5 or higher to enable generics) - -# 0: string -compiler.err.varargs.not.supported.in.source=\ - variable-arity methods are not supported in -source {0}\n\ - (use -source 5 or higher to enable variable-arity methods) - -# 0: string -compiler.err.annotations.not.supported.in.source=\ - annotations are not supported in -source {0}\n\ - (use -source 5 or higher to enable annotations) - # 0: string compiler.err.type.annotations.not.supported.in.source=\ type annotations are not supported in -source {0}\n\ @@ -2353,21 +2332,6 @@ compiler.err.repeatable.annotations.not.supported.in.source=\ repeated annotations are not supported in -source {0}\n\ (use -source 8 or higher to enable repeated annotations) -# 0: string -compiler.err.foreach.not.supported.in.source=\ - enhanced for loops are not supported in -source {0}\n\ - (use -source 5 or higher to enable for-each loops) - -# 0: string -compiler.err.static.import.not.supported.in.source=\ - static import declarations are not supported in -source {0}\n\ - (use -source 5 or higher to enable static import declarations) - -# 0: string -compiler.err.enums.not.supported.in.source=\ - enums are not supported in -source {0}\n\ - (use -source 5 or higher to enable enums) - # 0: string compiler.err.diamond.not.supported.in.source=\ diamond operator is not supported in -source {0}\n\ diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java index 691b9c66639..81290165535 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java @@ -270,16 +270,9 @@ public abstract class BaseFileManager implements JavaFileManager { } else if (result.isMalformed() || result.isUnmappable()) { // bad character in input - // report coding error (warn only pre 1.5) - if (!getSource().allowEncodingErrors()) { - log.error(new SimpleDiagnosticPosition(dest.limit()), - "illegal.char.for.encoding", - charset == null ? encodingName : charset.name()); - } else { - log.warning(new SimpleDiagnosticPosition(dest.limit()), - "illegal.char.for.encoding", - charset == null ? encodingName : charset.name()); - } + log.error(new SimpleDiagnosticPosition(dest.limit()), + "illegal.char.for.encoding", + charset == null ? encodingName : charset.name()); // skip past the coding error inbuf.position(inbuf.position() + result.length()); diff --git a/langtools/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java b/langtools/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java index 6a6f9a12e49..5389acbfacd 100644 --- a/langtools/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java +++ b/langtools/test/tools/javac/defaultMethods/crossCompile/CrossCompile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -25,7 +25,7 @@ * @test * @bug 7192246 * @summary check that clinit in interface doesn't cause spurious default method diagnostics - * @compile -source 1.4 -target 1.4 Clinit.java + * @compile Clinit.java * @compile CrossCompile.java */ class CrossCompile { diff --git a/langtools/test/tools/javac/defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8Test.java b/langtools/test/tools/javac/defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8Test.java index ea128931ab9..436f02b63c6 100644 --- a/langtools/test/tools/javac/defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8Test.java +++ b/langtools/test/tools/javac/defaultMethodsVisibility/DefaultMethodsNotVisibleForSourceLessThan8Test.java @@ -101,10 +101,6 @@ public class DefaultMethodsNotVisibleForSourceLessThan8Test { public static void main(String[] args) throws Exception { String[] sources = new String[] { - "1.2", - "1.3", - "1.4", - "1.5", "1.6", "1.7", }; diff --git a/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java b/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java deleted file mode 100644 index e318d70d6e3..00000000000 --- a/langtools/test/tools/javac/diags/examples/AnnotationsNotSupported.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.annotations.not.supported.in.source -// options: -source 1.4 -Xlint:-options - -@Deprecated -class AnnotationsNotSupported { } diff --git a/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java b/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java deleted file mode 100644 index 5a4e5a258f3..00000000000 --- a/langtools/test/tools/javac/diags/examples/AssertAsIdentifier.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.warn.assert.as.identifier -// options: -source 1.3 -Xlint:-options - -class AssertAsIdentifier { - int assert; -} diff --git a/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java b/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java deleted file mode 100644 index bfa3d211ad3..00000000000 --- a/langtools/test/tools/javac/diags/examples/EnumAsIdentifier.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.warn.enum.as.identifier -// options: -source 1.3 -Xlint:-options - -class EnumAsIdentifier { - int enum; -} diff --git a/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java b/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java deleted file mode 100644 index 5b90eec64b4..00000000000 --- a/langtools/test/tools/javac/diags/examples/EnumsNotSupported.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.enums.not.supported.in.source -// options: -source 1.4 -Xlint:-options - -enum EnumsNotSupported { A, B, C } diff --git a/langtools/test/tools/javac/diags/examples/Expected2.java b/langtools/test/tools/javac/diags/examples/Expected2.java index 0eee97aff20..e19b2d38799 100644 --- a/langtools/test/tools/javac/diags/examples/Expected2.java +++ b/langtools/test/tools/javac/diags/examples/Expected2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -22,6 +22,12 @@ */ // key: compiler.err.expected2 -// options: -source 1.4 -Xlint:-options +// options: -Xlint:-options -int Expected2; +class Expected2 { + + void m(){ + new x1; + + } +} diff --git a/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java b/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java deleted file mode 100644 index d64f74cb824..00000000000 --- a/langtools/test/tools/javac/diags/examples/GenericsNotSupported.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.generics.not.supported.in.source -// options: -source 1.4 -Xlint:-options - -class GenericsNotSupported { } diff --git a/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java b/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java index ac766332aad..7237cf5a8d5 100644 --- a/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java +++ b/langtools/test/tools/javac/diags/examples/NeitherConditionalSubtype.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -22,10 +22,13 @@ */ // key: compiler.err.neither.conditional.subtype -// options: -source 1.4 -Xlint:-options -class X { - Object m(boolean b) { - return (b ? 3 : b); +class NeitherConditionalSubtype { + public int test(Object o) { + // Should fail to compile since Object.wait() has a void return type. + System.out.println(o instanceof String ? o.hashCode() : o.wait()); + return 0; } } + + diff --git a/langtools/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java b/langtools/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java index 10416fd6aab..9ae185bedb6 100644 --- a/langtools/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java +++ b/langtools/test/tools/javac/diags/examples/ObsoleteSourceAndTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,7 +25,7 @@ // key: compiler.warn.option.obsolete.target // key: compiler.warn.option.obsolete.suppression // key: compiler.warn.source.no.bootclasspath -// options: -source 1.5 -target 1.5 +// options: -source 1.6 -target 1.6 class ObsoleteSourceAndTarget { public static void foo() {;} diff --git a/langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java b/langtools/test/tools/javac/diags/examples/OptionRemovedSource.java similarity index 79% rename from langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java rename to langtools/test/tools/javac/diags/examples/OptionRemovedSource.java index 8f70b6e88d8..fadc5142f0c 100644 --- a/langtools/test/tools/javac/diags/examples/UnsupportedFpLit.java +++ b/langtools/test/tools/javac/diags/examples/OptionRemovedSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -21,9 +21,10 @@ * questions. */ -// key: compiler.err.unsupported.fp.lit -// options: -source 1.4 -Xlint:-options +// key: compiler.err.option.removed.source +// key: compiler.warn.source.no.bootclasspath +// options: -source 1.5 -class UnsupportedFpLit { - float f = 0xCafe.BabeP1; +class RemovedSourceAndTarget { + public static void foo() {;} } diff --git a/langtools/test/tools/javac/diags/examples/ForeachNotSupported.java b/langtools/test/tools/javac/diags/examples/OptionRemovedTarget.java similarity index 75% rename from langtools/test/tools/javac/diags/examples/ForeachNotSupported.java rename to langtools/test/tools/javac/diags/examples/OptionRemovedTarget.java index 2590cb3c721..81f6d8e0ee0 100644 --- a/langtools/test/tools/javac/diags/examples/ForeachNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/OptionRemovedTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -21,13 +21,11 @@ * questions. */ -// key: compiler.err.foreach.not.supported.in.source -// options: -source 1.4 -Xlint:-options +// key: compiler.err.option.removed.source +// key: compiler.err.option.removed.target +// key: compiler.warn.source.no.bootclasspath +// options: -source 1.5 -target 1.5 -class ForeachNotSupported { - void m(String[] args) { - for (String a: args) { - System.out.println(a); - } - } +class RemovedSourceAndTarget { + public static void foo() {;} } diff --git a/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java b/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java index 6cc20165cef..d1d81a0f2d3 100644 --- a/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java +++ b/langtools/test/tools/javac/diags/examples/SourceNoBootclasspath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 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 @@ -22,6 +22,6 @@ */ // key: compiler.warn.source.no.bootclasspath -// options: -source 6 +// options: -source 7 class SourceNoBootclasspath { } diff --git a/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java b/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java deleted file mode 100644 index c545c19cd06..00000000000 --- a/langtools/test/tools/javac/diags/examples/StaticImportNotSupported.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.static.import.not.supported.in.source -// options: -source 1.4 -Xlint:-options - -import static java.util.regex.Pattern.*; - -class StaticImportNotSupported { } diff --git a/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java b/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java index 16e6b8b51d3..a91f21db743 100644 --- a/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.java +++ b/langtools/test/tools/javac/diags/examples/TypeAnnotationsNotSupported.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 @@ -23,7 +23,7 @@ // key: compiler.err.type.annotations.not.supported.in.source // key: compiler.warn.source.no.bootclasspath -// options: -source 6 +// options: -source 7 @interface Anno { } diff --git a/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java b/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java deleted file mode 100644 index 110b71af421..00000000000 --- a/langtools/test/tools/javac/diags/examples/VarargsNotSupported.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -// key: compiler.err.varargs.not.supported.in.source -// options: -source 1.4 -Xlint:-options - -class VarargsNotSupported { - void m(String... args) { } -} diff --git a/langtools/test/tools/javac/expression/_super/NonDirectSuper/Base.java b/langtools/test/tools/javac/expression/_super/NonDirectSuper/Base.java deleted file mode 100644 index cbe5b967f28..00000000000 --- a/langtools/test/tools/javac/expression/_super/NonDirectSuper/Base.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package base; - -public class Base extends PackagePrivate { } - -class PackagePrivate { - protected int refTobaseBase() { - return 0; - } - protected int refTotestOtherPackageTest() { - return 0; - } - protected int refTotestTarget11() { - return 0; - } - protected int refTotestCurPackagePrivateExt11() { - return 0; - } - protected int refTobaseBase; - protected int refTotestOtherPackageTest; - protected int refTotestTarget11; - protected int refTotestCurPackagePrivateExt11; -} diff --git a/langtools/test/tools/javac/expression/_super/NonDirectSuper/NonDirectSuper.java b/langtools/test/tools/javac/expression/_super/NonDirectSuper/NonDirectSuper.java deleted file mode 100644 index e9070e0b188..00000000000 --- a/langtools/test/tools/javac/expression/_super/NonDirectSuper/NonDirectSuper.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 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. - * - * 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 8027789 - * @summary check that the direct superclass is used as the site when calling - * a superclass' method - * @compile Base.java NonDirectSuper.java - * @compile -source 1.2 -target 1.1 Target11.java - * @run main test.NonDirectSuper - */ - -package test; - -import java.io.File; - -import com.sun.tools.classfile.Attribute; -import com.sun.tools.classfile.ClassFile; -import com.sun.tools.classfile.Code_attribute; -import com.sun.tools.classfile.ConstantPool.CPRefInfo; -import com.sun.tools.classfile.Instruction; -import com.sun.tools.classfile.Method; -import com.sun.tools.classfile.Opcode; - -public class NonDirectSuper { - public static void main(String... args) { - new NonDirectSuper().run(); - } - - void run() { - String workDir = System.getProperty("test.classes"); - File testPackage = new File(workDir, "test"); - - for (File clazz : testPackage.listFiles()) { - if ("NonDirectSuper.class".equals(clazz.getName())) continue; - verifyInvokeSpecialRefToObject(clazz); - } - } - - void verifyInvokeSpecialRefToObject(File clazz) { - try { - final ClassFile cf = ClassFile.read(clazz); - for (Method m : cf.methods) { - Code_attribute codeAttr = (Code_attribute)m.attributes.get(Attribute.Code); - for (Instruction instr : codeAttr.getInstructions()) { - if (instr.getOpcode() == Opcode.INVOKESPECIAL || - instr.getOpcode() == Opcode.INVOKEVIRTUAL) { - int pc_index = instr.getShort(1); - CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index); - String className = ref.getClassName(); - String methodName = ref.getNameAndTypeInfo().getName(); - if (methodName.equals("toString")) { - if (!className.equals("java/lang/Object")) - throw new IllegalStateException("Must directly refer to j.l.Object"); - } else if (methodName.startsWith("refTo")) { - String expectedClass = methodName.substring("refTo".length()); - if (!className.replace("/", "").equals(expectedClass)) { - throw new IllegalStateException("Unexpected reference to: " + - className + ", should be " + expectedClass); - } - } - } - if (instr.getOpcode() == Opcode.GETFIELD || - instr.getOpcode() == Opcode.PUTFIELD) { - int pc_index = instr.getShort(1); - CPRefInfo ref = (CPRefInfo)cf.constant_pool.get(pc_index); - String className = ref.getClassName(); - String fieldName = ref.getNameAndTypeInfo().getName(); - if (fieldName.startsWith("refTo")) { - String expectedClass = fieldName.substring("refTo".length()); - if (!className.replace("/", "").equals(expectedClass)) { - throw new IllegalStateException("Unexpected reference to: " + - className + ", should be " + expectedClass); - } - } - } - } - } - } catch (Exception e) { - e.printStackTrace(); - throw new Error("error reading " + clazz +": " + e); - } - } -} - -class OtherPackageTest extends base.Base { - void run() { - new Runnable() { - public void run() { - OtherPackageTest.super.refTobaseBase(); - OtherPackageTest.super.refTobaseBase = OtherPackageTest.super.refTobaseBase + 1; - OtherPackageTest.super.toString(); - refTotestOtherPackageTest(); - refTotestOtherPackageTest = refTotestOtherPackageTest + 1; - OtherPackageTest.this.refTotestOtherPackageTest(); - OtherPackageTest.this.refTotestOtherPackageTest = - OtherPackageTest.this.refTotestOtherPackageTest + 1; - } - }.run(); - super.refTobaseBase(); - super.refTobaseBase = super.refTobaseBase + 1; - super.toString(); - OtherPackageTest.super.refTobaseBase(); - OtherPackageTest.super.refTobaseBase = OtherPackageTest.super.refTobaseBase + 1; - OtherPackageTest.super.toString(); - refTotestOtherPackageTest(); - refTotestOtherPackageTest = refTotestOtherPackageTest + 1; - } - - static class InnerBase { - private void refTotestOtherPackageTest$InnerBase() { } - } - static class InnerTest extends InnerBase { - void run() { - new Runnable() { - public void run() { - InnerTest.super.refTotestOtherPackageTest$InnerBase(); - } - }.run(); - super.refTotestOtherPackageTest$InnerBase(); - InnerTest.super.refTotestOtherPackageTest$InnerBase(); - } - } -} - -class CurPackagePrivateBase { - void refTotestCurPackagePrivateExt() { } - void refTotestCurPackagePrivateTest() { } - int refTotestCurPackagePrivateExt; - int refTotestCurPackagePrivateTest; -} - -class CurPackagePrivateExt extends CurPackagePrivateBase { -} - -class CurPackagePrivateTest extends CurPackagePrivateExt { - void run() { - new Runnable() { - public void run() { - CurPackagePrivateTest.super.refTotestCurPackagePrivateExt(); - CurPackagePrivateTest.super.refTotestCurPackagePrivateExt = - CurPackagePrivateTest.super.refTotestCurPackagePrivateExt + 1; - CurPackagePrivateTest.this.refTotestCurPackagePrivateTest(); - CurPackagePrivateTest.this.refTotestCurPackagePrivateTest = - CurPackagePrivateTest.this.refTotestCurPackagePrivateTest + 1; - refTotestCurPackagePrivateTest(); - refTotestCurPackagePrivateTest = refTotestCurPackagePrivateTest + 1; - } - }.run(); - super.refTotestCurPackagePrivateExt(); - super.refTotestCurPackagePrivateExt = super.refTotestCurPackagePrivateExt + 1; - CurPackagePrivateTest.super.refTotestCurPackagePrivateExt(); - CurPackagePrivateTest.super.refTotestCurPackagePrivateExt = - CurPackagePrivateTest.super.refTotestCurPackagePrivateExt + 1; - refTotestCurPackagePrivateTest(); - refTotestCurPackagePrivateTest = refTotestCurPackagePrivateTest + 1; - } -} diff --git a/langtools/test/tools/javac/expression/_super/NonDirectSuper/Target11.java b/langtools/test/tools/javac/expression/_super/NonDirectSuper/Target11.java deleted file mode 100644 index a2d1e6677e1..00000000000 --- a/langtools/test/tools/javac/expression/_super/NonDirectSuper/Target11.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package test; - -class Target11 extends CurPackagePrivateExt11 { - void run() { - new Runnable() { - public void run() { - Target11.super.refTotestCurPackagePrivateBase11(); - Target11.super.refTotestCurPackagePrivateBase11 = - Target11.super.refTotestCurPackagePrivateBase11 + 1; - Target11.super.refTotestCurPackagePrivateExt11(); - Target11.super.refTotestCurPackagePrivateExt11 = - Target11.super.refTotestCurPackagePrivateExt11 + 1; - Target11.super.toString(); - refTotestCurPackagePrivateBase11(); - refTotestCurPackagePrivateBase11 = - refTotestCurPackagePrivateBase11 + 1; - refTotestTarget11(); - refTotestTarget11 = refTotestTarget11 + 1; - Target11.this.refTotestCurPackagePrivateBase11(); - Target11.this.refTotestCurPackagePrivateBase11 = - Target11.this.refTotestCurPackagePrivateBase11 + 1; - Target11.this.refTotestTarget11(); - Target11.this.refTotestTarget11 = - Target11.this.refTotestTarget11 + 1; - } - }.run(); - super.refTotestCurPackagePrivateBase11(); - super.refTotestCurPackagePrivateBase11 = - super.refTotestCurPackagePrivateBase11 + 1; - super.refTotestCurPackagePrivateExt11(); - super.refTotestCurPackagePrivateExt11 = - super.refTotestCurPackagePrivateExt11 + 1; - super.toString(); - - Target11.super.refTotestCurPackagePrivateBase11(); - Target11.super.refTotestCurPackagePrivateBase11 = - Target11.super.refTotestCurPackagePrivateBase11 + 1; - Target11.super.refTotestCurPackagePrivateExt11(); - Target11.super.refTotestCurPackagePrivateExt11 = - Target11.super.refTotestCurPackagePrivateExt11 + 1; - - refTotestCurPackagePrivateBase11(); - refTotestCurPackagePrivateBase11 = refTotestCurPackagePrivateBase11 + 1; - refTotestTarget11 = refTotestTarget11 + 1; - } -} - -class CurPackagePrivateBase11 extends base.Base { - protected void refTotestCurPackagePrivateBase11() {} - protected int refTotestCurPackagePrivateBase11; -} - -class CurPackagePrivateExt11 extends CurPackagePrivateBase11 { } diff --git a/langtools/test/tools/javac/miranda/6964669/T6964669.java b/langtools/test/tools/javac/miranda/6964669/T6964669.java deleted file mode 100644 index 6023b179338..00000000000 --- a/langtools/test/tools/javac/miranda/6964669/T6964669.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6964669 - * @summary javac reports error on miranda methods - * @compile -source 1.2 -target 1.1 pkg/A.java pkg/B.java pkg/C.java - */ diff --git a/langtools/test/tools/javac/miranda/6964669/pkg/A.java b/langtools/test/tools/javac/miranda/6964669/pkg/A.java deleted file mode 100644 index 71ee85449f7..00000000000 --- a/langtools/test/tools/javac/miranda/6964669/pkg/A.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package pkg; - -public abstract class A implements C {} diff --git a/langtools/test/tools/javac/miranda/6964669/pkg/B.java b/langtools/test/tools/javac/miranda/6964669/pkg/B.java deleted file mode 100644 index efafcfe1364..00000000000 --- a/langtools/test/tools/javac/miranda/6964669/pkg/B.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package pkg; - -public class B extends A { - public void a() {} -} diff --git a/langtools/test/tools/javac/miranda/6964669/pkg/C.java b/langtools/test/tools/javac/miranda/6964669/pkg/C.java deleted file mode 100644 index 9508349c0fd..00000000000 --- a/langtools/test/tools/javac/miranda/6964669/pkg/C.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package pkg; - -public interface C { - public void a(); -} diff --git a/langtools/test/tools/javac/mixedTarget/CompatibleAbstracts1.java b/langtools/test/tools/javac/mixedTarget/CompatibleAbstracts1.java deleted file mode 100644 index 4aada78617c..00000000000 --- a/langtools/test/tools/javac/mixedTarget/CompatibleAbstracts1.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004, 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 5009712 - * @summary 1.4 javac should not accept the Covariant Return Type - * @author gafter - * - * @compile CompatibleAbstracts1.java - * @compile CompatibleAbstracts2.java - * @compile -source 1.4 CompatibleAbstracts2.java - * @compile CompatibleAbstracts3.java - * @compile/fail -source 1.4 CompatibleAbstracts3.java - * @compile CompatibleAbstracts4.java - * @compile/fail -source 1.4 CompatibleAbstracts4.java - * @compile CompatibleAbstracts5.java - * @compile/fail -source 1.4 CompatibleAbstracts5.java - */ - -interface A { - A f(); -} - -interface B extends A { - B f(); -} - -interface C { - B f(); -} - -interface D { - D f(); -} diff --git a/langtools/test/tools/javac/mixedTarget/CompatibleAbstracts2.java b/langtools/test/tools/javac/mixedTarget/CompatibleAbstracts2.java deleted file mode 100644 index 0f52e53ec66..00000000000 --- a/langtools/test/tools/javac/mixedTarget/CompatibleAbstracts2.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2004, 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. - */ - -abstract class CompatibleAbstracts2 - implements A, B // OK, as interfaces A and B are already related -{ - void f(A a, B b) { - if (a == b) ; - B b2 = (B) a; - A a2 = (A) b; - } -} diff --git a/langtools/test/tools/javac/mixedTarget/ExtendCovariant1.java b/langtools/test/tools/javac/mixedTarget/ExtendCovariant1.java index 20797217594..3c786fca75a 100644 --- a/langtools/test/tools/javac/mixedTarget/ExtendCovariant1.java +++ b/langtools/test/tools/javac/mixedTarget/ExtendCovariant1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -24,10 +24,10 @@ /* * @test * @bug 5009712 - * @summary 1.4 javac should not accept the Covariant Return Type + * @summary Ensure covariant return type allowed * @author gafter * - * @compile -source 1.4 ExtendCovariant1.java + * @compile ExtendCovariant1.java */ /** @@ -37,8 +37,7 @@ * * java.lang.Appendable java.lang.Appendable.append(char) * - * Yet javac should allow extending PrintStream, as long as the user - * doesn't directly override a covariant method in -source 1.4. + * With JDK 1.5, a covariant return is allowed so check that is the case. **/ public class ExtendCovariant1 extends java.io.PrintStream { ExtendCovariant1() throws java.io.IOException { diff --git a/langtools/test/tools/javac/mixedTarget/ExtendCovariant2.java b/langtools/test/tools/javac/mixedTarget/ExtendCovariant2.java index b7d3fb2d082..6f313a72b54 100644 --- a/langtools/test/tools/javac/mixedTarget/ExtendCovariant2.java +++ b/langtools/test/tools/javac/mixedTarget/ExtendCovariant2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -24,10 +24,10 @@ /* * @test * @bug 5009712 - * @summary 1.4 javac should not accept the Covariant Return Type + * @summary Ensure Covariant Return Type allowed in minimum supported version * @author gafter * - * @compile/fail -source 1.4 ExtendCovariant2.java + * @compile -source 1.6 ExtendCovariant2.java * @compile ExtendCovariant2.java */ @@ -38,8 +38,8 @@ * * java.lang.Appendable java.lang.Appendable.append(char) * - * Yet javac should allow extending PrintStream, as long as the user - * doesn't directly override a covariant method in -source 1.4. + * With JDK 1.5, a Covariant Return is allowed so check that is the case. + * **/ public class ExtendCovariant2 extends java.io.PrintStream { ExtendCovariant2() throws java.io.IOException { diff --git a/langtools/test/tools/javac/options/T6900037.java b/langtools/test/tools/javac/options/T6900037.java index fd3a2de5fdc..30c56504790 100644 --- a/langtools/test/tools/javac/options/T6900037.java +++ b/langtools/test/tools/javac/options/T6900037.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 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,9 +26,9 @@ * @bug 6900037 * @summary javac should warn if earlier -source is used and bootclasspath not set * @compile T6900037.java - * @compile -source 1.6 T6900037.java - * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java - * @compile -Werror -source 1.6 -Xlint:-options T6900037.java + * @compile -source 1.8 T6900037.java + * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.8 T6900037.java + * @compile -Werror -source 1.8 -Xlint:-options T6900037.java */ class T6900037 { } diff --git a/langtools/test/tools/javac/options/T6900037.out b/langtools/test/tools/javac/options/T6900037.out index f98225f4ecf..d1f38f9d4b8 100644 --- a/langtools/test/tools/javac/options/T6900037.out +++ b/langtools/test/tools/javac/options/T6900037.out @@ -1,4 +1,4 @@ -- compiler.warn.source.no.bootclasspath: 1.6 +- compiler.warn.source.no.bootclasspath: 1.8 - compiler.err.warnings.and.werror 1 error 1 warning diff --git a/langtools/test/tools/javac/options/T7022337.java b/langtools/test/tools/javac/options/T7022337.java index 27be151b094..1143c8fa405 100644 --- a/langtools/test/tools/javac/options/T7022337.java +++ b/langtools/test/tools/javac/options/T7022337.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -51,7 +51,7 @@ public class T7022337 extends JavacTestingAbstractProcessor { "-XDrawDiagnostics", "-d", ".", "-processor", myName, - "-source", "6", // explicit use of older source value without bootclasspath + "-source", "8", // explicit use of older source value without bootclasspath file.getPath()); int count = 0; diff --git a/langtools/test/tools/javac/processing/messager/MessagerDiags.java b/langtools/test/tools/javac/processing/messager/MessagerDiags.java index 6f333a36090..db0e94967af 100644 --- a/langtools/test/tools/javac/processing/messager/MessagerDiags.java +++ b/langtools/test/tools/javac/processing/messager/MessagerDiags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -54,7 +54,7 @@ import javax.tools.ToolProvider; import static javax.tools.Diagnostic.Kind.*; import static javax.tools.JavaFileObject.Kind.*; -@SupportedSourceVersion(SourceVersion.RELEASE_6) +@SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedAnnotationTypes("*") public class MessagerDiags extends AbstractProcessor { static final String CNAME = "Test"; @@ -64,8 +64,8 @@ public class MessagerDiags extends AbstractProcessor { static final String WRN_WITH_SOURCE = "warning with source"; static final String NONE = ""; static final String[] EXPECTED = { NONE + ":-1--1:" + WRN_NO_SOURCE, - TEST_JAVA + ":0-13:" + WRN_WITH_SOURCE, - NONE + ":-1--1:" + WRN_NO_SOURCE + TEST_JAVA + ":0-13:" + WRN_WITH_SOURCE, + NONE + ":-1--1:" + WRN_NO_SOURCE }; @Override @@ -88,7 +88,7 @@ public class MessagerDiags extends AbstractProcessor { DiagnosticCollector dc = new DiagnosticCollector<>(); List options = new LinkedList<>(); options.addAll(Arrays.asList("-bootclasspath", bootPath, - "-source", "1.6", "-classpath", + "-source", "1.8", "-classpath", System.getProperty("java.class.path"))); options.addAll(Arrays.asList("-processor", MessagerDiags.class.getName())); diff --git a/langtools/test/tools/javac/versions/check.sh b/langtools/test/tools/javac/versions/check.sh index 3f8033863a7..cd91a9641cd 100644 --- a/langtools/test/tools/javac/versions/check.sh +++ b/langtools/test/tools/javac/versions/check.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2004, 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 @@ -25,13 +25,13 @@ # @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 # @summary Check interpretation of -target and -source options # @build CheckClassFileVersion -# @run shell check.sh +# @run shell check.sh TESTJAVA=${TESTJAVA:?} TC=${TESTCLASSES-.} -J="$TESTJAVA/bin/java" -JC="$TESTJAVA/bin/javac" +J="$TESTJAVA/bin/java" +JC="$TESTJAVA/bin/javac" CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion" rm -f $TC/X.java $TC/X.java @@ -58,27 +58,16 @@ check_source_target() { check_target $1 1.${2} $3 } -check 48.0 -source 1.4 -check 49.0 -source 1.4 -target 1.5 -check 49.0 -source 1.5 -target 1.5 - -check_target 50.0 1.4 6 -check_target 50.0 1.5 6 check_source_target 50.0 6 6 -check_target 51.0 1.4 7 -check_target 51.0 1.5 7 check_source_target 51.0 6 7 check_source_target 51.0 7 7 -check_target 52.0 1.4 8 -check_target 52.0 1.5 8 check_source_target 52.0 6 8 check_source_target 52.0 7 8 check_source_target 52.0 8 8 -check_target 52.0 1.5 9 check_source_target 52.0 8 9 check_source_target 52.0 9 9 @@ -115,11 +104,7 @@ checksrc17() { checksrc15 $* ; } checksrc18() { checksrc15 $* ; } checksrc19() { checksrc15 $* ; } -checksrc14 -source 1.4 -checksrc14 -source 1.4 -target 1.5 -checksrc15 -source 1.5 -checksrc15 -source 1.5 -target 1.5 checksrc16 -source 1.6 checksrc16 -source 6 @@ -144,9 +129,6 @@ checksrc19 -source 9 -target 9 checksrc19 -target 1.9 checksrc19 -target 9 -fail -source 1.5 -target 1.4 $TC/X.java -fail -source 1.6 -target 1.4 $TC/X.java -fail -source 6 -target 1.4 $TC/X.java fail -source 1.6 -target 1.5 $TC/X.java fail -source 6 -target 1.5 $TC/X.java fail -source 7 -target 1.6 $TC/X.java From f7234f052c1869baa9db4828ce46735ded003b2f Mon Sep 17 00:00:00 2001 From: Neil Toda Date: Thu, 10 Jul 2014 16:03:45 -0700 Subject: [PATCH 033/236] 8030610: replace test/tools/javac/versions/check.sh Reviewed-by: jjg --- .../javac/versions/CheckClassFileVersion.java | 60 ---- .../test/tools/javac/versions/Versions.java | 335 ++++++++++++++++++ langtools/test/tools/javac/versions/check.sh | 138 -------- 3 files changed, 335 insertions(+), 198 deletions(-) delete mode 100644 langtools/test/tools/javac/versions/CheckClassFileVersion.java create mode 100644 langtools/test/tools/javac/versions/Versions.java delete mode 100644 langtools/test/tools/javac/versions/check.sh diff --git a/langtools/test/tools/javac/versions/CheckClassFileVersion.java b/langtools/test/tools/javac/versions/CheckClassFileVersion.java deleted file mode 100644 index 8a6065197d7..00000000000 --- a/langtools/test/tools/javac/versions/CheckClassFileVersion.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.*; -import java.nio.*; -import java.nio.channels.*; - - -public class CheckClassFileVersion { - - static String get(String fn) throws IOException { - ByteBuffer bb = ByteBuffer.allocate(1024); - FileChannel fc = new FileInputStream(fn).getChannel(); - try { - bb.clear(); - if (fc.read(bb) < 0) - throw new IOException("Could not read any bytes"); - bb.flip(); - int minor = bb.getShort(4); - int major = bb.getShort(6); - return major + "." + minor; - } finally { - fc.close(); - } - } - - public static void main(String[] args) throws IOException { - String cfv = get(args[0]); - if (args.length == 1) { - System.out.println(cfv); - return; - } - if (!cfv.equals(args[1])) { - System.err.println("Class-file version mismatch: Expected " - + args[1] + ", got " + cfv); - System.exit(1); - } - } - -} diff --git a/langtools/test/tools/javac/versions/Versions.java b/langtools/test/tools/javac/versions/Versions.java new file mode 100644 index 00000000000..b600645e83b --- /dev/null +++ b/langtools/test/tools/javac/versions/Versions.java @@ -0,0 +1,335 @@ +/* + * 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 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 + * @summary Check interpretation of -target and -source options + * @run main Versions + */ + +import java.io.*; +import java.nio.*; +import java.nio.channels.*; + +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; + + +public class Versions { + + protected JavaCompiler javacompiler; + protected int failedCases; + + public Versions() throws IOException { + javacompiler = ToolProvider.getSystemJavaCompiler(); + genSourceFiles(); + failedCases = 0; + } + + public static void main(String... args) throws IOException { + Versions versions = new Versions(); + versions.run(); + } + + void run() { + + String jdk9cv = "52.0"; // class version.change when ./dev pushed to 53 + + String TC = ""; + System.out.println("Version.java: Starting"); + + check("52.0"); + check("52.0", "-source 1.6"); + check("52.0", "-source 1.7"); + check("52.0", "-source 1.8"); + check(jdk9cv, "-source 1.9"); + + check_source_target("50.0", "6", "6"); + check_source_target("51.0", "6", "7"); + check_source_target("51.0", "7", "7"); + check_source_target("52.0", "6", "8"); + check_source_target("52.0", "7", "8"); + check_source_target("52.0", "8", "8"); + check_source_target(jdk9cv, "6", "9"); + check_source_target(jdk9cv, "7", "9"); + check_source_target(jdk9cv, "8", "9"); + check_source_target(jdk9cv, "9", "9"); + + checksrc16("-source 1.6"); + checksrc16("-source 6"); + checksrc16("-source 1.6", "-target 1.6"); + checksrc16("-source 6", "-target 6"); + checksrc17("-source 1.7"); + checksrc17("-source 7"); + checksrc17("-source 1.7", "-target 1.7"); + checksrc17("-source 7", "-target 7"); + checksrc18("-source 1.8"); + checksrc18("-source 8"); + checksrc18("-source 1.8", "-target 1.8"); + checksrc18("-source 8", "-target 8"); + checksrc19(); + checksrc19("-source 1.9"); + checksrc19("-source 9"); + checksrc19("-source 1.9", "-target 1.9"); + checksrc19("-source 9", "-target 9"); + checksrc19("-target 1.9"); + checksrc19("-target 9"); + + fail("-source 7", "-target 1.6", "X.java"); + fail("-source 8", "-target 1.6", "X.java"); + fail("-source 8", "-target 1.7", "X.java"); + fail("-source 9", "-target 1.7", "X.java"); + fail("-source 9", "-target 1.8", "X.java"); + + if (failedCases > 0) { + System.err.println("failedCases = " + String.valueOf(failedCases)); + throw new Error("Test failed"); + } + + } + + + + protected void printargs(String fname,String... args) { + System.out.printf("test: %s", fname); + for (String onearg : args) { + System.out.printf(" %s", onearg); + } + System.out.printf("\n", fname); + } + + protected void check_source_target(String... args) { + printargs("check_source_target", args); + check_target(args[0], args[1], args[2]); + check_target(args[0], "1." + args[1], args[2]); + } + + protected void check_target(String... args) { + check(args[0], "-source " + args[1], "-target " + args[2]); + check(args[0], "-source " + args[1], "-target 1." + args[2]); + } + + protected void check(String major, String... args) { + printargs("check", args); + List jcargs = new ArrayList(); + jcargs.add("-Xlint:-options"); + + // add in args conforming to List requrements of JavaCompiler + for (String onearg : args) { + String[] fields = onearg.split(" "); + for (String onefield : fields) { + jcargs.add(onefield); + } + } + + boolean creturn = compile("X.java", jcargs); + if (!creturn) { + // compilation errors note and return.. assume no class file + System.err.println("check: Compilation Failed"); + System.err.println("\t classVersion:\t" + major); + System.err.println("\t arguments:\t" + jcargs); + failedCases++; + + } else if (!checkClassFileVersion("X.class", major)) { + failedCases++; + } + } + + protected void checksrc16(String... args) { + printargs("checksrc16", args); + int asize = args.length; + String[] newargs = new String[asize + 1]; + System.arraycopy(args, 0, newargs, 0, asize); + newargs[asize] = "X.java"; + pass(newargs); + newargs[asize] = "Y.java"; + fail(newargs); + } + + protected void checksrc17(String... args) { + printargs("checksrc17", args); + int asize = args.length; + String[] newargs = new String[asize+1]; + System.arraycopy(args, 0, newargs,0 , asize); + newargs[asize] = "X.java"; + pass(newargs); + newargs[asize] = "Y.java"; + pass(newargs); + } + + protected void checksrc18(String... args) { + printargs("checksrc18", args); + checksrc17(args); + } + + protected void checksrc19(String... args) { + printargs("checksrc19", args); + checksrc17(args); + } + + protected void pass(String... args) { + printargs("pass", args); + + List jcargs = new ArrayList(); + jcargs.add("-Xlint:-options"); + + // add in args conforming to List requrements of JavaCompiler + for (String onearg : args) { + String[] fields = onearg.split(" "); + for (String onefield : fields) { + jcargs.add(onefield); + } + } + + // empty list is error + if (jcargs.isEmpty()) { + System.err.println("error: test error in pass() - No arguments"); + System.err.println("\t arguments:\t" + jcargs); + failedCases++; + return; + } + + // the last argument is the filename *.java + String filename = jcargs.get(jcargs.size() - 1); + jcargs.remove(jcargs.size() - 1); + + boolean creturn = compile(filename, jcargs); + // expect a compilation failure, failure if otherwise + if (!creturn) { + System.err.println("pass: Compilation erroneously failed"); + System.err.println("\t arguments:\t" + jcargs); + System.err.println("\t file :\t" + filename); + failedCases++; + + } + + } + + protected void fail(String... args) { + printargs("fail", args); + + List jcargs = new ArrayList(); + jcargs.add("-Xlint:-options"); + + // add in args conforming to List requrements of JavaCompiler + for (String onearg : args) { + String[] fields = onearg.split(" "); + for (String onefield : fields) { + jcargs.add(onefield); + } + } + + // empty list is error + if (jcargs.isEmpty()) { + System.err.println("error: test error in fail()- No arguments"); + System.err.println("\t arguments:\t" + jcargs); + failedCases++; + return; + } + + // the last argument is the filename *.java + String filename = jcargs.get(jcargs.size() - 1); + jcargs.remove(jcargs.size() - 1); + + boolean creturn = compile(filename, jcargs); + // expect a compilation failure, failure if otherwise + if (creturn) { + System.err.println("fail: Compilation erroneously succeeded"); + System.err.println("\t arguments:\t" + jcargs); + System.err.println("\t file :\t" + filename); + failedCases++; + } + } + + protected boolean compile(String sourceFile, Listoptions) { + JavaCompiler.CompilationTask jctask; + StandardJavaFileManager fm = javacompiler.getStandardFileManager(null, null, null); + Iterable files = fm.getJavaFileObjects(sourceFile); + + jctask = javacompiler.getTask( + null, // Writer + fm, // JavaFileManager + null, // DiagnosticListener + options, // Iterable + null, // Iterable classes + files); // Iterable + return jctask.call(); + } + + + protected void genSourceFiles() throws IOException{ + /* Create a file that executes with all supported versions. */ + File fsource = new File("X.java"); + try (Writer fw = new FileWriter(fsource)) { + fw.write("public class X { }\n"); + fw.flush(); + } + + /* Create a file with feature not supported in deprecated version. + * New feature for 1.7, does not exist in 1.6. + */ + fsource = new File("Y.java"); + try (Writer fw = new FileWriter(fsource)) { + fw.write("import java.util.List;\n"); + fw.write("import java.util.ArrayList;\n"); + fw.write("class Z { List s = new ArrayList<>(); }\n"); + fw.flush(); + } + } + + protected boolean checkClassFileVersion + (String filename,String classVersionNumber) { + ByteBuffer bb = ByteBuffer.allocate(1024); + try (FileChannel fc = new FileInputStream(filename).getChannel()) { + bb.clear(); + if (fc.read(bb) < 0) + throw new IOException("Could not read from file : " + filename); + bb.flip(); + int minor = bb.getShort(4); + int major = bb.getShort(6); + String fileVersion = major + "." + minor; + if (fileVersion.equals(classVersionNumber)) { + return true; + } else { + System.err.println("checkClassFileVersion : Failed"); + System.err.println("\tclassfile version mismatch"); + System.err.println("\texpected : " + classVersionNumber); + System.err.println("\tfound : " + fileVersion); + return false; + } + } + catch (IOException e) { + System.err.println("checkClassFileVersion : Failed"); + System.err.println("\terror :\t" + e.getMessage()); + System.err.println("\tfile:\tfilename"); + } + return false; + } +} + diff --git a/langtools/test/tools/javac/versions/check.sh b/langtools/test/tools/javac/versions/check.sh deleted file mode 100644 index cd91a9641cd..00000000000 --- a/langtools/test/tools/javac/versions/check.sh +++ /dev/null @@ -1,138 +0,0 @@ -# -# Copyright (c) 2004, 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 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 -# @summary Check interpretation of -target and -source options -# @build CheckClassFileVersion -# @run shell check.sh - -TESTJAVA=${TESTJAVA:?} -TC=${TESTCLASSES-.} - -J="$TESTJAVA/bin/java" -JC="$TESTJAVA/bin/javac" -CFV="${TESTVMOPTS} -cp $TC CheckClassFileVersion" - -rm -f $TC/X.java $TC/X.java -echo 'public class X { }' > $TC/X.java -echo 'public enum Y { }' > $TC/Y.java - - -# Check class-file versions - -check() { - V=$1; shift - echo "+ javac $* [$V]" - "$JC" ${TESTTOOLVMOPTS} -Xlint:-options -d $TC $* $TC/X.java && "$J" $CFV $TC/X.class $V || exit 2 -} - -# check for all combinations of target values -check_target() { - check $1 -source $2 -target $3 - check $1 -source $2 -target 1.${3} -} -# check for all combinations of source and target values -check_source_target() { - check_target $1 $2 $3 - check_target $1 1.${2} $3 -} - - -check_source_target 50.0 6 6 - -check_source_target 51.0 6 7 -check_source_target 51.0 7 7 - -check_source_target 52.0 6 8 -check_source_target 52.0 7 8 -check_source_target 52.0 8 8 - -check_source_target 52.0 8 9 -check_source_target 52.0 9 9 - -# and finally the default with no options -check 52.0 - -# Check source versions - -fail() { - echo "+ javac $*" - if "$JC" ${TESTTOOLVMOPTS} -Xlint:-options -d $TC $*; then - echo "-- did not fail as expected" - exit 3 - else - echo "-- failed as expected" - fi -} - -pass() { - echo "+ javac $*" - if "$JC" ${TESTTOOLVMOPTS} -Xlint:options -d $TC $*; then - echo "-- passed" - else - echo "-- failed" - exit 4 - fi -} - -# the following need to be updated when -source 7 features are available -checksrc14() { pass $* $TC/X.java; fail $* $TC/Y.java; } -checksrc15() { pass $* $TC/X.java; pass $* $TC/Y.java; } -checksrc16() { checksrc15 $* ; } -checksrc17() { checksrc15 $* ; } -checksrc18() { checksrc15 $* ; } -checksrc19() { checksrc15 $* ; } - - - -checksrc16 -source 1.6 -checksrc16 -source 6 -checksrc16 -source 1.6 -target 1.6 -checksrc16 -source 6 -target 6 - -checksrc17 -source 1.7 -checksrc17 -source 7 -checksrc17 -source 1.7 -target 1.7 -checksrc17 -source 7 -target 7 - -checksrc18 -source 1.8 -checksrc18 -source 8 -checksrc18 -source 1.8 -target 1.8 -checksrc18 -source 8 -target 8 - -checksrc19 -checksrc19 -source 1.9 -checksrc19 -source 9 -checksrc19 -source 1.9 -target 1.9 -checksrc19 -source 9 -target 9 -checksrc19 -target 1.9 -checksrc19 -target 9 - -fail -source 1.6 -target 1.5 $TC/X.java -fail -source 6 -target 1.5 $TC/X.java -fail -source 7 -target 1.6 $TC/X.java -fail -source 8 -target 1.6 $TC/X.java -fail -source 8 -target 1.7 $TC/X.java -fail -source 9 -target 1.7 $TC/X.java -fail -source 9 -target 1.8 $TC/X.java From 4fa698fe42db9217e40f92e19b1eaf750f44dc1b Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Sun, 29 Jun 2014 17:13:55 -0700 Subject: [PATCH 034/236] 8049393: [javadoc] parameters are not sorted correctly Reviewed-by: jjg --- .../doclets/internal/toolkit/util/Util.java | 65 ++++-- .../javadoc/testOrdering/TestOrdering.java | 42 +++- .../com/sun/javadoc/testOrdering/pkg1/A.java | 60 +++++ .../com/sun/javadoc/testOrdering/pkg1/B.java | 43 ++++ .../testOrdering/pkg1/MethodOrder.java | 219 ++++++++++++++++++ .../javadoc/testOrdering/pkg1/UsedClass.java | 2 +- 6 files changed, 403 insertions(+), 28 deletions(-) create mode 100644 langtools/test/com/sun/javadoc/testOrdering/pkg1/A.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/pkg1/B.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/pkg1/MethodOrder.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java index b70c612533a..ff06c424fd5 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java @@ -814,22 +814,21 @@ public class Util { } /** - * A comparator for index file presentations, - * 1. this sorts first on simple names + * A comparator for index file presentations, and are sorted as follows: + * 1. sort on simple names of entities * 2. if equal, then compare the DocKind ex: Package, Interface etc. - * 3a. if equal and if the type is of ExecutableMemberDoc(Constructor, Fields), - * a case insensitive comparison of parameter types - * 3b. if equal, a case sensitive comparison of parameter types + * 3a. if equal and if the type is of ExecutableMemberDoc(Constructor, Methods), + * a case insensitive comparison of parameter the type signatures + * 3b. if equal, case sensitive comparison of the type signatures * 4. finally, if equal, compare the FQNs of the entities * @return a comparator for index file use */ public static Comparator makeComparatorForIndexUse() { return new Util.DocComparator() { /** - * Compare two given Doc entities, first sort on name, then on the kinds, + * Compare two given Doc entities, first sort on names, then on the kinds, * then on the parameters only if the type is an instance of ExecutableMemberDocs, - * the parameters are compared ignoring the case first, then a case sensitive comparison, - * and finally the fully qualified names. + * the parameters are compared and finally the fully qualified names. * * @param d1 - a Doc element. * @param d2 - a Doc element. @@ -862,17 +861,19 @@ public class Util { }; } /** - * Comparator for ClassUse presentations, and sorts as follows: - * 1. member names - * 2. then fully qualified member names - * 3. then parameter types if applicable + * Comparator for ClassUse presentations, and sorted as follows, + * 1. compares simple names of entities + * 2. if equal, the fully qualified names of the entities + * 3. if equal and if applicable, the string representation of parameter types + * 3a. first by using case insensitive comparison + * 3b. second by using a case sensitive comparison * 4. finally the Doc kinds ie. package, class, interface etc. * @return a comparator to sort classes and members for class use */ public static Comparator makeComparatorForClassUse() { return new Util.DocComparator() { /** - * Compare two given Doc entities, first sort on name, and if + * Compares two given Doc entities, first sort on name, and if * applicable on the fully qualified name, and if applicable * on the parameter types, and finally the DocKind. * @param d1 - a Doc element. @@ -952,23 +953,37 @@ public class Util { return getDocKind(d1).compareTo(getDocKind(d2)); } /** - * Compares two parameter arrays by comparing each Type of the parameter in the array, - * and as many as possible, otherwise compare their lengths. + * Compares arrays of parameters as a string representation of their types. + * * @param ignoreCase specifies case sensitive or insensitive comparison. * @param params1 the first parameter array. * @param params2 the first parameter array. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. + * @return a negative integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. */ - protected int compareParameters(boolean ignoreCase, Parameter[] params1, Parameter[] params2) { - // try to compare as many as possible - for (int i = 0; i < params1.length && i < params2.length; i++) { - int result = compareStrings(ignoreCase, params1[i].typeName(), params2[i].typeName()); - if (result != 0) { - return result; - } + protected int compareParameters(boolean caseSensitive, + Parameter[] params1, + Parameter[] params2) { + String s1 = getParametersAsString(params1); + String s2 = getParametersAsString(params2); + return compareStrings(caseSensitive, s1, s2); + } + /* + * This method returns a string representation solely for comparison purposes. + */ + protected String getParametersAsString(Parameter[] params) { + StringBuilder sb = new StringBuilder(); + for (Parameter param : params) { + Type t = param.type(); + // add parameter type to arrays, as TypeMirror does. + String tname = (t.asParameterizedType() != null && t.getElementType() != null) + ? t.getElementType() + t.dimension() + : t.toString(); + // prefix P for primitive and R for reference types, thus items will + // be ordered naturally. + sb.append(t.isPrimitive() ? "P" : "R").append("-").append(tname).append("-"); } - return Integer.compare(params1.length, params2.length); + return sb.toString(); } /** diff --git a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java index 638b2542fd8..578126ee2e1 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java +++ b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8039410 8042601 8042829 + * @bug 8039410 8042601 8042829 8049393 * @summary test to determine if members are ordered correctly * @author ksrini * @library ../lib/ @@ -66,6 +66,9 @@ public class TestOrdering extends JavadocTester { "pkg1"); checkExit(Exit.OK); checkClassUseOrdering("pkg1/class-use/UsedClass.html"); + checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseMethodOrdering); + checkOrder("pkg1/class-use/UsedClass.html", expectedClassUseWithTypeParams); + checkOrder("pkg1/class-use/UsedClass.html", expectedInnerClassContructors); } enum ListOrder { NONE, REVERSE, SHUFFLE }; @@ -273,10 +276,44 @@ public class TestOrdering extends JavadocTester { return in.replace("/", "."); } + final String expectedInnerClassContructors[] = { + "../../pkg1/A.html#A-pkg1.UsedClass-", + "../../pkg1/B.A.html#A-pkg1.UsedClass-", + "../../pkg1/B.html#B-pkg1.UsedClass-", + "../../pkg1/A.C.html#C-pkg1.UsedClass-java.lang.Object:A-", + "../../pkg1/A.C.html#C-pkg1.UsedClass-java.util.Collection-", + "../../pkg1/A.C.html#C-pkg1.UsedClass-java.util.List-" + }; + + final String expectedClassUseMethodOrdering[] = { + "../../pkg1/MethodOrder.html#m--", + "../../pkg1/MethodOrder.html#m-byte:A-", + "../../pkg1/MethodOrder.html#m-double-", + "../../pkg1/MethodOrder.html#m-double-double-", + "../../pkg1/MethodOrder.html#m-double-java.lang.Double-", + "../../pkg1/MethodOrder.html#m-int-", + "../../pkg1/MethodOrder.html#m-int-int-", + "../../pkg1/MethodOrder.html#m-int-java.lang.Integer-", + "../../pkg1/MethodOrder.html#m-java.lang.Double-", + "../../pkg1/MethodOrder.html#m-java.lang.Double-double-", + "../../pkg1/MethodOrder.html#m-java.lang.Double-java.lang.Double-", + "../../pkg1/MethodOrder.html#m-java.lang.Integer-", + "../../pkg1/MethodOrder.html#m-java.lang.Integer-int-", + "../../pkg1/MethodOrder.html#m-java.lang.Integer-java.lang.Integer-", + "../../pkg1/MethodOrder.html#m-java.lang.Object:A-", + "../../pkg1/MethodOrder.html#m-java.util.ArrayList-", + "../../pkg1/MethodOrder.html#m-java.util.Collection-", + "../../pkg1/MethodOrder.html#m-java.util.List-" + }; + final String expectedClassUseWithTypeParams[] = { + "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-", + "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass-", + "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-pkg1.UsedClass:A-", + "../../pkg1/MethodOrder.html#tpm-pkg1.UsedClass-java.lang.String-" + }; final String expectedMethodOrdering[] = { "Add.html#add--", "Add.html#add-double-", - "Add.html#add-java.lang.Double-", "Add.html#add-double-byte-", "Add.html#add-double-double-", "Add.html#add-double-java.lang.Double-", @@ -284,6 +321,7 @@ public class TestOrdering extends JavadocTester { "Add.html#add-float-int-", "Add.html#add-int-", "Add.html#add-int-float-", + "Add.html#add-java.lang.Double-", "Add.html#add-java.lang.Integer-" }; final String expectedEnumOrdering[] = { diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/A.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/A.java new file mode 100644 index 00000000000..ce651c74611 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/A.java @@ -0,0 +1,60 @@ +/* + * 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. + */ +package pkg1; +import java.util.Collection; +import java.util.List; +public class A { + + /** + * Constructor + * @param a class + */ + public A(UsedClass a) {} + + /** + * test inner classes + */ + public static class C { + + /** + * inner classes constructor + * @param u a param + * @param array a param + */ + public C(UsedClass u, Object[] array){} + + /** + * inner classes constructor + * @param u a param + * @param collection a param + */ + public C(UsedClass u, Collection collection){} + + /** + * inner classes constructor + * @param u a param + * @param list a param + */ + public C(UsedClass u, List list){} + } +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/B.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/B.java new file mode 100644 index 00000000000..dc332949dc8 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/B.java @@ -0,0 +1,43 @@ +/* + * 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. + */ +package pkg1; +public class B { + + /** + * constructor + * @param a param + */ + public B(UsedClass a) {} + + /** + * Inner class + */ + static public class A { + + /** + * constructor + * @param b param + */ + public A(UsedClass b){} + } +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/MethodOrder.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/MethodOrder.java new file mode 100644 index 00000000000..a380a0bdc5c --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/MethodOrder.java @@ -0,0 +1,219 @@ +/* + * 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. + */ + +package pkg1; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class MethodOrder { + /** + * method test for ordering parameters + * @return UsedClass something + */ + public UsedClass m(){return null;} + /** + * method test for ordering parameters + * @param i a param + * @return UsedClass something + */ + public UsedClass m(int i) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(int i1, int i2) {return null;} + + /** + * method test for ordering parameters + * @param array a param + * @return something + */ + public UsedClass m(byte[] array) {return null;} + + /** + * method test for ordering parameters + * @param in a param + * @return something + */ + public UsedClass m(Integer in) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(Integer i1, Integer i2) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(int i1, Integer i2) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(Integer i1, int i2) {return null;} + + /** + * method test for ordering parameters + * @param d a param + * @return something + */ + public UsedClass m(double d) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(double i1, double i2) {return null;} + + /** + * method test for ordering parameters + * @param in a param + * @return something + */ + public UsedClass m(Double in) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(Double i1, Double i2) {return null;} + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(double i1, Double i2) {return null;} + + /** + * method test for ordering parameters + * @param l1 param + * @return something + */ + public UsedClass m(long l1) {return null;} + + /** + * method test for ordering parameters + * @param l1 param + * @param l2 param + * @return something + */ + public UsedClass m(long l1, Long l2) {return null;} + + /** + * method test for ordering parameters + * @param l1 param + * @param l2 param + * @return something + */ + public UsedClass m(long l1, long l2) {return null;} + + /** + * method test for ordering parameters + * @param array a param + * @return something + */ + public UsedClass m(Object[] array); + + /** + * method test for ordering parameters + * @param arrayarray two dimensional array + * @return something + */ + public UsedClass m(Object[][] arrayarray); + + /** + * method test for ordering parameters + * @param i1 a param + * @param i2 a param + * @return something + */ + public UsedClass m(Double i1, double i2) {return null;} + + /** + * method test for ordering parameters + * @param collection a param + * @return something + */ + public UsedClass m(Collection collection) {return null;} + + /** + * method test for ordering parameters + * @param list a param + * @return something + */ + public UsedClass m(List list) {return null;} + + /** + * method test for ordering parameters + * @param collection a param + * @return something + */ + public UsedClass m(ArrayList collection) {return null;} + + /** + * method test for ordering parameters + * @param u use a type param + */ + public void tpm(UsedClass u) {} + + /** + * method test for ordering parameters + * @param u1 use a type param + * @param u2 use a type param + */ + public void tpm(UsedClass u1, UsedClass u2) {} + + /** + * method test for ordering parameters + * @param u use a type param + * @param array use a type param and an array + */ + public void tpm(UsedClass u, UsedClass[] array) {} + + /** + * method test for ordering parameters + * @param u use type param with extends + * @param a some string + */ + public void tpm(UsedClass u, String a) {} +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java index ed35353e9fd..2d11bc546ae 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java @@ -25,4 +25,4 @@ package pkg1; /** * For class-use testing */ -public class UsedClass {} +public class UsedClass {} From c626683b265c993df3371377f41babd8fd2d1049 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Fri, 11 Jul 2014 06:52:04 -0700 Subject: [PATCH 035/236] 8049396: [javadoc] add more class-use test cases Reviewed-by: jjg --- .../javadoc/testUseOption/TestUseOption.java | 24 ++++++++++ .../testUseOption/pkg1/AnAbstract.java | 24 ++++++++++ .../sun/javadoc/testUseOption/pkg1/C10.java | 47 +++++++++++++++++++ .../testUseOption/pkg1/UsedInterface.java | 2 +- .../testUseOption/pkg1/UsedInterfaceA.java | 2 +- 5 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 langtools/test/com/sun/javadoc/testUseOption/pkg1/AnAbstract.java diff --git a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java index 3379da40980..85f2f27662d 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java +++ b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java @@ -96,6 +96,30 @@ public class TestUseOption extends JavadocTester { checkOutput("pkg1/class-use/UsedClass.html", false, "methodInC1Protected" ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "AnAbstract" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "../../pkg1/C10.html#withReturningTypeParameters--" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "../../pkg1/C10.html#withTypeParametersOfType-java.lang.Class-" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "\"../../pkg1/package-summary.html\">pkg1 that return " + + "addAll" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "" + + "withTypeParametersOfType" + ); } @Test diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/AnAbstract.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/AnAbstract.java new file mode 100644 index 00000000000..00b5d40f117 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/AnAbstract.java @@ -0,0 +1,24 @@ +/* + * 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. + */ +package pkg1; +public abstract class AnAbstract implements UsedInterface {} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java index b4c1314572d..c920adf798f 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java @@ -23,6 +23,8 @@ package pkg1; +import java.util.List; + /** * An implementor * @@ -38,4 +40,49 @@ public class C10 extends UsedClass implements UsedInterface, UsedInterfaceA { * Me too */ public void doNothingA() {} + + /** + * returns a collection with type param + * @return something + */ + public List foo(){return null;} + + /** + * returns and takes type param variants + * @param yeah + * @return returns a type param + */ + public > UsedInterfaceA withTypeParametersOfType(Class c){return null;} + + /** + * returns a type param + * @param a param + * @return something + */ + public T[] withReturningTypeParameters(){return null;} + + /** + * a return a type parameter, as a static method + * @param a type param + * @param enumType something + * @param name something + * @return a trype param + */ + public static > T withReturnVariant(Class enumType, String name){return null;} + + /** + * another variant of a method returning type parameters + * @param something + * @param listenerInterface something + * @param target something + * @param action something + * @return a type param + */ + public T create(UsedInterfaceA listenerInterface, UsedInterface target, String action){return null;} + + /** + * input is an array + * @param elements a vararg + */ + public void addAll(UsedInterface... elements) {} } diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java index 7eaab237524..2d626059727 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java @@ -28,7 +28,7 @@ package pkg1; -public interface UsedInterface { +public interface UsedInterface { /** * Does nothing diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java index cab6298ae67..c41885c7266 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java @@ -28,7 +28,7 @@ package pkg1; -public interface UsedInterfaceA { +public interface UsedInterfaceA { /** * Does nothing From 0dd95d497bb069f6e5cc885e2941649e7a438223 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 11 Jul 2014 13:57:32 -0700 Subject: [PATCH 036/236] 8050086: jdk.Exported is missing @return Reviewed-by: jjg --- langtools/src/share/classes/jdk/Exported.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/langtools/src/share/classes/jdk/Exported.java b/langtools/src/share/classes/jdk/Exported.java index a768c8dae1f..d67d8b37e99 100644 --- a/langtools/src/share/classes/jdk/Exported.java +++ b/langtools/src/share/classes/jdk/Exported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -71,7 +71,10 @@ import java.lang.annotation.*; @Exported public @interface Exported { /** - * Whether or not the annotated type or package is an exported part of the JDK. + * Whether or not the annotated type or package is an exported + * part of the JDK. + * @return whether or not the annotated type or package is an exported + * part of the JDK */ boolean value() default true; } From 84e4fca0c86c6ef9a4ae01f5a739400f1d8642f6 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 11 Jul 2014 18:51:32 -0700 Subject: [PATCH 037/236] 8048806: Javadoc errors out on some valid HTML tags Reviewed-by: bpatel --- .../com/sun/tools/doclint/HtmlTag.java | 42 +++++++++++++++++-- langtools/test/tools/doclint/ValidTest.java | 36 +++++++++++++++- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java index 0a8c0b35dd2..ac33290e83c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java +++ b/langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.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 @@ -30,12 +30,12 @@ import java.util.Collections; import java.util.EnumMap; import java.util.EnumSet; import java.util.HashMap; -import java.util.Locale; import java.util.Map; import javax.lang.model.element.Name; import static com.sun.tools.doclint.HtmlTag.Attr.*; + import com.sun.tools.javac.util.StringUtils; /** @@ -58,6 +58,15 @@ public enum HtmlTag { A(BlockType.INLINE, EndKind.REQUIRED, attrs(AttrKind.OK, HREF, TARGET, NAME)), + ABBR(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + + ACRONYM(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + + ADDRESS(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + B(BlockType.INLINE, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), @@ -87,6 +96,10 @@ public enum HtmlTag { DD(BlockType.LIST_ITEM, EndKind.OPTIONAL, EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE, Flag.EXPECT_CONTENT)), + DEL(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST), + attrs(AttrKind.OK, Attr.CITE, Attr.DATETIME)), + DFN(BlockType.INLINE, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), @@ -138,6 +151,13 @@ public enum HtmlTag { attrs(AttrKind.OBSOLETE, NAME), attrs(AttrKind.USE_CSS, ALIGN, HSPACE, VSPACE, BORDER)), + INS(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST), + attrs(AttrKind.OK, Attr.CITE, Attr.DATETIME)), + + KBD(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + LI(BlockType.LIST_ITEM, EndKind.OPTIONAL, EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), attrs(AttrKind.OK, VALUE)), @@ -183,6 +203,15 @@ public enum HtmlTag { } }, + Q(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + + S(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + + SAMP(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT, Flag.NO_NEST)), + SCRIPT(BlockType.OTHER, EndKind.REQUIRED), SMALL(BlockType.INLINE, EndKind.REQUIRED, @@ -191,6 +220,9 @@ public enum HtmlTag { SPAN(BlockType.INLINE, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT)), + STRIKE(BlockType.INLINE, EndKind.REQUIRED, + EnumSet.of(Flag.EXPECT_CONTENT)), + STRONG(BlockType.INLINE, EndKind.REQUIRED, EnumSet.of(Flag.EXPECT_CONTENT)), @@ -229,7 +261,7 @@ public enum HtmlTag { TD(BlockType.TABLE_ITEM, EndKind.OPTIONAL, EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), - attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS, + attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, Attr.ABBR, AXIS, ALIGN, CHAR, CHAROFF, VALIGN), attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)), @@ -243,7 +275,7 @@ public enum HtmlTag { TH(BlockType.TABLE_ITEM, EndKind.OPTIONAL, EnumSet.of(Flag.ACCEPTS_BLOCK, Flag.ACCEPTS_INLINE), - attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, ABBR, AXIS, + attrs(AttrKind.OK, COLSPAN, ROWSPAN, HEADERS, SCOPE, Attr.ABBR, AXIS, ALIGN, CHAR, CHAROFF, VALIGN), attrs(AttrKind.USE_CSS, WIDTH, BGCOLOR, HEIGHT, NOWRAP)), @@ -321,11 +353,13 @@ public enum HtmlTag { CELLPADDING, CHAR, CHAROFF, + CITE, CLEAR, CLASS, COLOR, COLSPAN, COMPACT, + DATETIME, FACE, FRAME, HEADERS, diff --git a/langtools/test/tools/doclint/ValidTest.java b/langtools/test/tools/doclint/ValidTest.java index 5189f9c6e7b..588889e3366 100644 --- a/langtools/test/tools/doclint/ValidTest.java +++ b/langtools/test/tools/doclint/ValidTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 8004832 + * @bug 8004832 8048806 * @summary Add new doclint package * @build DocLintTester * @run main DocLintTester ValidTest.java @@ -35,6 +35,38 @@ class ValidTest { */ void entities() { } + /** + * abbreviation + * ABC + * citation + * code + * defining instance + * emphasis + * keyboard + * sample + * variable + * strong + */ + void phraseElements() { } + + /** + *

1 Main St., USA
+ */ + void address() { } + + /** + * deleted + * inserted + */ + void docChanges() {} + + /** + *
+ * A fine thing. + *
+ * A fine thing. + */ + /** *

...

*

...

From 92884a53388822ffb2bbb44303a0e5a45858c66c Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Sat, 12 Jul 2014 07:32:28 -0700 Subject: [PATCH 038/236] 8050106: JavaCompiler relies on inappropriate result from comparison Reviewed-by: darcy --- .../sun/tools/javac/main/JavaCompiler.java | 38 ++---- .../javac/versions/SourceTargetTest.java | 128 ++++++++++++++++++ 2 files changed, 142 insertions(+), 24 deletions(-) create mode 100644 langtools/test/tools/javac/versions/SourceTargetTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java index 19f8a72c63e..39d213f2d66 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java @@ -445,32 +445,22 @@ public class JavaCompiler { boolean lintOptions = options.isUnset(XLINT_CUSTOM, "-"+LintCategory.OPTIONS.option); - switch (source.compareTo(Source.MIN)) { - case -1: - log.error("option.removed.source", source.name, Source.MIN.name); - break; - case 0: - if (lintOptions) { - log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); - obsoleteOptionFound = true; - } - break; - } - // check target version request - switch (target.compareTo(Target.MIN)) { - case -1: - log.error("option.removed.target", target.name, Target.MIN.name); - break; - case 0: - if (lintOptions) { - log.warning(LintCategory.OPTIONS, "option.obsolete.target", target.name); - obsoleteOptionFound = true; - } - break; + if (source.compareTo(Source.MIN) < 0) { + log.error("option.removed.source", source.name, Source.MIN.name); + } else if (source == Source.MIN && lintOptions) { + log.warning(LintCategory.OPTIONS, "option.obsolete.source", source.name); + obsoleteOptionFound = true; } - if (obsoleteOptionFound) - log.warning(LintCategory.OPTIONS, "option.obsolete.suppression"); + if (target.compareTo(Target.MIN) < 0) { + log.error("option.removed.target", target.name, Target.MIN.name); + } else if (target == Target.MIN && lintOptions) { + log.warning(LintCategory.OPTIONS, "option.obsolete.target", target.name); + obsoleteOptionFound = true; + } + + if (obsoleteOptionFound) + log.warning(LintCategory.OPTIONS, "option.obsolete.suppression"); } /* Switches: diff --git a/langtools/test/tools/javac/versions/SourceTargetTest.java b/langtools/test/tools/javac/versions/SourceTargetTest.java new file mode 100644 index 00000000000..72e5105d90f --- /dev/null +++ b/langtools/test/tools/javac/versions/SourceTargetTest.java @@ -0,0 +1,128 @@ +/* + * 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 8050106 + * @summary JavaCompiler relies on inappropriate result from comparison + */ + +import java.io.*; +import java.util.*; +import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.jvm.Target; + +public class SourceTargetTest { + public static void main(String... args) throws Exception { + SourceTargetTest t = new SourceTargetTest(); + t.run(); + } + + public void run() throws Exception { + try (FileWriter out = new FileWriter("C.java")) { + out.write("class C { }"); + } + + for (Source s: Source.values()) { + test(s, null, "source", getKind(s, Source.MIN)); + } + + for (Target t: Target.values()) { + test(Source.values()[0], t, "target", getKind(t, Target.MIN)); + } + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + void test(Source s, Target t, String select, Kind kind) { + System.err.println("Test: source:" + s + ", target:" + t + " " + select + " " + kind); + List args = new ArrayList<>(); + args.add("-XDrawDiagnostics"); + args.add("-source"); + args.add(s.name); + if (t != null) { + args.add("-target"); + args.add(t.name); + } + args.add("C.java"); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw); + pw.close(); + String out = sw.toString(); + System.err.print(out); + + switch (kind) { + case INVALID: + check(out, "removed." + select, true); + check(out, "obsolete." + select, false); + break; + + case OBSOLETE: + check(out, "removed." + select, false); + check(out, "obsolete." + select, true); + break; + + case VALID: + check(out, "removed." + select, false); + check(out, "obsolete." + select, false); + break; + } + + System.err.println(); + } + + enum Kind { INVALID, OBSOLETE, VALID }; + + > Kind getKind(T t1, T t2) { + if (t1.compareTo(t2) < 0) + return Kind.INVALID; + else if (t1 == t2) + return Kind.OBSOLETE; + else + return Kind.VALID; + } + + void check(String out, String text, boolean expect) { + if (out.contains(text) == expect) { + if (expect) + System.err.println("expected string found: " + text); + else + System.err.println("string not found, as expected: " + text); + } else { + if (expect) + error("expected string not found: " + text); + else + error("unexpected string found: " + text); + } + } + + void error(String msg) { + System.err.println("error: " + msg); + errors++; + } + + int errors; +} From 0752cdda93655f532c73ea851f364100e3bcf227 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Sun, 15 Jun 2014 08:41:57 -0700 Subject: [PATCH 039/236] 8039028: [javadoc] refactor the usage of Util.java Reviewed-by: jjg --- .../formats/html/AbstractIndexWriter.java | 14 ++-- .../formats/html/AbstractMemberWriter.java | 12 +-- .../formats/html/AbstractTreeWriter.java | 4 +- .../formats/html/AllClassesFrameWriter.java | 4 +- .../html/AnnotationTypeWriterImpl.java | 4 +- .../doclets/formats/html/ClassUseWriter.java | 12 +-- .../doclets/formats/html/ClassWriterImpl.java | 12 +-- .../doclets/formats/html/FieldWriterImpl.java | 4 +- .../doclets/formats/html/HtmlDoclet.java | 5 +- .../formats/html/HtmlDocletWriter.java | 27 ++++--- .../doclets/formats/html/LinkFactoryImpl.java | 13 ++- .../doclets/formats/html/LinkInfoImpl.java | 5 +- .../formats/html/MethodWriterImpl.java | 4 +- .../formats/html/PackageFrameWriter.java | 10 +-- .../formats/html/PackageIndexFrameWriter.java | 2 +- .../formats/html/PackageIndexWriter.java | 2 +- .../formats/html/PackageTreeWriter.java | 2 +- .../formats/html/PackageUseWriter.java | 12 +-- .../formats/html/PackageWriterImpl.java | 8 +- .../html/ProfilePackageFrameWriter.java | 6 +- .../html/ProfilePackageIndexFrameWriter.java | 2 +- .../html/ProfilePackageWriterImpl.java | 5 +- .../formats/html/ProfileWriterImpl.java | 5 +- .../formats/html/PropertyWriterImpl.java | 4 +- .../formats/html/SourceToHTMLConverter.java | 12 +-- .../formats/html/SubWriterHolderWriter.java | 6 +- .../formats/html/TagletWriterImpl.java | 14 ++-- .../doclets/formats/html/TreeWriter.java | 2 +- .../internal/toolkit/AbstractDoclet.java | 10 ++- .../internal/toolkit/Configuration.java | 12 ++- .../toolkit/builders/AbstractBuilder.java | 5 +- .../builders/AnnotationTypeBuilder.java | 6 +- .../toolkit/builders/ClassBuilder.java | 10 +-- .../builders/MemberSummaryBuilder.java | 12 +-- .../toolkit/builders/MethodBuilder.java | 4 +- .../builders/PackageSummaryBuilder.java | 31 ++++--- .../ProfilePackageSummaryBuilder.java | 19 +++-- .../builders/ProfileSummaryBuilder.java | 2 +- .../builders/SerializedFormBuilder.java | 4 +- .../toolkit/taglets/InheritDocTaglet.java | 4 +- .../internal/toolkit/taglets/ParamTaglet.java | 4 +- .../toolkit/taglets/ReturnTaglet.java | 4 +- .../internal/toolkit/taglets/SeeTaglet.java | 4 +- .../toolkit/taglets/ThrowsTaglet.java | 6 +- .../toolkit/util/ClassDocCatalog.java | 10 ++- .../internal/toolkit/util/ClassTree.java | 28 ++++--- .../toolkit/util/CommentedMethodFinder.java | 43 ---------- .../util/DeprecatedAPIListBuilder.java | 15 ++-- .../internal/toolkit/util/DocFinder.java | 13 +-- .../toolkit/util/ImplementedMethods.java | 14 ++-- .../internal/toolkit/util/IndexBuilder.java | 10 ++- .../internal/toolkit/util/MetaKeywords.java | 6 +- .../internal/toolkit/util/MethodFinder.java | 72 ----------------- .../toolkit/util/PackageListWriter.java | 8 +- .../toolkit/util/TaggedMethodFinder.java | 45 ----------- .../toolkit/util/{Util.java => Utils.java} | 80 +++++++++---------- .../toolkit/util/VisibleMemberMap.java | 14 ++-- .../TestPrivateClasses.java | 15 +++- 58 files changed, 305 insertions(+), 417 deletions(-) delete mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java delete mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java delete mode 100644 langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java rename langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/{Util.java => Utils.java} (93%) diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java index 57e59e84974..a2993f50603 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -121,7 +121,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { * @param dlTree the content tree to which the description will be added */ protected void addDescription(PackageDoc pkg, Content dlTree) { - Content link = getPackageLink(pkg, new StringContent(Util.getPackageName(pkg))); + Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); Content dt = HtmlTree.DT(link); dt.addContent(" - "); dt.addContent(getResource("doclet.package")); @@ -159,9 +159,9 @@ public class AbstractIndexWriter extends HtmlDocletWriter { */ protected void addClassInfo(ClassDoc cd, Content contentTree) { contentTree.addContent(getResource("doclet.in", - Util.getTypeName(configuration, cd, false), + utils.getTypeName(configuration, cd, false), getPackageLink(cd.containingPackage(), - Util.getPackageName(cd.containingPackage())) + utils.getPackageName(cd.containingPackage())) )); } @@ -200,7 +200,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { Content span = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.block); - if (Util.isDeprecated(element)) { + if (utils.isDeprecated(element)) { div.addContent(span); if ((tags = element.tags("deprecated")).length > 0) addInlineDeprecatedComment(element, tags[0], div); @@ -208,7 +208,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { } else { ClassDoc cont = element.containingClass(); while (cont != null) { - if (Util.isDeprecated(cont)) { + if (utils.isDeprecated(cont)) { div.addContent(span); contentTree.addContent(div); break; @@ -228,7 +228,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { */ protected void addMemberDesc(MemberDoc member, Content contentTree) { ClassDoc containing = member.containingClass(); - String classdesc = Util.getTypeName( + String classdesc = utils.getTypeName( configuration, containing, true) + " "; if (member.isField()) { if (member.isStatic()) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java index 64fdbb96985..c42a692803f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.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 @@ -50,6 +50,7 @@ import com.sun.tools.doclets.internal.toolkit.util.*; public abstract class AbstractMemberWriter { protected final ConfigurationImpl configuration; + protected final Utils utils; protected final SubWriterHolderWriter writer; protected final ClassDoc classdoc; protected Map typeMap = new LinkedHashMap<>(); @@ -64,6 +65,7 @@ public abstract class AbstractMemberWriter { this.writer = writer; this.nodepr = configuration.nodeprecated; this.classdoc = classdoc; + this.utils = writer.configuration.utils; } public AbstractMemberWriter(SubWriterHolderWriter writer) { @@ -244,8 +246,8 @@ public abstract class AbstractMemberWriter { // it is updated to use the javax.lang.model.element.Modifier, we // will need to remove this. mod = (member.isMethod() && ((MethodDoc)member).isDefault()) ? - Util.replaceText(mod, "public", "default").trim() : - Util.replaceText(mod, "public", "").trim(); + utils.replaceText(mod, "public", "default").trim() : + utils.replaceText(mod, "public", "").trim(); } if(mod.length() > 0) { htmltree.addContent(mod); @@ -538,7 +540,7 @@ public abstract class AbstractMemberWriter { } public ProgramElementDoc[] eligibleMembers(ProgramElementDoc[] members) { - return nodepr? Util.excludeDeprecatedMembers(members): members; + return nodepr? utils.excludeDeprecatedMembers(members): members; } /** @@ -573,7 +575,7 @@ public abstract class AbstractMemberWriter { ? methodType | MethodTypes.ABSTRACT.value() : methodType | MethodTypes.CONCRETE.value(); } - if (Util.isDeprecated(member) || Util.isDeprecated(classdoc)) { + if (utils.isDeprecated(member) || utils.isDeprecated(classdoc)) { methodType = methodType | MethodTypes.DEPRECATED.value(); } methodTypesOr = methodTypesOr | methodType; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java index a0b5ed5c892..fe51c77026a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -137,7 +137,7 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { for (ClassDoc intf : interfaces) { if (parent != intf) { if (!(intf.isPublic() || - Util.isLinkable(intf, configuration))) { + utils.isLinkable(intf, configuration))) { continue; } if (counter == 0) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java index 3c92d90cbe8..71e27df0266 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -153,7 +153,7 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { Content content) { for (Doc doc : classlist) { ClassDoc cd = (ClassDoc) doc; - if (!Util.isCoreClass(cd)) { + if (!utils.isCoreClass(cd)) { continue; } Content label = italicsClassName(cd, false); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java index b8866fe1a1b..1bbc147e75a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java @@ -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 @@ -261,7 +261,7 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter Content hr = new HtmlTree(HtmlTag.HR); annotationInfoTree.addContent(hr); Tag[] deprs = annotationType.tags("deprecated"); - if (Util.isDeprecated(annotationType)) { + if (utils.isDeprecated(annotationType)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel); if (deprs.length > 0) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java index f1bb90158b6..7151b1b2e3b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java @@ -165,13 +165,13 @@ public class ClassUseWriter extends SubWriterHolderWriter { // the class-use page if the class is marked as deprecated but the containing // package is not since it could still be linked from that package-use page. if (!(configuration.nodeprecated && - Util.isDeprecated(aClass.containingPackage()))) + configuration.utils.isDeprecated(aClass.containingPackage()))) ClassUseWriter.generate(configuration, mapper, aClass); } for (PackageDoc pkg : configuration.packages) { // If -nodeprecated option is set and the package is marked // as deprecated, do not generate the package-use page. - if (!(configuration.nodeprecated && Util.isDeprecated(pkg))) + if (!(configuration.nodeprecated && configuration.utils.isDeprecated(pkg))) PackageUseWriter.generate(configuration, mapper, pkg); } } @@ -180,7 +180,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { Map> map = new HashMap<>(); List list= classMap.get(classdoc.qualifiedName()); if (list != null) { - Collections.sort(list, Util.makeComparatorForClassUse()); + Collections.sort(list, utils.makeComparatorForClassUse()); for (ProgramElementDoc doc : list) { PackageDoc pkg = doc.containingPackage(); pkgSet.add(pkg); @@ -337,7 +337,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { Content link = getResource("doclet.ClassUse_Uses.of.0.in.1", getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)), - getPackageLink(pkg, Util.getPackageName(pkg))); + getPackageLink(pkg, utils.getPackageName(pkg))); Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); li.addContent(heading); addClassUse(pkg, li); @@ -355,7 +355,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { */ protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException { Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, - getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg)))); + getHyperLink(pkg.name(), new StringContent(utils.getPackageName(pkg)))); contentTree.addContent(tdFirst); HtmlTree tdLast = new HtmlTree(HtmlTag.TD); tdLast.addStyle(HtmlStyle.colLast); @@ -372,7 +372,7 @@ public class ClassUseWriter extends SubWriterHolderWriter { protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException { Content classLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)); - Content pkgLink = getPackageLink(pkg, Util.getPackageName(pkg)); + Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg)); classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()), configuration.getResource("doclet.ClassUse_Annotation", classLink, pkgLink), classUseTableSummary, contentTree); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java index ebcb7b64cf3..1348af51010 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java @@ -260,7 +260,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter pre.addContent(span); } if (!isInterface) { - Type superclass = Util.getFirstVisibleSuperClass(classDoc, + Type superclass = utils.getFirstVisibleSuperClass(classDoc, configuration); if (superclass != null) { pre.addContent(DocletConstants.NL); @@ -276,7 +276,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter int counter = 0; for (Type implType : implIntfacs) { ClassDoc classDoc = implType.asClassDoc(); - if (!(classDoc.isPublic() || Util.isLinkable(classDoc, configuration))) { + if (!(classDoc.isPublic() || utils.isLinkable(classDoc, configuration))) { continue; } if (counter == 0) { @@ -329,7 +329,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter classTreeUl.addStyle(HtmlStyle.inheritance); Content liTree = null; do { - sup = Util.getFirstVisibleSuperClass( + sup = utils.getFirstVisibleSuperClass( type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(), configuration); if (sup != null) { @@ -471,7 +471,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter public void addImplementedInterfacesInfo(Content classInfoTree) { //NOTE: we really should be using ClassDoc.interfaceTypes() here, but // it doesn't walk up the tree like we want it to. - List interfaceArray = Util.getAllInterfaces(classDoc, configuration); + List interfaceArray = utils.getAllInterfaces(classDoc, configuration); if (classDoc.isClass() && interfaceArray.size() > 0) { Content label = getResource( "doclet.All_Implemented_Interfaces"); @@ -489,7 +489,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter public void addSuperInterfacesInfo(Content classInfoTree) { //NOTE: we really should be using ClassDoc.interfaceTypes() here, but // it doesn't walk up the tree like we want it to. - List interfaceArray = Util.getAllInterfaces(classDoc, configuration); + List interfaceArray = utils.getAllInterfaces(classDoc, configuration); if (classDoc.isInterface() && interfaceArray.size() > 0) { Content label = getResource( "doclet.All_Superinterfaces"); @@ -559,7 +559,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter Content hr = new HtmlTree(HtmlTag.HR); classInfoTree.addContent(hr); Tag[] deprs = classDoc.tags("deprecated"); - if (Util.isDeprecated(classDoc)) { + if (utils.isDeprecated(classDoc)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel); if (deprs.length > 0) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java index 5e5cebf07f7..9ae2501efb9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.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 @@ -130,7 +130,7 @@ public class FieldWriterImpl extends AbstractMemberWriter ClassDoc holder = field.containingClass(); if (field.inlineTags().length > 0) { if (holder.equals(classdoc) || - (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) { + (! (holder.isPublic() || utils.isLinkable(holder, configuration)))) { writer.addInlineComment(field, fieldDocTree); } else { Content link = diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java index a11e3055809..f2309b02926 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java @@ -28,7 +28,6 @@ import java.io.*; import java.util.*; import com.sun.javadoc.*; -import com.sun.tools.javac.sym.Profiles; import com.sun.tools.javac.jvm.Profile; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.builders.*; @@ -223,7 +222,7 @@ public class HtmlDoclet extends AbstractDoclet { // deprecated, do not generate the profilename-package-summary.html // and profilename-package-frame.html pages for that package. PackageDoc pkg = packages.get(j); - if (!(configuration.nodeprecated && Util.isDeprecated(pkg))) { + if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { ProfilePackageFrameWriter.generate(configuration, pkg, i); next = getNamedPackage(packages, j + 1); AbstractBuilder profilePackageSummaryBuilder = @@ -269,7 +268,7 @@ public class HtmlDoclet extends AbstractDoclet { // deprecated, do not generate the package-summary.html, package-frame.html // and package-tree.html pages for that package. PackageDoc pkg = pList.get(i); - if (!(configuration.nodeprecated && Util.isDeprecated(pkg))) { + if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { PackageFrameWriter.generate(configuration, pkg); next = getNamedPackage(pList, i + 1); //If the next package is unnamed package, skip 2 ahead if possible diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java index 13c6637fc98..78f14723010 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java @@ -82,6 +82,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { */ public final ConfigurationImpl configuration; + protected final Utils utils; + /** * To check whether annotation heading is printed or not. */ @@ -111,6 +113,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { throws IOException { super(configuration, path); this.configuration = configuration; + this.utils = configuration.utils; this.path = path; this.pathToRoot = path.parent().invert(); this.filename = path.basename(); @@ -347,7 +350,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { if (!isTypeInProfile(classes[i], profileValue)) { continue; } - if (!Util.isCoreClass(classes[i]) || + if (!utils.isCoreClass(classes[i]) || !configuration.isGeneratedDoc(classes[i])) { continue; } @@ -361,7 +364,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { tr.addStyle(HtmlStyle.rowColor); HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD); tdClassDescription.addStyle(HtmlStyle.colLast); - if (Util.isDeprecated(classes[i])) { + if (utils.isDeprecated(classes[i])) { tdClassDescription.addContent(deprecatedLabel); if (classes[i].tags("deprecated").length > 0) { addSummaryDeprecatedComment(classes[i], @@ -1021,7 +1024,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return getHyperLink(pathString(pkg, DocPaths.PACKAGE_SUMMARY), label); } else { - DocLink crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); + DocLink crossPkgLink = getCrossPackageLink(utils.getPackageName(pkg)); if (crossPkgLink != null) { return getHyperLink(crossPkgLink, label); } else { @@ -1288,7 +1291,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, Content label, boolean strong, boolean isProperty) { if (! (doc.isIncluded() || - Util.isLinkable(classDoc, configuration))) { + utils.isLinkable(classDoc, configuration))) { return label; } else if (doc instanceof ExecutableMemberDoc) { ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; @@ -1316,7 +1319,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { public Content getDocLink(LinkInfoImpl.Kind context, ClassDoc classDoc, MemberDoc doc, Content label) { if (! (doc.isIncluded() || - Util.isLinkable(classDoc, configuration))) { + utils.isLinkable(classDoc, configuration))) { return label; } else if (doc instanceof ExecutableMemberDoc) { ExecutableMemberDoc emd = (ExecutableMemberDoc) doc; @@ -1360,7 +1363,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return new ContentBuilder(); } - String seetext = replaceDocRootDir(Util.normalizeNewlines(see.text())); + String seetext = replaceDocRootDir(utils.normalizeNewlines(see.text())); //Check if @see is an href or "string" if (seetext.startsWith("<") || seetext.startsWith("\"")) { @@ -1422,7 +1425,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { ClassDoc containing = refMem.containingClass(); if (see.text().trim().startsWith("#") && ! (containing.isPublic() || - Util.isLinkable(containing, configuration))) { + utils.isLinkable(containing, configuration))) { // Since the link is relative and the holder is not even being // documented, this must be an inherited link. Redirect it. // The current class either overrides the referenced member or @@ -1628,8 +1631,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { if (isFirstSentence) { text = removeNonInlineHtmlTags(text); } - text = Util.replaceTabs(configuration, text); - text = Util.normalizeNewlines(text); + text = utils.replaceTabs(configuration, text); + text = utils.normalizeNewlines(text); result.addContent(new RawHtml(text)); } } @@ -1955,13 +1958,13 @@ public class HtmlDocletWriter extends HtmlDocWriter { // and also if its container annotation is not documented, do not add it // to the list. If an annotation of a repeatable type is not documented // but its container is documented, it will be added to the list. - if (!Util.isDocumentedAnnotation(annotationDoc) && + if (!utils.isDocumentedAnnotation(annotationDoc) && (!isAnnotationDocumented && !isContainerDocumented)) { continue; } /* TODO: check logic here to correctly handle declaration * and type annotations. - if (Util.isDeclarationAnnotation(annotationDoc, isJava5DeclarationLocation)) { + if (util.isDeclarationAnnotation(annotationDoc, isJava5DeclarationLocation)) { continue; }*/ annotation = new ContentBuilder(); @@ -2096,7 +2099,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { AnnotationTypeDoc annotationDoc = ((AnnotationDesc) annotationArray[0].value()).annotationType(); isContainerDocumented = true; - if (Util.isDocumentedAnnotation(annotationDoc)) { + if (utils.isDocumentedAnnotation(annotationDoc)) { isAnnotationDocumented = true; } return true; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java index 890635e3df0..3dd59058949 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java @@ -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 @@ -29,8 +29,6 @@ import java.util.List; import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.markup.ContentBuilder; -import com.sun.tools.doclets.formats.html.markup.RawHtml; -import com.sun.tools.doclets.formats.html.markup.StringContent; import com.sun.tools.doclets.internal.toolkit.*; import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.util.links.*; @@ -174,21 +172,22 @@ public class LinkFactoryImpl extends LinkFactory { */ private String getClassToolTip(ClassDoc classDoc, boolean isTypeLink) { Configuration configuration = m_writer.configuration; + Utils utils = configuration.utils; if (isTypeLink) { return configuration.getText("doclet.Href_Type_Param_Title", classDoc.name()); } else if (classDoc.isInterface()){ return configuration.getText("doclet.Href_Interface_Title", - Util.getPackageName(classDoc.containingPackage())); + utils.getPackageName(classDoc.containingPackage())); } else if (classDoc.isAnnotationType()) { return configuration.getText("doclet.Href_Annotation_Title", - Util.getPackageName(classDoc.containingPackage())); + utils.getPackageName(classDoc.containingPackage())); } else if (classDoc.isEnum()) { return configuration.getText("doclet.Href_Enum_Title", - Util.getPackageName(classDoc.containingPackage())); + utils.getPackageName(classDoc.containingPackage())); } else { return configuration.getText("doclet.Href_Class_Title", - Util.getPackageName(classDoc.containingPackage())); + utils.getPackageName(classDoc.containingPackage())); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java index 7e3b6042a50..6d8e65c22f9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java @@ -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 @@ -30,7 +30,6 @@ import com.sun.javadoc.*; import com.sun.tools.doclets.formats.html.markup.ContentBuilder; import com.sun.tools.doclets.formats.html.markup.StringContent; import com.sun.tools.doclets.internal.toolkit.Content; -import com.sun.tools.doclets.internal.toolkit.util.*; import com.sun.tools.doclets.internal.toolkit.util.links.*; /** @@ -426,6 +425,6 @@ public class LinkInfoImpl extends LinkInfo { * desired place. */ public boolean isLinkable() { - return Util.isLinkable(classDoc, configuration); + return configuration.utils.isLinkable(classDoc, configuration); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java index 8ff82ab0ccf..b3469223287 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java @@ -151,7 +151,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter if (method.inlineTags().length > 0) { if (holder.asClassDoc().equals(classdoc) || (! (holderClassDoc.isPublic() || - Util.isLinkable(holderClassDoc, configuration)))) { + utils.isLinkable(holderClassDoc, configuration)))) { writer.addInlineComment(method, methodDocTree); } else { Content link = @@ -292,7 +292,7 @@ public class MethodWriterImpl extends AbstractExecutableMemberWriter } ClassDoc holderClassDoc = overriddenType.asClassDoc(); if (! (holderClassDoc.isPublic() || - Util.isLinkable(holderClassDoc, writer.configuration))) { + writer.configuration.utils.isLinkable(holderClassDoc, writer.configuration))) { //This is an implementation detail that should not be documented. return; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java index feb4222f9ab..cadbd48ddfe 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -92,7 +92,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { PackageFrameWriter packgen; try { packgen = new PackageFrameWriter(configuration, packageDoc); - String pkgName = Util.getPackageName(packageDoc); + String pkgName = configuration.utils.getPackageName(packageDoc); Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName)); Content pkgNameContent = new StringContent(pkgName); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, @@ -136,7 +136,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { addClassKindListing(packageDoc.annotationTypes(), getResource("doclet.AnnotationTypes"), contentTree); } else { - String name = Util.getPackageName(packageDoc); + String name = utils.getPackageName(packageDoc); addClassKindListing(config.classDocCatalog.interfaces(name), getResource("doclet.Interfaces"), contentTree); addClassKindListing(config.classDocCatalog.ordinaryClasses(name), @@ -161,7 +161,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { */ protected void addClassKindListing(ClassDoc[] arr, Content labelContent, Content contentTree) { - arr = Util.filterOutPrivateClasses(arr, configuration.javafx); + arr = utils.filterOutPrivateClasses(arr, configuration.javafx); if(arr.length > 0) { Arrays.sort(arr); boolean printedHeader = false; @@ -171,7 +171,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { if (documentedClasses != null && !documentedClasses.contains(classDoc)) { continue; } - if (!Util.isCoreClass(classDoc) || !configuration.isGeneratedDoc(classDoc)) { + if (!utils.isCoreClass(classDoc) || !configuration.isGeneratedDoc(classDoc)) { continue; } if (!printedHeader) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java index 7c818ab6187..0e0acc38aa6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java @@ -90,7 +90,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { // Do not list the package if -nodeprecated option is set and the // package is marked as deprecated. if (aPackage != null && - (!(configuration.nodeprecated && Util.isDeprecated(aPackage)))) { + (!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) { ul.addContent(getPackage(aPackage)); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java index ef5ab138335..d488c1a2ece 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java @@ -168,7 +168,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { boolean altColor = true; for (PackageDoc pkg : packages) { if (pkg != null && !pkg.name().isEmpty()) { - if (!(configuration.nodeprecated && Util.isDeprecated(pkg))) { + if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg)); Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent); HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java index 70106641a45..016edfd6e9c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java @@ -115,7 +115,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { protected void generatePackageTreeFile() throws IOException { Content body = getPackageTreeHeader(); Content headContent = getResource("doclet.Hierarchy_For_Package", - Util.getPackageName(packagedoc)); + utils.getPackageName(packagedoc)); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java index 88a9ab6e80a..a9eb691f058 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java @@ -74,7 +74,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { .get(usingPackage.name()); if (usedClasses == null) { usedClasses = new TreeSet<>(); - usingPackageToUsedClasses.put(Util.getPackageName(usingPackage), + usingPackageToUsedClasses.put(utils.getPackageName(usingPackage), usedClasses); } usedClasses.add(usedClass); @@ -151,7 +151,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { Content table = HtmlTree.TABLE(HtmlStyle.useSummary, 0, 3, 0, useTableSummary, getTableCaption(configuration.getResource( "doclet.ClassUse_Packages.that.use.0", - getPackageLink(pkgdoc, Util.getPackageName(pkgdoc))))); + getPackageLink(pkgdoc, utils.getPackageName(pkgdoc))))); table.addContent(getSummaryTableHeader(packageTableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); Iterator it = usingPackageToUsedClasses.keySet().iterator(); @@ -194,8 +194,8 @@ public class PackageUseWriter extends SubWriterHolderWriter { Content table = HtmlTree.TABLE(HtmlStyle.useSummary, 0, 3, 0, tableSummary, getTableCaption(configuration.getResource( "doclet.ClassUse_Classes.in.0.used.by.1", - getPackageLink(pkgdoc, Util.getPackageName(pkgdoc)), - getPackageLink(usingPackage, Util.getPackageName(usingPackage))))); + getPackageLink(pkgdoc, utils.getPackageName(pkgdoc)), + getPackageLink(usingPackage, utils.getPackageName(usingPackage))))); table.addContent(getSummaryTableHeader(classTableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); Iterator itc = @@ -241,8 +241,8 @@ public class PackageUseWriter extends SubWriterHolderWriter { */ protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException { Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, - getHyperLink(Util.getPackageName(pkg), - new StringContent(Util.getPackageName(pkg)))); + getHyperLink(utils.getPackageName(pkg), + new StringContent(utils.getPackageName(pkg)))); contentTree.addContent(tdFirst); HtmlTree tdLast = new HtmlTree(HtmlTag.TD); tdLast.addStyle(HtmlStyle.colLast); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java index ef5b148ed1f..a3d4ddd208b 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.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 @@ -138,7 +138,7 @@ public class PackageWriterImpl extends HtmlDocletWriter */ public void addDeprecationInfo(Content div) { Tag[] deprs = packageDoc.tags("deprecated"); - if (Util.isDeprecated(packageDoc)) { + if (utils.isDeprecated(packageDoc)) { HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.addStyle(HtmlStyle.deprecatedContent); Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); @@ -175,7 +175,7 @@ public class PackageWriterImpl extends HtmlDocletWriter table.addContent(getSummaryTableHeader(tableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); for (int i = 0; i < classes.length; i++) { - if (!Util.isCoreClass(classes[i]) || + if (!utils.isCoreClass(classes[i]) || !configuration.isGeneratedDoc(classes[i])) { continue; } @@ -189,7 +189,7 @@ public class PackageWriterImpl extends HtmlDocletWriter tr.addStyle(HtmlStyle.rowColor); HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD); tdClassDescription.addStyle(HtmlStyle.colLast); - if (Util.isDeprecated(classes[i])) { + if (utils.isDeprecated(classes[i])) { tdClassDescription.addContent(deprecatedLabel); if (classes[i].tags("deprecated").length > 0) { addSummaryDeprecatedComment(classes[i], diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java index 8222d69df57..9a1efc4a839 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageFrameWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -91,7 +91,7 @@ public class ProfilePackageFrameWriter extends HtmlDocletWriter { StringBuilder winTitle = new StringBuilder(profileName); String sep = " - "; winTitle.append(sep); - String pkgName = Util.getPackageName(packageDoc); + String pkgName = configuration.utils.getPackageName(packageDoc); winTitle.append(pkgName); Content body = profpackgen.getBody(false, profpackgen.getWindowTitle(winTitle.toString())); @@ -163,7 +163,7 @@ public class ProfilePackageFrameWriter extends HtmlDocletWriter { if (!isTypeInProfile(classDoc, profileValue)) { continue; } - if (!Util.isCoreClass(classDoc) || ! + if (!utils.isCoreClass(classDoc) || ! configuration.isGeneratedDoc(classDoc)) { continue; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java index f536e14b2d9..55227f0f980 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java @@ -95,7 +95,7 @@ public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter { ul.setTitle(packagesLabel); List packages = configuration.profilePackages.get(profileName); for (PackageDoc packageDoc : packages) { - if ((!(configuration.nodeprecated && Util.isDeprecated(packageDoc)))) { + if ((!(configuration.nodeprecated && utils.isDeprecated(packageDoc)))) { ul.addContent(getPackage(packageDoc, profileName)); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java index 314e75f8196..6d66ed26faf 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageWriterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,7 +26,6 @@ package com.sun.tools.doclets.formats.html; import java.io.*; -import java.util.*; import com.sun.javadoc.*; import com.sun.tools.javac.jvm.Profile; @@ -155,7 +154,7 @@ public class ProfilePackageWriterImpl extends HtmlDocletWriter */ public void addDeprecationInfo(Content div) { Tag[] deprs = packageDoc.tags("deprecated"); - if (Util.isDeprecated(packageDoc)) { + if (utils.isDeprecated(packageDoc)) { HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.addStyle(HtmlStyle.deprecatedContent); Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java index 15838e0cf9d..0cdc38fef64 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileWriterImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,7 +26,6 @@ package com.sun.tools.doclets.formats.html; import java.io.*; -import java.util.*; import com.sun.javadoc.*; import com.sun.tools.javac.jvm.Profile; @@ -183,7 +182,7 @@ public class ProfileWriterImpl extends HtmlDocletWriter */ public void addPackageDeprecationInfo(Content li, PackageDoc pkg) { Tag[] deprs; - if (Util.isDeprecated(pkg)) { + if (utils.isDeprecated(pkg)) { deprs = pkg.tags("deprecated"); HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); deprDiv.addStyle(HtmlStyle.deprecatedContent); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java index d772c13be59..6bf0b278ea6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PropertyWriterImpl.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 @@ -126,7 +126,7 @@ public class PropertyWriterImpl extends AbstractMemberWriter ClassDoc holder = property.containingClass(); if (property.inlineTags().length > 0) { if (holder.equals(classdoc) || - (! (holder.isPublic() || Util.isLinkable(holder, configuration)))) { + (! (holder.isPublic() || utils.isLinkable(holder, configuration)))) { writer.addInlineComment(property, propertyDocTree); } else { Content link = diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java index 10935f2637a..479f51df5df 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -61,6 +61,7 @@ public class SourceToHTMLConverter { private static final String NEW_LINE = DocletConstants.NL; private final ConfigurationImpl configuration; + private final Utils utils; private final RootDoc rootDoc; @@ -75,6 +76,7 @@ public class SourceToHTMLConverter { private SourceToHTMLConverter(ConfigurationImpl configuration, RootDoc rd, DocPath outputdir) { this.configuration = configuration; + this.utils = configuration.utils; this.rootDoc = rd; this.outputdir = outputdir; } @@ -98,7 +100,7 @@ public class SourceToHTMLConverter { for (PackageDoc pd : rootDoc.specifiedPackages()) { // If -nodeprecated option is set and the package is marked as deprecated, // do not convert the package files to HTML. - if (!(configuration.nodeprecated && Util.isDeprecated(pd))) + if (!(configuration.nodeprecated && utils.isDeprecated(pd))) convertPackage(pd, outputdir); } for (ClassDoc cd : rootDoc.specifiedClasses()) { @@ -106,7 +108,7 @@ public class SourceToHTMLConverter { // or the containing package is deprecated, do not convert the // package files to HTML. if (!(configuration.nodeprecated && - (Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage())))) + (utils.isDeprecated(cd) || utils.isDeprecated(cd.containingPackage())))) convertClass(cd, outputdir); } } @@ -126,7 +128,7 @@ public class SourceToHTMLConverter { // do not convert the package files to HTML. We do not check for // containing package deprecation since it is already check in // the calling method above. - if (!(configuration.nodeprecated && Util.isDeprecated(cd))) + if (!(configuration.nodeprecated && utils.isDeprecated(cd))) convertClass(cd, outputdir); } } @@ -260,7 +262,7 @@ public class SourceToHTMLConverter { */ private void addLine(Content pre, String line, int currentLineNo) { if (line != null) { - pre.addContent(Util.replaceTabs(configuration, line)); + pre.addContent(utils.replaceTabs(configuration, line)); Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo)); pre.addContent(anchor); pre.addContent(NEW_LINE); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java index 77d481aa288..8b5de2e81fc 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.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 @@ -174,7 +174,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { Content tdSummary) { Tag[] deprs = member.tags("deprecated"); Content div; - if (Util.isDeprecated((ProgramElementDoc) member)) { + if (utils.isDeprecated((ProgramElementDoc) member)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); div = HtmlTree.DIV(HtmlStyle.block, deprLabel); div.addContent(getSpace()); @@ -185,7 +185,7 @@ public abstract class SubWriterHolderWriter extends HtmlDocletWriter { return; } else { ClassDoc cd = ((ProgramElementDoc)member).containingClass(); - if (cd != null && Util.isDeprecated(cd)) { + if (cd != null && utils.isDeprecated(cd)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); div = HtmlTree.DIV(HtmlStyle.block, deprLabel); div.addContent(getSpace()); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java index 831c13c3962..8c0c3765156 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java @@ -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 @@ -53,11 +53,13 @@ public class TagletWriterImpl extends TagletWriter { private final HtmlDocletWriter htmlWriter; private final ConfigurationImpl configuration; + private final Utils utils; public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) { super(isFirstSentence); this.htmlWriter = htmlWriter; configuration = htmlWriter.configuration; + this.utils = configuration.utils; } /** @@ -71,7 +73,7 @@ public class TagletWriterImpl extends TagletWriter { * {@inheritDoc} */ protected Content codeTagOutput(Tag tag) { - Content result = HtmlTree.CODE(new StringContent(Util.normalizeNewlines(tag.text()))); + Content result = HtmlTree.CODE(new StringContent(utils.normalizeNewlines(tag.text()))); return result; } @@ -94,7 +96,7 @@ public class TagletWriterImpl extends TagletWriter { ContentBuilder result = new ContentBuilder(); Tag[] deprs = doc.tags("deprecated"); if (doc instanceof ClassDoc) { - if (Util.isDeprecated((ProgramElementDoc) doc)) { + if (utils.isDeprecated((ProgramElementDoc) doc)) { result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, new StringContent(configuration.getText("doclet.Deprecated")))); result.addContent(RawHtml.nbsp); @@ -109,7 +111,7 @@ public class TagletWriterImpl extends TagletWriter { } } else { MemberDoc member = (MemberDoc) doc; - if (Util.isDeprecated((ProgramElementDoc) doc)) { + if (utils.isDeprecated((ProgramElementDoc) doc)) { result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, new StringContent(configuration.getText("doclet.Deprecated")))); result.addContent(RawHtml.nbsp); @@ -120,7 +122,7 @@ public class TagletWriterImpl extends TagletWriter { result.addContent(HtmlTree.SPAN(HtmlStyle.deprecationComment, body)); } } else { - if (Util.isDeprecated(member.containingClass())) { + if (utils.isDeprecated(member.containingClass())) { result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, new StringContent(configuration.getText("doclet.Deprecated")))); result.addContent(RawHtml.nbsp); @@ -134,7 +136,7 @@ public class TagletWriterImpl extends TagletWriter { * {@inheritDoc} */ protected Content literalTagOutput(Tag tag) { - Content result = new StringContent(Util.normalizeNewlines(tag.text())); + Content result = new StringContent(utils.normalizeNewlines(tag.text())); return result; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java index 872cc7e2c94..8f1e1b1977c 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java @@ -142,7 +142,7 @@ public class TreeWriter extends AbstractTreeWriter { // is set and the package is marked as deprecated, do not include // the page in the list of package hierarchies. if (pkg.name().isEmpty() || - (configuration.nodeprecated && Util.isDeprecated(pkg))) { + (configuration.nodeprecated && utils.isDeprecated(pkg))) { i++; continue; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java index 6d33a2ff7c2..f306d890961 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AbstractDoclet.java @@ -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 @@ -45,6 +45,10 @@ public abstract class AbstractDoclet { * The global configuration information for this run. */ public Configuration configuration; + /* + * a handle to our utility methods + */ + protected Utils utils; /** * The only doclet that may use this toolkit is {@value} @@ -75,6 +79,7 @@ public abstract class AbstractDoclet { public boolean start(AbstractDoclet doclet, RootDoc root) { configuration = configuration(); configuration.root = root; + utils = configuration.utils; if (! isValidDoclet(doclet)) { return false; } @@ -94,7 +99,6 @@ public abstract class AbstractDoclet { } return false; } catch (Exception exc) { - exc.printStackTrace(); return false; } return true; @@ -135,7 +139,7 @@ public abstract class AbstractDoclet { ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated); generateClassFiles(root, classtree); - Util.copyDocFiles(configuration, DocPaths.DOC_FILES); + configuration.utils.copyDocFiles(configuration, DocPaths.DOC_FILES); PackageListWriter.generate(configuration); generatePackageFiles(classtree); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java index 96a0855d780..27154a72162 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java @@ -140,7 +140,7 @@ public abstract class Configuration { /** * The meta tag keywords instance. */ - public final MetaKeywords metakeywords = new MetaKeywords(this); + public final MetaKeywords metakeywords; /** * The list of doc-file subdirectories to exclude @@ -157,6 +157,10 @@ public abstract class Configuration { */ public RootDoc root; + /** + * An utility class for commonly used helpers + */ + public Utils utils; /** * Destination directory name, in which doclet will generate the entire * documentation. Default is current directory. @@ -310,6 +314,8 @@ public abstract class Configuration { excludedDocFileDirs = new HashSet<>(); excludedQualifiers = new HashSet<>(); setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH); + utils = new Utils(); + metakeywords = new MetaKeywords(this); } /** @@ -397,7 +403,7 @@ public abstract class Configuration { interimResults.put(p, new ArrayList()); for (PackageDoc pkg: packages) { - if (nodeprecated && Util.isDeprecated(pkg)) { + if (nodeprecated && utils.isDeprecated(pkg)) { continue; } // the getProfile method takes a type name, not a package name, @@ -933,7 +939,7 @@ public abstract class Configuration { if (!nodeprecated) { return true; } - return !(Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage())); + return !(utils.isDeprecated(cd) || utils.isDeprecated(cd.containingPackage())); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java index 6da407613da..d6c7ba95c1e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java @@ -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,6 +85,8 @@ public abstract class AbstractBuilder { */ protected final Configuration configuration; + protected final Utils utils; + /** * Keep track of which packages we have seen for * efficiency purposes. We don't want to copy the @@ -106,6 +108,7 @@ public abstract class AbstractBuilder { */ public AbstractBuilder(Context c) { this.configuration = c.configuration; + this.utils = configuration.utils; this.containingPackagesSeen = c.containingPackagesSeen; this.layoutParser = c.layoutParser; } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java index 6926896cf43..1e0d32b19eb 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java @@ -26,11 +26,9 @@ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; -import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; -import com.sun.tools.doclets.internal.toolkit.util.*; /** * Builds the summary for a given annotation type. @@ -138,7 +136,7 @@ public class AnnotationTypeBuilder extends AbstractBuilder { //Only copy doc files dir if the containing package is not //documented AND if we have not documented a class from the same //package already. Otherwise, we are making duplicate copies. - Util.copyDocFiles(configuration, containingPackage); + utils.copyDocFiles(configuration, containingPackage); containingPackagesSeen.add(containingPackage); } } @@ -174,7 +172,7 @@ public class AnnotationTypeBuilder extends AbstractBuilder { public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) { StringBuilder modifiers = new StringBuilder( annotationTypeDoc.modifiers() + " "); - writer.addAnnotationTypeSignature(Util.replaceText( + writer.addAnnotationTypeSignature(utils.replaceText( modifiers.toString(), "interface", "@interface"), annotationInfoTree); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java index ba917d0035d..1f08e921a5a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java @@ -26,11 +26,9 @@ package com.sun.tools.doclets.internal.toolkit.builders; import java.io.*; -import java.util.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; -import com.sun.tools.doclets.internal.toolkit.util.*; /** * Builds the summary for a given class. @@ -94,7 +92,7 @@ public class ClassBuilder extends AbstractBuilder { } else if (classDoc.isEnum()) { isInterface = false; isEnum = true; - Util.setEnumDocumentation(configuration, classDoc); + utils.setEnumDocumentation(configuration, classDoc); } else { isInterface = false; isEnum = false; @@ -276,7 +274,7 @@ public class ClassBuilder extends AbstractBuilder { //Only copy doc files dir if the containing package is not //documented AND if we have not documented a class from the same //package already. Otherwise, we are making duplicate copies. - Util.copyDocFiles(configuration, containingPackage); + utils.copyDocFiles(configuration, containingPackage); containingPackagesSeen.add(containingPackage); } } @@ -296,12 +294,12 @@ public class ClassBuilder extends AbstractBuilder { if ((index = modifiers.indexOf("abstract")) >= 0) { modifiers.delete(index, index + "abstract".length()); modifiers = new StringBuilder( - Util.replaceText(modifiers.toString(), " ", " ")); + utils.replaceText(modifiers.toString(), " ", " ")); } if ((index = modifiers.indexOf("final")) >= 0) { modifiers.delete(index, index + "final".length()); modifiers = new StringBuilder( - Util.replaceText(modifiers.toString(), " ", " ")); + utils.replaceText(modifiers.toString(), " ", " ")); } //} else if (classDoc.isAnnotationType()) { //modifiers.append("@interface "); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java index f0e36cf2f17..e4b7fd85369 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java @@ -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 @@ -347,7 +347,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { //Inherit comments from overriden or implemented method if //necessary. DocFinder.Output inheritedDoc = - DocFinder.search(new DocFinder.Input((MethodDoc) member)); + DocFinder.search(configuration, new DocFinder.Input((MethodDoc) member)); if (inheritedDoc.holder != null && inheritedDoc.holder.firstSentenceTags().length > 0) { firstSentenceTags = inheritedDoc.holder.firstSentenceTags(); @@ -384,13 +384,13 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { commentTextBuilder.append( MessageFormat.format( configuration.getText("doclet.PropertySetterWithName"), - Util.propertyNameFromMethodName(configuration, member.name()))); + utils.propertyNameFromMethodName(configuration, member.name()))); } if (isGetter) { commentTextBuilder.append( MessageFormat.format( configuration.getText("doclet.PropertyGetterWithName"), - Util.propertyNameFromMethodName(configuration, member.name()))); + utils.propertyNameFromMethodName(configuration, member.name()))); } if (propertyDoc.commentText() != null && !propertyDoc.commentText().isEmpty()) { @@ -477,7 +477,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { VisibleMemberMap visibleMemberMap, LinkedList summaryTreeList) { for (ClassDoc inhclass : visibleMemberMap.getVisibleClassesList()) { if (!(inhclass.isPublic() || - Util.isLinkable(inhclass, configuration))) { + utils.isLinkable(inhclass, configuration))) { continue; } if (inhclass == classDoc) { @@ -491,7 +491,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { for (int j = 0; j < inhmembers.size(); ++j) { writer.addInheritedMemberSummary( inhclass.isPackagePrivate() && - !Util.isLinkable(inhclass, configuration) ? + !utils.isLinkable(inhclass, configuration) ? classDoc : inhclass, inhmembers.get(j), j == 0, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java index e61683fa5cf..1fea3e8fb42 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java @@ -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 @@ -207,7 +207,7 @@ public class MethodBuilder extends AbstractMemberBuilder { MethodDoc method = (MethodDoc) methods.get(currentMethodIndex); if (method.inlineTags().length == 0) { - DocFinder.Output docs = DocFinder.search( + DocFinder.Output docs = DocFinder.search(configuration, new DocFinder.Input(method)); method = docs.inlineTags != null && docs.inlineTags.length > 0 ? (MethodDoc) docs.holder : method; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java index b6e8fecc133..c65cf4cc5ed 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java @@ -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 @@ -29,7 +29,6 @@ import java.io.*; import com.sun.javadoc.*; import com.sun.tools.doclets.internal.toolkit.*; -import com.sun.tools.doclets.internal.toolkit.util.*; /** * Builds the summary for a given package. @@ -120,12 +119,12 @@ public class PackageSummaryBuilder extends AbstractBuilder { * @param contentTree the content tree to which the documentation will be added */ public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception { - contentTree = packageWriter.getPackageHeader(Util.getPackageName(packageDoc)); + contentTree = packageWriter.getPackageHeader(utils.getPackageName(packageDoc)); buildChildren(node, contentTree); packageWriter.addPackageFooter(contentTree); packageWriter.printDocument(contentTree); packageWriter.close(); - Util.copyDocFiles(configuration, packageDoc); + utils.copyDocFiles(configuration, packageDoc); } /** @@ -174,8 +173,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.interfaces() : configuration.classDocCatalog.interfaces( - Util.getPackageName(packageDoc)); - interfaces = Util.filterOutPrivateClasses(interfaces, configuration.javafx); + utils.getPackageName(packageDoc)); + interfaces = utils.filterOutPrivateClasses(interfaces, configuration.javafx); if (interfaces.length > 0) { packageWriter.addClassesSummary( interfaces, @@ -204,8 +203,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.ordinaryClasses() : configuration.classDocCatalog.ordinaryClasses( - Util.getPackageName(packageDoc)); - classes = Util.filterOutPrivateClasses(classes, configuration.javafx); + utils.getPackageName(packageDoc)); + classes = utils.filterOutPrivateClasses(classes, configuration.javafx); if (classes.length > 0) { packageWriter.addClassesSummary( classes, @@ -234,8 +233,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.enums() : configuration.classDocCatalog.enums( - Util.getPackageName(packageDoc)); - enums = Util.filterOutPrivateClasses(enums, configuration.javafx); + utils.getPackageName(packageDoc)); + enums = utils.filterOutPrivateClasses(enums, configuration.javafx); if (enums.length > 0) { packageWriter.addClassesSummary( enums, @@ -264,8 +263,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.exceptions() : configuration.classDocCatalog.exceptions( - Util.getPackageName(packageDoc)); - exceptions = Util.filterOutPrivateClasses(exceptions, configuration.javafx); + utils.getPackageName(packageDoc)); + exceptions = utils.filterOutPrivateClasses(exceptions, configuration.javafx); if (exceptions.length > 0) { packageWriter.addClassesSummary( exceptions, @@ -294,8 +293,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.errors() : configuration.classDocCatalog.errors( - Util.getPackageName(packageDoc)); - errors = Util.filterOutPrivateClasses(errors, configuration.javafx); + utils.getPackageName(packageDoc)); + errors = utils.filterOutPrivateClasses(errors, configuration.javafx); if (errors.length > 0) { packageWriter.addClassesSummary( errors, @@ -324,8 +323,8 @@ public class PackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.annotationTypes() : configuration.classDocCatalog.annotationTypes( - Util.getPackageName(packageDoc)); - annotationTypes = Util.filterOutPrivateClasses(annotationTypes, configuration.javafx); + utils.getPackageName(packageDoc)); + annotationTypes = utils.filterOutPrivateClasses(annotationTypes, configuration.javafx); if (annotationTypes.length > 0) { packageWriter.addClassesSummary( annotationTypes, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java index 98ae55d4f5e..603369ffa97 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfilePackageSummaryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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,7 +30,6 @@ import java.io.*; import com.sun.javadoc.*; import com.sun.tools.javac.jvm.Profile; import com.sun.tools.doclets.internal.toolkit.*; -import com.sun.tools.doclets.internal.toolkit.util.*; /** * Builds the summary for a given profile package. @@ -136,12 +135,12 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { */ public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception { contentTree = profilePackageWriter.getPackageHeader( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); buildChildren(node, contentTree); profilePackageWriter.addPackageFooter(contentTree); profilePackageWriter.printDocument(contentTree); profilePackageWriter.close(); - Util.copyDocFiles(configuration, packageDoc); + utils.copyDocFiles(configuration, packageDoc); } /** @@ -190,7 +189,7 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.interfaces() : configuration.classDocCatalog.interfaces( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); if (interfaces.length > 0) { profilePackageWriter.addClassesSummary( interfaces, @@ -219,7 +218,7 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.ordinaryClasses() : configuration.classDocCatalog.ordinaryClasses( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); if (classes.length > 0) { profilePackageWriter.addClassesSummary( classes, @@ -248,7 +247,7 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.enums() : configuration.classDocCatalog.enums( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); if (enums.length > 0) { profilePackageWriter.addClassesSummary( enums, @@ -277,7 +276,7 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.exceptions() : configuration.classDocCatalog.exceptions( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); if (exceptions.length > 0) { profilePackageWriter.addClassesSummary( exceptions, @@ -306,7 +305,7 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.errors() : configuration.classDocCatalog.errors( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); if (errors.length > 0) { profilePackageWriter.addClassesSummary( errors, @@ -335,7 +334,7 @@ public class ProfilePackageSummaryBuilder extends AbstractBuilder { packageDoc.isIncluded() ? packageDoc.annotationTypes() : configuration.classDocCatalog.annotationTypes( - Util.getPackageName(packageDoc)); + utils.getPackageName(packageDoc)); if (annotationTypes.length > 0) { profilePackageWriter.addClassesSummary( annotationTypes, diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java index 92525727b1f..af014c6f181 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ProfileSummaryBuilder.java @@ -129,7 +129,7 @@ public class ProfileSummaryBuilder extends AbstractBuilder { profileWriter.addProfileFooter(contentTree); profileWriter.printDocument(contentTree); profileWriter.close(); - Util.copyDocFiles(configuration, DocPaths.profileSummary(profile.name)); + utils.copyDocFiles(configuration, DocPaths.profileSummary(profile.name)); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java index fd230365ba4..975f6e4bfb6 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java @@ -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 @@ -201,7 +201,7 @@ public class SerializedFormBuilder extends AbstractBuilder { */ public void buildPackageHeader(XMLNode node, Content packageSerializedTree) { packageSerializedTree.addContent(writer.getPackageHeader( - Util.getPackageName(currentPackage))); + utils.getPackageName(currentPackage))); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java index 357a083bd0b..4a09d3c4208 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/InheritDocTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -133,7 +133,7 @@ public class InheritDocTaglet extends BaseInlineTaglet { "doclet.noInheritedDoc", message); } DocFinder.Output inheritedDoc = - DocFinder.search(new DocFinder.Input(ped, + DocFinder.search(configuration, new DocFinder.Input(ped, (InheritableTaglet) inheritableTaglet, holderTag, isFirstSentence, true)); if (inheritedDoc.isValidInheritDocTag) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java index 0cb09cac3bf..d84ed31dac2 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ParamTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -228,7 +228,7 @@ public class ParamTaglet extends BaseTaglet implements InheritableTaglet { //This parameter does not have any @param documentation. //Try to inherit it. DocFinder.Output inheritedDoc = - DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, + DocFinder.search(writer.configuration(), new DocFinder.Input((MethodDoc) holder, this, String.valueOf(i), ! isNonTypeParams)); if (inheritedDoc.inlineTags != null && inheritedDoc.inlineTags.length > 0) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java index 1e9e18f4c92..0345fa3bcc5 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ReturnTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -89,7 +89,7 @@ public class ReturnTaglet extends BaseExecutableMemberTaglet //Inherit @return tag if necessary. if (tags.length == 0) { DocFinder.Output inheritedDoc = - DocFinder.search(new DocFinder.Input((MethodDoc) holder, this)); + DocFinder.search(writer.configuration(), new DocFinder.Input((MethodDoc) holder, this)); tags = inheritedDoc.holderTag == null ? tags : new Tag[] {inheritedDoc.holderTag}; } return tags.length > 0 ? writer.returnTagOutput(tags[0]) : null; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java index de88897aef6..e8dff03cf7a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/SeeTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -66,7 +66,7 @@ public class SeeTaglet extends BaseTaglet implements InheritableTaglet { SeeTag[] tags = holder.seeTags(); if (tags.length == 0 && holder instanceof MethodDoc) { DocFinder.Output inheritedDoc = - DocFinder.search(new DocFinder.Input((MethodDoc) holder, this)); + DocFinder.search(writer.configuration(), new DocFinder.Input((MethodDoc) holder, this)); if (inheritedDoc.holder != null) { tags = inheritedDoc.holder.seeTags(); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java index 83ce569075a..cae8165f0fb 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/ThrowsTaglet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -116,10 +116,10 @@ public class ThrowsTaglet extends BaseExecutableMemberTaglet Set declaredExceptionTags = new LinkedHashSet<>(); for (Type declaredExceptionType : declaredExceptionTypes) { DocFinder.Output inheritedDoc = - DocFinder.search(new DocFinder.Input((MethodDoc) holder, this, + DocFinder.search(writer.configuration(), new DocFinder.Input((MethodDoc) holder, this, declaredExceptionType.typeName())); if (inheritedDoc.tagList.size() == 0) { - inheritedDoc = DocFinder.search(new DocFinder.Input( + inheritedDoc = DocFinder.search(writer.configuration(), new DocFinder.Input( (MethodDoc) holder, this, declaredExceptionType.qualifiedTypeName())); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java index 6b378812f4e..2ef9f36e570 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassDocCatalog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -91,6 +91,7 @@ import com.sun.tools.doclets.internal.toolkit.Configuration; private Map> interfaces; private Configuration configuration; + private Utils utils; /** * Construct a new ClassDocCatalog. @@ -100,6 +101,7 @@ import com.sun.tools.doclets.internal.toolkit.Configuration; public ClassDocCatalog (ClassDoc[] classdocs, Configuration config) { init(); this.configuration = config; + this.utils = config.utils; for (ClassDoc classdoc : classdocs) { addClassDoc(classdoc); } @@ -156,13 +158,13 @@ import com.sun.tools.doclets.internal.toolkit.Configuration; private void addClass(ClassDoc classdoc, Map> map) { PackageDoc pkg = classdoc.containingPackage(); - if (pkg.isIncluded() || (configuration.nodeprecated && Util.isDeprecated(pkg))) { + if (pkg.isIncluded() || (configuration.nodeprecated && utils.isDeprecated(pkg))) { //No need to catalog this class if it's package is //included on the command line or if -nodeprecated option is set // and the containing package is marked as deprecated. return; } - String key = Util.getPackageName(pkg); + String key = utils.getPackageName(pkg); Set s = map.get(key); if (s == null) { packageSet.add(key); @@ -190,7 +192,7 @@ import com.sun.tools.doclets.internal.toolkit.Configuration; public ClassDoc[] allClasses(PackageDoc pkgDoc) { return pkgDoc.isIncluded() ? pkgDoc.allClasses() : - getArray(allClasses, Util.getPackageName(pkgDoc)); + getArray(allClasses, utils.getPackageName(pkgDoc)); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java index e08dd46d633..c7371ed8884 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -81,6 +81,8 @@ public class ClassTree { */ private Map> implementingclasses = new HashMap<>(); + private final Configuration configuration; + private final Utils utils; /** * Constructor. Build the Tree using the Root of this Javadoc run. * @@ -90,17 +92,21 @@ public class ClassTree { */ public ClassTree(Configuration configuration, boolean noDeprecated) { configuration.message.notice("doclet.Building_Tree"); - buildTree(configuration.root.classes(), configuration); + this.configuration = configuration; + this.utils = configuration.utils; + buildTree(configuration.root.classes()); } /** * Constructor. Build the Tree using the Root of this Javadoc run. * * @param root Root of the Document. - * @param configuration The curren configuration of the doclet. + * @param configuration The current configuration of the doclet. */ public ClassTree(RootDoc root, Configuration configuration) { - buildTree(root.classes(), configuration); + this.configuration = configuration; + this.utils = configuration.utils; + buildTree(root.classes()); } /** @@ -110,7 +116,9 @@ public class ClassTree { * @param configuration The curren configuration of the doclet. */ public ClassTree(ClassDoc[] classes, Configuration configuration) { - buildTree(classes, configuration); + this.configuration = configuration; + this.utils = configuration.utils; + buildTree(classes); } /** @@ -122,14 +130,14 @@ public class ClassTree { * @param classes all the classes in this run. * @param configuration the current configuration of the doclet. */ - private void buildTree(ClassDoc[] classes, Configuration configuration) { + private void buildTree(ClassDoc[] classes) { for (ClassDoc aClass : classes) { // In the tree page (e.g overview-tree.html) do not include // information of classes which are deprecated or are a part of a // deprecated package. if (configuration.nodeprecated && - (Util.isDeprecated(aClass) || - Util.isDeprecated(aClass.containingPackage()))) { + (utils.isDeprecated(aClass) || + utils.isDeprecated(aClass.containingPackage()))) { continue; } @@ -177,7 +185,7 @@ public class ClassTree { */ private void processType(ClassDoc cd, Configuration configuration, List bases, Map> subs) { - ClassDoc superclass = Util.getFirstVisibleSuperClassCD(cd, configuration); + ClassDoc superclass = utils.getFirstVisibleSuperClassCD(cd, configuration); if (superclass != null) { if (!add(subs, superclass, cd)) { return; @@ -189,7 +197,7 @@ public class ClassTree { bases.add(cd); } } - List intfacs = Util.getAllInterfaces(cd, configuration); + List intfacs = utils.getAllInterfaces(cd, configuration); for (Type intfac : intfacs) { add(implementingclasses, intfac.asClassDoc(), cd); } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java deleted file mode 100644 index 5c8821450fd..00000000000 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/CommentedMethodFinder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.doclets.internal.toolkit.util; - -import com.sun.javadoc.*; - -/** - * Find a commented method. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - * - */ -public class CommentedMethodFinder extends MethodFinder { - public boolean isCorrectMethod(MethodDoc method) { - return method.inlineTags().length > 0; - } -} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java index 9b6780cd8d3..1290345b3ec 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DeprecatedAPIListBuilder.java @@ -61,7 +61,8 @@ public class DeprecatedAPIListBuilder { * List of deprecated type Lists. */ private List> deprecatedLists; - + private final Configuration configuration; + private final Utils utils; /** * Constructor. @@ -69,11 +70,13 @@ public class DeprecatedAPIListBuilder { * @param configuration the current configuration of the doclet */ public DeprecatedAPIListBuilder(Configuration configuration) { + this.configuration = configuration; + this.utils = configuration.utils; deprecatedLists = new ArrayList<>(); for (int i = 0; i < NUM_TYPES; i++) { deprecatedLists.add(i, new ArrayList()); } - buildDeprecatedAPIInfo(configuration); + buildDeprecatedAPIInfo(); } /** @@ -83,15 +86,15 @@ public class DeprecatedAPIListBuilder { * * @param configuration the current configuration of the doclet. */ - private void buildDeprecatedAPIInfo(Configuration configuration) { + private void buildDeprecatedAPIInfo() { Set packages = configuration.packages; for (PackageDoc pkg : packages) { - if (Util.isDeprecated(pkg)) { + if (utils.isDeprecated(pkg)) { getList(PACKAGE).add(pkg); } } for (ClassDoc cd : configuration.root.classes()) { - if (Util.isDeprecated(cd)) { + if (utils.isDeprecated(cd)) { if (cd.isOrdinaryClass()) { getList(CLASS).add(cd); } else if (cd.isInterface()) { @@ -128,7 +131,7 @@ public class DeprecatedAPIListBuilder { */ private void composeDeprecatedList(List list, MemberDoc[] members) { for (MemberDoc member : members) { - if (Util.isDeprecated(member)) { + if (utils.isDeprecated(member)) { list.add(member); } } diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java index 5bbd6ea47f7..e8cfea666db 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DocFinder.java @@ -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 @@ -28,6 +28,7 @@ package com.sun.tools.doclets.internal.toolkit.util; import java.util.*; import com.sun.javadoc.*; +import com.sun.tools.doclets.internal.toolkit.Configuration; import com.sun.tools.doclets.internal.toolkit.taglets.*; /** @@ -184,7 +185,7 @@ public class DocFinder { * * @return an Output object representing the documentation that was found. */ - public static Output search(Input input) { + public static Output search(Configuration configuration, Input input) { Output output = new Output(); if (input.isInheritDocTag) { //Do nothing because "element" does not have any documentation. @@ -209,7 +210,7 @@ public class DocFinder { MethodDoc overriddenMethod = ((MethodDoc) input.element).overriddenMethod(); if (overriddenMethod != null) { inheritedSearchInput.element = overriddenMethod; - output = search(inheritedSearchInput); + output = search(configuration, inheritedSearchInput); output.isValidInheritDocTag = true; if (output.inlineTags.length > 0) { return output; @@ -219,10 +220,10 @@ public class DocFinder { // not pass all implemented interfaces, we will use the // appropriate element here. MethodDoc[] implementedMethods = - (new ImplementedMethods((MethodDoc) input.element, null)).build(false); + (new ImplementedMethods((MethodDoc) input.element, configuration)).build(false); for (MethodDoc implementedMethod : implementedMethods) { inheritedSearchInput.element = implementedMethod; - output = search(inheritedSearchInput); + output = search(configuration, inheritedSearchInput); output.isValidInheritDocTag = true; if (output.inlineTags.length > 0) { return output; @@ -232,7 +233,7 @@ public class DocFinder { ProgramElementDoc superclass = ((ClassDoc) input.element).superclass(); if (superclass != null) { inheritedSearchInput.element = superclass; - output = search(inheritedSearchInput); + output = search(configuration, inheritedSearchInput); output.isValidInheritDocTag = true; if (output.inlineTags.length > 0) { return output; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java index c9e80ef2161..da528ab7857 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ImplementedMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, 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 @@ -43,15 +43,17 @@ import com.sun.tools.doclets.internal.toolkit.Configuration; */ public class ImplementedMethods { - private Map interfaces = new HashMap<>(); - private List methlist = new ArrayList<>(); - private Configuration configuration; + private final Map interfaces = new HashMap<>(); + private final List methlist = new ArrayList<>(); + private final Configuration configuration; + private final Utils utils; private final ClassDoc classdoc; private final MethodDoc method; public ImplementedMethods(MethodDoc method, Configuration configuration) { this.method = method; this.configuration = configuration; + this.utils = configuration.utils; classdoc = method.containingClass(); } @@ -88,9 +90,9 @@ public class ImplementedMethods { * from the array passed. */ private void buildImplementedMethodList(boolean sort) { - List intfacs = Util.getAllInterfaces(classdoc, configuration, sort); + List intfacs = utils.getAllInterfaces(classdoc, configuration, sort); for (Type interfaceType : intfacs) { - MethodDoc found = Util.findMethod(interfaceType.asClassDoc(), method); + MethodDoc found = utils.findMethod(interfaceType.asClassDoc(), method); if (found != null) { removeOverriddenMethod(found); if (!overridingMethodFound(found)) { diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java index 502a2cb02a8..bd950bc8557 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/IndexBuilder.java @@ -71,6 +71,7 @@ public class IndexBuilder { // make ProgramElementDoc[] when new toArray is available protected final Object[] elements; + private final Configuration configuration; /** * Constructor. Build the index map. * @@ -92,6 +93,7 @@ public class IndexBuilder { */ public IndexBuilder(Configuration configuration, boolean noDeprecated, boolean classesOnly) { + this.configuration = configuration; if (classesOnly) { configuration.message.notice("doclet.Building_Index_For_All_Classes"); } else { @@ -112,7 +114,7 @@ public class IndexBuilder { */ protected void sortIndexMap() { for (List docs : indexmap.values()) { - Collections.sort(docs, Util.makeComparatorForIndexUse()); + Collections.sort(docs, configuration.utils.makeComparatorForIndexUse()); } } @@ -202,14 +204,14 @@ public class IndexBuilder { if (element instanceof PackageDoc) // Do not add to index map if -nodeprecated option is set and the // package is marked as deprecated. - return !(noDeprecated && Util.isDeprecated(element)); + return !(noDeprecated && configuration.utils.isDeprecated(element)); else // Do not add to index map if -nodeprecated option is set and if the // Doc is marked as deprecated or the containing package is marked as // deprecated. return !(noDeprecated && - (Util.isDeprecated(element) || - Util.isDeprecated(((ProgramElementDoc)element).containingPackage()))); + (configuration.utils.isDeprecated(element) || + configuration.utils.isDeprecated(((ProgramElementDoc)element).containingPackage()))); } /** diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java index e30a162c69b..cf63a7f4660 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MetaKeywords.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -50,12 +50,14 @@ public class MetaKeywords { * The global configuration information for this run. */ private final Configuration configuration; + private final Utils utils; /** * Constructor */ public MetaKeywords(Configuration configuration) { this.configuration = configuration; + this.utils = configuration.utils; } /** @@ -98,7 +100,7 @@ public class MetaKeywords { */ public String[] getMetaKeywords(PackageDoc packageDoc) { if( configuration.keywords ) { - String pkgName = Util.getPackageName(packageDoc); + String pkgName = utils.getPackageName(packageDoc); return new String[] { pkgName + " " + "package" }; } else { return new String[] {}; diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java deleted file mode 100644 index bb0b53727a5..00000000000 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/MethodFinder.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.doclets.internal.toolkit.util; - -import com.sun.javadoc.*; - -/** - * This class is useful for searching a method which has documentation - * comment and documentation tags. The method is searched in all the - * superclasses and interfaces(subsequently super-interfaces also) - * recursively. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - */ -public abstract class MethodFinder { - - abstract boolean isCorrectMethod(MethodDoc method); - - public MethodDoc search(ClassDoc cd, MethodDoc method) { - MethodDoc meth = searchInterfaces(cd, method); - if (meth != null) { - return meth; - } - ClassDoc icd = cd.superclass(); - if (icd != null) { - meth = Util.findMethod(icd, method); - if (meth != null) { - if (isCorrectMethod(meth)) { - return meth; - } - } - return search(icd, method); - } - return null; - } - - public MethodDoc searchInterfaces(ClassDoc cd, MethodDoc method) { - MethodDoc[] implementedMethods = (new ImplementedMethods(method, null)).build(); - for (MethodDoc implementedMethod : implementedMethods) { - if (isCorrectMethod(implementedMethod)) { - return implementedMethod; - } - } - return null; - } -} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java index 69f29480322..9e1a0dc083f 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/PackageListWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -44,7 +44,8 @@ import com.sun.tools.doclets.internal.toolkit.*; */ public class PackageListWriter extends PrintWriter { - private Configuration configuration; + private final Configuration configuration; + private final Utils utils; /** * Constructor. @@ -54,6 +55,7 @@ public class PackageListWriter extends PrintWriter { public PackageListWriter(Configuration configuration) throws IOException { super(DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST).openWriter()); this.configuration = configuration; + this.utils = configuration.utils; } /** @@ -80,7 +82,7 @@ public class PackageListWriter extends PrintWriter { for (PackageDoc pkg : configuration.packages) { // if the -nodeprecated option is set and the package is marked as // deprecated, do not include it in the packages list. - if (!(configuration.nodeprecated && Util.isDeprecated(pkg))) + if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) names.add(pkg.name()); } Collections.sort(names); diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java deleted file mode 100644 index 2854b493f1a..00000000000 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/TaggedMethodFinder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package com.sun.tools.doclets.internal.toolkit.util; - -import com.sun.javadoc.*; - -/** - * Find a tagged method. - * - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. - * - * @author Atul M Dambalkar - */ -public class TaggedMethodFinder extends MethodFinder { - public boolean isCorrectMethod(MethodDoc method) { - return method.paramTags().length + method.tags("return").length + - method.throwsTags().length + method.seeTags().length > 0; - } -} diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Utils.java similarity index 93% rename from langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java rename to langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Utils.java index ff06c424fd5..fe407f5a33e 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Utils.java @@ -50,7 +50,7 @@ import com.sun.tools.javac.util.StringUtils; * @author Atul M Dambalkar * @author Jamie Ho */ -public class Util { +public class Utils { /** * Return array of class members whose documentation is to be generated. * If the member is deprecated do not include such a member in the @@ -60,7 +60,7 @@ public class Util { * @return ProgramElementDoc[] Array of eligible members for whom * documentation is getting generated. */ - public static ProgramElementDoc[] excludeDeprecatedMembers( + public ProgramElementDoc[] excludeDeprecatedMembers( ProgramElementDoc[] members) { return toProgramElementDocArray(excludeDeprecatedMembersAsList(members)); @@ -75,7 +75,7 @@ public class Util { * @return List List of eligible members for whom * documentation is getting generated. */ - public static List excludeDeprecatedMembersAsList( + public List excludeDeprecatedMembersAsList( ProgramElementDoc[] members) { List list = new ArrayList<>(); for (ProgramElementDoc member : members) { @@ -90,7 +90,7 @@ public class Util { /** * Return the list of ProgramElementDoc objects as Array. */ - public static ProgramElementDoc[] toProgramElementDocArray(List list) { + public ProgramElementDoc[] toProgramElementDocArray(List list) { ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()]; for (int i = 0; i < list.size(); i++) { pgmarr[i] = list.get(i); @@ -104,7 +104,7 @@ public class Util { * @param members Array of members to look into. * @return boolean True if non-public member found, false otherwise. */ - public static boolean nonPublicMemberFound(ProgramElementDoc[] members) { + public boolean nonPublicMemberFound(ProgramElementDoc[] members) { for (ProgramElementDoc member : members) { if (!member.isPublic()) { return true; @@ -120,7 +120,7 @@ public class Util { * @param method Method to be searched. * @return MethodDoc Method found, null otherwise. */ - public static MethodDoc findMethod(ClassDoc cd, MethodDoc method) { + public MethodDoc findMethod(ClassDoc cd, MethodDoc method) { MethodDoc[] methods = cd.methods(); for (MethodDoc m : methods) { if (executableMembersEqual(method, m)) { @@ -136,7 +136,7 @@ public class Util { * @param member2 the second method to compare. * @return true if member1 overrides/hides or is overriden/hidden by member2. */ - public static boolean executableMembersEqual(ExecutableMemberDoc member1, + public boolean executableMembersEqual(ExecutableMemberDoc member1, ExecutableMemberDoc member2) { if (! (member1 instanceof MethodDoc && member2 instanceof MethodDoc)) return false; @@ -175,11 +175,11 @@ public class Util { * The Java™ Language Specification, * all the outer classes and static inner classes are core classes. */ - public static boolean isCoreClass(ClassDoc cd) { + public boolean isCoreClass(ClassDoc cd) { return cd.containingClass() == null || cd.isStatic(); } - public static boolean matches(ProgramElementDoc doc1, + public boolean matches(ProgramElementDoc doc1, ProgramElementDoc doc2) { if (doc1 instanceof ExecutableMemberDoc && doc2 instanceof ExecutableMemberDoc) { @@ -204,11 +204,11 @@ public class Util { * @param dir The original directory name to copy from. * @param overwrite Overwrite files if true. */ - public static void copyDocFiles(Configuration configuration, PackageDoc pd) { + public void copyDocFiles(Configuration configuration, PackageDoc pd) { copyDocFiles(configuration, DocPath.forPackage(pd).resolve(DocPaths.DOC_FILES)); } - public static void copyDocFiles(Configuration configuration, DocPath dir) { + public void copyDocFiles(Configuration configuration, DocPath dir) { try { boolean first = true; for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) { @@ -272,7 +272,7 @@ public class Util { * @param sort if true, return list of interfaces sorted alphabetically. * @return List of all the required interfaces. */ - public static List getAllInterfaces(Type type, + public List getAllInterfaces(Type type, Configuration configuration, boolean sort) { Map results = sort ? new TreeMap() : @@ -316,7 +316,7 @@ public class Util { return resultsList; } - private static Type[] interfaceTypesOf(Type type) { + private Type[] interfaceTypesOf(Type type) { if (type instanceof AnnotatedType) type = ((AnnotatedType)type).underlyingType(); return type instanceof ClassDoc ? @@ -324,11 +324,11 @@ public class Util { ((ParameterizedType)type).interfaceTypes(); } - public static List getAllInterfaces(Type type, Configuration configuration) { + public List getAllInterfaces(Type type, Configuration configuration) { return getAllInterfaces(type, configuration, true); } - private static void findAllInterfaceTypes(Map results, ClassDoc c, boolean raw, + private void findAllInterfaceTypes(Map results, ClassDoc c, boolean raw, Configuration configuration) { Type superType = c.superclassType(); if (superType == null) @@ -338,7 +338,7 @@ public class Util { raw, configuration); } - private static void findAllInterfaceTypes(Map results, ParameterizedType p, + private void findAllInterfaceTypes(Map results, ParameterizedType p, Configuration configuration) { Type superType = p.superclassType(); if (superType == null) @@ -348,7 +348,7 @@ public class Util { false, configuration); } - private static void addAllInterfaceTypes(Map results, Type type, + private void addAllInterfaceTypes(Map results, Type type, Type[] interfaceTypes, boolean raw, Configuration configuration) { for (Type interfaceType : interfaceTypes) { @@ -380,7 +380,7 @@ public class Util { /** * Enclose in quotes, used for paths and filenames that contains spaces */ - public static String quote(String filepath) { + public String quote(String filepath) { return ("\"" + filepath + "\""); } @@ -389,7 +389,7 @@ public class Util { * @param packageDoc the package to check. * @return the name of the given package. */ - public static String getPackageName(PackageDoc packageDoc) { + public String getPackageName(PackageDoc packageDoc) { return packageDoc == null || packageDoc.name().length() == 0 ? DocletConstants.DEFAULT_PACKAGE_NAME : packageDoc.name(); } @@ -399,7 +399,7 @@ public class Util { * @param packageDoc the package to check. * @return the file name of the given package. */ - public static String getPackageFileHeadName(PackageDoc packageDoc) { + public String getPackageFileHeadName(PackageDoc packageDoc) { return packageDoc == null || packageDoc.name().length() == 0 ? DocletConstants.DEFAULT_PACKAGE_FILE_NAME : packageDoc.name(); } @@ -410,7 +410,7 @@ public class Util { * @param oldStr the string to replace. * @param newStr the string to insert in place of the old string. */ - public static String replaceText(String originalStr, String oldStr, + public String replaceText(String originalStr, String oldStr, String newStr) { if (oldStr == null || newStr == null || oldStr.equals(newStr)) { return originalStr; @@ -426,7 +426,7 @@ public class Util { * * @return true return true if it should be documented and false otherwise. */ - public static boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) { + public boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) { for (AnnotationDesc anno : annotationDoc.annotations()) { if (anno.annotationType().qualifiedName().equals( Documented.class.getName())) { @@ -436,7 +436,7 @@ public class Util { return false; } - private static boolean isDeclarationTarget(AnnotationDesc targetAnno) { + private boolean isDeclarationTarget(AnnotationDesc targetAnno) { // The error recovery steps here are analogous to TypeAnnotations ElementValuePair[] elems = targetAnno.elementValues(); if (elems == null @@ -451,7 +451,7 @@ public class Util { return true; // error recovery FieldDoc eValue = (FieldDoc) value; - if (Util.isJava5DeclarationElementType(eValue)) { + if (isJava5DeclarationElementType(eValue)) { return true; } } @@ -468,7 +468,7 @@ public class Util { * @param elemType the targeted elemType * @return true if annotationDoc is a declaration annotation */ - public static boolean isDeclarationAnnotation(AnnotationTypeDoc annotationDoc, + public boolean isDeclarationAnnotation(AnnotationTypeDoc annotationDoc, boolean isJava5DeclarationLocation) { if (!isJava5DeclarationLocation) return false; @@ -499,7 +499,7 @@ public class Util { * @return true if this class is linkable and false if we can't link to the * desired class. */ - public static boolean isLinkable(ClassDoc classDoc, + public boolean isLinkable(ClassDoc classDoc, Configuration configuration) { return ((classDoc.isIncluded() && configuration.isGeneratedDoc(classDoc))) || @@ -515,7 +515,7 @@ public class Util { * @return the closest visible super class. Return null if it cannot * be found (i.e. classDoc is java.lang.Object). */ - public static Type getFirstVisibleSuperClass(ClassDoc classDoc, + public Type getFirstVisibleSuperClass(ClassDoc classDoc, Configuration configuration) { if (classDoc == null) { return null; @@ -544,7 +544,7 @@ public class Util { * @return the closest visible super class. Return null if it cannot * be found (i.e. classDoc is java.lang.Object). */ - public static ClassDoc getFirstVisibleSuperClassCD(ClassDoc classDoc, + public ClassDoc getFirstVisibleSuperClassCD(ClassDoc classDoc, Configuration configuration) { if (classDoc == null) { return null; @@ -569,7 +569,7 @@ public class Util { * If false, the first letter of the name is capitalized. * @return */ - public static String getTypeName(Configuration config, + public String getTypeName(Configuration config, ClassDoc cd, boolean lowerCaseOnly) { String typeName = ""; if (cd.isOrdinaryClass()) { @@ -597,7 +597,7 @@ public class Util { * @param text the text for which the tabs should be expanded * @return the text with all tabs expanded */ - public static String replaceTabs(Configuration configuration, String text) { + public String replaceTabs(Configuration configuration, String text) { if (!text.contains("\t")) return text; @@ -628,7 +628,7 @@ public class Util { return result.toString(); } - public static String normalizeNewlines(String text) { + public String normalizeNewlines(String text) { StringBuilder sb = new StringBuilder(); final int textLength = text.length(); final String NL = DocletConstants.NL; @@ -658,7 +658,7 @@ public class Util { * The documentation for values() and valueOf() in Enums are set by the * doclet. */ - public static void setEnumDocumentation(Configuration configuration, + public void setEnumDocumentation(Configuration configuration, ClassDoc classDoc) { for (MethodDoc currentMethod : classDoc.methods()) { if (currentMethod.name().equals("values") && @@ -695,7 +695,7 @@ public class Util { * @param doc the Doc to check. * @return true if the given Doc is deprecated. */ - public static boolean isDeprecated(Doc doc) { + public boolean isDeprecated(Doc doc) { if (doc.tags("deprecated").length > 0) { return true; } @@ -719,7 +719,7 @@ public class Util { * @param name name of the getter or setter method. * @return the name of the property of the given setter of getter. */ - public static String propertyNameFromMethodName(Configuration configuration, String name) { + public String propertyNameFromMethodName(Configuration configuration, String name) { String propertyName = null; if (name.startsWith("get") || name.startsWith("set")) { propertyName = name.substring(3); @@ -742,7 +742,7 @@ public class Util { * @param javafx set to true if in JavaFX mode. * @return list of filtered classes. */ - public static ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes, + public ClassDoc[] filterOutPrivateClasses(final ClassDoc[] classes, boolean javafx) { if (!javafx) { return classes; @@ -772,7 +772,7 @@ public class Util { * @return true, iff the given ElementType is one of the constants defined in Java 5 * @since 1.8 */ - public static boolean isJava5DeclarationElementType(FieldDoc elt) { + public boolean isJava5DeclarationElementType(FieldDoc elt) { return elt.name().contentEquals(ElementType.ANNOTATION_TYPE.name()) || elt.name().contentEquals(ElementType.CONSTRUCTOR.name()) || elt.name().contentEquals(ElementType.FIELD.name()) || @@ -823,8 +823,8 @@ public class Util { * 4. finally, if equal, compare the FQNs of the entities * @return a comparator for index file use */ - public static Comparator makeComparatorForIndexUse() { - return new Util.DocComparator() { + public Comparator makeComparatorForIndexUse() { + return new Utils.DocComparator() { /** * Compare two given Doc entities, first sort on names, then on the kinds, * then on the parameters only if the type is an instance of ExecutableMemberDocs, @@ -870,8 +870,8 @@ public class Util { * 4. finally the Doc kinds ie. package, class, interface etc. * @return a comparator to sort classes and members for class use */ - public static Comparator makeComparatorForClassUse() { - return new Util.DocComparator() { + public Comparator makeComparatorForClassUse() { + return new Utils.DocComparator() { /** * Compares two given Doc entities, first sort on name, and if * applicable on the fully qualified name, and if applicable diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java index 4c1a1037372..ff4cac001b9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/VisibleMemberMap.java @@ -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 @@ -99,6 +99,7 @@ public class VisibleMemberMap { * The configuration this VisibleMemberMap was created with. */ private final Configuration configuration; + private final Utils utils; private static final Map propertiesCache = new HashMap<>(); private static final Map classPropertiesMap = new HashMap<>(); @@ -121,6 +122,7 @@ public class VisibleMemberMap { this.classdoc = classdoc; this.kind = kind; this.configuration = configuration; + this.utils = configuration.utils; new ClassMembers(classdoc, STARTLEVEL).build(); } @@ -173,7 +175,7 @@ public class VisibleMemberMap { for (ClassDoc currentClass : visibleClasses) { if (currentClass != classdoc && currentClass.isPackagePrivate() && - !Util.isLinkable(currentClass, configuration)) { + !utils.isLinkable(currentClass, configuration)) { // Document these members in the child class because // the parent is inaccessible. results.addAll(getMembersFor(currentClass)); @@ -270,7 +272,7 @@ public class VisibleMemberMap { public boolean isEqual(MethodDoc member) { for (ProgramElementDoc element : members) { - if (Util.executableMembersEqual(member, (MethodDoc) element)) { + if (utils.executableMembersEqual(member, (MethodDoc) element)) { members.add(member); return true; } @@ -465,7 +467,7 @@ public class VisibleMemberMap { } // Deprected members should be excluded or not? if (configuration.nodeprecated) { - return Util.excludeDeprecatedMembersAsList(members); + return utils.excludeDeprecatedMembersAsList(members); } return Arrays.asList(members); } @@ -496,7 +498,7 @@ public class VisibleMemberMap { private boolean found(List list, ProgramElementDoc elem) { for (ProgramElementDoc pgmelem : list) { - if (Util.matches(pgmelem, elem)) { + if (utils.matches(pgmelem, elem)) { return true; } } @@ -692,7 +694,7 @@ public class VisibleMemberMap { private boolean isPropertyGetterOrSetter(MethodDoc[] members, MethodDoc methodDoc) { boolean found = false; - String propertyName = Util.propertyNameFromMethodName(configuration, methodDoc.name()); + String propertyName = utils.propertyNameFromMethodName(configuration, methodDoc.name()); if (!propertyName.isEmpty()) { String propertyMethodName = propertyName + "Property"; for (MethodDoc member: members) { diff --git a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java index 1b051b6f3df..82c285db303 100644 --- a/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java +++ b/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java @@ -91,6 +91,19 @@ public class TestPrivateClasses extends JavadocTester { "PrivateParent", "PrivateInterface"); + checkOutput("pkg/PublicChild.html", false, + // Should not document comments from private inherited interfaces + "" + + "" + + "methodInterface(int p1)\n" + + "

Comment from interface.
\n", + // and similarly one more + "" + + "" + + "methodInterface2(int p1)\n" + + "
Comment from interface.
\n" + ); + checkOutput("pkg/PublicInterface.html", true, // Field inheritance from non-public superinterface. "" @@ -111,7 +124,7 @@ public class TestPrivateClasses extends JavadocTester { "PrivateInterface", "All Superinterfaces"); - checkOutput("pkg2/C.html", true, + checkOutput("pkg2/C.html", false, //Generic interface method test. "This comment should get copied to the implementing class"); From 1e5168fceda7570697a37ad007b7a044d91823cf Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 16 Jun 2014 15:12:24 +0400 Subject: [PATCH 040/236] 8044742: testlibrary_tests/whitebox/vm_flags/BooleanTest.java NoClassDefFoundError: com/oracle/java/testlibrary/JDKToolFinder Reviewed-by: kvn, roland --- .../test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java index cf313c37962..a76fd4d9a22 100644 --- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java @@ -25,7 +25,7 @@ * @test BooleanTest * @bug 8028756 * @library /testlibrary /testlibrary/whitebox - * @build BooleanTest + * @build BooleanTest ClassFileInstaller sun.hotspot.WhiteBox com.oracle.java.testlibrary.* * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BooleanTest * @summary testing of WB::set/getBooleanVMFlag() From da1c36533ec21e5f44bc158119a65a2cfca62dc2 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Mon, 16 Jun 2014 16:27:41 -0700 Subject: [PATCH 041/236] 8046769: Set T family feature bit on Niagara systems Reviewed-by: kvn, iveresov --- hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp index 70dc8f0e5d8..2f3cdf9ac83 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp @@ -55,7 +55,7 @@ int VM_Version::platform_features(int features) { if (detect_niagara()) { NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Detected Linux on Niagara");) - features = niagara1_m; + features = niagara1_m | T_family_m; } return features; From 802429b65f0d6a1227800cd7f5b769a625ff2a25 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Tue, 24 Jun 2014 00:43:46 -0700 Subject: [PATCH 042/236] 8037404: javac NPE or VerifyError for code with constructor reference of inner class 8047341: lambda reference to inner class in base class causes LambdaConversionException 8044748: JVM cannot access constructor though ::new reference although can call it directly 8044737: Lambda: NPE while obtaining method reference through lambda expression Revamp and simplify handling of complex method references Reviewed-by: dlsmith, vromero --- .../sun/tools/javac/comp/LambdaToMethod.java | 323 ++++++------------ .../javac/T8019486/WrongLNTForLambdaTest.java | 2 +- 2 files changed, 110 insertions(+), 215 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index 1431b531324..b222285d75a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -320,7 +320,9 @@ public class LambdaToMethod extends TreeTranslator { ListBuffer syntheticInits = new ListBuffer<>(); - if (!sym.isStatic()) { + if (localContext.methodReferenceReceiver != null) { + syntheticInits.append(localContext.methodReferenceReceiver); + } else if (!sym.isStatic()) { syntheticInits.append(makeThis( sym.owner.enclClass().asType(), localContext.owner.enclClass())); @@ -363,17 +365,10 @@ public class LambdaToMethod extends TreeTranslator { //first determine the method symbol to be used to generate the sam instance //this is either the method reference symbol, or the bridged reference symbol - Symbol refSym = localContext.needsBridge() - ? localContext.bridgeSym - : localContext.isSignaturePolymorphic() + Symbol refSym = localContext.isSignaturePolymorphic() ? localContext.sigPolySym : tree.sym; - //build the bridge method, if needed - if (localContext.needsBridge()) { - bridgeMemberReference(tree, localContext); - } - //the qualifying expression is treated as a special captured arg JCExpression init; switch(tree.kind) { @@ -743,54 +738,51 @@ public class LambdaToMethod extends TreeTranslator { // /** - * Generate an adapter method "bridge" for a method reference which cannot - * be used directly. + * Converts a method reference which cannot be used directly into a lambda */ - private class MemberReferenceBridger { + private class MemberReferenceToLambda { private final JCMemberReference tree; private final ReferenceTranslationContext localContext; + private final Symbol owner; private final ListBuffer args = new ListBuffer<>(); private final ListBuffer params = new ListBuffer<>(); - MemberReferenceBridger(JCMemberReference tree, ReferenceTranslationContext localContext) { + private JCExpression receiverExpression = null; + + MemberReferenceToLambda(JCMemberReference tree, ReferenceTranslationContext localContext, Symbol owner) { this.tree = tree; this.localContext = localContext; + this.owner = owner; } - /** - * Generate the bridge - */ - JCMethodDecl bridge() { + JCLambda lambda() { int prevPos = make.pos; try { make.at(tree); Type samDesc = localContext.bridgedRefSig(); List samPTypes = samDesc.getParameterTypes(); - //an extra argument is prepended to the signature of the bridge in case - //the member reference is an instance method reference (in which case - //the receiver expression is passed to the bridge itself). - Type recType = null; + // an extra argument is prepended in the case where the member + // reference is an unbound instance method reference (in which + // case the receiver expression in passed. + VarSymbol rcvr; switch (tree.kind) { - case IMPLICIT_INNER: - recType = tree.sym.owner.type.getEnclosingType(); - break; case BOUND: - recType = tree.getQualifierExpression().type; + rcvr = addParameter("rec$", tree.getQualifierExpression().type, false); + receiverExpression = attr.makeNullCheck(tree.getQualifierExpression()); break; case UNBOUND: - recType = samPTypes.head; + rcvr = addParameter("rec$", samPTypes.head, false); samPTypes = samPTypes.tail; break; + default: + rcvr = null; + break; } - //generate the parameter list for the bridged member reference - the - //bridge signature will match the signature of the target sam descriptor - - VarSymbol rcvr = (recType == null) - ? null - : addParameter("rec$", recType, false); + // generate the parameter list for the coverted member reference. + // the signature will match the signature of the target sam descriptor List refPTypes = tree.sym.type.getParameterTypes(); int refSize = refPTypes.size(); @@ -809,60 +801,46 @@ public class LambdaToMethod extends TreeTranslator { addParameter("xva$" + i, tree.varargsElement, true); } - //generate the bridge method declaration - JCMethodDecl bridgeDecl = make.MethodDef(make.Modifiers(localContext.bridgeSym.flags()), - localContext.bridgeSym.name, - make.QualIdent(samDesc.getReturnType().tsym), - List.nil(), - params.toList(), - tree.sym.type.getThrownTypes() == null - ? List.nil() - : make.Types(tree.sym.type.getThrownTypes()), - null, - null); - bridgeDecl.sym = (MethodSymbol) localContext.bridgeSym; - bridgeDecl.type = localContext.bridgeSym.type = - types.createMethodTypeWithParameters(samDesc, TreeInfo.types(params.toList())); - - //bridge method body generation - this can be either a method call or a + //body generation - this can be either a method call or a //new instance creation expression, depending on the member reference kind - JCExpression bridgeExpr = (tree.getMode() == ReferenceMode.INVOKE) - ? bridgeExpressionInvoke(makeReceiver(rcvr)) - : bridgeExpressionNew(); + JCExpression expr = (tree.getMode() == ReferenceMode.INVOKE) + ? expressionInvoke(rcvr) + : expressionNew(); - //the body is either a return expression containing a method call, - //or the method call itself, depending on whether the return type of - //the bridge is non-void/void. - bridgeDecl.body = makeLambdaExpressionBody(bridgeExpr, bridgeDecl); - - return bridgeDecl; + JCLambda slam = make.Lambda(params.toList(), expr); + slam.targets = tree.targets; + slam.type = tree.type; + slam.pos = tree.pos; + return slam; } finally { make.at(prevPos); } } - //where - private JCExpression makeReceiver(VarSymbol rcvr) { - if (rcvr == null) return null; - JCExpression rcvrExpr = make.Ident(rcvr); - Type rcvrType = tree.sym.enclClass().type; - if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { - rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); - } - return rcvrExpr; + + JCExpression getReceiverExpression() { + return receiverExpression; + } + + private JCExpression makeReceiver(VarSymbol rcvr) { + if (rcvr == null) return null; + JCExpression rcvrExpr = make.Ident(rcvr); + Type rcvrType = tree.sym.enclClass().type; + if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { + rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); } + return rcvrExpr; + } /** - * determine the receiver of the bridged method call - the receiver can - * be either the synthetic receiver parameter or a type qualifier; the - * original qualifier expression is never used here, as it might refer - * to symbols not available in the static context of the bridge + * determine the receiver of the method call - the receiver can + * be a type qualifier, the synthetic receiver parameter or 'super'. */ - private JCExpression bridgeExpressionInvoke(JCExpression rcvr) { + private JCExpression expressionInvoke(VarSymbol rcvr) { JCExpression qualifier = tree.sym.isStatic() ? make.Type(tree.sym.owner.type) : (rcvr != null) ? - rcvr : + makeReceiver(rcvr) : tree.getQualifierExpression(); //create the qualifier expression @@ -881,10 +859,9 @@ public class LambdaToMethod extends TreeTranslator { } /** - * the enclosing expression is either 'null' (no enclosing type) or set - * to the first bridge synthetic parameter + * Lambda body to use for a 'new'. */ - private JCExpression bridgeExpressionNew() { + private JCExpression expressionNew() { if (tree.kind == ReferenceKind.ARRAY_CTOR) { //create the array creation expression JCNewArray newArr = make.NewArray( @@ -894,15 +871,10 @@ public class LambdaToMethod extends TreeTranslator { newArr.type = tree.getQualifierExpression().type; return newArr; } else { - JCExpression encl = null; - switch (tree.kind) { - case UNBOUND: - case IMPLICIT_INNER: - encl = make.Ident(params.first()); - } - //create the instance creation expression - JCNewClass newClass = make.NewClass(encl, + //note that method reference syntax does not allow an explicit + //enclosing class (so the enclosing class is null) + JCNewClass newClass = make.NewClass(null, List.nil(), make.Type(tree.getQualifierExpression().type), convertArgs(tree.sym, args.toList(), tree.varargsElement), @@ -916,7 +888,8 @@ public class LambdaToMethod extends TreeTranslator { } private VarSymbol addParameter(String name, Type p, boolean genArg) { - VarSymbol vsym = new VarSymbol(0, names.fromString(name), p, localContext.bridgeSym); + VarSymbol vsym = new VarSymbol(PARAMETER | SYNTHETIC, names.fromString(name), p, owner); + vsym.pos = tree.pos; params.append(make.VarDef(vsym, null)); if (genArg) { args.append(make.Ident(vsym)); @@ -925,15 +898,6 @@ public class LambdaToMethod extends TreeTranslator { } } - /** - * Bridges a member reference - this is needed when: - * * Var args in the referenced method need to be flattened away - * * super is used - */ - private void bridgeMemberReference(JCMemberReference tree, ReferenceTranslationContext localContext) { - kInfo.addMethod(new MemberReferenceBridger(tree, localContext).bridge()); - } - private MethodType typeToMethodType(Type mt) { Type type = types.erasure(mt); return new MethodType(type.getParameterTypes(), @@ -1252,9 +1216,25 @@ public class LambdaToMethod extends TreeTranslator { @Override public void visitLambda(JCLambda tree) { + analyzeLambda(tree, "lambda.stat"); + } + + private void analyzeLambda(JCLambda tree, JCExpression methodReferenceReceiver) { + // Translation of the receiver expression must occur first + JCExpression rcvr = translate(methodReferenceReceiver); + LambdaTranslationContext context = analyzeLambda(tree, "mref.stat.1"); + if (rcvr != null) { + context.methodReferenceReceiver = rcvr; + } + } + + private LambdaTranslationContext analyzeLambda(JCLambda tree, String statKey) { List prevStack = frameStack; try { - LambdaTranslationContext context = (LambdaTranslationContext)makeLambdaContext(tree); + LambdaTranslationContext context = new LambdaTranslationContext(tree); + if (dumpLambdaToMethodStats) { + log.note(tree, statKey, context.needsAltMetafactory(), context.translatedSym); + } frameStack = frameStack.prepend(new Frame(tree)); for (JCVariableDecl param : tree.params) { context.addSymbol(param.sym, PARAM); @@ -1263,6 +1243,7 @@ public class LambdaToMethod extends TreeTranslator { contextMap.put(tree, context); super.visitLambda(tree); context.complete(); + return context; } finally { frameStack = prevStack; @@ -1351,47 +1332,24 @@ public class LambdaToMethod extends TreeTranslator { * information added in the LambdaToMethod pass will have the wrong * signature. Hooks between Lower and LambdaToMethod have been added to * handle normal "new" in this case. This visitor converts potentially - * effected method references into a lambda containing a normal "new" of - * the class. + * affected method references into a lambda containing a normal + * expression. * * @param tree */ @Override public void visitReference(JCMemberReference tree) { - if (tree.getMode() == ReferenceMode.NEW - && tree.kind != ReferenceKind.ARRAY_CTOR - && tree.sym.owner.isLocal()) { - MethodSymbol consSym = (MethodSymbol) tree.sym; - List ptypes = ((MethodType) consSym.type).getParameterTypes(); - Type classType = consSym.owner.type; - - // Build lambda parameters - // partially cloned from TreeMaker.Params until 8014021 is fixed - Symbol owner = owner(); - ListBuffer paramBuff = new ListBuffer<>(); - int i = 0; - for (List l = ptypes; l.nonEmpty(); l = l.tail) { - JCVariableDecl param = make.Param(make.paramName(i++), l.head, owner); - param.sym.pos = tree.pos; - paramBuff.append(param); - } - List params = paramBuff.toList(); - - // Make new-class call - JCNewClass nc = makeNewClass(classType, make.Idents(params)); - nc.pos = tree.pos; - - // Make lambda holding the new-class call - JCLambda slam = make.Lambda(params, nc); - slam.targets = tree.targets; - slam.type = tree.type; - slam.pos = tree.pos; - - // Now it is a lambda, process as such - visitLambda(slam); + ReferenceTranslationContext rcontext = new ReferenceTranslationContext(tree); + contextMap.put(tree, rcontext); + if (rcontext.needsConversionToLambda()) { + // Convert to a lambda, and process as such + MemberReferenceToLambda conv = new MemberReferenceToLambda(tree, rcontext, owner()); + analyzeLambda(conv.lambda(), conv.getReceiverExpression()); } else { super.visitReference(tree); - contextMap.put(tree, makeReferenceContext(tree)); + if (dumpLambdaToMethodStats) { + log.note(tree, "mref.stat", rcontext.needsAltMetafactory(), null); + } } } @@ -1646,14 +1604,6 @@ public class LambdaToMethod extends TreeTranslator { } } - private TranslationContext makeLambdaContext(JCLambda tree) { - return new LambdaTranslationContext(tree); - } - - private TranslationContext makeReferenceContext(JCMemberReference tree) { - return new ReferenceTranslationContext(tree); - } - private class Frame { final JCTree tree; List locals; @@ -1773,6 +1723,13 @@ public class LambdaToMethod extends TreeTranslator { */ final Set freeVarProcessedLocalClasses; + /** + * For method references converted to lambdas. The method + * reference receiver expression. Must be treated like a captured + * variable. + */ + JCExpression methodReferenceReceiver; + LambdaTranslationContext(JCLambda tree) { super(tree); Frame frame = frameStack.head; @@ -1792,9 +1749,6 @@ public class LambdaToMethod extends TreeTranslator { // This symbol will be filled-in in complete this.translatedSym = makePrivateSyntheticMethod(0, null, null, owner.enclClass()); - if (dumpLambdaToMethodStats) { - log.note(tree, "lambda.stat", needsAltMetafactory(), translatedSym); - } translatedSymbols = new EnumMap<>(LambdaSymbolKind.class); translatedSymbols.put(PARAM, new LinkedHashMap()); @@ -2011,6 +1965,13 @@ public class LambdaToMethod extends TreeTranslator { for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); } + if (methodReferenceReceiver != null) { + params.append(make.VarDef( + make.Modifiers(PARAMETER|FINAL), + names.fromString("$rcvr$"), + make.Type(methodReferenceReceiver.type), + null)); + } for (Symbol thisSym : getSymbolMap(PARAM).values()) { params.append(make.VarDef((VarSymbol) thisSym, null)); } @@ -2038,102 +1999,33 @@ public class LambdaToMethod extends TreeTranslator { * and the used by the main translation routines in order to adjust method * references (i.e. in case a bridge is needed) */ - private class ReferenceTranslationContext extends TranslationContext { + private final class ReferenceTranslationContext extends TranslationContext { final boolean isSuper; - final Symbol bridgeSym; final Symbol sigPolySym; ReferenceTranslationContext(JCMemberReference tree) { super(tree); this.isSuper = tree.hasKind(ReferenceKind.SUPER); - this.bridgeSym = needsBridge() - ? makePrivateSyntheticMethod(isSuper ? 0 : STATIC, - referenceBridgeName(), null, - owner.enclClass()) - : null; this.sigPolySym = isSignaturePolymorphic() ? makePrivateSyntheticMethod(tree.sym.flags(), tree.sym.name, bridgedRefSig(), tree.sym.enclClass()) : null; - if (dumpLambdaToMethodStats) { - String key = bridgeSym == null ? - "mref.stat" : "mref.stat.1"; - log.note(tree, key, needsAltMetafactory(), bridgeSym); - } } /** * Get the opcode associated with this method reference */ int referenceKind() { - return LambdaToMethod.this.referenceKind(needsBridge() - ? bridgeSym - : tree.sym); + return LambdaToMethod.this.referenceKind(tree.sym); } boolean needsVarArgsConversion() { return tree.varargsElement != null; } - /** - * Generate a disambiguating string to increase stability (important - * if serialized) - * - * @return String to differentiate synthetic lambda method names - */ - private String referenceBridgeDisambiguation() { - StringBuilder buf = new StringBuilder(); - // Append the enclosing method signature to differentiate - // overloaded enclosing methods. - if (owner.type != null) { - buf.append(typeSig(owner.type)); - buf.append(":"); - } - - // Append qualifier type - buf.append(classSig(tree.sym.owner.type)); - - // Note static/instance - buf.append(tree.sym.isStatic()? " S " : " I "); - - // Append referenced signature - buf.append(typeSig(tree.sym.erasure(types))); - - return buf.toString(); - } - - /** - * Construct a unique stable name for the method reference bridge - * - * @return Name to use for the synthetic method name - */ - private Name referenceBridgeName() { - StringBuilder buf = new StringBuilder(); - // Append lambda ID, this is semantically significant - buf.append(names.lambda); - // Note that it is a method reference bridge - buf.append("MR$"); - // Append the enclosing method name - buf.append(enclosingMethodName()); - buf.append('$'); - // Append the referenced method name - buf.append(syntheticMethodNameComponent(tree.sym.name)); - buf.append('$'); - // Append a hash of the disambiguating string : enclosing method - // signature, etc. - String disam = referenceBridgeDisambiguation(); - buf.append(Integer.toHexString(disam.hashCode())); - buf.append('$'); - // The above appended name components may not be unique, append - // a count based on the above name components. - buf.append(syntheticMethodNameCounts.getIndex(buf)); - String result = buf.toString(); - return names.fromString(result); - } - /** * @return Is this an array operation like clone() */ @@ -2169,13 +2061,16 @@ public class LambdaToMethod extends TreeTranslator { } /** - * Does this reference needs a bridge (i.e. var args need to be - * expanded or "super" is used) + * Does this reference need to be converted to a lambda + * (i.e. var args need to be expanded or "super" is used) */ - final boolean needsBridge() { + final boolean needsConversionToLambda() { return isSuper || needsVarArgsConversion() || isArrayOp() || isPrivateInOtherClass() || - !receiverAccessible(); + !receiverAccessible() || + (tree.getMode() == ReferenceMode.NEW && + tree.kind != ReferenceKind.ARRAY_CTOR && + (tree.sym.owner.isLocal() || tree.sym.owner.isInner())); } Type generatedRefSig() { diff --git a/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java index d3728e15610..3074de4229f 100644 --- a/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java +++ b/langtools/test/tools/javac/T8019486/WrongLNTForLambdaTest.java @@ -138,7 +138,7 @@ public class WrongLNTForLambdaTest { checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "$deserializeLambda$", deserializeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), - "Foo.class").toUri()), "lambda$MR$variablesInLambdas$notify$8bc4f5bd$1", lambdaBridgeExpectedLNT); + "Foo.class").toUri()), "lambda$variablesInLambdas$3", lambdaBridgeExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), "Foo.class").toUri()), "assignLambda", assignmentExpectedLNT); checkClassFile(new File(Paths.get(System.getProperty("user.dir"), From 29297396abbf478f4f9b43ddec9550600feba8f1 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 24 Jun 2014 16:04:46 +0100 Subject: [PATCH 043/236] 8046451: Add basic IntelliJ support for langtools Add new ant target 'idea' to create IntelliJ langtools project Reviewed-by: jjg --- langtools/.hgignore | 1 + langtools/make/build.xml | 10 ++ langtools/make/intellij/ant.xml | 17 +++ langtools/make/intellij/build.xml | 36 +++++ langtools/make/intellij/compiler.xml | 30 ++++ .../intellij/inspectionProfiles/langtools.xml | 26 ++++ .../inspectionProfiles/profiles_settings.xml | 7 + langtools/make/intellij/langtools.iml | 13 ++ langtools/make/intellij/misc.xml | 10 ++ langtools/make/intellij/modules.xml | 9 ++ langtools/make/intellij/vcs.xml | 7 + langtools/make/intellij/workspace.xml | 139 ++++++++++++++++++ 12 files changed, 305 insertions(+) create mode 100644 langtools/make/intellij/ant.xml create mode 100644 langtools/make/intellij/build.xml create mode 100644 langtools/make/intellij/compiler.xml create mode 100644 langtools/make/intellij/inspectionProfiles/langtools.xml create mode 100644 langtools/make/intellij/inspectionProfiles/profiles_settings.xml create mode 100644 langtools/make/intellij/langtools.iml create mode 100644 langtools/make/intellij/misc.xml create mode 100644 langtools/make/intellij/modules.xml create mode 100644 langtools/make/intellij/vcs.xml create mode 100644 langtools/make/intellij/workspace.xml diff --git a/langtools/.hgignore b/langtools/.hgignore index e05f09317c5..e742c856114 100644 --- a/langtools/.hgignore +++ b/langtools/.hgignore @@ -1,5 +1,6 @@ ^build/ ^dist/ +^.idea /nbproject/private/ ^.hgtip .DS_Store diff --git a/langtools/make/build.xml b/langtools/make/build.xml index b612a22715e..04c09d9fa6a 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -752,6 +752,16 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/langtools/make/intellij/compiler.xml b/langtools/make/intellij/compiler.xml new file mode 100644 index 00000000000..83881c52d34 --- /dev/null +++ b/langtools/make/intellij/compiler.xml @@ -0,0 +1,30 @@ + + + + + + + + diff --git a/langtools/make/intellij/inspectionProfiles/langtools.xml b/langtools/make/intellij/inspectionProfiles/langtools.xml new file mode 100644 index 00000000000..48316e07259 --- /dev/null +++ b/langtools/make/intellij/inspectionProfiles/langtools.xml @@ -0,0 +1,26 @@ + + + + diff --git a/langtools/make/intellij/inspectionProfiles/profiles_settings.xml b/langtools/make/intellij/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000000..a7b1624fa99 --- /dev/null +++ b/langtools/make/intellij/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + diff --git a/langtools/make/intellij/langtools.iml b/langtools/make/intellij/langtools.iml new file mode 100644 index 00000000000..1b6c00b8809 --- /dev/null +++ b/langtools/make/intellij/langtools.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/langtools/make/intellij/misc.xml b/langtools/make/intellij/misc.xml new file mode 100644 index 00000000000..6428d6a8e2b --- /dev/null +++ b/langtools/make/intellij/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/langtools/make/intellij/modules.xml b/langtools/make/intellij/modules.xml new file mode 100644 index 00000000000..a1884d5a0d7 --- /dev/null +++ b/langtools/make/intellij/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/langtools/make/intellij/vcs.xml b/langtools/make/intellij/vcs.xml new file mode 100644 index 00000000000..94ad9258305 --- /dev/null +++ b/langtools/make/intellij/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/langtools/make/intellij/workspace.xml b/langtools/make/intellij/workspace.xml new file mode 100644 index 00000000000..8348254caa5 --- /dev/null +++ b/langtools/make/intellij/workspace.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b963c0bc5906b6cf10b70c1722edb340f3fa4a55 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 24 Jun 2014 10:51:00 -0700 Subject: [PATCH 044/236] 7196160: Project Coin: allow @SafeVarargs on private methods Reviewed-by: jjg --- .../com/sun/tools/javac/code/Source.java | 3 ++ .../com/sun/tools/javac/comp/Check.java | 14 ++++++-- .../tools/javac/resources/compiler.properties | 4 +++ .../diags/examples/VarargsFinalOnly.java | 32 +++++++++++++++++++ .../tools/javac/varargs/warning/Warn4.java | 14 +++++--- .../tools/javac/varargs/warning/Warn5.java | 28 +++++++++------- 6 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java index a4d09cd8699..6621805c6a5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java @@ -240,6 +240,9 @@ public enum Source { public boolean allowPostApplicabilityVarargsAccessCheck() { return compareTo(JDK1_8) >= 0; } + public boolean allowPrivateSafeVarargs() { + return compareTo(JDK1_9) >= 0; + } public static SourceVersion toSourceVersion(Source source) { switch(source) { case JDK1_2: diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 139be89d75e..43728013aa9 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -127,6 +127,7 @@ public class Check { allowSimplifiedVarargs = source.allowSimplifiedVarargs(); allowDefaultMethods = source.allowDefaultMethods(); allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); + allowPrivateSafeVarargs = source.allowPrivateSafeVarargs(); complexInference = options.isSet("complexinference"); warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); @@ -181,6 +182,10 @@ public class Check { */ boolean allowStrictMethodClashCheck; + /** Switch: can the @SafeVarargs annotation be applied to private methods? + */ + boolean allowPrivateSafeVarargs; + /** Switch: -complexinference option set? */ boolean complexInference; @@ -816,8 +821,10 @@ public class Check { if (varargElemType != null) { log.error(tree, "varargs.invalid.trustme.anno", - syms.trustMeType.tsym, - diags.fragment("varargs.trustme.on.virtual.varargs", m)); + syms.trustMeType.tsym, + allowPrivateSafeVarargs ? + diags.fragment("varargs.trustme.on.virtual.varargs", m) : + diags.fragment("varargs.trustme.on.virtual.varargs.final.only", m)); } else { log.error(tree, "varargs.invalid.trustme.anno", @@ -840,7 +847,8 @@ public class Check { private boolean isTrustMeAllowedOnMethod(Symbol s) { return (s.flags() & VARARGS) != 0 && (s.isConstructor() || - (s.flags() & (STATIC | FINAL)) != 0); + (s.flags() & (STATIC | FINAL | + (allowPrivateSafeVarargs ? PRIVATE : 0) )) != 0); } Type checkMethod(final Type mtype, diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 658a97dce22..5df19716849 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1101,6 +1101,10 @@ compiler.misc.varargs.trustme.on.non.varargs.meth=\ # 0: symbol compiler.misc.varargs.trustme.on.virtual.varargs=\ + Instance method {0} is neither final nor private. + +# 0: symbol +compiler.misc.varargs.trustme.on.virtual.varargs.final.only=\ Instance method {0} is not final. # 0: type, 1: symbol kind, 2: symbol diff --git a/langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java b/langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java new file mode 100644 index 00000000000..167bf3efcc4 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/VarargsFinalOnly.java @@ -0,0 +1,32 @@ +/* + * 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 + * 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. + */ + +// key: compiler.err.varargs.invalid.trustme.anno +// key: compiler.misc.varargs.trustme.on.virtual.varargs.final.only +// options: -source 1.8 -Xlint:varargs,-options,-unchecked + +import java.util.List; + +class VarargsFinalOnly { + @SafeVarargs void m(List... args) { } +} diff --git a/langtools/test/tools/javac/varargs/warning/Warn4.java b/langtools/test/tools/javac/varargs/warning/Warn4.java index 1a068c74244..4598c483fd4 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn4.java +++ b/langtools/test/tools/javac/varargs/warning/Warn4.java @@ -73,13 +73,15 @@ public class Warn4 ModifierKind modKind) { switch(this) { case VARARGS: - return source == SourceLevel.JDK_6 || + return source.compareTo(SourceLevel.JDK_7) < 0 || suppressLevelDecl == SuppressLevel.UNCHECKED || trustMe == TrustMe.TRUST; case UNCHECKED: return suppressLevelClient == SuppressLevel.UNCHECKED || - (trustMe == TrustMe.TRUST && modKind != - ModifierKind.NONE && source == SourceLevel.JDK_7); + (trustMe == TrustMe.TRUST && + (((modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC) && + source.compareTo( SourceLevel.JDK_7) >= 0 ) || + (modKind == ModifierKind.PRIVATE && source.compareTo( SourceLevel.JDK_9) >= 0 ))); } SuppressLevel supLev = this == VARARGS ? @@ -92,7 +94,8 @@ public class Warn4 enum SourceLevel { JDK_6("6"), - JDK_7("7"); + JDK_7("7"), + JDK_9("9"); String sourceKey; @@ -115,7 +118,8 @@ public class Warn4 enum ModifierKind { NONE(" "), FINAL("final "), - STATIC("static "); + STATIC("static "), + PRIVATE("private "); String mod; diff --git a/langtools/test/tools/javac/varargs/warning/Warn5.java b/langtools/test/tools/javac/varargs/warning/Warn5.java index e45cd361637..b73d1af5fa8 100644 --- a/langtools/test/tools/javac/varargs/warning/Warn5.java +++ b/langtools/test/tools/javac/varargs/warning/Warn5.java @@ -89,7 +89,8 @@ public class Warn5 enum ModifierKind { NONE(""), FINAL("final"), - STATIC("static"); + STATIC("static"), + PRIVATE("private"); String mod; @@ -111,7 +112,8 @@ public class Warn5 enum SourceLevel { JDK_6("6"), - JDK_7("7"); + JDK_7("7"), + JDK_9("9"); String sourceKey; @@ -238,7 +240,7 @@ public class Warn5 EnumSet expectedWarnings = EnumSet.noneOf(WarningKind.class); - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.TRUST && suppressLevel != SuppressLevel.VARARGS && xlint != XlintOption.NONE && @@ -247,11 +249,12 @@ public class Warn5 body.hasAliasing && (methKind == MethodKind.CONSTRUCTOR || (methKind == MethodKind.METHOD && - modKind != ModifierKind.NONE))) { + modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC || + (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0)))) { expectedWarnings.add(WarningKind.UNSAFE_BODY); } - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.DONT_TRUST && sig.isVarargs && !sig.isReifiableArg && @@ -259,20 +262,22 @@ public class Warn5 expectedWarnings.add(WarningKind.UNSAFE_DECL); } - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.TRUST && (!sig.isVarargs || - (modKind == ModifierKind.NONE && - methKind == MethodKind.METHOD))) { + ((modKind == ModifierKind.NONE || + modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) < 0 ) && + methKind == MethodKind.METHOD))) { expectedWarnings.add(WarningKind.MALFORMED_SAFEVARARGS); } - if (sourceLevel == SourceLevel.JDK_7 && + if (sourceLevel.compareTo(SourceLevel.JDK_7) >= 0 && trustMe == TrustMe.TRUST && xlint != XlintOption.NONE && suppressLevel != SuppressLevel.VARARGS && - (modKind != ModifierKind.NONE || - methKind == MethodKind.CONSTRUCTOR) && + (modKind == ModifierKind.FINAL || modKind == ModifierKind.STATIC || + (modKind == ModifierKind.PRIVATE && sourceLevel.compareTo(SourceLevel.JDK_9) >= 0) || + methKind == MethodKind.CONSTRUCTOR) && sig.isVarargs && sig.isReifiableArg) { expectedWarnings.add(WarningKind.REDUNDANT_SAFEVARARGS); @@ -283,6 +288,7 @@ public class Warn5 throw new Error("invalid diagnostics for source:\n" + source.getCharContent(true) + "\nOptions: " + xlint.getXlintOption() + + "\nSource Level: " + sourceLevel + "\nExpected warnings: " + expectedWarnings + "\nFound warnings: " + dc.warnings); } From 7aa3c5905168b52701c30df7ce3d5dc59ba88d7a Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Tue, 24 Jun 2014 15:15:22 -0700 Subject: [PATCH 045/236] 8047157: [javadoc] fixup tests for determinism and add classes uses Reviewed-by: jjg --- .../sun/javadoc/testHtmlTag/TestHtmlTag.java | 9 ++-- .../javadoc/testUseOption/TestUseOption.java | 17 ++++++++ .../sun/javadoc/testUseOption/pkg1/C1.java | 15 ++++++- .../sun/javadoc/testUseOption/pkg1/C10.java | 41 +++++++++++++++++++ .../sun/javadoc/testUseOption/pkg1/C9.java | 32 +++++++++++++++ .../testUseOption/pkg1/UsedInterface.java | 37 +++++++++++++++++ .../testUseOption/pkg1/UsedInterfaceA.java | 37 +++++++++++++++++ 7 files changed, 182 insertions(+), 6 deletions(-) create mode 100644 langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java create mode 100644 langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java create mode 100644 langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java create mode 100644 langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java diff --git a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java index 4416eabfb78..155bbd53293 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java @@ -36,20 +36,19 @@ import java.util.Locale; public class TestHtmlTag extends JavadocTester { - + private static final String defaultLanguage = Locale.getDefault().getLanguage(); public static void main(String... args) throws Exception { TestHtmlTag tester = new TestHtmlTag(); tester.runTests(); } - @Test void test_default() { - javadoc("-d", "out-default", + javadoc("-locale", defaultLanguage, + "-d", "out-default", "-sourcepath", testSrc, "pkg1"); - checkExit(Exit.OK); - String defaultLanguage = Locale.getDefault().getLanguage(); + checkExit(Exit.OK); checkOutput("pkg1/C1.html", true, ""); diff --git a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java index 572aa097f94..3379da40980 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java +++ b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java @@ -79,6 +79,23 @@ public class TestUseOption extends JavadocTester { "" + "Frames" ); + checkOutput("pkg1/class-use/UsedClass.html", true, + "that return types with arguments of type" + ); + checkOutput("pkg1/class-use/UsedClass.html", true, + "methodInC1ReturningType" + ); + checkOutput("pkg1/class-use/UsedInterface.html", true, + "Classes in pkg1 that implement " + + "UsedInterface" + ); + checkOutput("pkg1/class-use/UsedInterfaceA.html", true, + "Classes in pkg1 that implement " + + "UsedInterfaceA" + ); + checkOutput("pkg1/class-use/UsedClass.html", false, + "methodInC1Protected" + ); } @Test diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java index c763c8ff4e9..57860948771 100644 --- a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -23,6 +23,8 @@ package pkg1; +import java.util.List; + /** * Test 3 passes. */ @@ -40,4 +42,15 @@ public class C1 { public UsedClass methodInC1(UsedClass p) { return p; } + + public List methodInC1ReturningType() { + return null; + } + + /* + * this must not appear anywhere. + */ + UsedClass methodInC1Protected(List p){ + return p; + } } diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java new file mode 100644 index 00000000000..b4c1314572d --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C10.java @@ -0,0 +1,41 @@ +/* + * 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. + */ + +package pkg1; + +/** + * An implementor + * + */ +public class C10 extends UsedClass implements UsedInterface, UsedInterfaceA { + + /** + * Nothing + */ + public void doNothing() {} + + /** + * Me too + */ + public void doNothingA() {} +} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java new file mode 100644 index 00000000000..4b86c8908bd --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/C9.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +package pkg1; + +/** + * An implementor + * + */ +public class C9 implements UsedInterface, UsedInterfaceA { + public void doNothing(){} +} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java new file mode 100644 index 00000000000..7eaab237524 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterface.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +/** + * An interface + * + */ + +package pkg1; + +public interface UsedInterface { + + /** + * Does nothing + */ + void doNothing(); +} diff --git a/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java new file mode 100644 index 00000000000..cab6298ae67 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testUseOption/pkg1/UsedInterfaceA.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +/** + * An interface + * + */ + +package pkg1; + +public interface UsedInterfaceA { + + /** + * Does nothing + */ + void doNothingA(); +} From 30f70a0e1ddf8b98c7908de6480b69a2ec980279 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Wed, 25 Jun 2014 11:22:27 -0700 Subject: [PATCH 046/236] 8048121: javac complex method references: revamp and simplify 8038776: VerifyError when running successfully compiled java class Add tests missing from the push of 8037404 Reviewed-by: dlsmith, vromero --- .../MethodRefNewInnerBootstrap.java | 72 +++++++++++++++++++ .../MethodRefNewInnerInLambdaNPE1.java | 48 +++++++++++++ .../MethodRefNewInnerInLambdaNPE2.java | 57 +++++++++++++++ .../MethodRefNewInnerInLambdaVerify1.java | 48 +++++++++++++ .../MethodRefNewInnerInLambdaVerify2.java | 62 ++++++++++++++++ ...ethodRefNewInnerInLambdaVerify2simple.java | 50 +++++++++++++ .../methodReference/MethodRefQualifier1.java | 62 ++++++++++++++++ .../MethodRefSingleRefEvalBridge.java | 70 ++++++++++++++++++ .../methodReference/MethodRefToInner.java | 52 ++++++++++++++ .../MethodReferenceComplexNullCheckTest.java | 54 ++++++++++++++ 10 files changed, 575 insertions(+) create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java create mode 100644 langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java new file mode 100644 index 00000000000..21789e1a820 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerBootstrap.java @@ -0,0 +1,72 @@ +/* + * 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 8044748 + * @summary JVM cannot access constructor though ::new reference although can call it directly + */ + +public class MethodRefNewInnerBootstrap { + + interface Constructor { + public MyTest execute(int i); + } + + public class MyTest { + public MyTest(int i) { System.out.println("Constructor executed " + i); } + } + + public Constructor getConstructor() { + return MyTest::new; + } + + public static void main(String argv[]) { + new MethodRefNewInnerBootstrap().call(); + } + + public void call() { + MyTest mt = new MyTest(0); + + Constructor c1 = MyTest::new; + c1.execute(1); + + Constructor c2 = getConstructor(); + c2.execute(2); + + Constructor c3 = new Constructor() { + public MyTest execute(int i) { + return new MyTest(3); + } + }; + c3.execute(3); + + Constructor c4 = new Constructor() { + public MyTest execute(int i) { + Constructor c = MyTest::new; + return c.execute(i); + } + }; + c4.execute(4); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java new file mode 100644 index 00000000000..ffdff556453 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE1.java @@ -0,0 +1,48 @@ +/* + * 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 8037404 + * @summary javac NPE or VerifyError for code with constructor reference of inner class + */ + +import java.util.function.Supplier; +import java.util.stream.Stream; + +public class MethodRefNewInnerInLambdaNPE1 { + public static void main(String[] args) { + if (new MethodRefNewInnerInLambdaNPE1().getList().get().getClass() != TT.class) + throw new AssertionError("sanity failed"); + } + + Supplier getList() { + return () -> Stream.of(1).map(TT::new).findFirst().get(); + } + + class TT { + public TT(int i) { + + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java new file mode 100644 index 00000000000..f43a8008d1e --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaNPE2.java @@ -0,0 +1,57 @@ +/* + * 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 8044737 + * @summary Lambda: NPE while obtaining method reference through lambda expression + * @compile MethodRefNewInnerInLambdaNPE2.java + */ + +public class MethodRefNewInnerInLambdaNPE2 { + + interface Constructor { + MyTest execute(); + } + + class MyTest { + MyTest() { System.out.println("Constructor executed"); } + } + + public Constructor getConstructor() { + return getConstructor(() -> { return MyTest::new; }); + } + + public static void main(String argv[]) { + MethodRefNewInnerInLambdaNPE2 t = new MethodRefNewInnerInLambdaNPE2(); + MyTest mytest = t.getConstructor().execute(); + } + + Constructor getConstructor(Wrapper arg) { + return arg.unwrap(); + } + + interface Wrapper { + Constructor unwrap(); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java new file mode 100644 index 00000000000..c6d7cef715c --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify1.java @@ -0,0 +1,48 @@ +/* + * 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 8037404 + * @summary javac NPE or VerifyError for code with constructor reference of inner class + */ + +import java.util.function.Function; +import java.util.stream.Stream; + +public class MethodRefNewInnerInLambdaVerify1 { + public static void main(String[] args) { + if (new MethodRefNewInnerInLambdaVerify1().map().apply(1).getClass() != TT.class) + throw new AssertionError("sanity failed"); + } + + Function map() { + return (i) -> Stream.of(i).map(TT::new).findFirst().get(); + } + + class TT { + public TT(int i) { + + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java new file mode 100644 index 00000000000..28e4db7ab87 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2.java @@ -0,0 +1,62 @@ +/* + * 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 8038776 + * @summary VerifyError when running successfully compiled java class + */ + +import java.util.function.Function; + +/** + * Derived from code by: + * @author Yawkat + */ +public class MethodRefNewInnerInLambdaVerify2 { + public static void main(String[] args) { new MethodRefNewInnerInLambdaVerify2().runTest(); } + + private void runTest() { + Worker worker = new Worker(); + run(() -> worker.check(field -> new SomeClass(field))); + run(() -> worker.check(SomeClass::new)); + } + + private void run(Runnable runnable) { + runnable.run(); + } + + private class SomeClass { + final Object field; + + SomeClass(Object field) { + this.field = field; + } + } + + private static class Worker { + void check(Function i) { + if (!i.apply("frank").field.equals("frank")) throw new AssertionError("sanity failed"); + } + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java new file mode 100644 index 00000000000..be6d4b25799 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefNewInnerInLambdaVerify2simple.java @@ -0,0 +1,50 @@ +/* + * 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 8038776 + * @summary VerifyError when running successfully compiled java class + */ + +import java.util.function.Function; + +/** + * Derived from code by: + * @author Yawkat + */ +public class MethodRefNewInnerInLambdaVerify2simple { + public static void main(String[] args) { new MethodRefNewInnerInLambdaVerify2simple().runTest(); } + + private void runTest() { + Runnable r = (() -> { Sup w = SomeClass::new; } ); + } + + private class SomeClass { + SomeClass() { } + } +} + +interface Sup { + Object get(); +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java new file mode 100644 index 00000000000..110d78aba99 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefQualifier1.java @@ -0,0 +1,62 @@ +/* + * 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 8048121 + * @summary javac complex method references: revamp and simplify + */ + +public class MethodRefQualifier1 { + + interface SAM { + void m(); + } + + static int count = 0; + + static void assertTrue(boolean cond, String msg) { + if (!cond) + throw new AssertionError(msg); + } + + MethodRefQualifier1 check() { + count++; + return this; + } + + void ido(Object... args) { } + + public static void main(String[] args) { + new MethodRefQualifier1().test(); + } + + void test() { + count = 0; + SAM s = check()::ido; + assertTrue(count == 1, "creation: unexpected: " + count); + count = 0; + s.m(); + assertTrue(count == 0, "evaluation: unexpected: " + count); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java new file mode 100644 index 00000000000..6970f5e14a1 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefSingleRefEvalBridge.java @@ -0,0 +1,70 @@ +/* + * 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 8048121 + * @summary javac complex method references: revamp and simplify + * + * Make sure that the method reference receiver is evaluated exactly once + * even in this bridging case. + */ + + public class MethodRefSingleRefEvalBridge { + + interface SAM { + int m(); + } + + class ZZ { + // private to force bridging + private int four() { return 4; } + } + + static int count = 0; + ZZ azz = new ZZ(); + + static void assertEqual(int expected, int got) { + if (got != expected) + throw new AssertionError("Expected " + expected + " got " + got); + } + + public static void main(String[] args) { + new MethodRefSingleRefEvalBridge().test(); + } + + ZZ check() { + count++; + return azz; + } + + void test() { + count = 0; + SAM s = check()::four; + assertEqual(1, count); + + count = 0; + assertEqual(4, s.m()); + assertEqual(0, count); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java b/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java new file mode 100644 index 00000000000..c1a98e64391 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodRefToInner.java @@ -0,0 +1,52 @@ +/* + * 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 8047341 + * @summary lambda reference to inner class in base class causes LambdaConversionException + */ + +import java.util.List; +import java.util.ArrayList; + +class MethodRefToInnerBase { + class TestString { + String str; + TestString(String strin) { + str = strin; + } + } +} +public class MethodRefToInner extends MethodRefToInnerBase { + public static void main(String[] args) { + new MethodRefToInner().run(); + } + MethodRefToInner() { + super(); + } + void run() { + List list = new ArrayList<>(); + list.stream().forEach(TestString::new); + } +} diff --git a/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java b/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java new file mode 100644 index 00000000000..44935abe9b4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/methodReference/MethodReferenceComplexNullCheckTest.java @@ -0,0 +1,54 @@ +/* + * 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. 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. + */ + +/** + * @test + * @bug 8048121 + * @summary javac complex method references: revamp and simplify + * + * Make sure NPE check is done even in the convert to Lambda case + */ + +public class MethodReferenceComplexNullCheckTest { + public static void main(String[] args) { + F fr = null; + boolean npeFired = false; + try { + IForm frf = fr::doit; + } catch (NullPointerException npe) { + npeFired = true; + } finally { + if (!npeFired) throw new AssertionError( "NPE should have been thrown"); + } + } + + interface IForm { + void xyz(Object... args); + } + + class F { + private void doit(Object... args) { } + } +} From 25618fc4700d14eca1b9abc1c243b45cea21dacc Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 25 Jun 2014 17:58:37 -0700 Subject: [PATCH 047/236] 8046613: Fill in missing doc comments Reviewed-by: darcy --- .../share/classes/com/sun/javadoc/AnnotatedType.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java b/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java index c39260e0faf..01d07dbaa16 100644 --- a/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java +++ b/langtools/src/share/classes/com/sun/javadoc/AnnotatedType.java @@ -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 @@ -39,7 +39,15 @@ package com.sun.javadoc; */ public interface AnnotatedType extends Type { + /** + * Returns the annotations associated with this type. + * @return the annotations associated with this type + */ AnnotationDesc[] annotations(); + /** + * Returns the underlying type. + * @return the underlying type + */ Type underlyingType(); } From a86ace6297265b8a1fe1971387753bb44665ed74 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 25 Jun 2014 19:04:52 -0700 Subject: [PATCH 048/236] 8046614: Fill in missing doc comments Reviewed-by: darcy --- .../com/sun/source/doctree/AttributeTree.java | 30 +- .../com/sun/source/doctree/AuthorTree.java | 6 +- .../com/sun/source/doctree/BlockTagTree.java | 6 +- .../com/sun/source/doctree/CommentTree.java | 6 +- .../sun/source/doctree/DeprecatedTree.java | 6 +- .../sun/source/doctree/DocCommentTree.java | 17 +- .../com/sun/source/doctree/DocTree.java | 13 +- .../sun/source/doctree/DocTreeVisitor.java | 207 +++++++- .../sun/source/doctree/EndElementTree.java | 6 +- .../com/sun/source/doctree/EntityTree.java | 10 +- .../com/sun/source/doctree/ErroneousTree.java | 4 +- .../sun/source/doctree/IdentifierTree.java | 6 +- .../com/sun/source/doctree/InlineTagTree.java | 6 +- .../com/sun/source/doctree/LinkTree.java | 11 +- .../com/sun/source/doctree/LiteralTree.java | 6 +- .../com/sun/source/doctree/ParamTree.java | 16 +- .../com/sun/source/doctree/ReferenceTree.java | 10 +- .../com/sun/source/doctree/ReturnTree.java | 6 +- .../com/sun/source/doctree/SeeTree.java | 6 +- .../sun/source/doctree/SerialDataTree.java | 6 +- .../sun/source/doctree/SerialFieldTree.java | 16 +- .../com/sun/source/doctree/SerialTree.java | 7 +- .../com/sun/source/doctree/SinceTree.java | 6 +- .../sun/source/doctree/StartElementTree.java | 17 +- .../com/sun/source/doctree/TextTree.java | 6 +- .../com/sun/source/doctree/ThrowsTree.java | 12 +- .../source/doctree/UnknownBlockTagTree.java | 6 +- .../source/doctree/UnknownInlineTagTree.java | 6 +- .../com/sun/source/doctree/ValueTree.java | 6 +- .../com/sun/source/doctree/VersionTree.java | 6 +- .../sun/source/tree/AnnotatedTypeTree.java | 13 +- .../com/sun/source/tree/AnnotationTree.java | 11 +- .../com/sun/source/tree/ArrayAccessTree.java | 11 +- .../com/sun/source/tree/ArrayTypeTree.java | 6 +- .../com/sun/source/tree/AssertTree.java | 13 +- .../com/sun/source/tree/AssignmentTree.java | 11 +- .../com/sun/source/tree/BinaryTree.java | 11 +- .../com/sun/source/tree/BlockTree.java | 11 +- .../com/sun/source/tree/BreakTree.java | 8 +- .../classes/com/sun/source/tree/CaseTree.java | 13 +- .../com/sun/source/tree/CatchTree.java | 16 +- .../com/sun/source/tree/ClassTree.java | 33 +- .../sun/source/tree/CompilationUnitTree.java | 40 +- .../source/tree/CompoundAssignmentTree.java | 11 +- .../tree/ConditionalExpressionTree.java | 16 +- .../com/sun/source/tree/ContinueTree.java | 8 +- .../com/sun/source/tree/DoWhileLoopTree.java | 13 +- .../sun/source/tree/EnhancedForLoopTree.java | 18 +- .../com/sun/source/tree/ErroneousTree.java | 6 +- .../source/tree/ExpressionStatementTree.java | 6 +- .../com/sun/source/tree/ForLoopTree.java | 26 +- .../com/sun/source/tree/IdentifierTree.java | 6 +- .../classes/com/sun/source/tree/IfTree.java | 22 +- .../com/sun/source/tree/ImportTree.java | 17 +- .../com/sun/source/tree/InstanceOfTree.java | 13 +- .../sun/source/tree/IntersectionTypeTree.java | 6 +- .../sun/source/tree/LabeledStatementTree.java | 11 +- .../sun/source/tree/LambdaExpressionTree.java | 23 +- .../classes/com/sun/source/tree/LineMap.java | 10 +- .../com/sun/source/tree/LiteralTree.java | 7 +- .../sun/source/tree/MemberReferenceTree.java | 26 +- .../com/sun/source/tree/MemberSelectTree.java | 11 +- .../sun/source/tree/MethodInvocationTree.java | 16 +- .../com/sun/source/tree/MethodTree.java | 46 +- .../com/sun/source/tree/ModifiersTree.java | 11 +- .../com/sun/source/tree/NewArrayTree.java | 30 +- .../com/sun/source/tree/NewClassTree.java | 27 +- .../com/sun/source/tree/PackageTree.java | 9 + .../source/tree/ParameterizedTypeTree.java | 11 +- .../sun/source/tree/ParenthesizedTree.java | 6 +- .../sun/source/tree/PrimitiveTypeTree.java | 6 +- .../com/sun/source/tree/ReturnTree.java | 8 +- .../classes/com/sun/source/tree/Scope.java | 8 +- .../com/sun/source/tree/SwitchTree.java | 13 +- .../com/sun/source/tree/SynchronizedTree.java | 13 +- .../com/sun/source/tree/ThrowTree.java | 8 +- .../classes/com/sun/source/tree/Tree.java | 16 +- .../com/sun/source/tree/TreeVisitor.java | 381 +++++++++++++- .../classes/com/sun/source/tree/TryTree.java | 29 +- .../com/sun/source/tree/TypeCastTree.java | 11 +- .../sun/source/tree/TypeParameterTree.java | 13 +- .../com/sun/source/tree/UnaryTree.java | 6 +- .../com/sun/source/tree/UnionTypeTree.java | 9 +- .../com/sun/source/tree/VariableTree.java | 28 +- .../com/sun/source/tree/WhileLoopTree.java | 13 +- .../com/sun/source/tree/WildcardTree.java | 6 +- .../sun/source/util/DocSourcePositions.java | 6 +- .../com/sun/source/util/DocTreePath.java | 33 +- .../sun/source/util/DocTreePathScanner.java | 15 +- .../com/sun/source/util/DocTreeScanner.java | 221 +++++++- .../classes/com/sun/source/util/DocTrees.java | 26 +- .../com/sun/source/util/JavacTask.java | 32 +- .../classes/com/sun/source/util/Plugin.java | 6 +- .../sun/source/util/SimpleDocTreeVisitor.java | 269 +++++++++- .../sun/source/util/SimpleTreeVisitor.java | 469 ++++++++++++++++- .../com/sun/source/util/SourcePositions.java | 6 +- .../com/sun/source/util/TaskEvent.java | 47 ++ .../com/sun/source/util/TaskListener.java | 10 +- .../classes/com/sun/source/util/TreePath.java | 44 +- .../com/sun/source/util/TreePathScanner.java | 13 +- .../com/sun/source/util/TreeScanner.java | 472 +++++++++++++++++- .../classes/com/sun/source/util/Trees.java | 98 ++-- .../formats/html/PackageIndexFrameWriter.java | 2 +- .../formats/html/ProfileIndexFrameWriter.java | 4 +- .../html/ProfilePackageIndexFrameWriter.java | 2 +- .../com/sun/tools/javac/api/JavacTrees.java | 2 +- .../tools/javac/parser/DocCommentParser.java | 1 - .../sun/tools/javac/util/JavacMessages.java | 4 +- .../javac/util/MandatoryWarningHandler.java | 4 +- .../javac/util/RichDiagnosticFormatter.java | 4 +- .../com/sun/tools/javah/NativeHeaderTool.java | 4 +- .../com/sun/tools/javap/DisassemblerTool.java | 4 +- .../share/classes/javax/tools/Diagnostic.java | 20 +- .../javax/tools/DiagnosticCollector.java | 4 +- .../javax/tools/DocumentationTool.java | 4 +- .../share/classes/javax/tools/FileObject.java | 16 +- .../classes/javax/tools/JavaCompiler.java | 4 +- .../classes/javax/tools/JavaFileManager.java | 14 +- .../classes/javax/tools/JavaFileObject.java | 4 +- .../javax/tools/StandardJavaFileManager.java | 12 +- .../classes/javax/tools/StandardLocation.java | 4 +- .../src/share/classes/javax/tools/Tool.java | 4 +- .../classes/javax/tools/ToolProvider.java | 6 +- 123 files changed, 3233 insertions(+), 306 deletions(-) diff --git a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java index 254042ebdb6..86d236f9295 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/AttributeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -35,10 +35,36 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface AttributeTree extends DocTree { + /** + * The kind of an attribute value. + */ @jdk.Exported - enum ValueKind { EMPTY, UNQUOTED, SINGLE, DOUBLE } + enum ValueKind { + /** The attribute value is empty. */ + EMPTY, + /** The attribute value is not enclosed in quotes. */ + UNQUOTED, + /** The attribute value is enclosed in single quotation marks. */ + SINGLE, + /** The attribute value is enclosed in double quotation marks. */ + DOUBLE + } + /** + * Returns the name of the attribute. + * @return the name of the attribute + */ Name getName(); + + /** + * Returns the kind of the attribute. + * @return the kind of the attribute. + */ ValueKind getValueKind(); + + /** + * Returns the value of the attribute, or {@code null} if the kind is EMPTY. + * @return the value of the attribute. + */ List getValue(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java index 5df14f3b623..4dce58feff9 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/AuthorTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface AuthorTree extends BlockTagTree { + /** + * Returns the name of the author. + * @return the name + */ List getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java index 9f709398924..2284f01057f 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/BlockTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -33,5 +33,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface BlockTagTree extends DocTree { + /** + * Returns the name of the tag. + * @return the name of the tag + */ String getTagName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java index c821c121cb5..346b1542714 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/CommentTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -35,6 +35,10 @@ package com.sun.source.doctree; */ @jdk.Exported public interface CommentTree extends DocTree { + /** + * Returns the text of the comment. + * @return the comment text + */ String getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java index 6757f43cc7a..bfcebcf7393 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DeprecatedTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface DeprecatedTree extends BlockTagTree { + /** + * Returns the description explaining why an item is deprecated. + * @return the description + */ List getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java index 8c55e694c4e..f00fbb30576 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DocCommentTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,7 +37,22 @@ import java.util.List; */ @jdk.Exported public interface DocCommentTree extends DocTree { + /** + * Returns the first sentence of a documentation comment. + * @return the first sentence of a documentation comment + */ List getFirstSentence(); + + /** + * Returns the body of a documentation comment, + * appearing after the first sentence, and before any block tags. + * @return the body of a documentation comment + */ List getBody(); + + /** + * Returns the block tags for a documentation comment. + * @return the block tags of a documentation comment + */ List getBlockTags(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java index 3c6e70810ea..5d728ee1aab 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DocTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DocTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface DocTree { + /** + * Enumerates all kinds of trees. + */ @jdk.Exported enum Kind { /** @@ -227,6 +230,9 @@ public interface DocTree { */ OTHER; + /** + * The name of the tag, if any, associated with this kind of node. + */ public final String tagName; Kind() { @@ -239,7 +245,7 @@ public interface DocTree { } /** - * Gets the kind of this tree. + * Returns the kind of this tree. * * @return the kind of this tree. */ @@ -251,6 +257,9 @@ public interface DocTree { * * @param result type of this operation. * @param type of additional data. + * @param visitor the visitor to be called + * @param data a parameter value to be passed to the visitor method + * @return the value returned from the visitor method */ R accept(DocTreeVisitor visitor, D data); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java index 67e67f881ff..fdfa116fc63 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/doctree/DocTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -56,33 +56,238 @@ package com.sun.source.doctree; */ @jdk.Exported public interface DocTreeVisitor { + + /** + * Visits an AttributeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAttribute(AttributeTree node, P p); + + /** + * Visits an AuthorTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitAuthor(AuthorTree node, P p); + + /** + * Visits a CommentTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitComment(CommentTree node, P p); + + /** + * Visits a DeprecatedTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDeprecated(DeprecatedTree node, P p); + + /** + * Visits a DocCommentTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDocComment(DocCommentTree node, P p); + + /** + * Visits a DocRootTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitDocRoot(DocRootTree node, P p); + + /** + * Visits an EndElementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitEndElement(EndElementTree node, P p); + + /** + * Visits an EntityTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitEntity(EntityTree node, P p); + + /** + * Visits an ErroneousTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitErroneous(ErroneousTree node, P p); + + /** + * Visits an IdentifierTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitIdentifier(IdentifierTree node, P p); + + /** + * Visits an InheritDocTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitInheritDoc(InheritDocTree node, P p); + + /** + * Visits a LinkTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLink(LinkTree node, P p); + + /** + * Visits an LiteralTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitLiteral(LiteralTree node, P p); + + /** + * Visits a ParamTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitParam(ParamTree node, P p); + + /** + * Visits a ReferenceTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitReference(ReferenceTree node, P p); + + /** + * Visits a ReturnTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitReturn(ReturnTree node, P p); + + /** + * Visits a SeeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSee(SeeTree node, P p); + + /** + * Visits a SerialTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSerial(SerialTree node, P p); + + /** + * Visits a SerialDataTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSerialData(SerialDataTree node, P p); + + /** + * Visits a SerialFieldTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSerialField(SerialFieldTree node, P p); + + /** + * Visits a SinceTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitSince(SinceTree node, P p); + + /** + * Visits a StartElementTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitStartElement(StartElementTree node, P p); + + /** + * Visits a TextTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitText(TextTree node, P p); + + /** + * Visits a ThrowsTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitThrows(ThrowsTree node, P p); + + /** + * Visits an UnknownBlockTagTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitUnknownBlockTag(UnknownBlockTagTree node, P p); + + /** + * Visits an UnknownInlineTagTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitUnknownInlineTag(UnknownInlineTagTree node, P p); + + /** + * Visits a ValueTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitValue(ValueTree node, P p); + + /** + * Visits a VersionTreeTree node. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitVersion(VersionTree node, P p); + + /** + * Visits an unknown type of DocTree node. + * This can occur if the set of tags evolves and new kinds + * of nodes are added to the {@code DocTree} hierarchy. + * @param node the node being visited + * @param p a parameter value + * @return a result value + */ R visitOther(DocTree node, P p); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java index 9e201b0a124..e54e3082d08 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/EndElementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface EndElementTree extends DocTree { + /** + * Returns the name of this element. + * @return the name + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java index d9bbed85072..5431fd7057c 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/EntityTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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,11 +32,17 @@ import javax.lang.model.element.Name; * A tree node for an HTML entity. * *

- * & name ; + * & name ;
+ * & # digits ;
+ * & #X hex-digits ; * * @since 1.8 */ @jdk.Exported public interface EntityTree extends DocTree { + /** + * Returns the name or value of the entity. + * @return the name or value of the entity + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java index ea5e6321760..1ece1e62887 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ErroneousTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -35,7 +35,7 @@ import javax.tools.JavaFileObject; @jdk.Exported public interface ErroneousTree extends TextTree { /** - * Gets a diagnostic object giving details about + * Returns a diagnostic object giving details about * the reason the body text is in error. * * @return a diagnostic diff --git a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java index 73419d7e972..a82bf142976 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/IdentifierTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface IdentifierTree extends DocTree { + /** + * Returns the name of the identifier. + * @return the name + */ Name getName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java index 7b8ec247099..6cbf1fc4258 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/InlineTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -33,5 +33,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface InlineTagTree extends DocTree { + /** + * Returns the name of the tag. + * @return the name of the tag + */ String getTagName(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java index ba7d6e972a7..1f4a0a12ded 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/LinkTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -38,6 +38,15 @@ import java.util.List; */ @jdk.Exported public interface LinkTree extends InlineTagTree { + /** + * Returns the reference of a link. + * @return the reference + */ ReferenceTree getReference(); + + /** + * Returns the label, if any, of the link. + * @return the label + */ List getLabel(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java index 6c5d0d839e1..91727ccd402 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/LiteralTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -36,5 +36,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface LiteralTree extends InlineTagTree { + /** + * Returns the body of the {@code @code} or {@code @literal} tag. + * @return the body of the tag + */ TextTree getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java index 67935315373..b721783e493 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ParamTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,7 +37,21 @@ import java.util.List; */ @jdk.Exported public interface ParamTree extends BlockTagTree { + /** + * Returns true if this is documenting a type parameter. + * @return true if this is documenting a type parameter + */ boolean isTypeParameter(); + + /** + * Returns the name of the parameter. + * @return the name of the parameter + */ IdentifierTree getName(); + + /** + * Returns the description of the parameter. + * @return the description + */ List getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java index 76a0311eaeb..ab623036702 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ReferenceTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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,14 +26,20 @@ package com.sun.source.doctree; /** - * A tree node to a reference to a Java language element. + * A tree node for a reference to a Java language element. * *

* package.class#field + * package.class#method(arg-types) * * @since 1.8 */ @jdk.Exported public interface ReferenceTree extends DocTree { + /** + * Returns the signature of the Java language element being referenced, + * as found in {@code @see} and similar nodes. + * @return the signature. + */ String getSignature(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java index 72bdf5b915a..305c92c19dc 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ReturnTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface ReturnTree extends BlockTagTree { + /** + * Returns the description of the return value of a method. + * @return the description + */ List getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java index 1ddac77edb9..4ff81c0f6ec 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SeeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -40,5 +40,9 @@ import java.util.List; */ @jdk.Exported public interface SeeTree extends BlockTagTree { + /** + * Returns the reference. + * @return the reference + */ List getReference(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java index b281e372641..90757595c66 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialDataTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface SerialDataTree extends BlockTagTree { + /** + * Returns the description of the serial data. + * @return the description + */ List getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java index 6ea77bab752..ff7c25a919d 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialFieldTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,7 +37,21 @@ import java.util.List; */ @jdk.Exported public interface SerialFieldTree extends BlockTagTree { + /** + * Returns the name of the serial field. + * @return the name of the serial field + */ IdentifierTree getName(); + + /** + * Returns the type of the serial field. + * @return the type of the serial field + */ ReferenceTree getType(); + + /** + * Returns the description of the serial field. + * @return the description of the serial field + */ List getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java index 3812569cdac..04feab793b3 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SerialTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,10 @@ import java.util.List; */ @jdk.Exported public interface SerialTree extends BlockTagTree { + /** + * Returns the description of the field, or the word + * "include" or "exclude". + * @return the description of the field + */ List getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java index d21be4c52fd..074aebd4cff 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/SinceTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface SinceTree extends BlockTagTree { + /** + * Returns the text explaining the availability of the item being documented. + * @return the text + */ List getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java index 1bac6e566d5..34f98e8ec71 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/StartElementTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -38,7 +38,22 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface StartElementTree extends DocTree { + /** + * Returns the name of the element. + * @return the name + */ Name getName(); + + /** + * Returns any attributes defined by this element. + * @return the attributes + */ List getAttributes(); + + /** + * Returns true if this is a self-closing element, + * as indicated by a "/" before the closing ">". + * @return true if this is a self-closing element + */ boolean isSelfClosing(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java index 1d03109eb8a..f2adf029dfc 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/TextTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/TextTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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,5 +32,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface TextTree extends DocTree { + /** + * Returns the text. + * @return the text + */ String getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java index cde8360c7dc..1f340469582 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ThrowsTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -40,6 +40,16 @@ import java.util.List; */ @jdk.Exported public interface ThrowsTree extends BlockTagTree { + /** + * Returns a name of the exception being documented. + * @return the name of the exception + */ ReferenceTree getExceptionName(); + + /** + * Returns the description of the reasons why the + * exception may be thrown. + * @return the description + */ List getDescription(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java index 701cdbfabd1..47739a6b791 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownBlockTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface UnknownBlockTagTree extends BlockTagTree { + /** + * Returns the content of an unrecognized block tag. + * @return the content + */ List getContent(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java index a67b6e8c192..9a0eb294976 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/UnknownInlineTagTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,5 +37,9 @@ import java.util.List; */ @jdk.Exported public interface UnknownInlineTagTree extends InlineTagTree { + /** + * Returns the content of an unrecognized inline tag. + * @return the content + */ List getContent(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java index bc7f2f91f9b..5c792b5bb1d 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/ValueTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -35,5 +35,9 @@ package com.sun.source.doctree; */ @jdk.Exported public interface ValueTree extends InlineTagTree { + /** + * Returns the reference to the value. + * @return the reference + */ ReferenceTree getReference(); } diff --git a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java index b54ddeb7ff3..eee4237aab8 100644 --- a/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java +++ b/langtools/src/share/classes/com/sun/source/doctree/VersionTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -38,5 +38,9 @@ import java.util.List; */ @jdk.Exported public interface VersionTree extends BlockTagTree { + /** + * Returns the body of the tag. + * @return the body + */ List getBody(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java index 37fc95b93cd..d84fcd60730 100644 --- a/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -28,7 +28,7 @@ package com.sun.source.tree; import java.util.List; /** - * A tree node for an annotated type + * A tree node for an annotated type. * * For example: *

@@ -43,6 +43,15 @@ import java.util.List;
  */
 @jdk.Exported
 public interface AnnotatedTypeTree extends ExpressionTree {
+    /**
+     * Returns the annotations associated with this type expression.
+     * @return the annotations
+     */
     List getAnnotations();
+
+    /**
+     * Returns the underlying type with which the annotations are associated.
+     * @return the underlying type
+     */
     ExpressionTree getUnderlyingType();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java b/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java
index 01c6c42dbf3..b47cdbced84 100644
--- a/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/AnnotationTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -44,6 +44,15 @@ import java.util.List;
  */
 @jdk.Exported
 public interface AnnotationTree extends ExpressionTree {
+    /**
+     * Returns the annotation type.
+     * @return the annotation type
+     */
     Tree getAnnotationType();
+
+    /**
+     * Returns the arguments, if any, for the annotation.
+     * @return the arguments for the annotation type
+     */
     List getArguments();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java b/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java
index a8c969985ff..515aee06d5f 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ArrayAccessTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -41,6 +41,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ArrayAccessTree extends ExpressionTree {
+    /**
+     * Returns the expression for the array being accessed.
+     * @return the array
+     */
     ExpressionTree getExpression();
+
+    /**
+     * Returns the expression for the index.
+     * @return the index
+     */
     ExpressionTree getIndex();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java
index c253a3b69c9..d7d8ceb55d8 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ArrayTypeTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -41,5 +41,9 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ArrayTypeTree extends Tree {
+    /**
+     * Returns the element type of this array type.
+     * @return the element type
+     */
     Tree getType();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/AssertTree.java b/langtools/src/share/classes/com/sun/source/tree/AssertTree.java
index f2c824ea0a4..080bc3ee5f7 100644
--- a/langtools/src/share/classes/com/sun/source/tree/AssertTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/AssertTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for an 'assert' statement.
+ * A tree node for an {@code assert} statement.
  *
  * For example:
  * 
@@ -43,6 +43,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface AssertTree extends StatementTree {
+    /**
+     * Returns the condition being asserted.
+     * @return the condition
+     */
     ExpressionTree getCondition();
+
+    /**
+     * Returns the detail expression.
+     * @return the detail expression
+     */
     ExpressionTree getDetail();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java b/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java
index 63f671f40d6..5ce69d24e8f 100644
--- a/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/AssignmentTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -41,6 +41,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface AssignmentTree extends ExpressionTree {
+    /**
+     * Returns the variable being assigned to.
+     * @return the variable
+     */
     ExpressionTree getVariable();
+
+    /**
+     * Returns the expression being assigned to the variable.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java b/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java
index f280fc1140a..8f0d155f334 100644
--- a/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/BinaryTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -42,6 +42,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface BinaryTree extends ExpressionTree {
+    /**
+     * Returns the left (first) operand of the expression.
+     * @return the left operand
+     */
     ExpressionTree getLeftOperand();
+
+    /**
+     * Returns the right (second) operand of the expression.
+     * @return the right operand
+     */
     ExpressionTree getRightOperand();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/BlockTree.java b/langtools/src/share/classes/com/sun/source/tree/BlockTree.java
index 8d15bd7ed6e..4b5721e1aa3 100644
--- a/langtools/src/share/classes/com/sun/source/tree/BlockTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/BlockTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -47,6 +47,15 @@ import java.util.List;
  */
 @jdk.Exported
 public interface BlockTree extends StatementTree {
+    /**
+     * Returns true if and only if this is a static initializer block.
+     * @return true if this is a static initializer block
+     */
     boolean isStatic();
+
+    /**
+     * Returns the statements comprising this block.
+     * @return the statements
+     */
     List getStatements();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/BreakTree.java b/langtools/src/share/classes/com/sun/source/tree/BreakTree.java
index c51731bbeb4..4f900a62ba8 100644
--- a/langtools/src/share/classes/com/sun/source/tree/BreakTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/BreakTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@ package com.sun.source.tree;
 import javax.lang.model.element.Name;
 
 /**
- * A tree node for a 'break' statement.
+ * A tree node for a {@code break} statement.
  *
  * For example:
  * 
@@ -45,5 +45,9 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface BreakTree extends StatementTree {
+    /**
+     * Returns the label for this {@code break} statement.
+     * @return the label
+     */
     Name getLabel();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/CaseTree.java b/langtools/src/share/classes/com/sun/source/tree/CaseTree.java
index 01e61c3fa80..6aa374f1cb5 100644
--- a/langtools/src/share/classes/com/sun/source/tree/CaseTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/CaseTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@ package com.sun.source.tree;
 import java.util.List;
 
 /**
- * A tree node for a 'case' in a 'switch' statement.
+ * A tree node for a {@code case} in a {@code switch} statement.
  *
  * For example:
  * 
@@ -48,8 +48,15 @@ import java.util.List;
 @jdk.Exported
 public interface CaseTree extends Tree {
     /**
-     * @return null if and only if this Case is {@code default:}
+     * Returns the expression for the case, or
+     * {@code null} if this is the default case.
+     * @return the expression for the case, or null
      */
     ExpressionTree getExpression();
+
+    /**
+     * Returns the statements labeled by the case.
+     * @return the statements labeled by the case
+     */
     List getStatements();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/CatchTree.java b/langtools/src/share/classes/com/sun/source/tree/CatchTree.java
index f2a5452e3a9..b91a94dce5b 100644
--- a/langtools/src/share/classes/com/sun/source/tree/CatchTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/CatchTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for a 'catch' block in a 'try' statement.
+ * A tree node for a {@code catch} block in a {@code try} statement.
  *
  * For example:
  * 
@@ -42,6 +42,18 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface CatchTree extends Tree {
+    /**
+     * Returns the catch variable.
+     * A multi-catch variable will have a
+     * {@link UnionTypeTree UnionTypeTree}
+     * as the type of the variable.
+     * @return the catch variable
+     */
     VariableTree getParameter();
+
+    /**
+     * Returns the catch block.
+     * @return the catch block
+     */
     BlockTree getBlock();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ClassTree.java b/langtools/src/share/classes/com/sun/source/tree/ClassTree.java
index 9a2303f18bc..3a7f5b34440 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ClassTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ClassTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -50,10 +50,41 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface ClassTree extends StatementTree {
+    /**
+     * Returns the modifiers, including any annotations,
+     * for this type declaration.
+     * @return the modifiers
+     */
     ModifiersTree getModifiers();
+
+    /**
+     * Returns the simple name of this type declaration.
+     * @return the simple name
+     */
     Name getSimpleName();
+
+    /**
+     * Returns any type parameters of this type declaration.
+     * @return the type parameters
+     */
     List getTypeParameters();
+
+    /**
+     * Returns the supertype of this type declaration,
+     * or {@code null} if none is provided.
+     * @return the supertype
+     */
     Tree getExtendsClause();
+
+    /**
+     * Returns the interfaces implemented by this type declaration.
+     * @return the interfaces
+     */
     List getImplementsClause();
+
+    /**
+     * Returns the members declared in this type declaration.
+     * @return the members
+     */
     List getMembers();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java b/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java
index d401a31bfa5..fa3e5745814 100644
--- a/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/CompilationUnitTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -39,21 +39,53 @@ import javax.tools.JavaFileObject;
  */
 @jdk.Exported
 public interface CompilationUnitTree extends Tree {
+    /**
+     * Returns the annotations listed on any package declaration
+     * at the head of this compilation unit, or {@code null} if there
+     * is no package declaration.
+     * @return the package annotations
+     */
     List getPackageAnnotations();
+
+    /**
+     * Returns the name contained in any package declaration
+     * at the head of this compilation unit, or {@code null} if there
+     * is no package declaration.
+     * @return the package name
+     */
     ExpressionTree getPackageName();
 
     /**
-     * Return the PackageTree associated with this compilation unit.
+     * Returns the package tree associated with this compilation unit,
+     * or {@code null} if there is no package declaration.
+     * @return the package tree
      * @since 1.9
      */
     PackageTree getPackage();
+
+    /**
+     * Returns the import declarations appearing in this compilation unit.
+     * @return the import declarations
+     */
     List getImports();
+
+    /**
+     * Returns the type declarations appearing in this compilation unit.
+     * The list may also include empty statements resulting from
+     * extraneous semicolons.
+     * @return the type declarations
+     */
     List getTypeDecls();
+
+    /**
+     * Returns the file object containing the source for this compilation unit.
+     * @return the file object
+     */
     JavaFileObject getSourceFile();
 
     /**
-     * Gets the line map for this compilation unit, if available.
-     * Returns null if the line map is not available.
+     * Returns the line map for this compilation unit, if available.
+     * Returns {@code null} if the line map is not available.
      * @return the line map for this compilation unit
      */
     LineMap getLineMap();
diff --git a/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java b/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java
index d3dca973ecc..e4db62bb053 100644
--- a/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/CompoundAssignmentTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -42,6 +42,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface CompoundAssignmentTree extends ExpressionTree {
+    /**
+     * Returns the variable on the left hand side of the compound assignment.
+     * @return the variable
+     */
     ExpressionTree getVariable();
+
+    /**
+     * Returns the expression on the right hand side of the compound assignment.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java b/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java
index b50a6a35955..fa3dd83769a 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ConditionalExpressionTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -41,7 +41,21 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ConditionalExpressionTree extends ExpressionTree {
+    /**
+     * Returns the condition.
+     * @return the condition
+     */
     ExpressionTree getCondition();
+
+    /**
+     * Returns the expression to be evaluated if the condition is true.
+     * @return the expression to be evaluated if the condition is true
+     */
     ExpressionTree getTrueExpression();
+
+    /**
+     * Returns the expression to be evaluated if the condition is false.
+     * @return the expression to be evaluated if the condition is false
+     */
     ExpressionTree getFalseExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java b/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java
index 6dd9992b2c6..2f6f3fa46e6 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ContinueTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@ package com.sun.source.tree;
 import javax.lang.model.element.Name;
 
 /**
- * A tree node for a 'continue' statement.
+ * A tree node for a {@code continue} statement.
  *
  * For example:
  * 
@@ -44,5 +44,9 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface ContinueTree extends StatementTree {
+    /**
+     * Returns the label for this {@code continue} statement.
+     * @return the label
+     */
     Name getLabel();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java
index ef59fbe0cc7..2aeac4b26ca 100644
--- a/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/DoWhileLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for a 'do' statement.
+ * A tree node for a {@code do} statement.
  *
  * For example:
  * 
@@ -43,6 +43,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface DoWhileLoopTree extends StatementTree {
+    /**
+     * Returns the condition of the loop.
+     * @return the condition
+     */
     ExpressionTree getCondition();
+
+    /**
+     * Returns the body of the loop.
+     * @return the body of the loop
+     */
     StatementTree getStatement();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java
index 943b762bb99..f9619f897ba 100644
--- a/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/EnhancedForLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for an "enhanced" 'for' loop statement.
+ * A tree node for an "enhanced" {@code for} loop statement.
  *
  * For example:
  * 
@@ -42,7 +42,21 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface EnhancedForLoopTree extends StatementTree {
+    /**
+     * Returns the control variable for the loop.
+     * @return the control variable
+     */
     VariableTree getVariable();
+
+    /**
+     * Returns the expression yielding the values for the control variable.
+     * @return the expression
+     */
     ExpressionTree getExpression();
+
+    /**
+     * Returns the body of the loop.
+     * @return the body of the loop
+     */
     StatementTree getStatement();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java b/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java
index 36748b46749..b56c3ee448c 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ErroneousTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -36,5 +36,9 @@ import java.util.List;
  */
 @jdk.Exported
 public interface ErroneousTree extends ExpressionTree {
+    /**
+     * Returns any trees that were saved in this node.
+     * @return the trees
+     */
     List getErrorTrees();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java b/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java
index 3eab1f80e30..7ae8c2265d9 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ExpressionStatementTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -41,5 +41,9 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ExpressionStatementTree extends StatementTree {
+    /**
+     * Returns the expression constituting this statement.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java
index baa9c11b821..e42daffe8f6 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ForLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@ package com.sun.source.tree;
 import java.util.List;
 
 /**
- * A tree node for a basic 'for' loop statement.
+ * A tree node for a basic {@code for} loop statement.
  *
  * For example:
  * 
@@ -44,8 +44,30 @@ import java.util.List;
  */
 @jdk.Exported
 public interface ForLoopTree extends StatementTree {
+    /**
+     * Returns any initializers of the {@code for} statement.
+     * The result will be an empty list if there are
+     * no initializers
+     * @return the initializers
+     */
     List getInitializer();
+
+    /**
+     * Returns the condition of the {@code for} statement.
+     * May be {@code null} if there is no condition.
+     * @return the condition
+     */
     ExpressionTree getCondition();
+
+    /**
+     * Returns any update expressions of the {@code for} statement.
+     * @return the update expressions
+     */
     List getUpdate();
+
+    /**
+     * Returns the body of the {@code for} statement.
+     * @return the body
+     */
     StatementTree getStatement();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java b/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java
index 2a1c484ae43..3f2a2f49249 100644
--- a/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/IdentifierTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -43,5 +43,9 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface IdentifierTree extends ExpressionTree {
+    /**
+     * Returns the name of the identifier.
+     * @return the name
+     */
     Name getName();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/IfTree.java b/langtools/src/share/classes/com/sun/source/tree/IfTree.java
index 227d9185510..f5790c7ea93 100644
--- a/langtools/src/share/classes/com/sun/source/tree/IfTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/IfTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for an 'if' statement.
+ * A tree node for an {@code if} statement.
  *
  * For example:
  * 
@@ -47,10 +47,22 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface IfTree extends StatementTree {
-    ExpressionTree getCondition();
-    StatementTree getThenStatement();
     /**
-     * @return null if this if statement has no else branch.
+     * Returns the condition of the if-statement.
+     * @return the condition
+     */
+    ExpressionTree getCondition();
+
+    /**
+     * Returns the statement to be executed if the condition is true
+     * @return the statement to be executed if the condition is true
+     */
+    StatementTree getThenStatement();
+
+    /**
+     * Returns the statement to be executed if the condition is false,
+     * or {@code null} if there is no such statement.
+     * @return the statement to be executed if the condition is false
      */
     StatementTree getElseStatement();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ImportTree.java b/langtools/src/share/classes/com/sun/source/tree/ImportTree.java
index 46cd1a89fd6..dfd57e5496b 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ImportTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ImportTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -43,10 +43,19 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ImportTree extends Tree {
-    boolean isStatic();
     /**
-     * @return a qualified identifier ending in "*" if and only if
-     * this is an import-on-demand.
+     * Returns true if this is a static import declaration.
+     * @return true if this is a static import
+     */
+    boolean isStatic();
+
+    /**
+     * Returns the qualified identifier for the declaration(s)
+     * being imported.
+     * If this is an import-on-demand declaration, the
+     * qualified identifier will end in "*".
+     * @return a qualified identifier, ending in "*" if and only if
+     * this is an import-on-demand
      */
     Tree getQualifiedIdentifier();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java b/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java
index b8e81006e0d..7766482daf1 100644
--- a/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/InstanceOfTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for an 'instanceof' expression.
+ * A tree node for an {@code instanceof} expression.
  *
  * For example:
  * 
@@ -41,6 +41,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface InstanceOfTree extends ExpressionTree {
+    /**
+     * Returns the expression to be tested.
+     * @return the expression
+     */
     ExpressionTree getExpression();
+
+    /**
+     * Returns the type for which to check.
+     * @return the type
+     */
     Tree getType();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java
index 147571ed7fc..0b2790a784e 100644
--- a/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/IntersectionTypeTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -36,5 +36,9 @@ import java.util.List;
  */
 @jdk.Exported
 public interface IntersectionTypeTree extends Tree {
+    /**
+     * Returns the bounds of the type.
+     * @return the bounds
+     */
     List getBounds();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java b/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java
index 424cc20b3fa..3fe724e01f7 100644
--- a/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/LabeledStatementTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -43,6 +43,15 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface LabeledStatementTree extends StatementTree {
+    /**
+     * Returns the label.
+     * @return the label
+     */
     Name getLabel();
+
+    /**
+     * Returns the statement that is labeled.
+     * @return the statement
+     */
     StatementTree getStatement();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
index 9854cc248ed..9f3c988d1cb 100644
--- a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -41,8 +41,11 @@ import java.util.List;
 public interface LambdaExpressionTree extends ExpressionTree {
 
     /**
-     * Lambda expressions come in two forms: (i) expression lambdas, whose body
-     * is an expression, and (ii) statement lambdas, whose body is a block
+     * Lambda expressions come in two forms:
+     * 
    + *
  • expression lambdas, whose body is an expression, and + *
  • statement lambdas, whose body is a block + *
*/ @jdk.Exported public enum BodyKind { @@ -52,7 +55,21 @@ public interface LambdaExpressionTree extends ExpressionTree { STATEMENT } + /** + * Returns the parameters of this lambda expression. + * @return the parameters + */ List getParameters(); + + /** + * Returns the body of the lambda expression. + * @return the body + */ Tree getBody(); + + /** + * Returns the kind of the body of the lambda expression. + * @return the kind of the body + */ BodyKind getBodyKind(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/LineMap.java b/langtools/src/share/classes/com/sun/source/tree/LineMap.java index f8b2ccab588..7a396d1270f 100644 --- a/langtools/src/share/classes/com/sun/source/tree/LineMap.java +++ b/langtools/src/share/classes/com/sun/source/tree/LineMap.java @@ -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 @@ -34,7 +34,7 @@ package com.sun.source.tree; @jdk.Exported public interface LineMap { /** - * Find the start position of a line. + * Finds the start position of a line. * * @param line line number (beginning at 1) * @return position of first character in line @@ -45,7 +45,7 @@ public interface LineMap { long getStartPosition(long line); /** - * Find the position corresponding to a (line,column). + * Finds the position corresponding to a (line,column). * * @param line line number (beginning at 1) * @param column tab-expanded column number (beginning 1) @@ -58,7 +58,7 @@ public interface LineMap { long getPosition(long line, long column); /** - * Find the line containing a position; a line termination + * Finds the line containing a position; a line termination * character is on the line it terminates. * * @param pos character offset of the position @@ -67,7 +67,7 @@ public interface LineMap { long getLineNumber(long pos); /** - * Find the column for a character position. + * Finds the column for a character position. * Tab characters preceding the position on the same line * will be expanded when calculating the column number. * diff --git a/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java b/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java index b166051765d..4c8fa521e81 100644 --- a/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/LiteralTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -42,5 +42,10 @@ package com.sun.source.tree; */ @jdk.Exported public interface LiteralTree extends ExpressionTree { + /** + * Returns the value of the literal expression. + * The value will be a boxed primitive value, a String, or {@code null}. + * @return the value + */ Object getValue(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java index 939c0c6f8e2..23c77bfb21c 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -48,13 +48,33 @@ public interface MemberReferenceTree extends ExpressionTree { */ @jdk.Exported public enum ReferenceMode { - /** enum constant for method references */ + /** enum constant for method references. */ INVOKE, - /** enum constant for constructor references */ + /** enum constant for constructor references. */ NEW } + + /** + * Returns the mode of the reference. + * @return the mode + */ ReferenceMode getMode(); + + /** + * Returns the qualifier expression for the reference. + * @return the qualifier expression + */ ExpressionTree getQualifierExpression(); + + /** + * Returns the name of the reference. + * @return the name + */ Name getName(); + + /** + * Returns the type arguments for the reference. + * @return the type arguments + */ List getTypeArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java b/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java index d40a6a31060..dac747208fc 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MemberSelectTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -43,6 +43,15 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface MemberSelectTree extends ExpressionTree { + /** + * Returns the expression for which a member is to be selected. + * @return the expression. + */ ExpressionTree getExpression(); + + /** + * Returns the name of the member to be selected. + * @return the member + */ Name getIdentifier(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java b/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java index 1b6ae1332ab..3e7088b6dd0 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MethodInvocationTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -45,7 +45,21 @@ import java.util.List; */ @jdk.Exported public interface MethodInvocationTree extends ExpressionTree { + /** + * Returns the type arguments for this method invocation. + * @return the type arguments + */ List getTypeArguments(); + + /** + * Returns the expression identifying the method to be invoked. + * @return the method selection expression + */ ExpressionTree getMethodSelect(); + + /** + * Returns the arguments for the method invocation. + * @return the arguments + */ List getArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java index bef5d8b3e0b..f16c521953b 100644 --- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -48,21 +48,63 @@ import javax.lang.model.element.Name; */ @jdk.Exported public interface MethodTree extends Tree { + /** + * Returns the modifiers, including any annotations for the method being declared. + * @return the modifiers + */ ModifiersTree getModifiers(); + + /** + * Returns the name of the method being declared. + * @return the name + */ Name getName(); + + /** + * Returns the return type of the method being declared. + * Returns {@code null} for a constructor. + * @return the return type + */ Tree getReturnType(); + + /** + * Returns the type parameters of the method being declared. + * @return the type parameters + */ List getTypeParameters(); + + /** + * Returns the parameters of the method being declared. + * @return the parameters + */ List getParameters(); /** - * Return an explicit receiver parameter ("this" parameter). + * Return an explicit receiver parameter ("this" parameter), + * or {@code null} if none. * * @return an explicit receiver parameter ("this" parameter) * @since 1.8 */ VariableTree getReceiverParameter(); + /** + * Returns the exceptions listed as being thrown by this method. + * @return the exceptions + */ List getThrows(); + + /** + * Returns the method body, or {@code null} if this is an abstract or native method. + * @return the method body + */ BlockTree getBody(); + + /** + * Returns the default value, if this is an element within + * an annotation type declaration. + * Returns {@code null} otherwise. + * @return the default value + */ Tree getDefaultValue(); // for annotation types } diff --git a/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java b/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java index ea22e06b777..1dd45fb0ebc 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ModifiersTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -47,6 +47,15 @@ import javax.lang.model.element.Modifier; */ @jdk.Exported public interface ModifiersTree extends Tree { + /** + * Returns the flags in this modifiers tree. + * @return the flags + */ Set getFlags(); + + /** + * Returns the annotations in this modifiers tree. + * @return the annotations + */ List getAnnotations(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java index 01236e71516..beea5bb23f3 100644 --- a/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/NewArrayTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -45,9 +45,37 @@ import java.util.List; */ @jdk.Exported public interface NewArrayTree extends ExpressionTree { + /** + * Returns the base type of the expression. + * May be {@code null} for an array initializer expression. + * @return the base type + */ Tree getType(); + + /** + * Returns the dimension expressions for the type. + * + * @return the dimension expressions + */ List getDimensions(); + + /** + * Returns the initializer expressions. + * + * @return the initializer expressions + */ List getInitializers(); + + /** + * Returns the annotations on the base type. + * @return the annotations + */ List getAnnotations(); + + /** + * Returns the annotations on each of the dimension + * expressions. + * @return the annotations on the dimensions expressions + */ List> getDimAnnotations(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java b/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java index a30cb30f9a6..b82faaf9669 100644 --- a/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/NewClassTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -50,9 +50,34 @@ import java.util.List; */ @jdk.Exported public interface NewClassTree extends ExpressionTree { + /** + * Returns the enclosing expression, or {@code null} if none. + * @return the enclosing expression + */ ExpressionTree getEnclosingExpression(); + + /** + * Returns the type arguments for the object being created. + * @return the type arguments + */ List getTypeArguments(); + + /** + * Returns the name of the class being instantiated. + * @return the name + */ ExpressionTree getIdentifier(); + + /** + * Returns the arguments for the constructor to be invoked. + * @return the arguments + */ List getArguments(); + + /** + * Returns the class body if an anonymous class is being + * instantiated, and {@code null} otherwise. + * @return the class body + */ ClassTree getClassBody(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/PackageTree.java b/langtools/src/share/classes/com/sun/source/tree/PackageTree.java index c2d822e8b05..8d722f6afb2 100644 --- a/langtools/src/share/classes/com/sun/source/tree/PackageTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/PackageTree.java @@ -37,6 +37,15 @@ import java.util.List; */ @jdk.Exported public interface PackageTree extends Tree { + /** + * Returns the annotations associated with this package declaration. + * @return the annotations + */ List getAnnotations(); + + /** + * Returns the name of the package being declared. + * @return the name + */ ExpressionTree getPackageName(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java index d054dbd3be8..99f5b751289 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ParameterizedTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -43,6 +43,15 @@ import java.util.List; */ @jdk.Exported public interface ParameterizedTypeTree extends Tree { + /** + * Returns the base type. + * @return the base type + */ Tree getType(); + + /** + * Returns the type arguments. + * @return the type arguments + */ List getTypeArguments(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java b/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java index 7c9392421ed..02eb7b3cc01 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ParenthesizedTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -42,5 +42,9 @@ package com.sun.source.tree; */ @jdk.Exported public interface ParenthesizedTree extends ExpressionTree { + /** + * Returns the expression within the parentheses. + * @return the expression + */ ExpressionTree getExpression(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java index 1c07a037875..4d509a7fb4e 100644 --- a/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/PrimitiveTypeTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -43,5 +43,9 @@ import javax.lang.model.type.TypeKind; */ @jdk.Exported public interface PrimitiveTypeTree extends Tree { + /** + * Returns the kind of this primitive type. + * @return the kind of the type + */ TypeKind getPrimitiveTypeKind(); } diff --git a/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java b/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java index 8fa16800e37..6f58574436e 100644 --- a/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java +++ b/langtools/src/share/classes/com/sun/source/tree/ReturnTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,7 +26,7 @@ package com.sun.source.tree; /** - * A tree node for a 'return' statement. + * A tree node for a {@code return} statement. * * For example: *
@@ -42,5 +42,9 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ReturnTree extends StatementTree {
+    /**
+     * Returns the expression to be returned.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/Scope.java b/langtools/src/share/classes/com/sun/source/tree/Scope.java
index 071ec963f58..e30d9279755 100644
--- a/langtools/src/share/classes/com/sun/source/tree/Scope.java
+++ b/langtools/src/share/classes/com/sun/source/tree/Scope.java
@@ -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
@@ -52,21 +52,25 @@ import javax.lang.model.element.TypeElement;
 public interface Scope {
     /**
      * Returns the enclosing scope.
+     * @return the enclosing scope
      */
     public Scope getEnclosingScope();
 
     /**
-     * Returns the innermost type element containing the position of this scope
+     * Returns the innermost type element containing the position of this scope.
+     * @return the innermost enclosing type element
      */
     public TypeElement getEnclosingClass();
 
     /**
      * Returns the innermost executable element containing the position of this scope.
+     * @return the innermost enclosing method declaration
      */
     public ExecutableElement getEnclosingMethod();
 
     /**
      * Returns the elements directly contained in this scope.
+     * @return the elements contained in this scope
      */
     public Iterable getLocalElements();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java b/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java
index cc1dbdd2697..76e90885ead 100644
--- a/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/SwitchTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@ package com.sun.source.tree;
 import java.util.List;
 
 /**
- * A tree node for a 'switch' statement.
+ * A tree node for a {@code switch} statement.
  *
  * For example:
  * 
@@ -45,6 +45,15 @@ import java.util.List;
  */
 @jdk.Exported
 public interface SwitchTree extends StatementTree {
+    /**
+     * Returns the expression for the {@code switch} statement.
+     * @return the expression
+     */
     ExpressionTree getExpression();
+
+    /**
+     * Returns the cases for the {@code switch} statement.
+     * @return the cases
+     */
     List getCases();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java b/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java
index afdd12612ce..cb72cf731c8 100644
--- a/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/SynchronizedTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for a 'synchronized' statement.
+ * A tree node for a {@code synchronized} statement.
  *
  * For example:
  * 
@@ -42,6 +42,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface SynchronizedTree extends StatementTree {
+    /**
+     * Returns the expression on which to synchronize.
+     * @return the expression
+     */
     ExpressionTree getExpression();
+
+    /**
+     * Returns the block of the {@code synchronized} statement.
+     * @return the block
+     */
     BlockTree getBlock();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java b/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java
index 8348168c46c..af319f3ffe9 100644
--- a/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/ThrowTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for a 'throw' statement.
+ * A tree node for a {@code throw} statement.
  *
  * For example:
  * 
@@ -41,5 +41,9 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface ThrowTree extends StatementTree {
+    /**
+     * Returns the expression to be thrown.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java
index de3166dc5ad..8c6b08803ad 100644
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -47,7 +47,10 @@ public interface Tree {
      */
     @jdk.Exported
     public enum Kind {
-
+        /**
+         * Used for instances of {@link AnnotatedTypeTree}
+         * representing annotated types.
+         */
         ANNOTATED_TYPE(AnnotatedTypeTree.class),
 
         /**
@@ -613,6 +616,10 @@ public interface Tree {
             associatedInterface = intf;
         }
 
+        /**
+         * Returns the associated interface type that uses this kind.
+         * @return the associated interface
+         */
         public Class asInterface() {
             return associatedInterface;
         }
@@ -621,7 +628,7 @@ public interface Tree {
     }
 
     /**
-     * Gets the kind of this tree.
+     * Returns the kind of this tree.
      *
      * @return the kind of this tree.
      */
@@ -633,6 +640,9 @@ public interface Tree {
      *
      * @param  result type of this operation.
      * @param  type of additional data.
+     * @param visitor the visitor to be called
+     * @param data a value to be passed to the visitor
+     * @return the result returned from calling the visitor
      */
      R accept(TreeVisitor visitor, D data);
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java
index db1f32af9ee..8f63188537a 100644
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -58,58 +58,437 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface TreeVisitor {
+    /**
+     * Visits an AnnotatedTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitAnnotatedType(AnnotatedTypeTree node, P p);
+
+    /**
+     * Visits an AnnotatedTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitAnnotation(AnnotationTree node, P p);
+
+    /**
+     * Visits a MethodInvocationTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitMethodInvocation(MethodInvocationTree node, P p);
+
+    /**
+     * Visits an AssertTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitAssert(AssertTree node, P p);
+
+    /**
+     * Visits an AssignmentTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitAssignment(AssignmentTree node, P p);
+
+    /**
+     * Visits a CompoundAssignmentTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitCompoundAssignment(CompoundAssignmentTree node, P p);
+
+    /**
+     * Visits a BinaryTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitBinary(BinaryTree node, P p);
+
+    /**
+     * Visits a BlockTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitBlock(BlockTree node, P p);
+
+    /**
+     * Visits a BreakTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitBreak(BreakTree node, P p);
+
+    /**
+     * Visits a CaseTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitCase(CaseTree node, P p);
+
+    /**
+     * Visits a CatchTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitCatch(CatchTree node, P p);
+
+    /**
+     * Visits a ClassTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitClass(ClassTree node, P p);
+
+    /**
+     * Visits a ConditionalExpressionTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitConditionalExpression(ConditionalExpressionTree node, P p);
+
+    /**
+     * Visits a ContinueTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitContinue(ContinueTree node, P p);
+
+    /**
+     * Visits a DoWhileTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitDoWhileLoop(DoWhileLoopTree node, P p);
+
+    /**
+     * Visits an ErroneousTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitErroneous(ErroneousTree node, P p);
+
+    /**
+     * Visits an ExpressionStatementTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitExpressionStatement(ExpressionStatementTree node, P p);
+
+    /**
+     * Visits an EnhancedForLoopTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitEnhancedForLoop(EnhancedForLoopTree node, P p);
+
+    /**
+     * Visits a ForLoopTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitForLoop(ForLoopTree node, P p);
+
+    /**
+     * Visits an IdentifierTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitIdentifier(IdentifierTree node, P p);
+
+    /**
+     * Visits an IfTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitIf(IfTree node, P p);
+
+    /**
+     * Visits an ImportTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitImport(ImportTree node, P p);
+
+    /**
+     * Visits an ArrayAccessTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitArrayAccess(ArrayAccessTree node, P p);
+
+    /**
+     * Visits a LabeledStatementTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitLabeledStatement(LabeledStatementTree node, P p);
+
+    /**
+     * Visits a LiteralTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitLiteral(LiteralTree node, P p);
+
+    /**
+     * Visits a MethodTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitMethod(MethodTree node, P p);
+
+    /**
+     * Visits a ModifiersTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitModifiers(ModifiersTree node, P p);
+
+    /**
+     * Visits a NewArrayTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitNewArray(NewArrayTree node, P p);
+
+    /**
+     * Visits a NewClassTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitNewClass(NewClassTree node, P p);
+
+    /**
+     * Visits a LambdaExpressionTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitLambdaExpression(LambdaExpressionTree node, P p);
+
+    /**
+     * Visits a PackageTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitPackage(PackageTree node, P p);
+
+    /**
+     * Visits a ParenthesizedTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitParenthesized(ParenthesizedTree node, P p);
+
+    /**
+     * Visits a ReturnTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitReturn(ReturnTree node, P p);
+
+    /**
+     * Visits a MemberSelectTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitMemberSelect(MemberSelectTree node, P p);
+
+    /**
+     * Visits a MemberReferenceTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitMemberReference(MemberReferenceTree node, P p);
+
+    /**
+     * Visits an EmptyStatementTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitEmptyStatement(EmptyStatementTree node, P p);
+
+    /**
+     * Visits a SwitchTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitSwitch(SwitchTree node, P p);
+
+    /**
+     * Visits a SynchronizedTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitSynchronized(SynchronizedTree node, P p);
+
+    /**
+     * Visits a ThrowTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitThrow(ThrowTree node, P p);
+
+    /**
+     * Visits a CompilationUnitTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitCompilationUnit(CompilationUnitTree node, P p);
+
+    /**
+     * Visits a TryTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitTry(TryTree node, P p);
+
+    /**
+     * Visits a ParameterizedTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitParameterizedType(ParameterizedTypeTree node, P p);
+
+    /**
+     * Visits a UnionTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitUnionType(UnionTypeTree node, P p);
+
+    /**
+     * Visits an IntersectionTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitIntersectionType(IntersectionTypeTree node, P p);
+
+    /**
+     * Visits an ArrayTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitArrayType(ArrayTypeTree node, P p);
+
+    /**
+     * Visits a TypeCastTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitTypeCast(TypeCastTree node, P p);
+
+    /**
+     * Visits a PrimitiveTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitPrimitiveType(PrimitiveTypeTree node, P p);
+
+    /**
+     * Visits a TypeParameterTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitTypeParameter(TypeParameterTree node, P p);
+
+    /**
+     * Visits an InstanceOfTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitInstanceOf(InstanceOfTree node, P p);
+
+    /**
+     * Visits a UnaryTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitUnary(UnaryTree node, P p);
+
+    /**
+     * Visits a VariableTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitVariable(VariableTree node, P p);
+
+    /**
+     * Visits a WhileLoopTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitWhileLoop(WhileLoopTree node, P p);
+
+    /**
+     * Visits a WildcardTypeTree node.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitWildcard(WildcardTree node, P p);
+
+    /**
+     * Visits an unknown type of Tree node.
+     * This can occur if the language evolves and new kinds
+     * of nodes are added to the {@code Tree} hierarchy.
+     * @param node the node being visited
+     * @param p a parameter value
+     * @return a result value
+     */
     R visitOther(Tree node, P p);
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/TryTree.java b/langtools/src/share/classes/com/sun/source/tree/TryTree.java
index 2ca79cfa82e..a02e2e5f0be 100644
--- a/langtools/src/share/classes/com/sun/source/tree/TryTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/TryTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -28,7 +28,7 @@ package com.sun.source.tree;
 import java.util.List;
 
 /**
- * A tree node for a 'try' statement.
+ * A tree node for a {@code try} statement.
  *
  * For example:
  * 
@@ -47,8 +47,33 @@ import java.util.List;
  */
 @jdk.Exported
 public interface TryTree extends StatementTree {
+    /**
+     * Returns the block of the {@code try} statement.
+     * @return the block
+     */
     BlockTree getBlock();
+
+    /**
+     * Returns any catch blocks provided in the {@code try} statement.
+     * The result will be an empty list if there are no
+     * catch blocks.
+     * @return the catch blocks
+     */
     List getCatches();
+
+    /**
+     * Returns the finally block provided in the {@code try} statement,
+     * or {@code null} if there is none.
+     * @return the finally block
+     */
     BlockTree getFinallyBlock();
+
+
+    /**
+     * Returns any resource declarations provided in the {@code try} statement.
+     * The result will be an empty list if there are no
+     * resource declarations.
+     * @return the resource declarations
+     */
     List getResources();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java b/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java
index 6464e4bdc11..23d14e86a6f 100644
--- a/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeCastTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -41,6 +41,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface TypeCastTree extends ExpressionTree {
+    /**
+     * Returns the target type of the cast.
+     * @return the cast
+     */
     Tree getType();
+
+    /**
+     * Returns the expression being cast.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java
index 2737dff3f96..5ffd552ac3d 100644
--- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -48,11 +48,20 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface TypeParameterTree extends Tree {
+    /**
+     * Returns the name of the type parameter.
+     * @return the name
+     */
     Name getName();
+
+    /**
+     * Returns the bounds of the type parameter.
+     * @return the bounds
+     */
     List getBounds();
 
     /**
-     * Return annotations on the type parameter declaration.
+     * Returns annotations on the type parameter declaration.
      *
      * Annotations need Target meta-annotations of
      * {@link java.lang.annotation.ElementType#TYPE_PARAMETER} or
diff --git a/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java b/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java
index 3dfbedd46ce..c9ad9210345 100644
--- a/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/UnaryTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -44,5 +44,9 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface UnaryTree extends ExpressionTree {
+    /**
+     * Returns the expression that is the operand of the unary operator.
+     * @return the expression
+     */
     ExpressionTree getExpression();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java b/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java
index 97da031feb5..544366844d2 100644
--- a/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/UnionTypeTree.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
@@ -28,7 +28,8 @@ package com.sun.source.tree;
 import java.util.List;
 
 /**
- * A tree node for a union type expression in a multicatch var declaration.
+ * A tree node for a union type expression in a multicatch
+ * variable declaration.
  *
  * @author Maurizio Cimadamore
  *
@@ -36,5 +37,9 @@ import java.util.List;
  */
 @jdk.Exported
 public interface UnionTypeTree extends Tree {
+    /**
+     * Returns the alternative type expressions.
+     * @return the alternative type expressions
+     */
     List getTypeAlternatives();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java
index de60550b0b8..203178b5976 100644
--- a/langtools/src/share/classes/com/sun/source/tree/VariableTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/VariableTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -44,9 +44,35 @@ import javax.lang.model.element.Name;
  */
 @jdk.Exported
 public interface VariableTree extends StatementTree {
+    /**
+     * Returns the modifiers, including any annotations, on the declaration.
+     * @return the modifiers
+     */
     ModifiersTree getModifiers();
+
+    /**
+     * Returns the name of the variable being declared.
+     * @return the name
+     */
     Name getName();
+
+    /**
+     * Returns the qualified identifier for the name being "declared".
+     * This is only used in certain cases for the receiver of a
+     * method declaration. Returns {@code null} in all other cases.
+     * @return the qualified identifier of a receiver declaration
+     */
     ExpressionTree getNameExpression();
+
+    /**
+     * Returns the type of the variable being declared.
+     * @return the type
+     */
     Tree getType();
+
+    /**
+     * Returns the initializer for the variable, or {@code null} if none.
+     * @return the initializer
+     */
     ExpressionTree getInitializer();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java b/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java
index 30dcf30cc10..e59a8d27a14 100644
--- a/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/WhileLoopTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +26,7 @@
 package com.sun.source.tree;
 
 /**
- * A tree node for a 'while' loop statement.
+ * A tree node for a {@code while} loop statement.
  *
  * For example:
  * 
@@ -43,6 +43,15 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface WhileLoopTree extends StatementTree {
+    /**
+     * Returns the condition of the loop.
+     * @return the condition
+     */
     ExpressionTree getCondition();
+
+    /**
+     * Returns the body of the loop.
+     * @return the body of the loop
+     */
     StatementTree getStatement();
 }
diff --git a/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java b/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java
index 4b87891798b..3fad97bdec2 100644
--- a/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/WildcardTree.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -46,5 +46,9 @@ package com.sun.source.tree;
  */
 @jdk.Exported
 public interface WildcardTree extends Tree {
+    /**
+     * Returns the bound of the wildcard.
+     * @return the bound
+     */
     Tree getBound();
 }
diff --git a/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java b/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java
index dc0eaa46423..a6d5c8d9f9b 100644
--- a/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java
+++ b/langtools/src/share/classes/com/sun/source/util/DocSourcePositions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -40,7 +40,7 @@ import com.sun.source.tree.CompilationUnitTree;
 public interface DocSourcePositions extends SourcePositions {
 
     /**
-     * Gets the starting position of the tree within the comment within the file.  If tree is not found within
+     * Returns the starting position of the tree within the comment within the file.  If tree is not found within
      * file, or if the starting position is not available,
      * return {@link javax.tools.Diagnostic#NOPOS}.
      * The given tree should be under the given comment tree, and the given documentation
@@ -64,7 +64,7 @@ public interface DocSourcePositions extends SourcePositions {
     long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
 
     /**
-     * Gets the ending position of the tree within the comment within the file.  If tree is not found within
+     * Returns the ending position of the tree within the comment within the file.  If tree is not found within
      * file, or if the ending position is not available,
      * return {@link javax.tools.Diagnostic#NOPOS}.
      * The given tree should be under the given comment tree, and the given documentation
diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreePath.java b/langtools/src/share/classes/com/sun/source/util/DocTreePath.java
index 3a801aae761..b2b53ff3347 100644
--- a/langtools/src/share/classes/com/sun/source/util/DocTreePath.java
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreePath.java
@@ -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
@@ -38,16 +38,23 @@ import java.util.Iterator;
 @jdk.Exported
 public class DocTreePath implements Iterable {
     /**
-     * Gets a documentation tree path for a tree node within a compilation unit.
-     * @return null if the node is not found
+     * Returns a documentation tree path for a tree node within a compilation unit,
+     * or {@code null} if the node is not found.
+     * @param treePath the path for the node with which the doc comment is associated
+     * @param doc the doc comment associated with the node
+     * @param target a node within the doc comment
+     * @return a path identifying the target within the tree
      */
     public static DocTreePath getPath(TreePath treePath, DocCommentTree doc, DocTree target) {
         return getPath(new DocTreePath(treePath, doc), target);
     }
 
     /**
-     * Gets a documentation tree path for a tree node within a subtree identified by a DocTreePath object.
-     * @return null if the node is not found
+     * Returns a documentation tree path for a tree node within a subtree
+     * identified by a DocTreePath object, or {@code null} if the node is not found.
+     * @param path a path identifying a node within a doc comment tree
+     * @param target a node to be located within the given node
+     * @return a path identifying the target node
      */
     public static DocTreePath getPath(DocTreePath path, DocTree target) {
         path.getClass();
@@ -100,6 +107,8 @@ public class DocTreePath implements Iterable {
 
     /**
      * Creates a DocTreePath for a child node.
+     * @param p the parent node
+     * @param t the child node
      */
     public DocTreePath(DocTreePath p, DocTree t) {
         if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
@@ -113,31 +122,31 @@ public class DocTreePath implements Iterable {
     }
 
     /**
-     * Get the TreePath associated with this path.
-     * @return TreePath for this DocTreePath
+     * Returns the TreePath associated with this path.
+     * @return the TreePath for this DocTreePath
      */
     public TreePath getTreePath() {
         return treePath;
     }
 
     /**
-     * Get the DocCommentTree associated with this path.
-     * @return DocCommentTree for this DocTreePath
+     * Returns the DocCommentTree associated with this path.
+     * @return the DocCommentTree for this DocTreePath
      */
     public DocCommentTree getDocComment() {
         return docComment;
     }
 
     /**
-     * Get the leaf node for this path.
-     * @return DocTree for this DocTreePath
+     * Returns the leaf node for this path.
+     * @return the DocTree for this DocTreePath
      */
     public DocTree getLeaf() {
         return leaf;
     }
 
     /**
-     * Get the path for the enclosing node, or null if there is no enclosing node.
+     * Returns the path for the enclosing node, or {@code null} if there is no enclosing node.
      * @return DocTreePath of parent
      */
     public DocTreePath getParentPath() {
diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java
index d069a349619..42d8414e703 100644
--- a/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreePathScanner.java
@@ -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
@@ -39,7 +39,10 @@ import com.sun.source.doctree.DocTree;
 @jdk.Exported
 public class DocTreePathScanner extends DocTreeScanner {
     /**
-     * Scan a tree from a position identified by a TreePath.
+     * Scans a tree from a position identified by a tree path.
+     * @param path the path
+     * @param p a value to be passed to visitor methods
+     * @return the result returned from the main visitor method
      */
     public R scan(DocTreePath path, P p) {
         this.path = path;
@@ -51,8 +54,11 @@ public class DocTreePathScanner extends DocTreeScanner {
     }
 
     /**
-     * Scan a single node.
+     * Scans a single node.
      * The current path is updated for the duration of the scan.
+     * @param tree the tree to be scanned
+     * @param p a value to be passed to visitor methods
+     * @return the result returned from the main visitor method
      */
     @Override
     public R scan(DocTree tree, P p) {
@@ -69,8 +75,9 @@ public class DocTreePathScanner extends DocTreeScanner {
     }
 
     /**
-     * Get the current path for the node, as built up by the currently
+     * Returns the current path for the node, as built up by the currently
      * active set of scan calls.
+     * @return the current path
      */
     public DocTreePath getCurrentPath() {
         return path;
diff --git a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java
index 19f0b09a670..55fe6e14541 100644
--- a/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java
+++ b/langtools/src/share/classes/com/sun/source/util/DocTreeScanner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -38,7 +38,7 @@ import com.sun.source.doctree.*;
  * 

The default implementation of the visitXYZ methods will determine * a result as follows: *

    - *
  • If the node being visited has no children, the result will be null. + *
  • If the node being visited has no children, the result will be {@code null}. *
  • If the node being visited has one child, the result will be the * result of calling {@code scan} on that child. The child may be a simple node * or itself a list of nodes. @@ -71,7 +71,10 @@ import com.sun.source.doctree.*; public class DocTreeScanner implements DocTreeVisitor { /** - * Scan a single node. + * Scans a single node. + * @param node the node to be scanned + * @param p a parameter value passed to the visit method + * @return the result value from the visit method */ public R scan(DocTree node, P p) { return (node == null) ? null : node.accept(this, p); @@ -82,7 +85,11 @@ public class DocTreeScanner implements DocTreeVisitor { } /** - * Scan a list of nodes. + * Scans a sequence of nodes. + * @param nodes the nodes to be scanned + * @param p a parameter value to be passed to the visit method for each node + * @return the combined return value from the visit methods. + * The values are combined using the {@link #reduce reduce} method. */ public R scan(Iterable nodes, P p) { R r = null; @@ -104,6 +111,9 @@ public class DocTreeScanner implements DocTreeVisitor { * Reduces two results into a combined result. * The default implementation is to return the first parameter. * The general contract of the method is that it may take any action whatsoever. + * @param r1 the first of the values to be combined + * @param r2 the second of the values to be combined + * @return the result of combining the two parameters */ public R reduce(R r1, R r2) { return r1; @@ -114,26 +124,61 @@ public class DocTreeScanner implements DocTreeVisitor { * Visitor methods ****************************************************************************/ + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitAttribute(AttributeTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitAuthor(AuthorTree node, P p) { return scan(node.getName(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitComment(CommentTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitDeprecated(DeprecatedTree node, P p) { return scan(node.getBody(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitDocComment(DocCommentTree node, P p) { R r = scan(node.getFirstSentence(), p); @@ -142,36 +187,85 @@ public class DocTreeScanner implements DocTreeVisitor { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitDocRoot(DocRootTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitEndElement(EndElementTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitEntity(EntityTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitErroneous(ErroneousTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitIdentifier(IdentifierTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitInheritDoc(InheritDocTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitLink(LinkTree node, P p) { R r = scan(node.getReference(), p); @@ -179,11 +273,25 @@ public class DocTreeScanner implements DocTreeVisitor { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitLiteral(LiteralTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitParam(ParamTree node, P p) { R r = scan(node.getName(), p); @@ -191,31 +299,73 @@ public class DocTreeScanner implements DocTreeVisitor { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitReference(ReferenceTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitReturn(ReturnTree node, P p) { return scan(node.getDescription(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSee(SeeTree node, P p) { return scan(node.getReference(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSerial(SerialTree node, P p) { return scan(node.getDescription(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSerialData(SerialDataTree node, P p) { return scan(node.getDescription(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSerialField(SerialFieldTree node, P p) { R r = scan(node.getName(), p); @@ -224,21 +374,49 @@ public class DocTreeScanner implements DocTreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitSince(SinceTree node, P p) { return scan(node.getBody(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitStartElement(StartElementTree node, P p) { return scan(node.getAttributes(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitText(TextTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitThrows(ThrowsTree node, P p) { R r = scan(node.getExceptionName(), p); @@ -246,26 +424,61 @@ public class DocTreeScanner implements DocTreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) { return scan(node.getContent(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) { return scan(node.getContent(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitValue(ValueTree node, P p) { return scan(node.getReference(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitVersion(VersionTree node, P p) { return scan(node.getBody(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ @Override public R visitOther(DocTree node, P p) { return null; diff --git a/langtools/src/share/classes/com/sun/source/util/DocTrees.java b/langtools/src/share/classes/com/sun/source/util/DocTrees.java index b8d076a4d89..2000a117b8b 100644 --- a/langtools/src/share/classes/com/sun/source/util/DocTrees.java +++ b/langtools/src/share/classes/com/sun/source/util/DocTrees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -40,8 +40,9 @@ import javax.tools.Diagnostic; @jdk.Exported public abstract class DocTrees extends Trees { /** - * Gets a DocTrees object for a given CompilationTask. + * Returns a DocTrees object for a given CompilationTask. * @param task the compilation task for which to get the Trees object + * @return the DocTrees object * @throws IllegalArgumentException if the task does not support the Trees API. */ public static DocTrees instance(CompilationTask task) { @@ -49,8 +50,9 @@ public abstract class DocTrees extends Trees { } /** - * Gets a DocTrees object for a given ProcessingEnvironment. + * Returns a DocTrees object for a given ProcessingEnvironment. * @param env the processing environment for which to get the Trees object + * @return the DocTrees object * @throws IllegalArgumentException if the env does not support the Trees API. */ public static DocTrees instance(ProcessingEnvironment env) { @@ -60,17 +62,26 @@ public abstract class DocTrees extends Trees { } /** - * Gets the doc comment tree, if any, for the Tree node identified by a given TreePath. - * Returns null if no doc comment was found. + * Returns the doc comment tree, if any, for the Tree node identified by a given TreePath. + * Returns {@code null} if no doc comment was found. + * @param path the path for the tree node + * @return the doc comment tree */ public abstract DocCommentTree getDocCommentTree(TreePath path); /** - * Gets the language model element referred to by the leaf node of the given - * {@link DocTreePath}, or null if unknown. + * Returns the language model element referred to by the leaf node of the given + * {@link DocTreePath}, or {@code null} if unknown. + * @param path the path for the tree node + * @return the element */ public abstract Element getElement(DocTreePath path); + /** + * Returns a utility object for accessing the source positions + * of documentation tree nodes. + * @return the utility object + */ public abstract DocSourcePositions getSourcePositions(); /** @@ -80,6 +91,7 @@ public abstract class DocTrees extends Trees { * @param kind the kind of message * @param msg the message, or an empty string if none * @param t the tree to use as a position hint + * @param c the doc comment tree to use as a position hint * @param root the compilation unit that contains tree */ public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg, diff --git a/langtools/src/share/classes/com/sun/source/util/JavacTask.java b/langtools/src/share/classes/com/sun/source/util/JavacTask.java index b515ddb8e2a..d115f3977be 100644 --- a/langtools/src/share/classes/com/sun/source/util/JavacTask.java +++ b/langtools/src/share/classes/com/sun/source/util/JavacTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -52,7 +52,7 @@ import com.sun.tools.javac.util.Context; public abstract class JavacTask implements CompilationTask { /** - * Get the {@code JavacTask} for a {@code ProcessingEnvironment}. + * Returns the {@code JavacTask} for a {@code ProcessingEnvironment}. * If the compiler is being invoked using a * {@link javax.tools.JavaCompiler.CompilationTask CompilationTask}, * then that task will be returned. @@ -70,7 +70,7 @@ public abstract class JavacTask implements CompilationTask { } /** - * Parse the specified files returning a list of abstract syntax trees. + * Parses the specified files returning a list of abstract syntax trees. * * @return a list of abstract syntax trees * @throws IOException if an unhandled I/O error occurred in the compiler. @@ -80,7 +80,7 @@ public abstract class JavacTask implements CompilationTask { throws IOException; /** - * Complete all analysis. + * Completes all analysis. * * @return a list of elements that were analyzed * @throws IOException if an unhandled I/O error occurred in the compiler. @@ -89,7 +89,7 @@ public abstract class JavacTask implements CompilationTask { public abstract Iterable analyze() throws IOException; /** - * Generate code. + * Generates code. * * @return a list of files that were generated * @throws IOException if an unhandled I/O error occurred in the compiler. @@ -98,7 +98,7 @@ public abstract class JavacTask implements CompilationTask { public abstract Iterable generate() throws IOException; /** - * The specified listener will receive notification of events + * Sets a specified listener to receive notification of events * describing the progress of this compilation task. * * If another listener is receiving notifications as a result of a prior @@ -108,46 +108,54 @@ public abstract class JavacTask implements CompilationTask { * any listener that has been previously set, followed by {@code addTaskListener} * for the new listener. * + * @param taskListener the task listener * @throws IllegalStateException if the specified listener has already been added. */ public abstract void setTaskListener(TaskListener taskListener); /** - * The specified listener will receive notification of events + * Adds a specified listener so that it receives notification of events * describing the progress of this compilation task. * * This method may be called at any time before or during the compilation. * + * @param taskListener the task listener * @throws IllegalStateException if the specified listener has already been added. * @since 1.8 */ public abstract void addTaskListener(TaskListener taskListener); /** - * The specified listener will no longer receive notification of events - * describing the progress of this compilation task. + * Removes the specified listener so that it no longer receives + * notification of events describing the progress of this + * compilation task. * * This method may be called at any time before or during the compilation. * + * @param taskListener the task listener * @since 1.8 */ public abstract void removeTaskListener(TaskListener taskListener); /** - * Get a type mirror of the tree node determined by the specified path. + * Returns a type mirror of the tree node determined by the specified path. * This method has been superceded by methods on * {@link com.sun.source.util.Trees Trees}. + * @param path the path + * @return the type mirror * @see com.sun.source.util.Trees#getTypeMirror */ public abstract TypeMirror getTypeMirror(Iterable path); /** - * Get a utility object for dealing with program elements. + * Returns a utility object for dealing with program elements. + * @return the utility object for dealing with program elements */ public abstract Elements getElements(); /** - * Get a utility object for dealing with type mirrors. + * Returns a utility object for dealing with type mirrors. + * @return the utility object for dealing with type mirrors */ public abstract Types getTypes(); } diff --git a/langtools/src/share/classes/com/sun/source/util/Plugin.java b/langtools/src/share/classes/com/sun/source/util/Plugin.java index 06f2dafce7c..ccfacfae204 100644 --- a/langtools/src/share/classes/com/sun/source/util/Plugin.java +++ b/langtools/src/share/classes/com/sun/source/util/Plugin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -51,13 +51,13 @@ import javax.tools.StandardLocation; @jdk.Exported public interface Plugin { /** - * Get the user-friendly name of this plug-in. + * Returns the user-friendly name of this plug-in. * @return the user-friendly name of the plug-in */ String getName(); /** - * Initialize the plug-in for a given compilation task. + * Initializes the plug-in for a given compilation task. * @param task The compilation task that has just been started * @param args Arguments, if any, for the plug-in */ diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java index 3072c276902..13bce1293df 100644 --- a/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,28 +30,63 @@ import com.sun.source.doctree.*; /** * A simple visitor for tree nodes. * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * * @since 1.8 */ @jdk.Exported public class SimpleDocTreeVisitor implements DocTreeVisitor { + /** + * The default value, returned by the {@link #defaultAction default action}. + */ protected final R DEFAULT_VALUE; + /** + * Creates a visitor, with a DEFAULT_VALUE of {@code null}. + */ protected SimpleDocTreeVisitor() { DEFAULT_VALUE = null; } + /** + * Creates a visitor, with a specified DEFAULT_VALUE. + * @param defaultValue the default value to be returned by the default action. + */ protected SimpleDocTreeVisitor(R defaultValue) { DEFAULT_VALUE = defaultValue; } + /** + * The default action, used by all visit methods that are not overridden. + * @param node the node being visited + * @param p the parameter value passed to the visit method + * @return the result value to be returned from the visit method + */ protected R defaultAction(DocTree node, P p) { return DEFAULT_VALUE; } + /** + * Invokes the appropriate visit method specific to the type of the node. + * @param node the node on which to dispatch + * @param p a parameter to be passed to the appropriate visit method + * @return the value returns from the appropriate visit method + */ public final R visit(DocTree node, P p) { return (node == null) ? null : node.accept(this, p); } + /** + * Invokes the appropriate visit method on each of a sequence of nodes. + * @param nodes the nodes on which to dispatch + * @param p a parameter value to be passed to each appropriate visit method + * @return the value return from the last of the visit methods, or null + * if none were called. + */ public final R visit(Iterable nodes, P p) { R r = null; if (nodes != null) { @@ -61,118 +96,350 @@ public class SimpleDocTreeVisitor implements DocTreeVisitor { return r; } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAttribute(AttributeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAuthor(AuthorTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitComment(CommentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDeprecated(DeprecatedTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDocComment(DocCommentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDocRoot(DocRootTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEndElement(EndElementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEntity(EntityTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitErroneous(ErroneousTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIdentifier(IdentifierTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitInheritDoc(InheritDocTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLink(LinkTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLiteral(LiteralTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitParam(ParamTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitReference(ReferenceTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitReturn(ReturnTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSee(SeeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSerial(SerialTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSerialData(SerialDataTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSerialField(SerialFieldTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSince(SinceTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitStartElement(StartElementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitText(TextTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitThrows(ThrowsTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnknownBlockTag(UnknownBlockTagTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnknownInlineTag(UnknownInlineTagTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitValue(ValueTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitVersion(VersionTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitOther(DocTree node, P p) { return defaultAction(node, p); } diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java index 19599456959..28bd802f253 100644 --- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java +++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,29 +30,64 @@ import com.sun.source.tree.*; /** * A simple visitor for tree nodes. * + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

    the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * * @author Peter von der Ahé * @since 1.6 */ @jdk.Exported public class SimpleTreeVisitor implements TreeVisitor { + /** + * The default value, returned by the {@link #defaultAction default action}. + */ protected final R DEFAULT_VALUE; + /** + * Creates a visitor, with a DEFAULT_VALUE of {@code null}. + */ protected SimpleTreeVisitor() { DEFAULT_VALUE = null; } + /** + * Creates a visitor, with a specified DEFAULT_VALUE. + * @param defaultValue the default value to be returned by the default action. + */ protected SimpleTreeVisitor(R defaultValue) { DEFAULT_VALUE = defaultValue; } + /** + * The default action, used by all visit methods that are not overridden. + * @param node the node being visited + * @param p the parameter value passed to the visit method + * @return the result value to be returned from the visit method + */ protected R defaultAction(Tree node, P p) { return DEFAULT_VALUE; } + /** + * Invokes the appropriate visit method specific to the type of the node. + * @param node the node on which to dispatch + * @param p a parameter to be passed to the appropriate visit method + * @return the value returns from the appropriate visit method + */ public final R visit(Tree node, P p) { return (node == null) ? null : node.accept(this, p); } + /** + * Invokes the appropriate visit method on each of a sequence of nodes. + * @param nodes the nodes on which to dispatch + * @param p a parameter value to be passed to each appropriate visit method + * @return the value return from the last of the visit methods, or null + * if none were called. + */ public final R visit(Iterable nodes, P p) { R r = null; if (nodes != null) @@ -61,218 +96,650 @@ public class SimpleTreeVisitor implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCompilationUnit(CompilationUnitTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitPackage(PackageTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitImport(ImportTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitClass(ClassTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMethod(MethodTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitVariable(VariableTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEmptyStatement(EmptyStatementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitBlock(BlockTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitDoWhileLoop(DoWhileLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitWhileLoop(WhileLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitForLoop(ForLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLabeledStatement(LabeledStatementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSwitch(SwitchTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCase(CaseTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitSynchronized(SynchronizedTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitTry(TryTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCatch(CatchTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitConditionalExpression(ConditionalExpressionTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIf(IfTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitExpressionStatement(ExpressionStatementTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitBreak(BreakTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitContinue(ContinueTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitReturn(ReturnTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitThrow(ThrowTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAssert(AssertTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMethodInvocation(MethodInvocationTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitNewClass(NewClassTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitNewArray(NewArrayTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLambdaExpression(LambdaExpressionTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitParenthesized(ParenthesizedTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAssignment(AssignmentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnary(UnaryTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitBinary(BinaryTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitTypeCast(TypeCastTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitInstanceOf(InstanceOfTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitArrayAccess(ArrayAccessTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMemberSelect(MemberSelectTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitMemberReference(MemberReferenceTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIdentifier(IdentifierTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitLiteral(LiteralTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitPrimitiveType(PrimitiveTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitArrayType(ArrayTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitParameterizedType(ParameterizedTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitUnionType(UnionTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitIntersectionType(IntersectionTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitTypeParameter(TypeParameterTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitWildcard(WildcardTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitModifiers(ModifiersTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAnnotation(AnnotationTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitAnnotatedType(AnnotatedTypeTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitErroneous(ErroneousTree node, P p) { return defaultAction(node, p); } + /** + * {@inheritDoc} This implementation calls {@code defaultAction}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of {@code defaultAction} + */ + @Override public R visitOther(Tree node, P p) { return defaultAction(node, p); } diff --git a/langtools/src/share/classes/com/sun/source/util/SourcePositions.java b/langtools/src/share/classes/com/sun/source/util/SourcePositions.java index 9c4d02d0ec6..7a2054b3469 100644 --- a/langtools/src/share/classes/com/sun/source/util/SourcePositions.java +++ b/langtools/src/share/classes/com/sun/source/util/SourcePositions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -39,7 +39,7 @@ import com.sun.source.tree.*; public interface SourcePositions { /** - * Gets the starting position of tree within file. If tree is not found within + * Returns the starting position of tree within file. If tree is not found within * file, or if the starting position is not available, * return {@link javax.tools.Diagnostic#NOPOS}. * The returned position must be at the start of the yield of this tree, that @@ -58,7 +58,7 @@ public interface SourcePositions { long getStartPosition(CompilationUnitTree file, Tree tree); /** - * Gets the ending position of tree within file. If tree is not found within + * Returns the ending position of tree within file. If tree is not found within * file, or if the ending position is not available, * return {@link javax.tools.Diagnostic#NOPOS}. * The returned position must be at the end of the yield of this tree, diff --git a/langtools/src/share/classes/com/sun/source/util/TaskEvent.java b/langtools/src/share/classes/com/sun/source/util/TaskEvent.java index 5ecde4d4036..9ead33e0aeb 100644 --- a/langtools/src/share/classes/com/sun/source/util/TaskEvent.java +++ b/langtools/src/share/classes/com/sun/source/util/TaskEvent.java @@ -79,18 +79,45 @@ public final class TaskEvent COMPILATION, } + /** + * Creates a task event for a given kind. + * The source file, compilation unit and type element + * are all set to {@code null}. + * @param kind the kind of the event + */ public TaskEvent(Kind kind) { this(kind, null, null, null); } + /** + * Creates a task event for a given kind and source file. + * The compilation unit and type element are both set to {@code null}. + * @param kind the kind of the event + * @param sourceFile the source file + */ public TaskEvent(Kind kind, JavaFileObject sourceFile) { this(kind, sourceFile, null, null); } + /** + * Creates a task event for a given kind and compilation unit. + * The source file is set from the compilation unit, + * and the type element is set to {@code null}. + * @param kind the kind of the event + * @param unit the compilation unit + */ public TaskEvent(Kind kind, CompilationUnitTree unit) { this(kind, unit.getSourceFile(), unit, null); } + /** + * Creates a task event for a given kind, compilation unit + * and type element. + * The source file is set from the compilation unit. + * @param kind the kind of the event + * @param unit the compilation unit + * @param clazz the type element + */ public TaskEvent(Kind kind, CompilationUnitTree unit, TypeElement clazz) { this(kind, unit.getSourceFile(), unit, clazz); } @@ -102,22 +129,42 @@ public final class TaskEvent this.clazz = clazz; } + /** + * Returns the kind for this event. + * @return the kind + */ public Kind getKind() { return kind; } + /** + * Returns the source file for this event. + * May be {@code null}. + * @return the source file + */ public JavaFileObject getSourceFile() { return file; } + /** + * Returns the compilation unit for this event. + * May be {@code null}. + * @return the compilation unit + */ public CompilationUnitTree getCompilationUnit() { return unit; } + /** + * Returns the type element for this event. + * May be {@code null}. + * @return the type element + */ public TypeElement getTypeElement() { return clazz; } + @Override public String toString() { return "TaskEvent[" + kind + "," diff --git a/langtools/src/share/classes/com/sun/source/util/TaskListener.java b/langtools/src/share/classes/com/sun/source/util/TaskListener.java index 97f31fb5966..7c8f81a6076 100644 --- a/langtools/src/share/classes/com/sun/source/util/TaskListener.java +++ b/langtools/src/share/classes/com/sun/source/util/TaskListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -35,7 +35,15 @@ package com.sun.source.util; @jdk.Exported public interface TaskListener { + /** + * Invoked when an event has begun. + * @param e the event + */ public void started(TaskEvent e); + /** + * Invoked when an event has been completed. + * @param e the event + */ public void finished(TaskEvent e); } diff --git a/langtools/src/share/classes/com/sun/source/util/TreePath.java b/langtools/src/share/classes/com/sun/source/util/TreePath.java index 8c7cb028de5..3178944a4f6 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreePath.java +++ b/langtools/src/share/classes/com/sun/source/util/TreePath.java @@ -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 @@ -39,16 +39,22 @@ import com.sun.source.tree.*; @jdk.Exported public class TreePath implements Iterable { /** - * Gets a tree path for a tree node within a compilation unit. - * @return null if the node is not found + * Returns a tree path for a tree node within a compilation unit, + * or {@code null} if the node is not found. + * @param unit the compilation unit to search + * @param target the node to locate + * @return the tree path */ public static TreePath getPath(CompilationUnitTree unit, Tree target) { return getPath(new TreePath(unit), target); } /** - * Gets a tree path for a tree node within a subtree identified by a TreePath object. - * @return null if the node is not found + * Returns a tree path for a tree node within a subtree identified by a TreePath object. + * Returns {@code null} if the node is not found. + * @param path the path in which to search + * @param target the node to locate + * @return the tree path of the target node */ public static TreePath getPath(TreePath path, Tree target) { path.getClass(); @@ -85,41 +91,47 @@ public class TreePath implements Iterable { /** * Creates a TreePath for a root node. + * @param node the root node */ - public TreePath(CompilationUnitTree t) { - this(null, t); + public TreePath(CompilationUnitTree node) { + this(null, node); } /** * Creates a TreePath for a child node. + * @param path the parent path + * @param tree the child node */ - public TreePath(TreePath p, Tree t) { - if (t.getKind() == Tree.Kind.COMPILATION_UNIT) { - compilationUnit = (CompilationUnitTree) t; + public TreePath(TreePath path, Tree tree) { + if (tree.getKind() == Tree.Kind.COMPILATION_UNIT) { + compilationUnit = (CompilationUnitTree) tree; parent = null; } else { - compilationUnit = p.compilationUnit; - parent = p; + compilationUnit = path.compilationUnit; + parent = path; } - leaf = t; + leaf = tree; } /** - * Get the compilation unit associated with this path. + * Returns the compilation unit associated with this path. + * @return the compilation unit */ public CompilationUnitTree getCompilationUnit() { return compilationUnit; } /** - * Get the leaf node for this path. + * Returns the leaf node for this path. + * @return the leaf node */ public Tree getLeaf() { return leaf; } /** - * Get the path for the enclosing node, or null if there is no enclosing node. + * Returns the path for the enclosing node, or {@code null} if there is no enclosing node. + * @return the path for the enclosing node */ public TreePath getParentPath() { return parent; diff --git a/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java b/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java index 967bcfd809b..a07f829096c 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/TreePathScanner.java @@ -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 @@ -42,7 +42,10 @@ import com.sun.source.tree.*; public class TreePathScanner extends TreeScanner { /** - * Scan a tree from a position identified by a TreePath. + * Scans a tree from a position identified by a TreePath. + * @param path the path identifying the node to be scanned + * @param p a parameter value passed to visit methods + * @return the result value from the visit method */ public R scan(TreePath path, P p) { this.path = path; @@ -54,8 +57,9 @@ public class TreePathScanner extends TreeScanner { } /** - * Scan a single node. + * Scans a single node. * The current path is updated for the duration of the scan. + * @return the result value from the visit method */ @Override public R scan(Tree tree, P p) { @@ -72,8 +76,9 @@ public class TreePathScanner extends TreeScanner { } /** - * Get the current path for the node, as built up by the currently + * Returns the current path for the node, as built up by the currently * active set of scan calls. + * @return the current path */ public TreePath getCurrentPath() { return path; diff --git a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java index a14cad476c4..275d9c8fb9c 100644 --- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java +++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -37,7 +37,7 @@ import com.sun.source.tree.*; *

    The default implementation of the visitXYZ methods will determine * a result as follows: *

      - *
    • If the node being visited has no children, the result will be null. + *
    • If the node being visited has no children, the result will be {@code null}. *
    • If the node being visited has one child, the result will be the * result of calling {@code scan} on that child. The child may be a simple node * or itself a list of nodes. @@ -64,6 +64,12 @@ import com.sun.source.tree.*; * } *
* + * @param the return type of this visitor's methods. Use {@link + * Void} for visitors that do not need to return results. + * @param

the type of the additional parameter to this visitor's + * methods. Use {@code Void} for visitors that do not need an + * additional parameter. + * * @author Peter von der Ahé * @author Jonathan Gibbons * @since 1.6 @@ -71,17 +77,26 @@ import com.sun.source.tree.*; @jdk.Exported public class TreeScanner implements TreeVisitor { - /** Scan a single node. + /** + * Scans a single node. + * @param tree the node to be scanned + * @param p a parameter value passed to the visit method + * @return the result value from the visit method */ - public R scan(Tree node, P p) { - return (node == null) ? null : node.accept(this, p); + public R scan(Tree tree, P p) { + return (tree == null) ? null : tree.accept(this, p); } private R scanAndReduce(Tree node, P p, R r) { return reduce(scan(node, p), r); } - /** Scan a list of nodes. + /** + * Scans a sequence of nodes. + * @param nodes the nodes to be scanned + * @param p a parameter value to be passed to the visit method for each node + * @return the combined return value from the visit methods. + * The values are combined using the {@link #reduce reduce} method. */ public R scan(Iterable nodes, P p) { R r = null; @@ -103,6 +118,9 @@ public class TreeScanner implements TreeVisitor { * Reduces two results into a combined result. * The default implementation is to return the first parameter. * The general contract of the method is that it may take any action whatsoever. + * @param r1 the first of the values to be combined + * @param r2 the second of the values to be combined + * @return the result of combining the two parameters */ public R reduce(R r1, R r2) { return r1; @@ -113,6 +131,14 @@ public class TreeScanner implements TreeVisitor { * Visitor methods ****************************************************************************/ + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCompilationUnit(CompilationUnitTree node, P p) { R r = scan(node.getPackage(), p); r = scanAndReduce(node.getImports(), p, r); @@ -120,16 +146,40 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitPackage(PackageTree node, P p) { R r = scan(node.getAnnotations(), p); r = scanAndReduce(node.getPackageName(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitImport(ImportTree node, P p) { return scan(node.getQualifiedIdentifier(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitClass(ClassTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getTypeParameters(), p, r); @@ -139,6 +189,14 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMethod(MethodTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getReturnType(), p, r); @@ -151,6 +209,14 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitVariable(VariableTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getType(), p, r); @@ -159,26 +225,66 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitEmptyStatement(EmptyStatementTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitBlock(BlockTree node, P p) { return scan(node.getStatements(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitDoWhileLoop(DoWhileLoopTree node, P p) { R r = scan(node.getStatement(), p); r = scanAndReduce(node.getCondition(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitWhileLoop(WhileLoopTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getStatement(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitForLoop(ForLoopTree node, P p) { R r = scan(node.getInitializer(), p); r = scanAndReduce(node.getCondition(), p, r); @@ -187,6 +293,14 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitEnhancedForLoop(EnhancedForLoopTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); @@ -194,28 +308,68 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitLabeledStatement(LabeledStatementTree node, P p) { return scan(node.getStatement(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitSwitch(SwitchTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getCases(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCase(CaseTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getStatements(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitSynchronized(SynchronizedTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getBlock(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitTry(TryTree node, P p) { R r = scan(node.getResources(), p); r = scanAndReduce(node.getBlock(), p, r); @@ -224,12 +378,28 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCatch(CatchTree node, P p) { R r = scan(node.getParameter(), p); r = scanAndReduce(node.getBlock(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitConditionalExpression(ConditionalExpressionTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getTrueExpression(), p, r); @@ -237,6 +407,14 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitIf(IfTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getThenStatement(), p, r); @@ -244,32 +422,88 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitExpressionStatement(ExpressionStatementTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitBreak(BreakTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitContinue(ContinueTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitReturn(ReturnTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitThrow(ThrowTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitAssert(AssertTree node, P p) { R r = scan(node.getCondition(), p); r = scanAndReduce(node.getDetail(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMethodInvocation(MethodInvocationTree node, P p) { R r = scan(node.getTypeArguments(), p); r = scanAndReduce(node.getMethodSelect(), p, r); @@ -277,6 +511,14 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitNewClass(NewClassTree node, P p) { R r = scan(node.getEnclosingExpression(), p); r = scanAndReduce(node.getIdentifier(), p, r); @@ -286,6 +528,14 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitNewArray(NewArrayTree node, P p) { R r = scan(node.getType(), p); r = scanAndReduce(node.getDimensions(), p, r); @@ -297,126 +547,326 @@ public class TreeScanner implements TreeVisitor { return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitLambdaExpression(LambdaExpressionTree node, P p) { R r = scan(node.getParameters(), p); r = scanAndReduce(node.getBody(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitParenthesized(ParenthesizedTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitAssignment(AssignmentTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitCompoundAssignment(CompoundAssignmentTree node, P p) { R r = scan(node.getVariable(), p); r = scanAndReduce(node.getExpression(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitUnary(UnaryTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitBinary(BinaryTree node, P p) { R r = scan(node.getLeftOperand(), p); r = scanAndReduce(node.getRightOperand(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitTypeCast(TypeCastTree node, P p) { R r = scan(node.getType(), p); r = scanAndReduce(node.getExpression(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitInstanceOf(InstanceOfTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getType(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitArrayAccess(ArrayAccessTree node, P p) { R r = scan(node.getExpression(), p); r = scanAndReduce(node.getIndex(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMemberSelect(MemberSelectTree node, P p) { return scan(node.getExpression(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitMemberReference(MemberReferenceTree node, P p) { R r = scan(node.getQualifierExpression(), p); r = scanAndReduce(node.getTypeArguments(), p, r); return r; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitIdentifier(IdentifierTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitLiteral(LiteralTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitPrimitiveType(PrimitiveTypeTree node, P p) { return null; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitArrayType(ArrayTypeTree node, P p) { return scan(node.getType(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitParameterizedType(ParameterizedTypeTree node, P p) { R r = scan(node.getType(), p); r = scanAndReduce(node.getTypeArguments(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitUnionType(UnionTypeTree node, P p) { return scan(node.getTypeAlternatives(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitIntersectionType(IntersectionTypeTree node, P p) { return scan(node.getBounds(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitTypeParameter(TypeParameterTree node, P p) { R r = scan(node.getAnnotations(), p); r = scanAndReduce(node.getBounds(), p, r); return r; } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitWildcard(WildcardTree node, P p) { return scan(node.getBound(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitModifiers(ModifiersTree node, P p) { return scan(node.getAnnotations(), p); } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitAnnotation(AnnotationTree node, P p) { R r = scan(node.getAnnotationType(), p); r = scanAndReduce(node.getArguments(), p, r); return r; } - public R visitAnnotatedType(AnnotatedTypeTree node, P p) { - R r = scan(node.getAnnotations(), p); - r = scanAndReduce(node.getUnderlyingType(), p, r); - return r; - } + /** + * {@inheritDoc} This implementation scans the children in left to right order. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override + public R visitAnnotatedType(AnnotatedTypeTree node, P p) { + R r = scan(node.getAnnotations(), p); + r = scanAndReduce(node.getUnderlyingType(), p, r); + return r; + } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitOther(Tree node, P p) { return null; } + /** + * {@inheritDoc} This implementation returns {@code null}. + * + * @param node {@inheritDoc} + * @param p {@inheritDoc} + * @return the result of scanning + */ + @Override public R visitErroneous(ErroneousTree node, P p) { return null; } diff --git a/langtools/src/share/classes/com/sun/source/util/Trees.java b/langtools/src/share/classes/com/sun/source/util/Trees.java index 50e02045a03..5f1c2047d89 100644 --- a/langtools/src/share/classes/com/sun/source/util/Trees.java +++ b/langtools/src/share/classes/com/sun/source/util/Trees.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -54,9 +54,10 @@ import com.sun.source.tree.Tree; @jdk.Exported public abstract class Trees { /** - * Gets a Trees object for a given CompilationTask. + * Returns a Trees object for a given CompilationTask. * @param task the compilation task for which to get the Trees object * @throws IllegalArgumentException if the task does not support the Trees API. + * @return the Trees object */ public static Trees instance(CompilationTask task) { String taskClassName = task.getClass().getName(); @@ -67,9 +68,10 @@ public abstract class Trees { } /** - * Gets a Trees object for a given ProcessingEnvironment. + * Returns a Trees object for a given ProcessingEnvironment. * @param env the processing environment for which to get the Trees object * @throws IllegalArgumentException if the env does not support the Trees API. + * @return the Trees object */ public static Trees instance(ProcessingEnvironment env) { if (!env.getClass().getName().equals("com.sun.tools.javac.processing.JavacProcessingEnvironment")) @@ -90,89 +92,123 @@ public abstract class Trees { } /** - * Gets a utility object for obtaining source positions. + * Returns a utility object for obtaining source positions. + * @return the utility object for obtaining source positions */ public abstract SourcePositions getSourcePositions(); /** - * Gets the Tree node for a given Element. - * Returns null if the node can not be found. + * Returns the Tree node for a given Element. + * Returns {@code null} if the node can not be found. + * @param element the element + * @return the tree node */ public abstract Tree getTree(Element element); /** - * Gets the ClassTree node for a given TypeElement. - * Returns null if the node can not be found. + * Returns the ClassTree node for a given TypeElement. + * Returns {@code null} if the node can not be found. + * @param element the element + * @return the class tree node */ public abstract ClassTree getTree(TypeElement element); /** - * Gets the MethodTree node for a given ExecutableElement. - * Returns null if the node can not be found. + * Returns the MethodTree node for a given ExecutableElement. + * Returns {@code null} if the node can not be found. + * @param method the executable element + * @return the method tree node */ public abstract MethodTree getTree(ExecutableElement method); /** - * Gets the Tree node for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the Tree node for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @return the tree node */ public abstract Tree getTree(Element e, AnnotationMirror a); /** - * Gets the Tree node for an AnnotationValue for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the Tree node for an AnnotationValue for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @param v the annotation value + * @return the tree node */ public abstract Tree getTree(Element e, AnnotationMirror a, AnnotationValue v); /** - * Gets the path to tree node within the specified compilation unit. + * Returns the path to tree node within the specified compilation unit. + * @param unit the compilation unit + * @param node the tree node + * @return the tree path */ public abstract TreePath getPath(CompilationUnitTree unit, Tree node); /** - * Gets the TreePath node for a given Element. - * Returns null if the node can not be found. + * Returns the TreePath node for a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @return the tree path */ public abstract TreePath getPath(Element e); /** - * Gets the TreePath node for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the TreePath node for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @return the tree path */ public abstract TreePath getPath(Element e, AnnotationMirror a); /** - * Gets the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. - * Returns null if the node can not be found. + * Returns the TreePath node for an AnnotationValue for an AnnotationMirror on a given Element. + * Returns {@code null} if the node can not be found. + * @param e the element + * @param a the annotation mirror + * @param v the annotation value + * @return the tree path */ public abstract TreePath getPath(Element e, AnnotationMirror a, AnnotationValue v); /** - * Gets the Element for the Tree node identified by a given TreePath. - * Returns null if the element is not available. + * Returns the Element for the Tree node identified by a given TreePath. + * Returns {@code null} if the element is not available. + * @param path the tree path + * @return the element * @throws IllegalArgumentException is the TreePath does not identify * a Tree node that might have an associated Element. */ public abstract Element getElement(TreePath path); /** - * Gets the TypeMirror for the Tree node identified by a given TreePath. - * Returns null if the TypeMirror is not available. + * Returns the TypeMirror for the Tree node identified by a given TreePath. + * Returns {@code null} if the TypeMirror is not available. + * @param path the tree path + * @return the type mirror * @throws IllegalArgumentException is the TreePath does not identify * a Tree node that might have an associated TypeMirror. */ public abstract TypeMirror getTypeMirror(TreePath path); /** - * Gets the Scope for the Tree node identified by a given TreePath. - * Returns null if the Scope is not available. + * Returns the Scope for the Tree node identified by a given TreePath. + * Returns {@code null} if the Scope is not available. + * @param path the tree path + * @return the scope */ public abstract Scope getScope(TreePath path); /** - * Gets the doc comment, if any, for the Tree node identified by a given TreePath. - * Returns null if no doc comment was found. + * Returns the doc comment, if any, for the Tree node identified by a given TreePath. + * Returns {@code null} if no doc comment was found. * @see DocTrees#getDocCommentTree(TreePath) + * @param path the tree path + * @return the doc comment */ public abstract String getDocComment(TreePath path); @@ -195,7 +231,7 @@ public abstract class Trees { public abstract boolean isAccessible(Scope scope, Element member, DeclaredType type); /** - * Gets the original type from the ErrorType object. + * Returns the original type from the ErrorType object. * @param errorType The errorType for which we want to get the original type. * @return javax.lang.model.type.TypeMirror corresponding to the original type, replaced by the ErrorType. */ @@ -215,7 +251,7 @@ public abstract class Trees { com.sun.source.tree.CompilationUnitTree root); /** - * Gets the lub of an exception parameter declared in a catch clause. + * Returns the lub of an exception parameter declared in a catch clause. * @param tree the tree for the catch clause * @return The lub of the exception parameter */ diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java index 479e3ba39f8..7c818ab6187 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java @@ -99,7 +99,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { } /** - * Gets each package name as a separate link. + * Returns each package name as a separate link. * * @param pd PackageDoc * @return content for the package link diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java index c5caa90a10c..e9df15378d7 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfileIndexFrameWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -101,7 +101,7 @@ public class ProfileIndexFrameWriter extends AbstractProfileIndexWriter { } /** - * Gets each profile name as a separate link. + * Returns each profile name as a separate link. * * @param profileName the profile being documented * @return content for the profile link diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java index 4804d962209..f536e14b2d9 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ProfilePackageIndexFrameWriter.java @@ -104,7 +104,7 @@ public class ProfilePackageIndexFrameWriter extends AbstractProfileIndexWriter { } /** - * Gets each package name as a separate link. + * Returns each package name as a separate link. * * @param pd PackageDoc * @param profileName the name of the profile being documented diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java index 56296d458c6..d9c2c248bcb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java @@ -854,7 +854,7 @@ public class JavacTrees extends DocTrees { } /** - * Gets the original type from the ErrorType object. + * Returns the original type from the ErrorType object. * @param errorType The errorType for which we want to get the original type. * @returns TypeMirror corresponding to the original type, replaced by the ErrorType. * noType (type.tag == NONE) is returned if there is no original type. diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java index 2b3f11beefa..17409cca180 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/DocCommentParser.java @@ -693,7 +693,6 @@ public class DocCommentParser { int p = bp; nextChar(); Name name = null; - boolean checkSemi = false; if (ch == '#') { int namep = bp; nextChar(); diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java b/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java index 7a6f97e9ed0..37b74b03ed5 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/JavacMessages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -153,7 +153,7 @@ public class JavacMessages implements Messages { /** - * Gets a localized string from the compiler's default bundle. + * Returns a localized string from the compiler's default bundle. */ // used to support legacy Log.getLocalizedString static String getDefaultLocalizedString(String key, Object... args) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java b/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java index 27cf3df50f0..7b9980f3e4e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -42,7 +42,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; * about conditions that would otherwise merit a warning. Such processing * is done when the condition is detected, and in those cases, no call is * made on any API to generate a warning at all. In consequence, this handler only - * gets to handle those warnings that JLS says must be generated. + * Returns to handle those warnings that JLS says must be generated. * *

This is NOT part of any supported API. * If you write code that depends on this, you do so at your own risk. diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java index f198591d668..3fcdadcd706 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -142,7 +142,7 @@ public class RichDiagnosticFormatter extends } /** - * Gets the type/symbol printer used by this formatter. + * Returns the type/symbol printer used by this formatter. * @return type/symbol rich printer */ protected RichPrinter getRichPrinter() { diff --git a/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java b/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java index 1f4adc0c82c..7bcebc515dc 100644 --- a/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java +++ b/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -86,7 +86,7 @@ public interface NativeHeaderTool extends Tool, OptionChecker { Iterable classes); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signalled with the appropriate exceptions. diff --git a/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java b/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java index 8f7a588b4da..d425e42b0fb 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java +++ b/langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -87,7 +87,7 @@ public interface DisassemblerTool extends Tool, OptionChecker { Iterable classes); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signalled with the appropriate exceptions. diff --git a/langtools/src/share/classes/javax/tools/Diagnostic.java b/langtools/src/share/classes/javax/tools/Diagnostic.java index 03b11fd97aa..dfa5ef4a39d 100644 --- a/langtools/src/share/classes/javax/tools/Diagnostic.java +++ b/langtools/src/share/classes/javax/tools/Diagnostic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -92,14 +92,14 @@ public interface Diagnostic { public final static long NOPOS = -1; /** - * Gets the kind of this diagnostic, for example, error or + * Returns the kind of this diagnostic, for example, error or * warning. * @return the kind of this diagnostic */ Kind getKind(); /** - * Gets the source object associated with this diagnostic. + * Returns the source object associated with this diagnostic. * * @return the source object associated with this diagnostic. * {@code null} if no source object is associated with the @@ -108,7 +108,7 @@ public interface Diagnostic { S getSource(); /** - * Gets a character offset from the beginning of the source object + * Returns a character offset from the beginning of the source object * associated with this diagnostic that indicates the location of * the problem. In addition, the following must be true: * @@ -122,7 +122,7 @@ public interface Diagnostic { long getPosition(); /** - * Gets the character offset from the beginning of the file + * Returns the character offset from the beginning of the file * associated with this diagnostic that indicates the start of the * problem. * @@ -132,7 +132,7 @@ public interface Diagnostic { long getStartPosition(); /** - * Gets the character offset from the beginning of the file + * Returns the character offset from the beginning of the file * associated with this diagnostic that indicates the end of the * problem. * @@ -142,7 +142,7 @@ public interface Diagnostic { long getEndPosition(); /** - * Gets the line number of the character offset returned by + * Returns the line number of the character offset returned by * {@linkplain #getPosition()}. * * @return a line number or {@link #NOPOS} if and only if {@link @@ -151,7 +151,7 @@ public interface Diagnostic { long getLineNumber(); /** - * Gets the column number of the character offset returned by + * Returns the column number of the character offset returned by * {@linkplain #getPosition()}. * * @return a column number or {@link #NOPOS} if and only if {@link @@ -160,7 +160,7 @@ public interface Diagnostic { long getColumnNumber(); /** - * Gets a diagnostic code indicating the type of diagnostic. The + * Returns a diagnostic code indicating the type of diagnostic. The * code is implementation-dependent and might be {@code null}. * * @return a diagnostic code @@ -168,7 +168,7 @@ public interface Diagnostic { String getCode(); /** - * Gets a localized message for the given locale. The actual + * Returns a localized message for the given locale. The actual * message is implementation-dependent. If the locale is {@code * null} use the default locale. * diff --git a/langtools/src/share/classes/javax/tools/DiagnosticCollector.java b/langtools/src/share/classes/javax/tools/DiagnosticCollector.java index 8f290f50ed3..160c748bf4a 100644 --- a/langtools/src/share/classes/javax/tools/DiagnosticCollector.java +++ b/langtools/src/share/classes/javax/tools/DiagnosticCollector.java @@ -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 @@ -48,7 +48,7 @@ public final class DiagnosticCollector implements DiagnosticListener { } /** - * Gets a list view of diagnostics collected by this object. + * Returns a list view of diagnostics collected by this object. * * @return a list view of diagnostics */ diff --git a/langtools/src/share/classes/javax/tools/DocumentationTool.java b/langtools/src/share/classes/javax/tools/DocumentationTool.java index 63158ed005e..2d11778c756 100644 --- a/langtools/src/share/classes/javax/tools/DocumentationTool.java +++ b/langtools/src/share/classes/javax/tools/DocumentationTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -83,7 +83,7 @@ public interface DocumentationTool extends Tool, OptionChecker { Iterable compilationUnits); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signaled with the appropriate exceptions. diff --git a/langtools/src/share/classes/javax/tools/FileObject.java b/langtools/src/share/classes/javax/tools/FileObject.java index 132962862f0..492ca6b3cc9 100644 --- a/langtools/src/share/classes/javax/tools/FileObject.java +++ b/langtools/src/share/classes/javax/tools/FileObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 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 @@ -57,7 +57,7 @@ public interface FileObject { URI toUri(); /** - * Gets a user-friendly name for this file object. The exact + * Returns a user-friendly name for this file object. The exact * value returned is not specified but implementations should take * care to preserve names as given by the user. For example, if * the user writes the filename {@code "BobsApp\Test.java"} on @@ -71,7 +71,7 @@ public interface FileObject { String getName(); /** - * Gets an InputStream for this file object. + * Returns an InputStream for this file object. * * @return an InputStream * @throws IllegalStateException if this file object was @@ -83,7 +83,7 @@ public interface FileObject { InputStream openInputStream() throws IOException; /** - * Gets an OutputStream for this file object. + * Returns an OutputStream for this file object. * * @return an OutputStream * @throws IllegalStateException if this file object was @@ -95,7 +95,7 @@ public interface FileObject { OutputStream openOutputStream() throws IOException; /** - * Gets a reader for this object. The returned reader will + * Returns a reader for this object. The returned reader will * replace bytes that cannot be decoded with the default * translation character. In addition, the reader may report a * diagnostic unless {@code ignoreEncodingErrors} is true. @@ -111,7 +111,7 @@ public interface FileObject { Reader openReader(boolean ignoreEncodingErrors) throws IOException; /** - * Gets the character content of this file object, if available. + * Returns the character content of this file object, if available. * Any byte that cannot be decoded will be replaced by the default * translation character. In addition, a diagnostic may be * reported unless {@code ignoreEncodingErrors} is true. @@ -127,7 +127,7 @@ public interface FileObject { CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException; /** - * Gets a Writer for this file object. + * Returns a Writer for this file object. * * @return a Writer * @throws IllegalStateException if this file object was @@ -139,7 +139,7 @@ public interface FileObject { Writer openWriter() throws IOException; /** - * Gets the time this file object was last modified. The time is + * Returns the time this file object was last modified. The time is * measured in milliseconds since the epoch (00:00:00 GMT, January * 1, 1970). * diff --git a/langtools/src/share/classes/javax/tools/JavaCompiler.java b/langtools/src/share/classes/javax/tools/JavaCompiler.java index 09c70bae48e..f3663874834 100644 --- a/langtools/src/share/classes/javax/tools/JavaCompiler.java +++ b/langtools/src/share/classes/javax/tools/JavaCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -263,7 +263,7 @@ public interface JavaCompiler extends Tool, OptionChecker { Iterable compilationUnits); /** - * Gets a new instance of the standard file manager implementation + * Returns a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signaled with the appropriate exceptions. diff --git a/langtools/src/share/classes/javax/tools/JavaFileManager.java b/langtools/src/share/classes/javax/tools/JavaFileManager.java index d519a5c9619..e5e911ee084 100644 --- a/langtools/src/share/classes/javax/tools/JavaFileManager.java +++ b/langtools/src/share/classes/javax/tools/JavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -110,7 +110,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { */ interface Location { /** - * Gets the name of this location. + * Returns the name of this location. * * @return a name */ @@ -127,7 +127,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { } /** - * Gets a class loader for loading plug-ins from the given + * Returns a class loader for loading plug-ins from the given * location. For example, to load annotation processors, a * compiler will request a class loader for the {@link * StandardLocation#ANNOTATION_PROCESSOR_PATH @@ -224,7 +224,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { boolean hasLocation(Location location); /** - * Gets a {@linkplain JavaFileObject file object} for input + * Returns a {@linkplain JavaFileObject file object} for input * representing the specified class of the specified kind in the * given location. * @@ -250,7 +250,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { throws IOException; /** - * Gets a {@linkplain JavaFileObject file object} for output + * Returns a {@linkplain JavaFileObject file object} for output * representing the specified class of the specified kind in the * given location. * @@ -288,7 +288,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { throws IOException; /** - * Gets a {@linkplain FileObject file object} for input + * Returns a {@linkplain FileObject file object} for input * representing the specified relative * name in the specified package in the given location. * @@ -332,7 +332,7 @@ public interface JavaFileManager extends Closeable, Flushable, OptionChecker { throws IOException; /** - * Gets a {@linkplain FileObject file object} for output + * Returns a {@linkplain FileObject file object} for output * representing the specified relative * name in the specified package in the given location. * diff --git a/langtools/src/share/classes/javax/tools/JavaFileObject.java b/langtools/src/share/classes/javax/tools/JavaFileObject.java index d331e5dcb3a..dba8fe49e5c 100644 --- a/langtools/src/share/classes/javax/tools/JavaFileObject.java +++ b/langtools/src/share/classes/javax/tools/JavaFileObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -84,7 +84,7 @@ public interface JavaFileObject extends FileObject { } /** - * Gets the kind of this file object. + * Returns the kind of this file object. * * @return the kind */ diff --git a/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java b/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java index cd7120bd916..2b1ad4b7303 100644 --- a/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java +++ b/langtools/src/share/classes/javax/tools/StandardJavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 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 @@ -155,7 +155,7 @@ public interface StandardJavaFileManager extends JavaFileManager { boolean isSameFile(FileObject a, FileObject b); /** - * Gets file objects representing the given files. + * Returns file objects representing the given files. * * @param files a list of files * @return a list of file objects @@ -166,7 +166,7 @@ public interface StandardJavaFileManager extends JavaFileManager { Iterable files); /** - * Gets file objects representing the given files. + * Returns file objects representing the given files. * Convenience method equivalent to: * *

@@ -183,7 +183,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
     Iterable getJavaFileObjects(File... files);
 
     /**
-     * Gets file objects representing the given file names.
+     * Returns file objects representing the given file names.
      *
      * @param names a list of file names
      * @return a list of file objects
@@ -194,7 +194,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
         Iterable names);
 
     /**
-     * Gets file objects representing the given file names.
+     * Returns file objects representing the given file names.
      * Convenience method equivalent to:
      *
      * 
@@ -227,7 +227,7 @@ public interface StandardJavaFileManager extends JavaFileManager {
         throws IOException;
 
     /**
-     * Gets the path associated with the given location.
+     * Returns the path associated with the given location.
      *
      * @param location a location
      * @return a list of files or {@code null} if this location has no
diff --git a/langtools/src/share/classes/javax/tools/StandardLocation.java b/langtools/src/share/classes/javax/tools/StandardLocation.java
index 629c0d029d4..199f22d42f3 100644
--- a/langtools/src/share/classes/javax/tools/StandardLocation.java
+++ b/langtools/src/share/classes/javax/tools/StandardLocation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2012, 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
@@ -75,7 +75,7 @@ public enum StandardLocation implements Location {
     NATIVE_HEADER_OUTPUT;
 
     /**
-     * Gets a location object with the given name.  The following
+     * Returns a location object with the given name.  The following
      * property must hold: {@code locationFor(x) ==
      * locationFor(y)} if and only if {@code x.equals(y)}.
      * The returned location will be an output location if and only if
diff --git a/langtools/src/share/classes/javax/tools/Tool.java b/langtools/src/share/classes/javax/tools/Tool.java
index 0d9593f1445..5ffeccd37cd 100644
--- a/langtools/src/share/classes/javax/tools/Tool.java
+++ b/langtools/src/share/classes/javax/tools/Tool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +63,7 @@ public interface Tool {
     int run(InputStream in, OutputStream out, OutputStream err, String... arguments);
 
     /**
-     * Gets the source versions of the Java™ programming language
+     * Returns the source versions of the Java™ programming language
      * supported by this tool.
      * @return a set of supported source versions
      */
diff --git a/langtools/src/share/classes/javax/tools/ToolProvider.java b/langtools/src/share/classes/javax/tools/ToolProvider.java
index 07637a14d4b..ccd37aa6d52 100644
--- a/langtools/src/share/classes/javax/tools/ToolProvider.java
+++ b/langtools/src/share/classes/javax/tools/ToolProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -93,7 +93,7 @@ public class ToolProvider {
         = "com.sun.tools.javac.api.JavacTool";
 
     /**
-     * Gets the Java™ programming language compiler provided
+     * Returns the Java™ programming language compiler provided
      * with this platform.
      * @return the compiler provided with this platform or
      * {@code null} if no compiler is provided
@@ -106,7 +106,7 @@ public class ToolProvider {
         = "com.sun.tools.javadoc.api.JavadocTool";
 
     /**
-     * Gets the Java™ programming language documentation tool provided
+     * Returns the Java™ programming language documentation tool provided
      * with this platform.
      * @return the documentation tool provided with this platform or
      * {@code null} if no documentation tool is provided

From 101aaaa4684a316f694f5790fecedbb95818c521 Mon Sep 17 00:00:00 2001
From: Jonathan Gibbons 
Date: Wed, 25 Jun 2014 19:15:53 -0700
Subject: [PATCH 049/236] 8048162: Restrict catch type from Throwable to
 ReflectiveOperationException

Reviewed-by: darcy
---
 langtools/src/share/classes/com/sun/source/util/Trees.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/langtools/src/share/classes/com/sun/source/util/Trees.java b/langtools/src/share/classes/com/sun/source/util/Trees.java
index 5f1c2047d89..5e464c71de3 100644
--- a/langtools/src/share/classes/com/sun/source/util/Trees.java
+++ b/langtools/src/share/classes/com/sun/source/util/Trees.java
@@ -86,7 +86,7 @@ public abstract class Trees {
             argType = Class.forName(argType.getName(), false, cl);
             Method m = c.getMethod("instance", argType);
             return (Trees) m.invoke(null, arg);
-        } catch (Throwable e) {
+        } catch (ReflectiveOperationException e) {
             throw new AssertionError(e);
         }
     }

From 5b1596bc2530d21361704defec576e49ec50f654 Mon Sep 17 00:00:00 2001
From: Paul Govereau 
Date: Thu, 26 Jun 2014 13:48:58 -0400
Subject: [PATCH 050/236] 8042345: getDocComment fails for doc comments on
 PackageElement found in package-info.java

Reviewed-by: jjg
---
 .../com/sun/tools/javac/tree/TreeInfo.java    |   4 +
 .../doccomments/TestPackageInfoComments.java  | 101 ++++++++++++++++++
 .../elements/doccomments/p/package-info.java  |  25 +++++
 3 files changed, 130 insertions(+)
 create mode 100644 langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java
 create mode 100644 langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java

diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index 463d7b84142..1c52c0f6858 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -656,6 +656,10 @@ public class TreeInfo {
                 if (that.packge == sym) result = that;
                 else super.visitTopLevel(that);
             }
+            public void visitPackageDef(JCPackageDecl that) {
+                if (that.packge == sym) result = that;
+                else super.visitPackageDef(that);
+            }
             public void visitClassDef(JCClassDecl that) {
                 if (that.sym == sym) result = that;
                 else super.visitClassDef(that);
diff --git a/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java
new file mode 100644
index 00000000000..61b70d28c70
--- /dev/null
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/TestPackageInfoComments.java
@@ -0,0 +1,101 @@
+/*
+ * 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 8042345
+ * @summary getDocComment() fails for doc comments on PackageElement found in package-info.java
+ */
+
+import com.sun.source.util.JavacTask;
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+@SupportedAnnotationTypes("*")
+public class TestPackageInfoComments extends AbstractProcessor {
+
+    public static void main(String... args) throws Exception {
+        String[] opts = {
+            "-implicit:none",
+            "-processor", TestPackageInfoComments.class.getName(),
+            "-processorpath", System.getProperty("test.classes")
+        };
+        File[] files = {
+            new File(System.getProperty("test.src"), "p/package-info.java")
+        };
+        run_test(opts, files);
+    }
+
+    static void run_test(String[] opts, File[] files) throws IOException {
+        DiagnosticListener dl = new DiagnosticListener() {
+            public void report(Diagnostic diagnostic) {
+                throw new Error(diagnostic.toString());
+            }
+        };
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+        Iterable units = fm.getJavaFileObjects(files);
+        JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
+        t.parse();
+        t.analyze();
+    }
+
+    // -- Annotation processor: Check all PackageDecl's have a doc comment
+
+    Messager messager;
+    Elements elements;
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        messager = pEnv.getMessager();
+        elements = pEnv.getElementUtils();
+    }
+
+    @Override
+    public boolean process(Set annotations, RoundEnvironment roundEnv) {
+        for (Element e: roundEnv.getRootElements())
+            new TestElementScanner().scan(e);
+        return true;
+    }
+
+    class TestElementScanner extends ElementScanner7 {
+        @Override
+        public Void visitPackage(PackageElement e, Void v) {
+            if (elements.getDocComment(e) == null)
+                messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e);
+            return v;
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java b/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java
new file mode 100644
index 00000000000..a69d89200d8
--- /dev/null
+++ b/langtools/test/tools/javac/processing/model/util/elements/doccomments/p/package-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/** A non-empty comment. */
+package foo;

From bd97e7d5ecc7a130a9cf289f5243e2894e8bb5d2 Mon Sep 17 00:00:00 2001
From: Jonathan Gibbons 
Date: Thu, 26 Jun 2014 11:31:59 -0700
Subject: [PATCH 051/236] 8047183: JDK build fails with sjavac enabled

Reviewed-by: mcimadamore
---
 .../tools/sjavac/comp/SmartFileManager.java   |  21 +++-
 .../tools/sjavac/server/CompilerThread.java   |   5 +-
 .../test/tools/sjavac/IgnoreSymbolFile.java   | 108 ++++++++++++++++++
 3 files changed, 127 insertions(+), 7 deletions(-)
 create mode 100644 langtools/test/tools/sjavac/IgnoreSymbolFile.java

diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java
index 8ab2998c8ac..43baf12caeb 100644
--- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/SmartFileManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -25,17 +25,21 @@
 
 package com.sun.tools.sjavac.comp;
 
-import com.sun.tools.javac.util.ListBuffer;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.URI;
-import java.util.Set;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
-import java.util.HashMap;
+import java.util.Set;
+
 import javax.tools.*;
 import javax.tools.JavaFileObject.Kind;
 
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.BaseFileManager;
+import com.sun.tools.javac.util.ListBuffer;
+
 /**
  * Intercepts reads and writes to the file system to gather
  * information about what artifacts are generated.
@@ -76,6 +80,15 @@ public class SmartFileManager extends ForwardingJavaFileManager
         stdout = pw;
     }
 
+    /**
+     * Set whether or not to use ct.sym as an alternate to rt.jar.
+     */
+    public void setSymbolFileEnabled(boolean b) {
+        if (!(fileManager instanceof JavacFileManager))
+            throw new IllegalStateException();
+        ((JavacFileManager) fileManager).setSymbolFileEnabled(b);
+    }
+
     public Map> getPackageArtifacts() {
         return packageArtifacts;
     }
diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
index c3873c3409e..cb60be23814 100644
--- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
+++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java
@@ -44,15 +44,13 @@ import java.util.Set;
 import java.util.concurrent.Future;
 
 import javax.tools.JavaCompiler.CompilationTask;
-import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
 
 import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.util.BaseFileManager;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.ListBuffer;
-import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
 import com.sun.tools.javac.util.StringUtils;
 import com.sun.tools.sjavac.comp.AttrWithDeps;
 import com.sun.tools.sjavac.comp.Dependencies;
@@ -320,6 +318,7 @@ public class CompilerThread implements Runnable {
 
                     // Do the compilation!
                     CompilationTask task = compiler.getTask(stderr, smartFileManager, null, the_options, null, compilationUnits, context);
+                    smartFileManager.setSymbolFileEnabled(!Options.instance(context).isSet("ignore.symbol.file"));
                     rc = ((JavacTaskImpl) task).doCall();
 
                     while (numActiveSubTasks()>0) {
diff --git a/langtools/test/tools/sjavac/IgnoreSymbolFile.java b/langtools/test/tools/sjavac/IgnoreSymbolFile.java
new file mode 100644
index 00000000000..b7898bbc23c
--- /dev/null
+++ b/langtools/test/tools/sjavac/IgnoreSymbolFile.java
@@ -0,0 +1,108 @@
+/*
+ * 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.  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.
+ */
+
+/*
+ * @test
+ * @bug 8047183
+ * @summary JDK build fails with sjavac enabled
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+public class IgnoreSymbolFile {
+    public static void main(String... args) throws Exception {
+        if (sjavacAvailable()) {
+            IgnoreSymbolFile test = new IgnoreSymbolFile();
+            test.run();
+        } else {
+            System.err.println("sjavac not available; test skipped");
+        }
+    }
+
+    void run() throws Exception {
+        String body =
+                "package p;\n"
+                + "import sun.reflect.annotation.*;\n"
+                + "class X {\n"
+                + "    ExceptionProxy proxy;"
+                + "}";
+        writeFile("src/p/X.java", body);
+
+        new File("classes").mkdirs();
+
+        String server = "--server:portfile=testserver,background=false";
+        int rc1 = compile(server, "-d", "classes", "-Werror", "src");
+        if (rc1 == 0)
+            error("compilation succeeded unexpectedly");
+
+        int rc2 = compile(server, "-d", "classes", "-Werror", "-XDignore.symbol.file=true", "src");
+        if (rc2 != 0)
+            error("compilation failed unexpectedly: rc=" + rc2);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    int compile(String... args) throws ReflectiveOperationException {
+        // Use reflection to avoid a compile-time dependency on sjavac Main
+        System.err.println("compile: " + Arrays.toString(args));
+        Class c = Class.forName("com.sun.tools.sjavac.Main");
+        Method m = c.getDeclaredMethod("go", String[].class, PrintStream.class, PrintStream.class);
+        Object sjavac = c.newInstance();
+        int rc = (Integer) m.invoke(sjavac, args, System.err, System.err);
+        System.err.println("rc=" + rc);
+        return rc;
+    }
+
+    void writeFile(String path, String body) throws IOException {
+        File f = new File(path);
+        if (f.getParentFile() != null)
+            f.getParentFile().mkdirs();
+        try (FileWriter w = new FileWriter(f)) {
+            w.write(body);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    static boolean sjavacAvailable() {
+        try {
+            Class.forName("com.sun.tools.sjavac.Main");
+            return true;
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
+    }
+}

From 47c543e53bebf473a3fa2b8e400e52ea8a69378c Mon Sep 17 00:00:00 2001
From: Jonathan Gibbons 
Date: Thu, 26 Jun 2014 11:45:51 -0700
Subject: [PATCH 052/236] 8007307: DPrinter: support the DocTree API

Reviewed-by: mcimadamore
---
 .../sun/tools/javac/api/JavacTaskImpl.java    |   3 +
 langtools/test/tools/javac/lib/DPrinter.java  | 297 ++++++++++++++++--
 2 files changed, 271 insertions(+), 29 deletions(-)

diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
index 9d9ad45c5a4..6f413af5708 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
@@ -126,6 +126,9 @@ public class JavacTaskImpl extends BasicJavacTask {
             initContext();
             notYetEntered = new HashMap<>();
             compilerMain.setAPIMode(true);
+            compiler = JavaCompiler.instance(context);
+            compiler.keepComments = true;
+            compiler.genEndPos = true;
             result = compilerMain.compile(args, classNames, context, fileObjects, processors);
             cleanup();
             return result;
diff --git a/langtools/test/tools/javac/lib/DPrinter.java b/langtools/test/tools/javac/lib/DPrinter.java
index 544d21fcb0a..c20b913babe 100644
--- a/langtools/test/tools/javac/lib/DPrinter.java
+++ b/langtools/test/tools/javac/lib/DPrinter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 8043484
+ * @bug 8043484 8007307
  * @summary Make sure DPrinter.java compiles
  * @compile DPrinter.java
  */
@@ -50,6 +50,7 @@ import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 import javax.tools.ToolProvider;
 
+import com.sun.source.doctree.*;
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.TaskEvent;
 import com.sun.source.util.TaskListener;
@@ -74,6 +75,7 @@ import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Convert;
 import com.sun.tools.javac.util.Log;
 
 
@@ -248,6 +250,20 @@ public class DPrinter {
         }
     }
 
+    public void printDocTree(String label, DocTree tree) {
+        if (tree == null) {
+             printNull(label);
+        } else {
+            indent();
+            out.print(label);
+            out.println(": " + tree.getClass().getSimpleName() + "," + tree.getKind());
+
+            indent(+1);
+            tree.accept(docTreeVisitor, null);
+            indent(-1);
+        }
+    }
+
     public void printFileObject(String label, FileObject fo) {
         if (fo == null) {
             printNull(label);
@@ -265,6 +281,17 @@ public class DPrinter {
         printString(label, String.valueOf(i));
     }
 
+    public void printLimitedEscapedString(String label, String text) {
+        String s = Convert.quote(text);
+        if (s.length() > maxSrcLength) {
+            String trim = "[...]";
+            int head = (maxSrcLength - trim.length()) * 2 / 3;
+            int tail = maxSrcLength - trim.length() - head;
+            s = s.substring(0, head) + trim + s.substring(s.length() - tail);
+        }
+        printString(label, s);
+    }
+
     public void printList(String label, List list) {
         if (list == null) {
              printNull(label);
@@ -304,6 +331,8 @@ public class DPrinter {
             printType(label, (Type) item, details);
         } else if (item instanceof JCTree) {
             printTree(label, (JCTree) item);
+        } else if (item instanceof DocTree) {
+            printDocTree(label, (DocTree) item);
         } else if (item instanceof List) {
             printList(label, (List) item);
         } else if (item instanceof Name) {
@@ -877,6 +906,191 @@ public class DPrinter {
 
     // 
 
+    // 
+
+    protected DocTreeVisitor docTreeVisitor = new DefaultDocTreeVisitor();
+
+    /**
+     * Default visitor class for DocTree objects.
+     * Note: each visitXYZ method ends by calling the corresponding
+     * visit method for its superclass.
+     */
+    class DefaultDocTreeVisitor implements DocTreeVisitor {
+
+        public Void visitAttribute(AttributeTree node, Void p) {
+            printName("name", node.getName());
+            printString("vkind", node.getValueKind().name());
+            printList("value", node.getValue());
+            return visitTree(node, null);
+        }
+
+        public Void visitAuthor(AuthorTree node, Void p) {
+            printList("name", node.getName());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitComment(CommentTree node, Void p) {
+            printLimitedEscapedString("body", node.getBody());
+            return visitTree(node, null);
+        }
+
+        public Void visitDeprecated(DeprecatedTree node, Void p) {
+            printList("body", node.getBody());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitDocComment(DocCommentTree node, Void p) {
+            printList("firstSentence", node.getFirstSentence());
+            printList("body", node.getBody());
+            printList("tags", node.getBlockTags());
+            return visitTree(node, null);
+        }
+
+        public Void visitDocRoot(DocRootTree node, Void p) {
+            return visitInlineTag(node, null);
+        }
+
+        public Void visitEndElement(EndElementTree node, Void p) {
+            printName("name", node.getName());
+            return visitTree(node, null);
+        }
+
+        public Void visitEntity(EntityTree node, Void p) {
+            printName("name", node.getName());
+            return visitTree(node, null);
+        }
+
+        public Void visitErroneous(ErroneousTree node, Void p) {
+            printLimitedEscapedString("body", node.getBody());
+            printString("diag", node.getDiagnostic().getMessage(Locale.getDefault()));
+            return visitTree(node, null);
+        }
+
+        public Void visitIdentifier(IdentifierTree node, Void p) {
+            printName("name", node.getName());
+            return visitTree(node, null);
+        }
+
+        public Void visitInheritDoc(InheritDocTree node, Void p) {
+            return visitInlineTag(node, null);
+        }
+
+        public Void visitLink(LinkTree node, Void p) {
+            printString("kind", node.getKind().name());
+            printDocTree("ref", node.getReference());
+            printList("list", node.getLabel());
+            return visitInlineTag(node, null);
+        }
+
+        public Void visitLiteral(LiteralTree node, Void p) {
+            printString("kind", node.getKind().name());
+            printDocTree("body", node.getBody());
+            return visitInlineTag(node, null);
+        }
+
+        public Void visitParam(ParamTree node, Void p) {
+            printString("isTypeParameter", String.valueOf(node.isTypeParameter()));
+            printString("kind", node.getKind().name());
+            printList("desc", node.getDescription());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitReference(ReferenceTree node, Void p) {
+            printString("signature", node.getSignature());
+            return visitTree(node, null);
+        }
+
+        public Void visitReturn(ReturnTree node, Void p) {
+            printList("desc", node.getDescription());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitSee(SeeTree node, Void p) {
+            printList("ref", node.getReference());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitSerial(SerialTree node, Void p) {
+            printList("desc", node.getDescription());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitSerialData(SerialDataTree node, Void p) {
+            printList("desc", node.getDescription());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitSerialField(SerialFieldTree node, Void p) {
+            printDocTree("name", node.getName());
+            printDocTree("type", node.getType());
+            printList("desc", node.getDescription());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitSince(SinceTree node, Void p) {
+            printList("body", node.getBody());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitStartElement(StartElementTree node, Void p) {
+            printName("name", node.getName());
+            printList("attrs", node.getAttributes());
+            printString("selfClosing", String.valueOf(node.isSelfClosing()));
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitText(TextTree node, Void p) {
+            printLimitedEscapedString("body", node.getBody());
+            return visitTree(node, null);
+        }
+
+        public Void visitThrows(ThrowsTree node, Void p) {
+            printDocTree("name", node.getExceptionName());
+            printList("desc", node.getDescription());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) {
+            printString("name", node.getTagName());
+            printList("content", node.getContent());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitUnknownInlineTag(UnknownInlineTagTree node, Void p) {
+            printString("name", node.getTagName());
+            printList("content", node.getContent());
+            return visitInlineTag(node, null);
+        }
+
+        public Void visitValue(ValueTree node, Void p) {
+            printDocTree("value", node.getReference());
+            return visitInlineTag(node, null);
+        }
+
+        public Void visitVersion(VersionTree node, Void p) {
+            printList("body", node.getBody());
+            return visitBlockTag(node, null);
+        }
+
+        public Void visitOther(DocTree node, Void p) {
+            return visitTree(node, null);
+        }
+
+        public Void visitBlockTag(DocTree node, Void p) {
+            return visitTree(node, null);
+        }
+
+        public Void visitInlineTag(DocTree node, Void p) {
+            return visitTree(node, null);
+        }
+
+        public Void visitTree(DocTree node, Void p) {
+            return null;
+        }
+    }
+
+    // 
+
     // 
 
     protected Symbol.Visitor symVisitor = new SymbolVisitor();
@@ -1228,18 +1442,19 @@ public class DPrinter {
                 }
 
                 private void handle(TaskEvent e) {
+                    JCCompilationUnit unit = (JCCompilationUnit) e.getCompilationUnit();
                      switch (e.getKind()) {
                          case PARSE:
                          case ENTER:
                              h.handle(e.getSourceFile().getName(),
-                                     (JCTree) e.getCompilationUnit(),
+                                     unit, unit,
                                      dprinter);
                              break;
 
                          default:
                              TypeElement elem = e.getTypeElement();
                              h.handle(elem.toString(),
-                                     (JCTree) trees.getTree(elem),
+                                     unit, (JCTree) trees.getTree(elem),
                                      dprinter);
                              break;
                      }
@@ -1258,7 +1473,9 @@ public class DPrinter {
             Handler(String name) {
                 this.name = name;
             }
-            abstract void handle(String label, JCTree tree, DPrinter dprinter);
+            abstract void handle(String label,
+                    JCCompilationUnit unit, JCTree tree,
+                    DPrinter dprinter);
         }
 
         Map getHandlers() {
@@ -1272,36 +1489,36 @@ public class DPrinter {
         protected final Handler[] defaultHandlers = {
             new Handler("trees") {
                 @Override
-                void handle(String name, JCTree tree, DPrinter dprinter) {
+                void handle(String name, JCCompilationUnit unit, JCTree tree, DPrinter dprinter) {
                     dprinter.printTree(name, tree);
                     dprinter.out.println();
                 }
             },
 
+            new Handler("doctrees") {
+                @Override
+                void handle(final String name, final JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) {
+                    TreeScanner ds = new DeclScanner() {
+                        public void visitDecl(JCTree tree, Symbol sym) {
+                            DocTree dt = unit.docComments.getCommentTree(tree);
+                            if (dt != null) {
+                                String label = (sym == null) ? Pretty.toSimpleString(tree) : sym.name.toString();
+                                dprinter.printDocTree(label, dt);
+                                dprinter.out.println();
+                            }
+                        }
+                    };
+                    ds.scan(tree);
+                }
+            },
+
             new Handler("symbols") {
                 @Override
-                void handle(String name, JCTree tree, final DPrinter dprinter) {
-                    TreeScanner ds = new TreeScanner() {
-                        @Override
-                        public void visitClassDef(JCClassDecl tree) {
-                            visitDecl(tree, tree.sym);
-                            super.visitClassDef(tree);
-                        }
-
-                        @Override
-                        public void visitMethodDef(JCMethodDecl tree) {
-                            visitDecl(tree, tree.sym);
-                            super.visitMethodDef(tree);
-                        }
-
-                        @Override
-                        public void visitVarDef(JCVariableDecl tree) {
-                            visitDecl(tree, tree.sym);
-                            super.visitVarDef(tree);
-                        }
-
-                        void visitDecl(JCTree tree, Symbol sym) {
-                            dprinter.printSymbol(sym.name.toString(), sym);
+                void handle(String name, JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) {
+                    TreeScanner ds = new DeclScanner() {
+                        public void visitDecl(JCTree tree, Symbol sym) {
+                            String label = (sym == null) ? Pretty.toSimpleString(tree) : sym.name.toString();
+                            dprinter.printSymbol(label, sym);
                             dprinter.out.println();
                         }
                     };
@@ -1311,7 +1528,7 @@ public class DPrinter {
 
             new Handler("types") {
                 @Override
-                void handle(String name, JCTree tree, final DPrinter dprinter) {
+                void handle(String name, JCCompilationUnit unit, JCTree tree, final DPrinter dprinter) {
                     TreeScanner ts = new TreeScanner() {
                         @Override
                         public void scan(JCTree tree) {
@@ -1332,6 +1549,28 @@ public class DPrinter {
         };
     }
 
+    protected static abstract class DeclScanner extends TreeScanner {
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            visitDecl(tree, tree.sym);
+            super.visitClassDef(tree);
+        }
+
+        @Override
+        public void visitMethodDef(JCMethodDecl tree) {
+            visitDecl(tree, tree.sym);
+            super.visitMethodDef(tree);
+        }
+
+        @Override
+        public void visitVarDef(JCVariableDecl tree) {
+            visitDecl(tree, tree.sym);
+            super.visitVarDef(tree);
+        }
+
+        protected abstract void visitDecl(JCTree tree, Symbol sym);
+    }
+
     // 
 
 }

From 7470fabe6f2c5e7a39023f2ab66a3b7d26c34d77 Mon Sep 17 00:00:00 2001
From: Sonali Goel 
Date: Thu, 26 Jun 2014 15:21:44 -0700
Subject: [PATCH 053/236] 8047303: update
 com/sun/javadoc/DocRootSlash/DocRootSlash for unexpected 

Reviewed-by: jjg, ksrini
---
 langtools/test/com/sun/javadoc/DocRootSlash/overview.html | 8 --------
 .../test/com/sun/javadoc/DocRootSlash/p1/package.html     | 7 -------
 2 files changed, 15 deletions(-)

diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html
index 3ff9efd1378..9a2ebdccfee 100644
--- a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html
+++ b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html
@@ -60,13 +60,5 @@ Sub-test 33 Actual: ./../docs1/p2/package-summary.html#package_description
 

- -Bonus links, not part of automated test (bug 4662945):
-Actual: package description {@docRoot}p1/packagesummary#package_description
- -Actual: package description {@docRoot}/p1/package-summary.html#package_description
- -Expect: ./p1/package-summary.html#package description - diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html index b31149b5d34..af0bfbb35d5 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html @@ -61,12 +61,5 @@ Sub-test 22 Actual: ../../docs1/p2/package-summary.html#package_description

-Bonus links, not part of automated test (bug 4662945):
-Actual: package description {@docRoot}p1/packagesummary#package_description
- -Actual: package description {@docRoot}/p1/package-summary.html#package_description
- -Expect: ../p1/package-summary.html#package description - From 41005acef28e4c4a425fd6bc90efc5d395e2a484 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Thu, 26 Jun 2014 15:30:21 -0700 Subject: [PATCH 054/236] 8047743: update com/sun/javadoc/testHref for unrecognized Reviewed-by: jjg, ksrini --- .../test/com/sun/javadoc/testHref/pkg/C3.java | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 langtools/test/com/sun/javadoc/testHref/pkg/C3.java diff --git a/langtools/test/com/sun/javadoc/testHref/pkg/C3.java b/langtools/test/com/sun/javadoc/testHref/pkg/C3.java deleted file mode 100644 index 48d0dee9cab..00000000000 --- a/langtools/test/com/sun/javadoc/testHref/pkg/C3.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - -package pkg; - -/** - * - */ -public class C3 {} From 88288709719e9569544549a49f7a627b7584f44b Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Thu, 26 Jun 2014 15:41:05 -0700 Subject: [PATCH 055/236] 8047744: update 2 javadoc tests for nested emphasis Reviewed-by: jjg, ksrini --- .../testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java | 4 ---- .../com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java | 2 +- .../TestSerializedFormDeprecationInfo.java | 2 -- .../javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java | 2 +- 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java index 3ed9594cff4..2a2e6de8ed4 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java +++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java @@ -250,8 +250,6 @@ public class TestHtmlDefinitionListTag extends JavadocTester { + "

\n" + "
Throws:" + "
\n" - + "
" - + "IOException
\n" + "
java.io.IOException
\n" + "
", "Deprecated." @@ -358,8 +356,6 @@ public class TestHtmlDefinitionListTag extends JavadocTester { + "
\n" + "
Throws:" + "
\n" - + "
" - + "IOException
\n" + "
java.io.IOException
\n" + "
", "Deprecated." diff --git a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java index 022ea741151..d44f05ac658 100644 --- a/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java +++ b/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java @@ -76,7 +76,7 @@ public class C2 implements Serializable { * Reads the object stream. * * @param s ObjectInputStream - * @throws IOException + * @throws IOException * @deprecated As of JDK version 1.5, replaced by * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}. */ diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java index 67893c46650..99e7cdb3d40 100644 --- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java +++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java @@ -122,8 +122,6 @@ public class TestSerializedFormDeprecationInfo extends JavadocTester { + "
Reads the object stream.
\n" + "
\n" + "
Throws:
\n" - + "
" - + "IOException
\n" + "
java.io.IOException
\n" + "
", "Deprecated." diff --git a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java index 022ea741151..d44f05ac658 100644 --- a/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java +++ b/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java @@ -76,7 +76,7 @@ public class C2 implements Serializable { * Reads the object stream. * * @param s ObjectInputStream - * @throws IOException + * @throws IOException * @deprecated As of JDK version 1.5, replaced by * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}. */ From bbc0df83f4bb6beef38710af4f0c47388d5471f9 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Thu, 26 Jun 2014 15:47:52 -0700 Subject: [PATCH 056/236] 8048168: update 2 javadoc tests to add summary attribute for table tag Reviewed-by: jjg, ksrini --- .../javadoc/testHtmlTableStyles/TestHtmlTableStyles.java | 2 +- .../com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java | 2 +- .../com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java | 4 ++-- .../test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java index 9f719a9d278..de6f152d5a2 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/TestHtmlTableStyles.java @@ -47,7 +47,7 @@ public class TestHtmlTableStyles extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg1/TestTable.html", true, - "", + "
", "
", diff --git a/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java b/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java index 866c3f42ee9..6e1c684d054 100644 --- a/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java +++ b/langtools/test/com/sun/javadoc/testHtmlTableStyles/pkg1/TestTable.java @@ -28,7 +28,7 @@ package pkg1; * should be displayed as a regular table and not have any styles that the javadoc * generated tables have. * - *
+ *
* * * diff --git a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java index 8cae5034bab..da4c72aa194 100644 --- a/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java +++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/TestLegacyTaglet.java @@ -51,9 +51,9 @@ public class TestLegacyTaglet extends JavadocTester { checkExit(Exit.OK); checkOutput("C.html", true, "This is an underline", - "
To Do:
Summary of test table
" + + "
To Do:
" + "
Finish this class.
", - "
To Do:
" + + "
To Do:
" + "
Tag in Method.
"); checkOutput(Output.STDERR, false, "NullPointerException"); diff --git a/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java b/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java index a3c52c26b4f..a2a0cd5541a 100644 --- a/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java +++ b/langtools/test/com/sun/javadoc/testLegacyTaglet/ToDoTaglet.java @@ -33,7 +33,7 @@ import java.util.Map; *
*
* To Do: - *
Fix this! + *
Fix this! *
* * @@ -150,7 +150,7 @@ public class ToDoTaglet implements Taglet { */ public String toString(Tag tag) { return "
" + HEADER + "
" - + "
" + + "
" + tag.text() + "
\n"; } @@ -165,7 +165,7 @@ public class ToDoTaglet implements Taglet { return null; } String result = "\n
" + HEADER + "
"; - result += "
"; + result += "
"; for (int i = 0; i < tags.length; i++) { if (i > 0) { result += ", "; From 3e316a337275e0a08f210d4e7ade492facc51888 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Thu, 26 Jun 2014 16:07:07 -0700 Subject: [PATCH 057/236] 8047316: update javadoc tests to fix tidy warning for incorrect html comment Reviewed-by: jjg, ksrini --- langtools/test/com/sun/javadoc/DocRootSlash/overview.html | 2 +- langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java | 2 +- langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html index 9a2ebdccfee..fc14f0fbaf2 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/overview.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/overview.html @@ -38,7 +38,7 @@ Sub-test 29 Actual: ./../docs1/p2/package-summary.html#package_description

- + Allow docRoot to work without a trailing slash for those who had to change their comments to work with the 1.4.0 bug: diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java b/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java index 84254e76fb8..69f8df4dc4c 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/C1.java @@ -59,7 +59,7 @@ package p1; * Sub-test 7 Expect: ../../docs1/p2/package-summary.html#package_description *

* - * + * * * Allow docRoot to work without a trailing slash for those who had to change their comments * to work with the 1.4.0 bug: diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html index af0bfbb35d5..cc61652a4cf 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html @@ -39,7 +39,7 @@ Sub-test 18 Actual: ../../docs1/p2/package-summary.html#package_description

- + Allow docRoot to work without a trailing slash for those who had to change their comments to work with the 1.4.0 bug: From 2f5e083ceef554e3a3e0c653f3f0a430a76e074e Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Thu, 26 Jun 2014 16:39:14 -0700 Subject: [PATCH 058/236] 8048293: update tools/javadoc/6227454 to have missing tag Reviewed-by: jjg, bpatel --- langtools/test/tools/javadoc/6227454/Test.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/javadoc/6227454/Test.java b/langtools/test/tools/javadoc/6227454/Test.java index 89c02a89dda..62dad90c549 100644 --- a/langtools/test/tools/javadoc/6227454/Test.java +++ b/langtools/test/tools/javadoc/6227454/Test.java @@ -40,14 +40,15 @@ public class Test extends Doclet { void run() throws Exception { String docType = ""; + String headTag = "Title "; test(docType+"ABC XYZ"); test(docType+"ABC XYZ"); test(docType+"ABC XYZ"); test(docType+"ABC XYZ"); test(docType+"ABC XYZ"); - test(docType+" ABC XYZ", "Body tag missing from HTML"); + test(docType+""+headTag+" ABC XYZ", "Body tag missing from HTML"); test(docType+"ABC XYZ ", "Close body tag missing from HTML"); - test(docType+" ABC XYZ ", "Body tag missing from HTML"); + test(docType+""+headTag+" ABC XYZ ", "Body tag missing from HTML"); test(docType+"ABC" + bigText(8192, 40) + "XYZ"); if (errors > 0) From ce0935812b5f02955dbec57ceb267256da2fad70 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 27 Jun 2014 20:32:12 +0100 Subject: [PATCH 059/236] 8047719: Incorrect LVT in switch statement Reviewed-by: jjg, jlahoda --- .../classes/com/sun/tools/javac/jvm/Code.java | 10 ++++---- .../classes/com/sun/tools/javac/jvm/Gen.java | 2 +- .../LocalVariableTableTest.java | 12 --------- .../LocalVariableTypeTableTest.java | 12 --------- .../test/tools/javac/flow/LVTHarness.java | 2 +- .../javac/flow/tests/TestCaseSwitch.java | 25 +++++++++++++------ 6 files changed, 25 insertions(+), 38 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java index b933b4632b6..cd4b5559057 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java @@ -1953,12 +1953,12 @@ public class Code { } } - public void closeRange(char end) { - if (isLastRangeInitialized()) { + public void closeRange(char length) { + if (isLastRangeInitialized() && length > 0) { Range range = lastRange(); if (range != null) { if (range.length == Character.MAX_VALUE) { - range.length = end; + range.length = length; } } } else { @@ -2022,7 +2022,7 @@ public class Code { } if (localVar.sym == aliveLocal && localVar.lastRange() != null) { char length = (char)(closingCP - localVar.lastRange().start_pc); - if (length > 0 && length < Character.MAX_VALUE) { + if (length < Character.MAX_VALUE) { localVar.closeRange(length); } } @@ -2093,7 +2093,7 @@ public class Code { lvar[adr].isLastRangeInitialized()) { LocalVar v = lvar[adr]; char length = (char)(curCP() - v.lastRange().start_pc); - if (length > 0 && length < Character.MAX_VALUE) { + if (length < Character.MAX_VALUE) { lvar[adr] = v.dup(); v.closeRange(length); putVar(v); diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java index 2ee148947b6..1eb989d81ec 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java @@ -2766,7 +2766,7 @@ public class Gen extends JCTree.Visitor { boolean trackVar(VarSymbol var) { return (var.owner.kind == MTH && - (var.flags() & (PARAMETER | HASINIT)) == 0 && + (var.flags() & PARAMETER) == 0 && analyzer.trackable(var)); } diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java index b2fdd48e6f7..9093dea79e6 100644 --- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTableTest.java @@ -153,7 +153,6 @@ public class LocalVariableTableTest extends LocalVariableTestBase { @ExpectedLocals(name = "inTry", type = "D") @ExpectedLocals(name = "inSync", type = "F") @ExpectedLocals(name = "inDo", type = "B") - @ExpectedLocals(name = "inSwitch", type = "S") @ExpectedLocals(name = "inFor", type = "J") @ExpectedLocals(name = "s", type = "Ljava/util/stream/Stream;") public void deepScope() { @@ -179,17 +178,6 @@ public class LocalVariableTableTest extends LocalVariableTestBase { } } - @ExpectedLocals(name = "i", type = "I", scope = 0) - @ExpectedLocals(name = "i", type = "J", scope = 1) - public void reuseByLong() { - { - int i = 0; - } - { - long i = 1; - } - } - class LocalVariableTable implements VariableTable { final LocalVariableTable_attribute att; diff --git a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java index 324ed9a7c5f..4a783a518a1 100644 --- a/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java +++ b/langtools/test/tools/javac/classfiles/attributes/LocalVariableTable/LocalVariableTypeTableTest.java @@ -104,7 +104,6 @@ public class LocalVariableTypeTableTest extends LocalVariableTestBase { @ExpectedLocals(name = "inTry", type = "TTHIS;") @ExpectedLocals(name = "inSync", type = "TTHIS;") @ExpectedLocals(name = "inDo", type = "TTHIS;") - @ExpectedLocals(name = "inSwitch", type = "TTHIS;") @ExpectedLocals(name = "inFor", type = "LLocalVariableTypeTableTest<-TTHIS;>;") @ExpectedLocals(name = "s", type = "Ljava/util/stream/Stream<+Ljava/lang/Integer;>;") public void deepScope() { @@ -130,17 +129,6 @@ public class LocalVariableTypeTableTest extends LocalVariableTestBase { } } - @ExpectedLocals(name = "i", type = "TTHIS;", scope = 0) - @ExpectedLocals(name = "i", type = "Ljava/util/List;", scope = 1) - public void reuseByLong() { - { - THIS i = null; - } - { - List i = null; - } - } - class LocalVariableTypeTable implements VariableTable { final LocalVariableTypeTable_attribute att; diff --git a/langtools/test/tools/javac/flow/LVTHarness.java b/langtools/test/tools/javac/flow/LVTHarness.java index 7039a626a57..c176e5e8ae8 100644 --- a/langtools/test/tools/javac/flow/LVTHarness.java +++ b/langtools/test/tools/javac/flow/LVTHarness.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7047734 8027660 8037937 + * @bug 7047734 8027660 8037937 8047719 * @summary The LVT is not generated correctly during some try/catch scenarios * javac crash while creating LVT entry for a local variable defined in * an inner block diff --git a/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java b/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java index d96850ffd21..e67e191122d 100644 --- a/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java +++ b/langtools/test/tools/javac/flow/tests/TestCaseSwitch.java @@ -5,7 +5,7 @@ public class TestCaseSwitch { @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=16) @AliveRange(varName="o", bytecodeStart=50, bytecodeLength=15) @AliveRange(varName="o", bytecodeStart=68, bytecodeLength=1) - @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=26) + @AliveRange(varName="oo", bytecodeStart=39, bytecodeLength=8) @AliveRange(varName="uu", bytecodeStart=59, bytecodeLength=6) void m1(String[] args) { Object o; @@ -29,7 +29,7 @@ public class TestCaseSwitch { @AliveRange(varName="o", bytecodeStart=95, bytecodeLength=18) @AliveRange(varName="o", bytecodeStart=116, bytecodeLength=15) @AliveRange(varName="o", bytecodeStart=134, bytecodeLength=1) - @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=27) + @AliveRange(varName="oo", bytecodeStart=104, bytecodeLength=9) @AliveRange(varName="uu", bytecodeStart=125, bytecodeLength=6) void m2(String[] args) { Object o; @@ -50,12 +50,14 @@ public class TestCaseSwitch { o = "return"; } - @AliveRange(varName="o", bytecodeStart=31, bytecodeLength=8) - @AliveRange(varName="o", bytecodeStart=42, bytecodeLength=8) - @AliveRange(varName="o", bytecodeStart=53, bytecodeLength=9) - void m3(String[] args) { + @AliveRange(varName="o", bytecodeStart=35, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=46, bytecodeLength=8) + @AliveRange(varName="o", bytecodeStart=78, bytecodeLength=5) + @AliveRange(varName="o", bytecodeStart=86, bytecodeLength=1) + @AliveRange(varName="oo", bytecodeStart=56, bytecodeLength=16) + void m3(int i) { Object o; - switch (args.length) { + switch (i) { case 0: o = "0"; o.hashCode(); @@ -64,10 +66,19 @@ public class TestCaseSwitch { o = "1"; o.hashCode(); break; + case 2: + int oo = i; + if (oo > 1) { + System.out.println("greater"); + } + break; + case 3: + int uu = i; default: o = "default"; o.hashCode(); } o = "finish"; } + } From 8baafcf7ef015ac11ba56dddc1e57e8c2d0624e4 Mon Sep 17 00:00:00 2001 From: Andreas Lundblad Date: Tue, 17 Jun 2014 14:01:27 +0200 Subject: [PATCH 060/236] 8048594: The sjavac client/server protocol should be hidden behind an interface Reviewed-by: jfranck --- .../com/sun/tools/sjavac/CleanProperties.java | 4 +- .../sun/tools/sjavac/CompileJavaPackages.java | 59 ++- .../sun/tools/sjavac/CompileProperties.java | 4 +- .../com/sun/tools/sjavac/CopyFile.java | 4 +- .../com/sun/tools/sjavac/JavacState.java | 17 +- .../classes/com/sun/tools/sjavac/Main.java | 9 +- .../com/sun/tools/sjavac/Transformer.java | 4 +- .../classes/com/sun/tools/sjavac/Util.java | 21 +- .../sjavac/comp/JavaCompilerWithDeps.java | 14 +- .../tools/sjavac/comp/JavacServiceImpl.java | 121 ++++++ .../sjavac/server/CompilationResult.java | 30 ++ .../sun/tools/sjavac/server/CompilerPool.java | 6 +- .../tools/sjavac/server/CompilerThread.java | 7 +- .../sun/tools/sjavac/server/JavacServer.java | 396 +---------------- .../sun/tools/sjavac/server/JavacService.java | 18 + .../sjavac/server/JavacServiceClient.java | 408 ++++++++++++++++++ langtools/test/tools/sjavac/SJavac.java | 34 +- 17 files changed, 697 insertions(+), 459 deletions(-) create mode 100644 langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java create mode 100644 langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java create mode 100644 langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java create mode 100644 langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java b/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java index 346853c9faf..3c39532b7bf 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CleanProperties.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Properties; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * The clean properties transform should not be necessary. @@ -56,7 +57,8 @@ public class CleanProperties implements Transformer // Any extra information is ignored for clean properties. } - public boolean transform(Map> pkgSrcs, + public boolean transform(JavacService javacService, + Map> pkgSrcs, Set visibleSrcs, Map> visibleClasses, Map> oldPackageDependencies, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java b/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java index f66e8952c1e..93346c6ad52 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CompileJavaPackages.java @@ -25,15 +25,18 @@ package com.sun.tools.sjavac; +import java.io.File; import java.io.PrintStream; import java.net.URI; import java.util.Arrays; +import java.util.Collections; import java.util.Random; import java.util.Set; import java.util.Map; import com.sun.tools.sjavac.options.Options; -import com.sun.tools.sjavac.server.JavacServer; +import com.sun.tools.sjavac.server.CompilationResult; +import com.sun.tools.sjavac.server.JavacService; import com.sun.tools.sjavac.server.SysInfo; /** @@ -64,9 +67,10 @@ public class CompileJavaPackages implements Transformer { args = a; } - public boolean transform(Map> pkgSrcs, - Set visibleSources, - Map> visibleClasses, + public boolean transform(final JavacService javacService, + Map> pkgSrcs, + final Set visibleSources, + final Map> visibleClasses, Map> oldPackageDependents, URI destRoot, final Map> packageArtifacts, @@ -75,24 +79,25 @@ public class CompileJavaPackages implements Transformer { int debugLevel, boolean incremental, int numCores, - PrintStream out, - PrintStream err) + final PrintStream out, + final PrintStream err) { boolean rc = true; boolean concurrentCompiles = true; // Fetch the id. - String id = Util.extractStringOption("id", args.getServerConf()); - if (id == null || id.equals("")) { + String idOpt = Util.extractStringOption("id", args.getServerConf()); + if (idOpt == null || idOpt.equals("")) { // No explicit id set. Create a random id so that the requests can be // grouped properly in the server. - id = "id"+(((new Random()).nextLong())&Long.MAX_VALUE); + idOpt = "id"+(((new Random()).nextLong())&Long.MAX_VALUE); } + final String id = idOpt; // Only keep portfile and sjavac settings.. String psServerSettings = Util.cleanSubOptions(Util.set("portfile","sjavac","background","keepalive"), args.getServerConf()); // Get maximum heap size from the server! - SysInfo sysinfo = JavacServer.connectGetSysInfo(psServerSettings, out, err); + SysInfo sysinfo = javacService.getSysInfo(); if (sysinfo.numCores == -1) { Log.error("Could not query server for sysinfo!"); return false; @@ -201,13 +206,10 @@ public class CompileJavaPackages implements Transformer { } // The return values for each chunked compile. - final int[] rn = new int[numCompiles]; + final CompilationResult[] rn = new CompilationResult[numCompiles]; // The requets, might or might not run as a background thread. final Thread[] requests = new Thread[numCompiles]; - final Set fvisible_sources = visibleSources; - final Map> fvisible_classes = visibleClasses; - long start = System.currentTimeMillis(); for (int i=0; iemptyList(), + cc.srcs, + visibleSources); + packageArtifacts.putAll(rn[ii].packageArtifacts); + packageDependencies.putAll(rn[ii].packageDependencies); + packagePubapis.putAll(rn[ii].packagePubapis); } }; @@ -253,7 +252,7 @@ public class CompileJavaPackages implements Transformer { else { requests[ii].run(); // If there was an error, then stop early when running single threaded. - if (rn[i] != 0) { + if (rn[i].returnCode != 0) { return false; } } @@ -269,7 +268,7 @@ public class CompileJavaPackages implements Transformer { // Check the return values. for (int i=0; i 0) { - if (rn[i] != 0) { + if (rn[i].returnCode != 0) { rc = false; } } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java b/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java index 48213c47991..4658f96b9dc 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CompileProperties.java @@ -38,6 +38,7 @@ import java.util.HashSet; import java.util.Map; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * Compile properties transform a properties file into a Java source file. @@ -63,7 +64,8 @@ public class CompileProperties implements Transformer public void setExtra(Options a) { } - public boolean transform(Map> pkgSrcs, + public boolean transform(JavacService javacService, + Map> pkgSrcs, Set visibleSrcs, Map> visibleClasses, Map> oldPackageDependents, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java b/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java index a791ef0f28b..3d32229eea6 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/CopyFile.java @@ -32,6 +32,7 @@ import java.util.HashSet; import java.util.Map; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * The copy file transform simply copies a matching file from -src to -d . @@ -50,7 +51,8 @@ public class CopyFile implements Transformer { public void setExtra(Options a) { } - public boolean transform(Map> pkgSrcs, + public boolean transform(JavacService javacService, + Map> pkgSrcs, Set visibleSrcs, Map> visibleClasses, Map> oldPackageDependents, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java b/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java index 1ec71c2bf56..aa26025ea5a 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/JavacState.java @@ -40,6 +40,7 @@ import java.util.*; import com.sun.tools.sjavac.options.Options; import com.sun.tools.sjavac.options.SourceLocation; +import com.sun.tools.sjavac.server.JavacService; /** * The javac state class maintains the previous (prev) and the current (now) @@ -625,7 +626,7 @@ public class JavacState sr.put(e.getKey(), e.getValue()); } } - perform(binDir, sr); + perform(null, binDir, sr); } /** @@ -641,20 +642,21 @@ public class JavacState sr.put(e.getKey(), e.getValue()); } - perform(gensrcDir, sr); + perform(null, gensrcDir, sr); } /** * Compile all the java sources. Return true, if it needs to be called again! */ - public boolean performJavaCompilations(Options args, + public boolean performJavaCompilations(JavacService javacService, + Options args, Set recentlyCompiled, boolean[] rcValue) { Map suffixRules = new HashMap<>(); suffixRules.put(".java", compileJavaPackages); compileJavaPackages.setExtra(args); - rcValue[0] = perform(binDir, suffixRules); + rcValue[0] = perform(javacService, binDir, suffixRules); recentlyCompiled.addAll(taintedPackages()); clearTaintedPackages(); boolean again = !packagesWithChangedPublicApis.isEmpty(); @@ -684,7 +686,9 @@ public class JavacState * For all packages, find all sources belonging to the package, group the sources * based on their transformers and apply the transformers on each source code group. */ - private boolean perform(File outputDir, Map suffixRules) + private boolean perform(JavacService javacService, + File outputDir, + Map suffixRules) { boolean rc = true; // Group sources based on transforms. A source file can only belong to a single transform. @@ -709,7 +713,8 @@ public class JavacState Map packagePublicApis = Collections.synchronizedMap(new HashMap()); - boolean r = t.transform(srcs, + boolean r = t.transform(javacService, + srcs, visibleSrcs, visibleClasses, prev.dependents(), diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java index dc97eae6e11..3ec46f60af4 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Main.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Main.java @@ -33,7 +33,9 @@ import java.nio.file.Files; import com.sun.tools.sjavac.options.Options; import com.sun.tools.sjavac.options.SourceLocation; +import com.sun.tools.sjavac.server.JavacService; import com.sun.tools.sjavac.server.JavacServer; +import com.sun.tools.sjavac.server.JavacServiceClient; /** * The main class of the smart javac wrapper tool. @@ -339,7 +341,12 @@ public class Main { do { // Clean out artifacts in tainted packages. javac_state.deleteClassArtifactsInTaintedPackages(); - again = javac_state.performJavaCompilations(options, recently_compiled, rc); + // Create a JavacService to delegate the actual compilation to. + // Currently sjavac always connects to a server through a socket + // regardless if sjavac runs as a background service or not. + // This will most likely change in the future. + JavacService javacService = new JavacServiceClient(options.getServerConf()); + again = javac_state.performJavaCompilations(javacService, options, recently_compiled, rc); if (!rc[0]) break; } while (again); // Only update the state if the compile went well. diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java b/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java index 125a02659d4..9922c7ad941 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Transformer.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.Map; import com.sun.tools.sjavac.options.Options; +import com.sun.tools.sjavac.server.JavacService; /** * The transform interface is used to transform content inside a package, from one form to another. @@ -82,7 +83,8 @@ public interface Transformer * If num_cores is set to a non-zero value. The transform should attempt to use no more than these * number of threads for heavy work. */ - boolean transform(Map> pkgSrcs, + boolean transform(JavacService javacService, + Map> pkgSrcs, Set visibleSources, Map> visibleClasses, Map> oldPackageDependencies, diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/Util.java b/langtools/src/share/classes/com/sun/tools/sjavac/Util.java index 146bb172245..5039051977b 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/Util.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/Util.java @@ -26,6 +26,8 @@ package com.sun.tools.sjavac; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.nio.file.Path; import java.util.Arrays; import java.util.HashSet; @@ -67,17 +69,32 @@ public class Util { } public static String extractStringOption(String opName, String s) { + return extractStringOption(opName, s, null); + } + + public static String extractStringOption(String opName, String s, String deflt) { int p = s.indexOf(opName+"="); - if (p == -1) return null; + if (p == -1) return deflt; p+=opName.length()+1; int pe = s.indexOf(',', p); if (pe == -1) pe = s.length(); return s.substring(p, pe); } + public static boolean extractBooleanOption(String opName, String s, boolean deflt) { + String str = extractStringOption(opName, s); + return "true".equals(str) ? true + : "false".equals(str) ? false + : deflt; + } + public static int extractIntOption(String opName, String s) { + return extractIntOption(opName, s, 0); + } + + public static int extractIntOption(String opName, String s, int deflt) { int p = s.indexOf(opName+"="); - if (p == -1) return 0; + if (p == -1) return deflt; p+=opName.length()+1; int pe = s.indexOf(',', p); if (pe == -1) pe = s.length(); diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java index 4f49543352c..0599a8106fe 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavaCompilerWithDeps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -29,8 +29,6 @@ import java.util.StringTokenizer; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.sjavac.server.CompilerThread; -import java.io.File; /** Subclass to Resolve that overrides collect. * @@ -44,16 +42,16 @@ public class JavaCompilerWithDeps extends JavaCompiler { /** The dependency database */ protected Dependencies deps; - protected CompilerThread compilerThread; + protected JavacServiceImpl javacService; - public JavaCompilerWithDeps(Context context, CompilerThread t) { + public JavaCompilerWithDeps(Context context, JavacServiceImpl jsi) { super(context); deps = Dependencies.instance(context); - compilerThread = t; + javacService = jsi; needRootClasses = true; } - public static void preRegister(Context context, final CompilerThread t) { + public static void preRegister(Context context, final JavacServiceImpl t) { context.put(compilerKey, new Context.Factory() { public JavaCompiler make(Context c) { JavaCompiler instance = new JavaCompilerWithDeps(c, t); @@ -99,7 +97,7 @@ public class JavaCompilerWithDeps extends JavaCompiler { // Now check if the truncated uri ends with the path. (It does not == failure!) if (path.length() > 0 && !path.equals("/unnamed package/") && !pp.endsWith(path)) { - compilerThread.logError("Error: The source file "+sym.sourcefile.getName()+ + javacService.logError("Error: The source file "+sym.sourcefile.getName()+ " is located in the wrong package directory, because it contains the class "+ sym.getQualifiedName()); } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java new file mode 100644 index 00000000000..d7dcdc109fc --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/JavacServiceImpl.java @@ -0,0 +1,121 @@ +package com.sun.tools.sjavac.comp; + +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import javax.tools.JavaCompiler.CompilationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; + +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.sjavac.Util; +import com.sun.tools.sjavac.server.CompilationResult; +import com.sun.tools.sjavac.server.JavacServer; +import com.sun.tools.sjavac.server.JavacService; +import com.sun.tools.sjavac.server.SysInfo; + +public class JavacServiceImpl implements JavacService { + + JavacServer javacServer; + private ThreadLocal forcedExit; + + public JavacServiceImpl(JavacServer javacServer) { + this.javacServer = javacServer; + + } + + public void logError(String msg) { +// stderr.println(msg); + forcedExit.set(true); + } + + @Override + public SysInfo getSysInfo() { + return new SysInfo(Runtime.getRuntime().availableProcessors(), + Runtime.getRuntime().maxMemory()); + } + + @Override + public CompilationResult compile(String protocolId, + String invocationId, + String[] args, + List explicitSources, + Set sourcesToCompile, + Set visibleSources) { + + JavacTool compiler = JavacTool.create(); + StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); + SmartFileManager smartFileManager = new SmartFileManager(fileManager); + Context context = new Context(); + ResolveWithDeps.preRegister(context); + AttrWithDeps.preRegister(context); + JavaCompilerWithDeps.preRegister(context, this); + + // Now setup the actual compilation.... + CompilationResult compilationResult = new CompilationResult(0); + + // First deal with explicit source files on cmdline and in at file. + ListBuffer compilationUnits = new ListBuffer<>(); + for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(explicitSources)) { + compilationUnits.append(i); + } + // Now deal with sources supplied as source_to_compile. + ListBuffer sourcesToCompileFiles = new ListBuffer<>(); + for (URI u : sourcesToCompile) { + sourcesToCompileFiles.append(new File(u)); + } + for (JavaFileObject i : fileManager.getJavaFileObjectsFromFiles(sourcesToCompileFiles)) { + compilationUnits.append(i); + } + // Log the options to be used. + StringBuilder options = new StringBuilder(); + for (String s : args) { + options.append(">").append(s).append("< "); + } + javacServer.log(protocolId+" <"+invocationId+"> options "+options.toString()); + + forcedExit.set(false); + // Create a new logger. + StringWriter stdoutLog = new StringWriter(); + StringWriter stderrLog = new StringWriter(); + PrintWriter stdout = new PrintWriter(stdoutLog); + PrintWriter stderr = new PrintWriter(stderrLog); + com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK; + try { + if (compilationUnits.size() > 0) { + smartFileManager.setVisibleSources(visibleSources); + smartFileManager.cleanArtifacts(); + smartFileManager.setLog(stdout); + + + // Do the compilation! + CompilationTask task = compiler.getTask(stderr, smartFileManager, null, Arrays.asList(args), null, compilationUnits, context); + rc = ((JavacTaskImpl) task).doCall(); + smartFileManager.flush(); + } + } catch (Exception e) { + stderr.println(e.getMessage()); + forcedExit.set(true); + } + + compilationResult.packageArtifacts = smartFileManager.getPackageArtifacts(); + + Dependencies deps = Dependencies.instance(context); + compilationResult.packageDependencies = deps.getDependencies(); + compilationResult.packagePubapis = deps.getPubapis(); + + compilationResult.stdout = stdoutLog.toString(); + compilationResult.stderr = stderrLog.toString(); + compilationResult.returnCode = rc.exitCode == 0 && forcedExit.get() ? -1 : rc.exitCode; + + return compilationResult; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java new file mode 100644 index 00000000000..731cd34a5b3 --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilationResult.java @@ -0,0 +1,30 @@ +package com.sun.tools.sjavac.server; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class CompilationResult { + + // Return code constants + public final static int ERROR_BUT_TRY_AGAIN = -4712; + public final static int ERROR_FATAL = -1; + + public int returnCode; + public Map> packageArtifacts = new HashMap<>(); + public Map> packageDependencies = new HashMap<>(); + public Map packagePubapis = new HashMap<>(); + public SysInfo sysinfo; + public String stdout; + public String stderr; + + public CompilationResult(int returnCode) { + this.returnCode = returnCode; + this.sysinfo = new SysInfo(-1, -1); + } + + public void setReturnCode(int returnCode) { + this.returnCode = returnCode; + } +} diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java index d881a4889c1..38e2399ee71 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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,8 @@ import java.util.concurrent.Semaphore; import java.util.Stack; import java.util.concurrent.Future; +import com.sun.tools.sjavac.comp.JavacServiceImpl; + /** The compiler pool maintains compiler threads. * *

This is NOT part of any supported API. @@ -147,7 +149,7 @@ public class CompilerPool { public CompilerThread grabCompilerThread() throws InterruptedException { available.acquire(); if (compilers.empty()) { - return new CompilerThread(this); + return new CompilerThread(this, new JavacServiceImpl(javacServer)); } return compilers.pop(); } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java index cb60be23814..59bff44c207 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java @@ -55,6 +55,7 @@ import com.sun.tools.javac.util.StringUtils; import com.sun.tools.sjavac.comp.AttrWithDeps; import com.sun.tools.sjavac.comp.Dependencies; import com.sun.tools.sjavac.comp.JavaCompilerWithDeps; +import com.sun.tools.sjavac.comp.JavacServiceImpl; import com.sun.tools.sjavac.comp.ResolveWithDeps; import com.sun.tools.sjavac.comp.SmartFileManager; @@ -71,6 +72,7 @@ import com.sun.tools.sjavac.comp.SmartFileManager; public class CompilerThread implements Runnable { private JavacServer javacServer; private CompilerPool compilerPool; + private JavacServiceImpl javacServiceImpl; private List> subTasks; // Communicating over this socket. @@ -85,9 +87,10 @@ public class CompilerThread implements Runnable { // If true, then this thread is serving a request. private boolean inUse = false; - CompilerThread(CompilerPool cp) { + CompilerThread(CompilerPool cp, JavacServiceImpl javacServiceImpl) { compilerPool = cp; javacServer = cp.getJavacServer(); + this.javacServiceImpl = javacServiceImpl; } /** @@ -131,7 +134,7 @@ public class CompilerThread implements Runnable { context = new Context(); ResolveWithDeps.preRegister(context); AttrWithDeps.preRegister(context); - JavaCompilerWithDeps.preRegister(context, this); + JavaCompilerWithDeps.preRegister(context, javacServiceImpl); subTasks = new ArrayList<>(); } diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java index 2592a423965..c181be9d566 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServer.java @@ -24,30 +24,22 @@ */ package com.sun.tools.sjavac.server; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.FileNotFoundException; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; import java.util.HashMap; import java.util.Map; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; -import java.net.SocketAddress; import java.util.ArrayList; import java.util.Random; import com.sun.tools.sjavac.Util; import com.sun.tools.sjavac.ProblemException; import java.io.*; -import java.util.*; /** * The JavacServer class contains methods both to setup a server that responds to requests and methods to connect to this server. @@ -73,8 +65,6 @@ public class JavacServer { // Though usually only one javac server is started by a client. private static Map allPortFiles; private static Map maxServerMemory; - final static int ERROR_FATAL = -1; - final static int ERROR_BUT_TRY_AGAIN = -4712; final static String PROTOCOL_COOKIE_VERSION = "----THE-COOKIE-V2----"; final static String PROTOCOL_CWD = "----THE-CWD----"; final static String PROTOCOL_ID = "----THE-ID----"; @@ -99,7 +89,7 @@ public class JavacServer { /** * Acquire the port file. Synchronized since several threads inside an smart javac wrapper client acquires the same port file at the same time. */ - private static synchronized PortFile getPortFile(String filename) throws FileNotFoundException { + public static synchronized PortFile getPortFile(String filename) throws FileNotFoundException { if (allPortFiles == null) { allPortFiles = new HashMap<>(); } @@ -179,17 +169,12 @@ public class JavacServer { // and stderr are redirected already. // The pool size is a limit the number of concurrent compiler threads used. // The server might use less than these to avoid memory problems. - int poolsize = Util.extractIntOption("poolsize", settings); - if (poolsize <= 0) { - // If not set, default to the number of cores. - poolsize = Runtime.getRuntime().availableProcessors(); - } + int defaultPoolSize = Runtime.getRuntime().availableProcessors(); + int poolsize = Util.extractIntOption("poolsize", settings, defaultPoolSize); // How many seconds of inactivity will the server accept before quitting? - int keepalive = Util.extractIntOption("keepalive", settings); - if (keepalive <= 0) { - keepalive = 120; - } + int keepalive = Util.extractIntOption("keepalive", settings, 120); + // The port file is locked and the server port and cookie is written into it. PortFile portFile = getPortFile(portfile); JavacServer s; @@ -219,134 +204,6 @@ public class JavacServer { } } - /** - * Dispatch a compilation request to a javac server. - * - * @param args are the command line args to javac and is allowed to contain source files, @file and other command line options to javac. - * - * The generated classes, h files and other artifacts from the javac invocation are stored by the javac server to disk. - * - * @param sources_to_compile The sources to compile. - * - * @param visibleSources If visible sources has a non zero size, then visible_sources are the only files in the file system that the javac server can see! - * (Sources to compile are always visible.) The visible sources are those supplied by the (filtered) -sourcepath - * - * @param visibleClasses If visible classes for a specific root/jar has a non zero size, then visible_classes are the only class files that the javac server - * can see, in that root/jar. It maps from a classpath root or a jar file to the set of visible classes for that root/jar. - * - * The server return meta data about the build in the following parameters. - * @param package_artifacts, map from package name to set of created artifacts for that package. - * @param package_dependencies, map from package name to set of packages that it depends upon. - * @param package_pubapis, map from package name to unique string identifying its pub api. - */ - public static int useServer(String settings, String[] args, - Set sourcesToCompile, - Set visibleSources, - Map> visibleClasses, - Map> packageArtifacts, - Map> packageDependencies, - Map packagePubapis, - SysInfo sysinfo, - PrintStream out, - PrintStream err) { - try { - // The id can perhaps be used in the future by the javac server to reuse the - // JavaCompiler instance for several compiles using the same id. - String id = Util.extractStringOption("id", settings); - String portfile = Util.extractStringOption("portfile", settings); - String logfile = Util.extractStringOption("logfile", settings); - String stdouterrfile = Util.extractStringOption("stdouterrfile", settings); - String background = Util.extractStringOption("background", settings); - if (background == null || !background.equals("false")) { - background = "true"; - } - // The sjavac option specifies how the server part of sjavac is spawned. - // If you have the experimental sjavac in your path, you are done. If not, you have - // to point to a com.sun.tools.sjavac.Main that supports --startserver - // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main - String sjavac = Util.extractStringOption("sjavac", settings); - int poolsize = Util.extractIntOption("poolsize", settings); - int keepalive = Util.extractIntOption("keepalive", settings); - - if (keepalive <= 0) { - // Default keepalive for server is 120 seconds. - // I.e. it will accept 120 seconds of inactivity before quitting. - keepalive = 120; - } - if (portfile == null) { - err.println("No portfile was specified!"); - return -1; - } - if (logfile == null) { - logfile = portfile + ".javaclog"; - } - if (stdouterrfile == null) { - stdouterrfile = portfile + ".stdouterr"; - } - // Default to sjavac and hope it is in the path. - if (sjavac == null) { - sjavac = "sjavac"; - } - - int attempts = 0; - int rc = -1; - do { - PortFile port_file = getPortFile(portfile); - synchronized (port_file) { - port_file.lock(); - port_file.getValues(); - port_file.unlock(); - } - if (!port_file.containsPortInfo()) { - String cmd = fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, err, stdouterrfile, background); - - if (background.equals("true") && !port_file.waitForValidValues()) { - // Ouch the server did not start! Lets print its stdouterrfile and the command used. - printFailedAttempt(cmd, stdouterrfile, err); - // And give up. - return -1; - } - } - rc = connectAndCompile(port_file, id, args, sourcesToCompile, visibleSources, - packageArtifacts, packageDependencies, packagePubapis, sysinfo, - out, err); - // Try again until we manage to connect. Any error after that - // will cause the compilation to fail. - if (rc == ERROR_BUT_TRY_AGAIN) { - // We could not connect to the server. Try again. - attempts++; - try { - Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS * 1000); - } catch (InterruptedException e) { - } - } - } while (rc == ERROR_BUT_TRY_AGAIN && attempts < MAX_NUM_CONNECT_ATTEMPTS); - return rc; - } catch (Exception e) { - e.printStackTrace(err); - return -1; - } - } - - private static void printFailedAttempt(String cmd, String f, PrintStream err) { - err.println("---- Failed to start javac server with this command -----"); - err.println(cmd); - try { - BufferedReader in = new BufferedReader(new FileReader(f)); - err.println("---- stdout/stderr output from attempt to start javac server -----"); - for (;;) { - String l = in.readLine(); - if (l == null) { - break; - } - err.println(l); - } - err.println("------------------------------------------------------------------"); - } catch (Exception e) { - err.println("The stdout/stderr output in file " + f + " does not exist and the server did not start."); - } - } - /** * Spawn the server instance. */ @@ -367,15 +224,15 @@ public class JavacServer { /** * Fork a background process. Returns the command line used that can be printed if something failed. */ - private static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive, - final PrintStream err, String stdouterrfile, String background) + public static String fork(String sjavac, String portfile, String logfile, int poolsize, int keepalive, + final PrintStream err, String stdouterrfile, boolean background) throws IOException, ProblemException { if (stdouterrfile != null && stdouterrfile.trim().equals("")) { stdouterrfile = null; } final String startserver = "--startserver:portfile=" + portfile + ",logfile=" + logfile + ",stdouterrfile=" + stdouterrfile + ",poolsize=" + poolsize + ",keepalive="+ keepalive; - if (background.equals("true")) { + if (background) { sjavac += "%20" + startserver; sjavac = sjavac.replaceAll("%20", " "); sjavac = sjavac.replaceAll("%2C", ","); @@ -420,243 +277,6 @@ public class JavacServer { return ""; } - /** - * Expect this key on the next line read from the reader. - */ - private static boolean expect(BufferedReader in, String key) throws IOException { - String s = in.readLine(); - if (s != null && s.equals(key)) { - return true; - } - return false; - } - - /** - * Make a request to the server only to get the maximum possible heap size to use for compilations. - * - * @param port_file The port file used to synchronize creation of this server. - * @param id The identify of the compilation. - * @param out Standard out information. - * @param err Standard err information. - * @return The maximum heap size in bytes. - */ - public static SysInfo connectGetSysInfo(String serverSettings, PrintStream out, PrintStream err) { - SysInfo sysinfo = new SysInfo(-1, -1); - String id = Util.extractStringOption("id", serverSettings); - String portfile = Util.extractStringOption("portfile", serverSettings); - try { - PortFile pf = getPortFile(portfile); - useServer(serverSettings, new String[0], - new HashSet(), - new HashSet(), - new HashMap>(), - new HashMap>(), - new HashMap>(), - new HashMap(), - sysinfo, out, err); - } catch (Exception e) { - e.printStackTrace(err); - } - return sysinfo; - } - - /** - * Connect and compile using the javac server settings and the args. When using more advanced features, the sources_to_compile and visible_sources are - * supplied to the server and meta data is returned in package_artifacts, package_dependencies and package_pubapis. - */ - private static int connectAndCompile(PortFile portFile, String id, String[] args, - Set sourcesToCompile, - Set visibleSources, - Map> packageArtifacts, - Map> packageDependencies, - Map packagePublicApis, - SysInfo sysinfo, - PrintStream out, - PrintStream err) { - int rc = -3; - try { - int port = portFile.containsPortInfo() ? portFile.getPort() : 0; - if (port == 0) { - return ERROR_BUT_TRY_AGAIN; - } - long cookie = portFile.getCookie(); - - // Acquire the localhost/127.0.0.1 address. - InetAddress addr = InetAddress.getByName(null); - SocketAddress sockaddr = new InetSocketAddress(addr, port); - Socket sock = new Socket(); - int timeoutMs = CONNECTION_TIMEOUT * 1000; - try { - sock.connect(sockaddr, timeoutMs); - } catch (java.net.ConnectException e) { - err.println("Could not connect to javac server found in portfile: " + portFile.getFilename() + " " + e); - return ERROR_BUT_TRY_AGAIN; - } - if (!sock.isConnected()) { - err.println("Could not connect to javac server found in portfile: " + portFile.getFilename()); - return ERROR_BUT_TRY_AGAIN; - } - BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); - PrintWriter sockout = new PrintWriter(sock.getOutputStream()); - - sockout.println(PROTOCOL_COOKIE_VERSION); - sockout.println("" + cookie); - sockout.println(PROTOCOL_CWD); - sockout.println(System.getProperty("user.dir")); - sockout.println(PROTOCOL_ID); - sockout.println(id); - sockout.println(PROTOCOL_ARGS); - for (String s : args) { - StringBuffer buf = new StringBuffer(); - String[] paths = s.split(File.pathSeparator); - int c = 0; - for (String path : paths) { - File f = new File(path); - if (f.isFile() || f.isDirectory()) { - buf.append(f.getAbsolutePath()); - c++; - if (c < paths.length) { - buf.append(File.pathSeparator); - } - } else { - buf = new StringBuffer(s); - break; - } - } - sockout.println(buf.toString()); - } - sockout.println(PROTOCOL_SOURCES_TO_COMPILE); - for (URI uri : sourcesToCompile) { - sockout.println(uri.toString()); - } - sockout.println(PROTOCOL_VISIBLE_SOURCES); - for (URI uri : visibleSources) { - sockout.println(uri.toString()); - } - sockout.println(PROTOCOL_END); - sockout.flush(); - - StringBuffer stdout = new StringBuffer(); - StringBuffer stderr = new StringBuffer(); - - if (!expect(in, PROTOCOL_STDOUT)) { - return ERROR_FATAL; - } - // Load stdout - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_STDERR)) { - break; - } - stdout.append(l); - stdout.append('\n'); - } - // Load stderr - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_PACKAGE_ARTIFACTS)) { - break; - } - stderr.append(l); - stderr.append('\n'); - } - // Load the package artifacts - Set lastUriSet = null; - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_PACKAGE_DEPENDENCIES)) { - break; - } - if (l.length() > 1 && l.charAt(0) == '+') { - String pkg = l.substring(1); - lastUriSet = new HashSet<>(); - packageArtifacts.put(pkg, lastUriSet); - } else if (l.length() > 1 && lastUriSet != null) { - lastUriSet.add(new URI(l.substring(1))); - } - } - // Load package dependencies - Set lastPackageSet = null; - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_PACKAGE_PUBLIC_APIS)) { - break; - } - if (l.length() > 1 && l.charAt(0) == '+') { - String pkg = l.substring(1); - lastPackageSet = new HashSet<>(); - packageDependencies.put(pkg, lastPackageSet); - } else if (l.length() > 1 && lastPackageSet != null) { - lastPackageSet.add(l.substring(1)); - } - } - // Load package pubapis - Map tmp = new HashMap<>(); - StringBuffer lastPublicApi = null; - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_SYSINFO)) { - break; - } - if (l.length() > 1 && l.charAt(0) == '+') { - String pkg = l.substring(1); - lastPublicApi = new StringBuffer(); - tmp.put(pkg, lastPublicApi); - } else if (l.length() > 1 && lastPublicApi != null) { - lastPublicApi.append(l.substring(1)); - lastPublicApi.append("\n"); - } - } - for (String p : tmp.keySet()) { - assert (packagePublicApis.get(p) == null); - String api = tmp.get(p).toString(); - packagePublicApis.put(p, api); - } - // Now reading the max memory possible. - for (;;) { - String l = in.readLine(); - if (l == null) { - return ERROR_FATAL; - } - if (l.equals(PROTOCOL_RETURN_CODE)) { - break; - } - if (l.startsWith("num_cores=") && sysinfo != null) { - sysinfo.numCores = Integer.parseInt(l.substring(10)); - } - if (l.startsWith("max_memory=") && sysinfo != null) { - sysinfo.maxMemory = Long.parseLong(l.substring(11)); - } - } - String l = in.readLine(); - if (l == null) { - err.println("No return value from the server!"); - return ERROR_FATAL; - } - rc = Integer.parseInt(l); - out.print(stdout); - err.print(stderr); - } catch (Exception e) { - e.printStackTrace(err); - } - return rc; - } - /** * Run the server thread until it exits. Either because of inactivity or because the port file has been deleted by someone else, or overtaken by some other * javac server. diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java new file mode 100644 index 00000000000..d6f6d3af6ae --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacService.java @@ -0,0 +1,18 @@ +package com.sun.tools.sjavac.server; + +import java.io.File; +import java.net.URI; +import java.util.List; +import java.util.Set; + +public interface JavacService { + + SysInfo getSysInfo(); + + CompilationResult compile(String protocolId, + String invocationId, + String[] args, + List explicitSources, + Set sourcesToCompile, + Set visibleSources); +} diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java new file mode 100644 index 00000000000..f9f6e2b05fa --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/JavacServiceClient.java @@ -0,0 +1,408 @@ +package com.sun.tools.sjavac.server; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketAddress; +import java.net.URI; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.sun.tools.sjavac.Util; + +import static com.sun.tools.sjavac.server.CompilationResult.ERROR_BUT_TRY_AGAIN; +import static com.sun.tools.sjavac.server.CompilationResult.ERROR_FATAL; + +public class JavacServiceClient implements JavacService { + + + // The id can perhaps be used in the future by the javac server to reuse the + // JavaCompiler instance for several compiles using the same id. + private final String id; + private final String portfile; + private final String logfile; + private final String stdouterrfile; + private final boolean background; + + // Default keepalive for server is 120 seconds. + // I.e. it will accept 120 seconds of inactivity before quitting. + private final int keepalive; + private final int poolsize; + + // The sjavac option specifies how the server part of sjavac is spawned. + // If you have the experimental sjavac in your path, you are done. If not, you have + // to point to a com.sun.tools.sjavac.Main that supports --startserver + // for example by setting: sjavac=java%20-jar%20...javac.jar%com.sun.tools.sjavac.Main + private final String sjavac; + + public JavacServiceClient(String settings) { + id = Util.extractStringOption("id", settings); + portfile = Util.extractStringOption("portfile", settings); + logfile = Util.extractStringOption("logfile", settings, portfile + ".javaclog"); + stdouterrfile = Util.extractStringOption("stdouterrfile", settings, portfile + ".stdouterr"); + background = Util.extractBooleanOption("background", settings, true); + sjavac = Util.extractStringOption("sjavac", settings, "sjavac"); + int poolsize = Util.extractIntOption("poolsize", settings); + keepalive = Util.extractIntOption("keepalive", settings, 120); + + this.poolsize = poolsize > 0 ? poolsize : Runtime.getRuntime().availableProcessors(); + } + + + /** + * Make a request to the server only to get the maximum possible heap size to use for compilations. + * + * @param port_file The port file used to synchronize creation of this server. + * @param id The identify of the compilation. + * @param out Standard out information. + * @param err Standard err information. + * @return The maximum heap size in bytes. + */ + @Override + public SysInfo getSysInfo() { + try { + CompilationResult cr = useServer(new String[0], + Collections.emptySet(), + Collections.emptySet(), + Collections.>emptyMap()); + return cr.sysinfo; + } catch (Exception e) { + return new SysInfo(-1, -1); + } + } + + @Override + public CompilationResult compile(String protocolId, + String invocationId, + String[] args, + List explicitSources, + Set sourcesToCompile, + Set visibleSources) { + // Delegate to useServer, which delegates to compileHelper + return useServer(args, sourcesToCompile, visibleSources, null); + } + + /** + * Connect and compile using the javac server settings and the args. When using more advanced features, the sources_to_compile and visible_sources are + * supplied to the server and meta data is returned in package_artifacts, package_dependencies and package_pubapis. + */ + public CompilationResult compileHelper(String id, + String[] args, + Set sourcesToCompile, + Set visibleSources) { + + CompilationResult rc = new CompilationResult(-3); + + try { + PortFile portFile = JavacServer.getPortFile(this.portfile); + + int port = portFile.containsPortInfo() ? portFile.getPort() : 0; + if (port == 0) { + return new CompilationResult(ERROR_BUT_TRY_AGAIN); + } + long cookie = portFile.getCookie(); + // Acquire the localhost/127.0.0.1 address. + InetAddress addr = InetAddress.getByName(null); + SocketAddress sockaddr = new InetSocketAddress(addr, port); + Socket sock = new Socket(); + int timeoutMs = JavacServer.CONNECTION_TIMEOUT * 1000; + try { + sock.connect(sockaddr, timeoutMs); + } catch (java.net.ConnectException e) { + rc.setReturnCode(ERROR_BUT_TRY_AGAIN); + rc.stderr = "Could not connect to javac server found in portfile: " + portFile.getFilename() + " " + e; + return rc; + } + if (!sock.isConnected()) { + rc.setReturnCode(ERROR_BUT_TRY_AGAIN); + rc.stderr = "Could not connect to javac server found in portfile: " + portFile.getFilename(); + return rc; + } + + // + // Send arguments + // + BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream())); + PrintWriter sockout = new PrintWriter(sock.getOutputStream()); + + sockout.println(JavacServer.PROTOCOL_COOKIE_VERSION); + sockout.println("" + cookie); + sockout.println(JavacServer.PROTOCOL_CWD); + sockout.println(System.getProperty("user.dir")); + sockout.println(JavacServer.PROTOCOL_ID); + sockout.println(id); + sockout.println(JavacServer.PROTOCOL_ARGS); + for (String s : args) { + StringBuffer buf = new StringBuffer(); + String[] paths = s.split(File.pathSeparator); + int c = 0; + for (String path : paths) { + File f = new File(path); + if (f.isFile() || f.isDirectory()) { + buf.append(f.getAbsolutePath()); + c++; + if (c < paths.length) { + buf.append(File.pathSeparator); + } + } else { + buf = new StringBuffer(s); + break; + } + } + sockout.println(buf.toString()); + } + sockout.println(JavacServer.PROTOCOL_SOURCES_TO_COMPILE); + for (URI uri : sourcesToCompile) { + sockout.println(uri.toString()); + } + sockout.println(JavacServer.PROTOCOL_VISIBLE_SOURCES); + for (URI uri : visibleSources) { + sockout.println(uri.toString()); + } + sockout.println(JavacServer.PROTOCOL_END); + sockout.flush(); + + // + // Receive result + // + StringBuffer stdout = new StringBuffer(); + StringBuffer stderr = new StringBuffer(); + + if (!JavacServiceClient.expect(in, JavacServer.PROTOCOL_STDOUT)) { + return new CompilationResult(ERROR_FATAL); + } + // Load stdout + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_STDERR)) { + break; + } + stdout.append(l); + stdout.append('\n'); + } + // Load stderr + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_PACKAGE_ARTIFACTS)) { + break; + } + stderr.append(l); + stderr.append('\n'); + } + // Load the package artifacts + Set lastUriSet = null; + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_PACKAGE_DEPENDENCIES)) { + break; + } + if (l.length() > 1 && l.charAt(0) == '+') { + String pkg = l.substring(1); + lastUriSet = new HashSet<>(); + rc.packageArtifacts.put(pkg, lastUriSet); + } else if (l.length() > 1 && lastUriSet != null) { + lastUriSet.add(new URI(l.substring(1))); + } + } + // Load package dependencies + Set lastPackageSet = null; + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_PACKAGE_PUBLIC_APIS)) { + break; + } + if (l.length() > 1 && l.charAt(0) == '+') { + String pkg = l.substring(1); + lastPackageSet = new HashSet<>(); + rc.packageDependencies.put(pkg, lastPackageSet); + } else if (l.length() > 1 && lastPackageSet != null) { + lastPackageSet.add(l.substring(1)); + } + } + // Load package pubapis + Map tmp = new HashMap<>(); + StringBuffer lastPublicApi = null; + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_SYSINFO)) { + break; + } + if (l.length() > 1 && l.charAt(0) == '+') { + String pkg = l.substring(1); + lastPublicApi = new StringBuffer(); + tmp.put(pkg, lastPublicApi); + } else if (l.length() > 1 && lastPublicApi != null) { + lastPublicApi.append(l.substring(1)); + lastPublicApi.append("\n"); + } + } + for (String p : tmp.keySet()) { + //assert (packagePublicApis.get(p) == null); + String api = tmp.get(p).toString(); + rc.packagePubapis.put(p, api); + } + // Now reading the max memory possible. + for (;;) { + String l = in.readLine(); + if (l == null) { + return new CompilationResult(ERROR_FATAL); + } + if (l.equals(JavacServer.PROTOCOL_RETURN_CODE)) { + break; + } + if (l.startsWith("num_cores=")) { + rc.sysinfo.numCores = Integer.parseInt(l.substring(10)); + } + if (l.startsWith("max_memory=")) { + rc.sysinfo.maxMemory = Long.parseLong(l.substring(11)); + } + } + String l = in.readLine(); + if (l == null) { + rc.setReturnCode(ERROR_FATAL); + rc.stderr = "No return value from the server!"; + return rc; + } + rc.setReturnCode(Integer.parseInt(l)); + rc.stdout = stdout.toString(); + rc.stderr = stderr.toString(); + } catch (Exception e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + rc.stderr = sw.toString(); + } + return rc; + } + + /** + * Dispatch a compilation request to a javac server. + * + * @param args are the command line args to javac and is allowed to contain source files, @file and other command line options to javac. + * + * The generated classes, h files and other artifacts from the javac invocation are stored by the javac server to disk. + * + * @param sources_to_compile The sources to compile. + * + * @param visibleSources If visible sources has a non zero size, then visible_sources are the only files in the file system that the javac server can see! + * (Sources to compile are always visible.) The visible sources are those supplied by the (filtered) -sourcepath + * + * @param visibleClasses If visible classes for a specific root/jar has a non zero size, then visible_classes are the only class files that the javac server + * can see, in that root/jar. It maps from a classpath root or a jar file to the set of visible classes for that root/jar. + * + * The server return meta data about the build in the following parameters. + * @param package_artifacts, map from package name to set of created artifacts for that package. + * @param package_dependencies, map from package name to set of packages that it depends upon. + * @param package_pubapis, map from package name to unique string identifying its pub api. + */ + public CompilationResult useServer(String[] args, + Set sourcesToCompile, + Set visibleSources, + Map> visibleClasses) { + try { + if (portfile == null) { + CompilationResult cr = new CompilationResult(CompilationResult.ERROR_FATAL); + cr.stderr = "No portfile was specified!"; + return cr; + } + + int attempts = 0; + CompilationResult rc; + do { + PortFile port_file = JavacServer.getPortFile(portfile); + synchronized (port_file) { + port_file.lock(); + port_file.getValues(); + port_file.unlock(); + } + if (!port_file.containsPortInfo()) { + String cmd = JavacServer.fork(sjavac, port_file.getFilename(), logfile, poolsize, keepalive, System.err, stdouterrfile, background); + + if (background && !port_file.waitForValidValues()) { + // Ouch the server did not start! Lets print its stdouterrfile and the command used. + StringWriter sw = new StringWriter(); + JavacServiceClient.printFailedAttempt(cmd, stdouterrfile, new PrintWriter(sw)); + // And give up. + CompilationResult cr = new CompilationResult(ERROR_FATAL); + cr.stderr = sw.toString(); + return cr; + } + } + rc = compileHelper(id, args, sourcesToCompile, visibleSources); + // Try again until we manage to connect. Any error after that + // will cause the compilation to fail. + if (rc.returnCode == CompilationResult.ERROR_BUT_TRY_AGAIN) { + // We could not connect to the server. Try again. + attempts++; + try { + Thread.sleep(JavacServer.WAIT_BETWEEN_CONNECT_ATTEMPTS * 1000); + } catch (InterruptedException e) { + } + } + } while (rc.returnCode == ERROR_BUT_TRY_AGAIN && attempts < JavacServer.MAX_NUM_CONNECT_ATTEMPTS); + return rc; + } catch (Exception e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + CompilationResult cr = new CompilationResult(ERROR_FATAL); + cr.stderr = sw.toString(); + return cr; + } + } + + public static void printFailedAttempt(String cmd, String f, PrintWriter err) { + err.println("---- Failed to start javac server with this command -----"); + err.println(cmd); + try { + BufferedReader in = new BufferedReader(new FileReader(f)); + err.println("---- stdout/stderr output from attempt to start javac server -----"); + for (;;) { + String l = in.readLine(); + if (l == null) { + break; + } + err.println(l); + } + err.println("------------------------------------------------------------------"); + } catch (Exception e) { + err.println("The stdout/stderr output in file " + f + " does not exist and the server did not start."); + } + } + + /** + * Expect this key on the next line read from the reader. + */ + public static boolean expect(BufferedReader in, String key) throws IOException { + String s = in.readLine(); + if (s != null && s.equals(key)) { + return true; + } + return false; + } +} diff --git a/langtools/test/tools/sjavac/SJavac.java b/langtools/test/tools/sjavac/SJavac.java index 867643e7f98..59fb7585024 100644 --- a/langtools/test/tools/sjavac/SJavac.java +++ b/langtools/test/tools/sjavac/SJavac.java @@ -23,7 +23,6 @@ import java.util.*; import java.io.*; -import java.net.*; import java.nio.file.*; import java.nio.file.attribute.*; import java.nio.charset.*; @@ -43,6 +42,9 @@ class SJavac { } FileSystem defaultfs = FileSystems.getDefault(); + String serverArg = "--server:" + + "portfile=testportfile," + + "background=false"; // Where to put generated sources that will // test aspects of sjavac, ie JTWork/scratch/gensrc @@ -136,7 +138,7 @@ class SJavac { "private int b() { return A.DEFINITION; } native void foo(); }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); previous_bin_state = collectState(bin); previous_headers_state = collectState(headers); } @@ -145,7 +147,7 @@ class SJavac { System.out.println("\nTesting that no change in sources implies no change in binaries."); System.out.println("------------------------------------------------------------------"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyEqual(new_bin_state, previous_bin_state); Map new_headers_state = collectState(headers); @@ -158,7 +160,7 @@ class SJavac { System.out.println("-----------------------------------------"); removeFrom(gensrc, "alfa/omega/AA.java"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyThatFilesHaveBeenRemoved(previous_bin_state, new_bin_state, "bin/alfa/omega/AA$1.class", @@ -185,7 +187,7 @@ class SJavac { "public final static int DEFINITION = 18; public void aint() { } private void foo() { } }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, @@ -211,7 +213,7 @@ class SJavac { "private int b() { return A.DEFINITION; } }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, "bin/beta/B.class", @@ -236,7 +238,7 @@ class SJavac { "@java.lang.annotation.Native final static int alfa = 42; }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, "bin/beta/B.class", @@ -262,7 +264,7 @@ class SJavac { "@java.lang.annotation.Native final static int alfa = 43; }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, "bin/beta/B.class", @@ -299,7 +301,7 @@ class SJavac { "package beta; public class B { }"); compile("-x", "beta", "gensrc", "gensrc2", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); Map new_bin_state = collectState(bin); verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, "bin/alfa/omega/A.class", @@ -310,7 +312,7 @@ class SJavac { System.out.println("----- Compile with exluded beta went well!"); delete(bin); compileExpectFailure("gensrc", "gensrc2", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); System.out.println("----- Compile without exluded beta failed, as expected! Good!"); delete(bin); @@ -341,7 +343,7 @@ class SJavac { compile("gensrc", "-x", "beta", "-sourcepath", "gensrc2", "-sourcepath", "gensrc3", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); System.out.println("The first compile went well!"); Map new_bin_state = collectState(bin); @@ -353,7 +355,7 @@ class SJavac { delete(bin); compileExpectFailure("gensrc", "-sourcepath", "gensrc2", "-sourcepath", "gensrc3", "-d", "bin", "-h", "headers", "-j", "1", - "--server:portfile=testserver,background=false"); + serverArg); System.out.println("----- Compile without exluded beta failed, as expected! Good!"); delete(bin); @@ -378,7 +380,7 @@ class SJavac { "package gamma; public class C { alfa.omega.A a; }"); compile("gensrc", "-d", "bin", "-h", "headers", "-j", "3", - "--server:portfile=testserver,background=false","--log=debug"); + serverArg,"--log=debug"); Map new_bin_state = collectState(bin); verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, "bin/alfa/omega/A.class", @@ -407,7 +409,7 @@ class SJavac { "package beta; public class B { }"); compile("-x", "beta", "-src", "gensrc", "-x", "alfa/omega", "-sourcepath", "gensrc", - "-d", "bin", "--server:portfile=testserver,background=false"); + "-d", "bin", serverArg); Map new_bin_state = collectState(bin); verifyThatFilesHaveBeenAdded(previous_bin_state, new_bin_state, @@ -431,7 +433,7 @@ class SJavac { "}"); compile("gensrc", "-d", "bin", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map previous_bin_state = collectState(bin); // Change pubapi of A, this should trigger a recompile of B. @@ -443,7 +445,7 @@ class SJavac { "}"); compile("gensrc", "-d", "bin", "-j", "1", - "--server:portfile=testserver,background=false", "--log=debug"); + serverArg, "--log=debug"); Map new_bin_state = collectState(bin); verifyNewerFiles(previous_bin_state, new_bin_state, From f5e233d84be06e3f83004b29839bfca9dda0984f Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Tue, 8 Jul 2014 14:35:05 -0400 Subject: [PATCH 061/236] 8049244: XML Signature performance issue caused by unbuffered signature data Reviewed-by: xuelei --- .../xml/dsig/internal/dom/DOMSignedInfo.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java index 0004c328849..71a13c3605c 100644 --- a/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java +++ b/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java @@ -221,8 +221,17 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { } OutputStream os = new UnsyncBufferedOutputStream(bos); + + DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true); try { - os.close(); + ((DOMCanonicalizationMethod) + canonicalizationMethod).canonicalize(subTree, context, os); + } catch (TransformException te) { + throw new XMLSignatureException(te); + } + + try { + os.flush(); } catch (IOException e) { if (log.isLoggable(java.util.logging.Level.FINE)) { log.log(java.util.logging.Level.FINE, e.getMessage(), e); @@ -230,15 +239,6 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { // Impossible } - DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true); - - try { - ((DOMCanonicalizationMethod) - canonicalizationMethod).canonicalize(subTree, context, bos); - } catch (TransformException te) { - throw new XMLSignatureException(te); - } - byte[] signedInfoBytes = bos.toByteArray(); // this whole block should only be done if logging is enabled @@ -253,6 +253,15 @@ public final class DOMSignedInfo extends DOMStructure implements SignedInfo { } this.canonData = new ByteArrayInputStream(signedInfoBytes); + + try { + os.close(); + } catch (IOException e) { + if (log.isLoggable(java.util.logging.Level.FINE)) { + log.log(java.util.logging.Level.FINE, e.getMessage(), e); + } + // Impossible + } } public void marshal(Node parent, String dsPrefix, DOMCryptoContext context) From cdbe91ef12e222182683ace7701c8221671dafd9 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 9 Jul 2014 15:10:42 +0800 Subject: [PATCH 062/236] 7150092: NTLM authentication fail if user specified a different realm Reviewed-by: michaelm --- .../classes/com/sun/security/ntlm/Client.java | 31 +++----- .../classes/com/sun/security/ntlm/Server.java | 10 ++- .../sun/security/sasl/ntlm/NTLMClient.java | 12 ++- .../sun/security/sasl/ntlm/NTLMServer.java | 6 +- .../http/ntlm/NTLMAuthentication.java | 9 +-- .../com/sun/security/sasl/ntlm/NTLMTest.java | 78 +++---------------- 6 files changed, 46 insertions(+), 100 deletions(-) diff --git a/jdk/src/share/classes/com/sun/security/ntlm/Client.java b/jdk/src/share/classes/com/sun/security/ntlm/Client.java index ba3e90c3858..9aacd433793 100644 --- a/jdk/src/share/classes/com/sun/security/ntlm/Client.java +++ b/jdk/src/share/classes/com/sun/security/ntlm/Client.java @@ -46,7 +46,7 @@ public final class Client extends NTLM { final private String hostname; final private String username; - private String domain; // might be updated by Type 2 msg + private String domain; private byte[] pw1, pw2; /** @@ -82,7 +82,7 @@ public final class Client extends NTLM { } this.hostname = hostname; this.username = username; - this.domain = domain; + this.domain = domain == null ? "" : domain; this.pw1 = getP1(password); this.pw2 = getP2(password); debug("NTLM Client: (h,u,t,version(v)) = (%s,%s,%s,%s(%s))\n", @@ -95,19 +95,13 @@ public final class Client extends NTLM { */ public byte[] type1() { Writer p = new Writer(1, 32); - int flags = 0x8203; - if (hostname != null) { - flags |= 0x2000; - } - if (domain != null) { - flags |= 0x1000; - } + // Negotiate always sign, Negotiate NTLM, + // Request Target, Negotiate OEM, Negotiate unicode + int flags = 0x8207; if (v != Version.NTLM) { flags |= 0x80000; } p.writeInt(12, flags); - p.writeSecurityBuffer(24, hostname, false); - p.writeSecurityBuffer(16, domain, false); debug("NTLM Client: Type 1 created\n"); debug(p.getBytes()); return p.getBytes(); @@ -133,13 +127,10 @@ public final class Client extends NTLM { byte[] challenge = r.readBytes(24, 8); int inputFlags = r.readInt(20); boolean unicode = (inputFlags & 1) == 1; - String domainFromServer = r.readSecurityBuffer(12, unicode); - if (domainFromServer != null) { - domain = domainFromServer; - } - if (domain == null) { - domain = ""; - } + + // IE uses domainFromServer to generate an alist if server has not + // provided one. Firefox/WebKit do not. Neither do we. + //String domainFromServer = r.readSecurityBuffer(12, unicode); int flags = 0x88200 | (inputFlags & 3); Writer p = new Writer(3, 64); @@ -163,7 +154,9 @@ public final class Client extends NTLM { if (writeLM) lm = calcV2(nthash, username.toUpperCase(Locale.US)+domain, nonce, challenge); if (writeNTLM) { - byte[] alist = type2.length > 48 ? + // Some client create a alist even if server does not send + // one: (i16)2 (i16)len target_in_unicode (i16)0 (i16) 0 + byte[] alist = ((inputFlags & 0x800000) != 0) ? r.readSecurityBuffer(40) : new byte[0]; byte[] blob = new byte[32+alist.length]; System.arraycopy(new byte[]{1,1,0,0,0,0,0,0}, 0, blob, 0, 8); diff --git a/jdk/src/share/classes/com/sun/security/ntlm/Server.java b/jdk/src/share/classes/com/sun/security/ntlm/Server.java index 0593b2e1c89..adec1a3fa29 100644 --- a/jdk/src/share/classes/com/sun/security/ntlm/Server.java +++ b/jdk/src/share/classes/com/sun/security/ntlm/Server.java @@ -1,3 +1,4 @@ + /* * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,7 +93,9 @@ public abstract class Server extends NTLM { debug("NTLM Server: Type 1 received\n"); if (type1 != null) debug(type1); Writer p = new Writer(2, 32); - int flags = 0x80205; + // Negotiate NTLM2 Key, Target Type Domain, + // Negotiate NTLM, Request Target, Negotiate unicode + int flags = 0x90205; p.writeSecurityBuffer(12, domain, true); p.writeInt(20, flags); p.writeBytes(24, nonce); @@ -127,8 +130,9 @@ public abstract class Server extends NTLM { "Wrong domain: " + incomingDomain + " vs " + domain); // Needed? }*/ + boolean verified = false; - char[] password = getPassword(domain, username); + char[] password = getPassword(incomingDomain, username); if (password == null) { throw new NTLMException(NTLMException.USER_UNKNOWN, "Unknown user"); @@ -179,6 +183,8 @@ public abstract class Server extends NTLM { } } if (incomingNTLM.length > 0) { + // We didn't sent alist in type2(), so there + // is nothing to check here. byte[] clientBlob = Arrays.copyOfRange( incomingNTLM, 16, incomingNTLM.length); byte[] ntlmresponse = calcV2(nthash, diff --git a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java index dbb1d610d31..2cf561c0d3c 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java @@ -160,9 +160,17 @@ final class NTLMClient implements SaslClient { } } try { + String name = ncb.getName(); + if (name == null) { + name = authzid; + } + String domain = dcb.getText(); + if (domain == null) { + domain = serverName; + } client = new Client(version, hostname, - ncb.getName(), - dcb.getText(), + name, + domain, pcb.getPassword()); } catch (NTLMException ne) { throw new SaslException( diff --git a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java index 9589abd358e..c1a8eb6d595 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java +++ b/jdk/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java @@ -141,8 +141,10 @@ final class NTLMServer implements SaslServer { server = new Server(version, domain) { public char[] getPassword(String ntdomain, String username) { try { - RealmCallback rcb = new RealmCallback( - "Domain: ", ntdomain); + RealmCallback rcb = + (ntdomain == null || ntdomain.isEmpty()) + ? new RealmCallback("Domain: ") + : new RealmCallback("Domain: ", ntdomain); NameCallback ncb = new NameCallback( "Name: ", username); PasswordCallback pcb = new PasswordCallback( diff --git a/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java index 3554d31c558..6211811e512 100644 --- a/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java +++ b/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java @@ -77,8 +77,7 @@ public class NTLMAuthentication extends AuthenticationInfo { static { defaultDomain = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("http.auth.ntlm.domain", - "domain")); + new sun.security.action.GetPropertyAction("http.auth.ntlm.domain", "")); }; public static boolean supportsTransparentAuth () { @@ -100,17 +99,13 @@ public class NTLMAuthentication extends AuthenticationInfo { public String run() { String localhost; try { - localhost = InetAddress.getLocalHost().getHostName().toUpperCase(); + localhost = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { localhost = "localhost"; } return localhost; } }); - int x = hostname.indexOf ('.'); - if (x != -1) { - hostname = hostname.substring (0, x); - } }; PasswordAuthentication pw; diff --git a/jdk/test/com/sun/security/sasl/ntlm/NTLMTest.java b/jdk/test/com/sun/security/sasl/ntlm/NTLMTest.java index 64f5eae184c..46d2f041383 100644 --- a/jdk/test/com/sun/security/sasl/ntlm/NTLMTest.java +++ b/jdk/test/com/sun/security/sasl/ntlm/NTLMTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6911951 + * @bug 6911951 7150092 * @summary NTLM should be a supported Java SASL mechanism */ import java.io.IOException; @@ -59,7 +59,6 @@ public class NTLMTest { checkAuthOnly(); checkClientNameOverride(); - checkServerDomainOverride(); checkClientDomainOverride(); checkVersions(); checkClientHostname(); @@ -116,15 +115,12 @@ public class NTLMTest { Map ps = new HashMap<>(); ps.put("com.sun.security.sasl.ntlm.version", vs); SaslClient clnt = Sasl.createSaslClient( - new String[]{MECH}, USER1, PROTOCOL, null, pc, + new String[]{MECH}, USER1, PROTOCOL, REALM, pc, new CallbackHandler() { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback cb: callbacks) { - if (cb instanceof NameCallback) { - NameCallback ncb = (NameCallback)cb; - ncb.setName(ncb.getDefaultName()); - } else if (cb instanceof PasswordCallback) { + if (cb instanceof PasswordCallback) { ((PasswordCallback)cb).setPassword(PASS1); } } @@ -159,15 +155,12 @@ public class NTLMTest { Map pc = new HashMap<>(); pc.put("com.sun.security.sasl.ntlm.hostname", "this.is.com"); SaslClient clnt = Sasl.createSaslClient( - new String[]{MECH}, USER1, PROTOCOL, null, pc, + new String[]{MECH}, USER1, PROTOCOL, REALM, pc, new CallbackHandler() { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback cb: callbacks) { - if (cb instanceof NameCallback) { - NameCallback ncb = (NameCallback)cb; - ncb.setName(ncb.getDefaultName()); - } else if (cb instanceof PasswordCallback) { + if (cb instanceof PasswordCallback) { ((PasswordCallback)cb).setPassword(PASS1); } } @@ -212,12 +205,8 @@ public class NTLMTest { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback cb: callbacks) { - if (cb instanceof NameCallback) { - NameCallback ncb = (NameCallback)cb; - ncb.setName(ncb.getDefaultName()); - } else if(cb instanceof RealmCallback) { - RealmCallback dcb = (RealmCallback)cb; - dcb.setText("THIRDDOMAIN"); + if (cb instanceof RealmCallback) { + ((RealmCallback)cb).setText(REALM); } else if (cb instanceof PasswordCallback) { ((PasswordCallback)cb).setPassword(PASS1); } @@ -255,13 +244,13 @@ public class NTLMTest { */ private static void checkClientNameOverride() throws Exception { SaslClient clnt = Sasl.createSaslClient( - new String[]{MECH}, null, PROTOCOL, null, null, + new String[]{MECH}, "someone", PROTOCOL, REALM, null, new CallbackHandler() { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback cb: callbacks) { if (cb instanceof NameCallback) { - NameCallback ncb = (NameCallback)cb; + NameCallback ncb = (NameCallback) cb; ncb.setName(USER1); } else if (cb instanceof PasswordCallback) { ((PasswordCallback)cb).setPassword(PASS1); @@ -270,54 +259,7 @@ public class NTLMTest { } }); - SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, REALM, null, - new CallbackHandler() { - public void handle(Callback[] callbacks) - throws IOException, UnsupportedCallbackException { - String domain = null, name = null; - PasswordCallback pcb = null; - for (Callback cb: callbacks) { - if (cb instanceof NameCallback) { - name = ((NameCallback)cb).getDefaultName(); - } else if (cb instanceof RealmCallback) { - domain = ((RealmCallback)cb).getDefaultText(); - } else if (cb instanceof PasswordCallback) { - pcb = (PasswordCallback)cb; - } - } - if (pcb != null) { - pcb.setPassword(getPass(domain, name)); - } - } - }); - - handshake(clnt, srv); - } - - /** - * server side domain provided in props. - * @throws Exception - */ - private static void checkServerDomainOverride() throws Exception { - SaslClient clnt = Sasl.createSaslClient( - new String[]{MECH}, USER1, PROTOCOL, null, null, - new CallbackHandler() { - public void handle(Callback[] callbacks) - throws IOException, UnsupportedCallbackException { - for (Callback cb: callbacks) { - if (cb instanceof NameCallback) { - NameCallback ncb = (NameCallback)cb; - ncb.setName(ncb.getDefaultName()); - } else if (cb instanceof PasswordCallback) { - ((PasswordCallback)cb).setPassword(PASS1); - } - } - } - }); - - Map ps = new HashMap<>(); - ps.put("com.sun.security.sasl.ntlm.domain", REALM); - SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, null, ps, + SaslServer srv = Sasl.createSaslServer(MECH, PROTOCOL, "FAKE", null, new CallbackHandler() { public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { From 8167fa4c808ecd4a1795f48eaebe91ed1155a49c Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Wed, 9 Jul 2014 16:34:31 +0800 Subject: [PATCH 063/236] 8047765: Generate blacklist.certs in build Reviewed-by: dholmes, alanb --- jdk/make/CopyFiles.gmk | 19 ----- jdk/make/GenerateData.gmk | 3 + jdk/make/Tools.gmk | 3 + .../blacklisted.certs.pem | 6 ++ jdk/make/gendata/GendataBlacklistedCerts.gmk | 36 +++++++++ .../BlacklistedCertsConverter.java | 80 ++++++++++++------- jdk/src/share/lib/security/blacklisted.certs | 19 ----- 7 files changed, 99 insertions(+), 67 deletions(-) rename jdk/{src/share/lib/security => make/data/blacklistedcertsconverter}/blacklisted.certs.pem (99%) create mode 100644 jdk/make/gendata/GendataBlacklistedCerts.gmk rename jdk/{src/share/lib/security => make/src/classes/build/tools/blacklistedcertsconverter}/BlacklistedCertsConverter.java (56%) delete mode 100644 jdk/src/share/lib/security/blacklisted.certs diff --git a/jdk/make/CopyFiles.gmk b/jdk/make/CopyFiles.gmk index 396f2534317..acab2541256 100644 --- a/jdk/make/CopyFiles.gmk +++ b/jdk/make/CopyFiles.gmk @@ -407,16 +407,11 @@ COPY_FILES += $(CACERTS_DST) ########################################################################################## -BLACKLISTED_CERTS_SRC := $(JDK_TOPDIR)/src/share/lib/security/blacklisted.certs -BLACKLISTED_CERTS_DST := $(JDK_OUTPUTDIR)/lib/security/blacklisted.certs - ifndef OPENJDK BLACKLIST_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/blacklist BLACKLIST_DST := $(JDK_OUTPUTDIR)/lib/security/blacklist - BLACKLISTED_CERTS_SRC += $(wildcard $(JDK_TOPDIR)/src/closed/share/lib/security/blacklisted.certs) - TRUSTEDLIBS_SRC := $(JDK_TOPDIR)/src/closed/share/lib/security/trusted.libraries TRUSTEDLIBS_DST := $(JDK_OUTPUTDIR)/lib/security/trusted.libraries @@ -432,20 +427,6 @@ ifndef OPENJDK endif -$(BLACKLISTED_CERTS_DST): $(BLACKLISTED_CERTS_SRC) - $(MKDIR) -p $(@D) - $(CAT) $^ | $(SED) '/^$$/d' | $(SORT) | $(UNIQ) > $@.tmp - $(GREP) -i Algorithm $@.tmp > $@ - if [ `$(SED) -n -e "$$=" $@` != 1 ]; then \ - $(ECHO) "Different algorithms defined in $^"; \ - $(RM) $@ $@.tmp; \ - false; \ - fi - $(GREP) -iv Algorithm $@.tmp >> $@ - $(RM) $@.tmp - -COPY_FILES += $(BLACKLISTED_CERTS_DST) - ########################################################################################## ifndef OPENJDK diff --git a/jdk/make/GenerateData.gmk b/jdk/make/GenerateData.gmk index 437dd0b1d38..8228f917800 100644 --- a/jdk/make/GenerateData.gmk +++ b/jdk/make/GenerateData.gmk @@ -50,6 +50,9 @@ GENDATA += $(GENDATA_TZDB) include gendata/GendataHtml32dtd.gmk GENDATA += $(GENDATA_HTML32DTD) +include gendata/GendataBlacklistedCerts.gmk +GENDATA += $(GENDATA_BLACKLISTED_CERTS) + ########################################################################################## GENDATA_UNINAME := $(JDK_OUTPUTDIR)/classes/java/lang/uniName.dat diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index d223f4afa62..0f781909490 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -87,6 +87,9 @@ TOOL_HASHER = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ TOOL_TZDB = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.tzdb.TzdbZoneRulesCompiler +TOOL_BLACKLISTED_CERTS = $(JAVA_SMALL) -cp $(JDK_OUTPUTDIR)/btclasses \ + build.tools.blacklistedcertsconverter.BlacklistedCertsConverter + # TODO: There are references to the jdwpgen.jar in jdk/make/netbeans/jdwpgen/build.xml # and nbproject/project.properties in the same dir. Needs to be looked at. diff --git a/jdk/src/share/lib/security/blacklisted.certs.pem b/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem similarity index 99% rename from jdk/src/share/lib/security/blacklisted.certs.pem rename to jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem index f44a6985352..db1c077ccb0 100644 --- a/jdk/src/share/lib/security/blacklisted.certs.pem +++ b/jdk/make/data/blacklistedcertsconverter/blacklisted.certs.pem @@ -1,3 +1,9 @@ +#! java BlacklistedCertsConverter SHA-256 + +# The line above must be the first line of the blacklisted.certs.pem +# file inside src/share/lib/security/. It will be ignored if added in +# src/closed/share/lib/security/blacklisted.certs.pem. + // Subject: CN=Digisign Server ID (Enrich), // OU=457608-K, // O=Digicert Sdn. Bhd., diff --git a/jdk/make/gendata/GendataBlacklistedCerts.gmk b/jdk/make/gendata/GendataBlacklistedCerts.gmk new file mode 100644 index 00000000000..ab62ca69ef9 --- /dev/null +++ b/jdk/make/gendata/GendataBlacklistedCerts.gmk @@ -0,0 +1,36 @@ +# +# 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. 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. +# + +GENDATA_BLACKLISTED_CERTS_SRC := $(JDK_TOPDIR)/make/data/blacklistedcertsconverter/blacklisted.certs.pem +GENDATA_BLACKLISTED_CERTS := $(JDK_OUTPUTDIR)/lib/security/blacklisted.certs + +ifndef OPENJDK + GENDATA_BLACKLISTED_CERTS_SRC += $(wildcard $(JDK_TOPDIR)/make/closed/data/blacklistedcertsconverter/blacklisted.certs.pem) +endif + +$(GENDATA_BLACKLISTED_CERTS): $(BUILD_TOOLS) $(GENDATA_BLACKLISTED_CERTS_SRC) + $(ECHO) "Generating blacklisted certs" + $(MKDIR) -p $(@D) + ($(CAT) $(GENDATA_BLACKLISTED_CERTS_SRC) | $(TOOL_BLACKLISTED_CERTS) > $@) || exit 1 diff --git a/jdk/src/share/lib/security/BlacklistedCertsConverter.java b/jdk/make/src/classes/build/tools/blacklistedcertsconverter/BlacklistedCertsConverter.java similarity index 56% rename from jdk/src/share/lib/security/BlacklistedCertsConverter.java rename to jdk/make/src/classes/build/tools/blacklistedcertsconverter/BlacklistedCertsConverter.java index 65a88f00a2e..9f8ce873c57 100644 --- a/jdk/src/share/lib/security/BlacklistedCertsConverter.java +++ b/jdk/make/src/classes/build/tools/blacklistedcertsconverter/BlacklistedCertsConverter.java @@ -21,37 +21,65 @@ * questions. */ +package build.tools.blacklistedcertsconverter; + import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.security.cert.Certificate; -import java.security.cert.CertificateEncodingException; import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.util.Collection; +import java.util.Set; +import java.util.TreeSet; + /** - * This is the tool to convert blacklisted.certs.pem to blacklisted.certs. - * Every time a new blacklisted certs is added, please append the PEM format - * to the end of blacklisted.certs.pem (with proper comments) and then use - * this tool to generate an updated blacklisted.certs. Make sure to include - * changes to both in a changeset. + * Converts blacklisted.certs.pem from System.in to blacklisted.certs in + * System.out. The input must start with a #! line including the fingerprint + * algorithm. The output is sorted and unique. */ public class BlacklistedCertsConverter { + public static void main(String[] args) throws Exception { - if (args.length == 0) { - System.out.println("Usage: java BlacklistedCertsConverter SHA-256" + - " < blacklisted.certs.pem > blacklisted.certs"); - System.exit(1); + + byte[] pattern = "#! java BlacklistedCertsConverter ".getBytes(); + String mdAlg = ""; + + for (int i=0; ; i++) { + int n = System.in.read(); + if (n < 0) { + throw new Exception("Unexpected EOF"); + } + if (i < pattern.length) { + if (n != pattern[i]) { + throw new Exception("The first line must start with \"" + + new String(pattern) + "\""); + } + } else if (i < pattern.length + 100) { + if (n < 32) { + break; + } else { + mdAlg = mdAlg + String.format("%c", n); + } + } } - String mdAlg = args[0]; + + mdAlg = mdAlg.trim(); + System.out.println("Algorithm=" + mdAlg); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); Collection certs = cf.generateCertificates(System.in); - System.out.println("Algorithm=" + mdAlg); + + // Output sorted so that it's easy to locate an entry. + Set fingerprints = new TreeSet<>(); for (Certificate cert: certs) { - System.out.println( + fingerprints.add( getCertificateFingerPrint(mdAlg, (X509Certificate)cert)); } + + for (String s: fingerprints) { + System.out.println(s); + } } /** @@ -69,21 +97,15 @@ public class BlacklistedCertsConverter { /** * Gets the requested finger print of the certificate. */ - private static String getCertificateFingerPrint(String mdAlg, - X509Certificate cert) { - String fingerPrint = ""; - try { - byte[] encCertInfo = cert.getEncoded(); - MessageDigest md = MessageDigest.getInstance(mdAlg); - byte[] digest = md.digest(encCertInfo); - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < digest.length; i++) { - byte2hex(digest[i], buf); - } - fingerPrint = buf.toString(); - } catch (NoSuchAlgorithmException | CertificateEncodingException e) { - // ignored + private static String getCertificateFingerPrint( + String mdAlg, X509Certificate cert) throws Exception { + byte[] encCertInfo = cert.getEncoded(); + MessageDigest md = MessageDigest.getInstance(mdAlg); + byte[] digest = md.digest(encCertInfo); + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < digest.length; i++) { + byte2hex(digest[i], buf); } - return fingerPrint; + return buf.toString(); } } diff --git a/jdk/src/share/lib/security/blacklisted.certs b/jdk/src/share/lib/security/blacklisted.certs deleted file mode 100644 index cb1e4d59e38..00000000000 --- a/jdk/src/share/lib/security/blacklisted.certs +++ /dev/null @@ -1,19 +0,0 @@ -Algorithm=SHA-256 -76A45A496031E4DD2D7ED23E8F6FF97DBDEA980BAAC8B0BA94D7EDB551348645 -4CBBF8256BC9888A8007B2F386940A2E394378B0D903CBB3863C5A6394B889CE -D24566BF315F4E597D6E381C87119FB4198F5E9E2607F5F4AB362EF7E2E7672F -14E6D2764A4B06701C6CBC376A253775F79C782FBCB6C0EE6F99DE4BA1024ADD -D3A936E1A7775A45217C8296A1F22AC5631DCDEC45594099E78EEEBBEDCBA967 -5E83124D68D24E8E177E306DF643D5EA99C5A94D6FC34B072F7544A1CABB7C7B -9ED8F9B0E8E42A1656B8E1DD18F42BA42DC06FE52686173BA2FC70E756F207DC -FDEDB5BDFCB67411513A61AEE5CB5B5D7C52AF06028EFC996CC1B05B1D6CEA2B -A686FEE577C88AB664D0787ECDFFF035F4806F3DE418DC9E4D516324FFF02083 -4FEE0163686ECBD65DB968E7494F55D84B25486D438E9DE558D629D28CD4D176 -8A1BD21661C60015065212CC98B1ABB50DFD14C872A208E66BAE890F25C448AF -B8686723E415534BC0DBD16326F9486F85B0B0799BF6639334E61DAAE67F36CD -3946901F46B0071E90D78279E82FABABCA177231A704BE72C5B0E8918566EA66 -31C8FD37DB9B56E708B03D1F01848B068C6DA66F36FB5D82C008C6040FA3E133 -450F1B421BB05C8609854884559C323319619E8B06B001EA2DCBB74A23AA3BE2 -FC02FD48DB92D4DCE6F11679D38354CF750CFC7F584A520EB90BDE80E241F2BD -DF21016B00FC54F9FE3BC8B039911BB216E9162FAD2FD14D990AB96E951B49BE -F5B6F88F75D391A4B1EB336F9E201239FB6B1377DB8CFA7B84736216E5AFFFD7 From b94232fe213ad7f0636e836570eb14127b5792cd Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Wed, 9 Jul 2014 12:30:17 +0200 Subject: [PATCH 064/236] 8049220: URL.factory data race Reviewed-by: alanb, psandoz --- jdk/src/share/classes/java/net/URL.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/classes/java/net/URL.java b/jdk/src/share/classes/java/net/URL.java index 9987bc08a4d..e0abaace2b5 100644 --- a/jdk/src/share/classes/java/net/URL.java +++ b/jdk/src/share/classes/java/net/URL.java @@ -1071,7 +1071,7 @@ public final class URL implements java.io.Serializable { /** * The URLStreamHandler factory. */ - static URLStreamHandlerFactory factory; + private static volatile URLStreamHandlerFactory factory; /** * Sets an application's {@code URLStreamHandlerFactory}. @@ -1106,6 +1106,7 @@ public final class URL implements java.io.Serializable { security.checkSetFactory(); } handlers.clear(); + // safe publication of URLStreamHandlerFactory with volatile write factory = fac; } } @@ -1127,9 +1128,11 @@ public final class URL implements java.io.Serializable { boolean checkedWithFactory = false; - // Use the factory (if any) - if (factory != null) { - handler = factory.createURLStreamHandler(protocol); + // Use the factory (if any). Volatile read makes + // URLStreamHandlerFactory appear fully initialized to current thread. + URLStreamHandlerFactory fac = factory; + if (fac != null) { + handler = fac.createURLStreamHandler(protocol); checkedWithFactory = true; } @@ -1193,8 +1196,8 @@ public final class URL implements java.io.Serializable { // Check with factory if another thread set a // factory since our last check - if (!checkedWithFactory && factory != null) { - handler2 = factory.createURLStreamHandler(protocol); + if (!checkedWithFactory && (fac = factory) != null) { + handler2 = fac.createURLStreamHandler(protocol); } if (handler2 != null) { From 7c04b456669cd82c49f1aff19326b6ca6a994cfb Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 9 Jul 2014 17:51:50 +0200 Subject: [PATCH 065/236] 8048913: java/util/logging/LoggingDeadlock2.java times out Removes the /timeout=15 parameter from the @run command line Reviewed-by: mchung, dholmes --- jdk/test/java/util/logging/LoggingDeadlock2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/java/util/logging/LoggingDeadlock2.java b/jdk/test/java/util/logging/LoggingDeadlock2.java index de328e7681a..c5b4e893738 100644 --- a/jdk/test/java/util/logging/LoggingDeadlock2.java +++ b/jdk/test/java/util/logging/LoggingDeadlock2.java @@ -28,7 +28,7 @@ * @author Serguei Spitsyn / Hitachi / Martin Buchholz * * @build LoggingDeadlock2 - * @run main/timeout=15 LoggingDeadlock2 + * @run main LoggingDeadlock2 * * There is a clear deadlock between LogManager. and * Cleaner.run() methods. From f38db6ce1112cc4190154d2ace5ec28dee9ea694 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 9 Jul 2014 10:02:30 -0700 Subject: [PATCH 066/236] 8048515: Read outside array bounds in jdk/src/solaris/native/java/lang/java_props_md.c Reviewed-by: okutsu --- jdk/src/share/native/java/lang/java_props.h | 2 +- jdk/src/solaris/native/java/lang/locale_str.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/native/java/lang/java_props.h b/jdk/src/share/native/java/lang/java_props.h index 21207d9fb92..98caf63fcca 100644 --- a/jdk/src/share/native/java/lang/java_props.h +++ b/jdk/src/share/native/java/lang/java_props.h @@ -117,7 +117,7 @@ typedef struct { char *exceptionList; - char *awt_headless /* java.awt.headless setting, if NULL (default) will not be set */ + char *awt_headless; /* java.awt.headless setting, if NULL (default) will not be set */ #endif } java_props_t; diff --git a/jdk/src/solaris/native/java/lang/locale_str.h b/jdk/src/solaris/native/java/lang/locale_str.h index d63e26ce37d..72a796c7a9f 100644 --- a/jdk/src/solaris/native/java/lang/locale_str.h +++ b/jdk/src/solaris/native/java/lang/locale_str.h @@ -135,7 +135,7 @@ "sr_SP", "sr_YU", "tchinese", "zh_TW", #endif - "" + "", "", }; /* @@ -188,7 +188,7 @@ static char *language_names[] = { "japanese", "ja", "korean", "ko", #endif - "", + "", "", }; /* @@ -201,7 +201,7 @@ static char *script_names[] = { "iqtelif", "Latn", "latin", "Latn", #endif - "", + "", "", }; /* @@ -212,7 +212,7 @@ static char *country_names[] = { "RN", "US", // used on Linux, not clear what it stands for #endif "YU", "CS", // YU has been removed from ISO 3166 - "", + "", "", }; /* @@ -220,5 +220,5 @@ static char *country_names[] = { */ static char *variant_names[] = { "nynorsk", "NY", - "", + "", "", }; From 037699d88a2f1743b9c91afb4f3d995876d5caa1 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 9 Jul 2014 17:02:03 -0700 Subject: [PATCH 067/236] 8049794: Fix raw and unchecked warnings in jvmstat Reviewed-by: mchung --- .../event/MonitorStatusChangeEvent.java | 13 +++---- .../monitor/event/VmStatusChangeEvent.java | 16 ++++----- .../monitor/AbstractPerfDataBuffer.java | 4 +-- .../perfdata/monitor/MonitorStatus.java | 13 +++---- .../perfdata/monitor/PerfDataBufferImpl.java | 30 ++++++++-------- .../protocol/local/LocalMonitoredVm.java | 15 ++++---- .../protocol/local/MonitoredHostProvider.java | 27 ++++++++------- .../protocol/rmi/MonitoredHostProvider.java | 34 ++++++++++--------- .../protocol/rmi/RemoteMonitoredVm.java | 22 ++++++------ .../perfdata/monitor/v1_0/PerfDataBuffer.java | 16 ++++----- .../perfdata/monitor/v2_0/PerfDataBuffer.java | 12 +++---- 11 files changed, 105 insertions(+), 97 deletions(-) diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/event/MonitorStatusChangeEvent.java b/jdk/src/share/classes/sun/jvmstat/monitor/event/MonitorStatusChangeEvent.java index 618ef6f7a3e..0333151fbdf 100644 --- a/jdk/src/share/classes/sun/jvmstat/monitor/event/MonitorStatusChangeEvent.java +++ b/jdk/src/share/classes/sun/jvmstat/monitor/event/MonitorStatusChangeEvent.java @@ -27,6 +27,7 @@ package sun.jvmstat.monitor.event; import java.util.List; import sun.jvmstat.monitor.MonitoredVm; +import sun.jvmstat.monitor.Monitor; /** * Provides a description of a change in status of the instrumentation @@ -42,13 +43,13 @@ public class MonitorStatusChangeEvent extends VmEvent { * List of instrumentation objects inserted since the last event. * Elements of this list will always be of type Monitor. */ - protected List inserted; + protected List inserted; /** * List of instrumentation objects removed since the last event. * Elements of this list will always be of type Monitor. */ - protected List removed; + protected List removed; /** * Construct a new MonitorStatusChangeEvent. @@ -59,8 +60,8 @@ public class MonitorStatusChangeEvent extends VmEvent { * @param removed the list of instrumentation objects removed since * the last event. */ - public MonitorStatusChangeEvent(MonitoredVm vm, List inserted, - List removed) { + public MonitorStatusChangeEvent(MonitoredVm vm, List inserted, + List removed) { super(vm); this.inserted = inserted; this.removed = removed; @@ -75,7 +76,7 @@ public class MonitorStatusChangeEvent extends VmEvent { * new instrumentation was inserted, an emply List is * returned. */ - public List getInserted() { + public List getInserted() { return inserted; } @@ -87,7 +88,7 @@ public class MonitorStatusChangeEvent extends VmEvent { * instrumentation exported by the MonitoredHost. If no * instrumentation was removed, an emply List is returned. */ - public List getRemoved() { + public List getRemoved() { return removed; } } diff --git a/jdk/src/share/classes/sun/jvmstat/monitor/event/VmStatusChangeEvent.java b/jdk/src/share/classes/sun/jvmstat/monitor/event/VmStatusChangeEvent.java index 73509a0a2bb..176d56bd897 100644 --- a/jdk/src/share/classes/sun/jvmstat/monitor/event/VmStatusChangeEvent.java +++ b/jdk/src/share/classes/sun/jvmstat/monitor/event/VmStatusChangeEvent.java @@ -44,7 +44,7 @@ public class VmStatusChangeEvent extends HostEvent { * active Java Virtual Machine on the MonitoredHost. This Set will only * contain Integer objects. */ - protected Set active; + protected Set active; /** * The set of Java Virtual Machines started on MonitoredHost since the @@ -52,7 +52,7 @@ public class VmStatusChangeEvent extends HostEvent { * lvmid for each Java Virtual Machine started on the * MonitoredHost. This Set will only contain Integer objects. */ - protected Set started; + protected Set started; /** * The set of Java Virtual Machines terminated on MonitoredHost since the @@ -60,7 +60,7 @@ public class VmStatusChangeEvent extends HostEvent { * lvmid for each Java Virtual Machine started on the * MonitoredHost. This Set will only contain Integer objects. */ - protected Set terminated; + protected Set terminated; /** * Construct a new VmStatusChangeEvent instance. @@ -72,8 +72,8 @@ public class VmStatusChangeEvent extends HostEvent { * @param terminated the set of Java Virtual Machines terminated since * the last event. */ - public VmStatusChangeEvent(MonitoredHost host, Set active, - Set started, Set terminated) { + public VmStatusChangeEvent(MonitoredHost host, Set active, + Set started, Set terminated) { super(host); this.active = active; this.started = started; @@ -90,7 +90,7 @@ public class VmStatusChangeEvent extends HostEvent { * there are no active Java Virtual Machines on the host, * an empty Set is returned. */ - public Set getActive() { + public Set getActive() { return active; } @@ -105,7 +105,7 @@ public class VmStatusChangeEvent extends HostEvent { * no Java Virtual Machines were recently started on the * host, an empty Set is returned. */ - public Set getStarted() { + public Set getStarted() { return started; } @@ -120,7 +120,7 @@ public class VmStatusChangeEvent extends HostEvent { * no Java Virtual Machines were recently terminated on the * host, an empty Set is returned. */ - public Set getTerminated() { + public Set getTerminated() { return terminated; } } diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java index 1a1820a53ba..90931ecc00a 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/AbstractPerfDataBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -169,7 +169,7 @@ public abstract class AbstractPerfDataBuffer { try { Class implClass = Class.forName(classname); - Constructor cons = implClass.getConstructor(new Class[] { + Constructor cons = implClass.getConstructor(new Class[] { Class.forName("java.nio.ByteBuffer"), Integer.TYPE }); diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/MonitorStatus.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/MonitorStatus.java index 60697f2f0de..23e8f0633d3 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/MonitorStatus.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/MonitorStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 sun.jvmstat.perfdata.monitor; import java.util.List; +import sun.jvmstat.monitor.Monitor; /** * Immutable class containing the list of inserted and deleted @@ -39,12 +40,12 @@ public class MonitorStatus { /** * The list of Monitors inserted since the last query. */ - protected List inserted; + protected List inserted; /** * The list of Monitors removed since the last query. */ - protected List removed; + protected List removed; /** * Create a MonitorStatus instance. @@ -52,7 +53,7 @@ public class MonitorStatus { * @param inserted the list of Monitors inserted * @param removed the list of Monitors removed */ - public MonitorStatus(List inserted, List removed) { + public MonitorStatus(List inserted, List removed) { this.inserted = inserted; this.removed = removed; } @@ -62,7 +63,7 @@ public class MonitorStatus { * * @return List - the List of Monitor objects inserted or an empty List. */ - public List getInserted() { + public List getInserted() { return inserted; } @@ -71,7 +72,7 @@ public class MonitorStatus { * * @return List - the List of Monitor objects removed or an empty List. */ - public List getRemoved() { + public List getRemoved() { return removed; } } diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java index e1a5a380841..2bde91cf719 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/PerfDataBufferImpl.java @@ -66,7 +66,7 @@ public abstract class PerfDataBufferImpl { /** * A cache of resolved monitor aliases. */ - protected Map aliasCache; + protected Map aliasCache; /** @@ -79,9 +79,9 @@ public abstract class PerfDataBufferImpl { protected PerfDataBufferImpl(ByteBuffer buffer, int lvmid) { this.buffer = buffer; this.lvmid = lvmid; - this.monitors = new TreeMap(); - this.aliasMap = new HashMap>(); - this.aliasCache = new HashMap(); + this.monitors = new TreeMap<>(); + this.aliasMap = new HashMap<>(); + this.aliasCache = new HashMap<>(); } /** @@ -200,12 +200,12 @@ public abstract class PerfDataBufferImpl { protected Monitor findByAlias(String name) { assert Thread.holdsLock(this); - Monitor m = (Monitor)aliasCache.get(name); + Monitor m = aliasCache.get(name); if (m == null) { - ArrayList al = aliasMap.get(name); + ArrayList al = aliasMap.get(name); if (al != null) { - for (Iterator i = al.iterator(); i.hasNext() && m == null; ) { - String alias = (String)i.next(); + for (Iterator i = al.iterator(); i.hasNext() && m == null; ) { + String alias = i.next(); m = monitors.get(alias); } } @@ -287,21 +287,21 @@ public abstract class PerfDataBufferImpl { Pattern pattern = Pattern.compile(patternString); Matcher matcher = pattern.matcher(""); - List matches = new ArrayList(); + List matches = new ArrayList<>(); - Set monitorSet = monitors.entrySet(); + Set> monitorSet = monitors.entrySet(); - for (Iterator i = monitorSet.iterator(); i.hasNext(); /* empty */) { - Map.Entry me = (Map.Entry)i.next(); - String name = (String)me.getKey(); - Monitor m = (Monitor)me.getValue(); + for (Iterator> i = monitorSet.iterator(); i.hasNext(); /* empty */) { + Map.Entry me = i.next(); + String name = me.getKey(); + Monitor m = me.getValue(); // apply pattern to monitor item name matcher.reset(name); // if the pattern matches, then add monitor to list if (matcher.lookingAt()) { - matches.add((Monitor)me.getValue()); + matches.add(me.getValue()); } } return matches; diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java index d9a9084f3b1..ca1b210aaac 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/LocalMonitoredVm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -143,16 +143,17 @@ public class LocalMonitoredVm extends AbstractMonitoredVm { * @param inserted List of Monitor objects inserted. * @param removed List of Monitor objects removed. */ - void fireMonitorStatusChangedEvents(List inserted, List removed) { + @SuppressWarnings("unchecked") // Cast of result of clone + void fireMonitorStatusChangedEvents(List inserted, List removed) { MonitorStatusChangeEvent ev = null; - ArrayList registered = null; + ArrayList registered = null; synchronized (listeners) { registered = (ArrayList)listeners.clone(); } - for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { - VmListener l = (VmListener)i.next(); + for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { + VmListener l = i.next(); // lazily create the event object; if (ev == null) { ev = new MonitorStatusChangeEvent(this, inserted, removed); @@ -190,8 +191,8 @@ public class LocalMonitoredVm extends AbstractMonitoredVm { super.run(); try { MonitorStatus status = getMonitorStatus(); - List inserted = status.getInserted(); - List removed = status.getRemoved(); + List inserted = status.getInserted(); + List removed = status.getRemoved(); if (!inserted.isEmpty() || !removed.isEmpty()) { fireMonitorStatusChangedEvents(inserted, removed); diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostProvider.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostProvider.java index 0b3ec64eac8..851cde20b48 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostProvider.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/MonitoredHostProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -160,17 +160,18 @@ public class MonitoredHostProvider extends MonitoredHost { * @param terminated a set of Integer objects containing the vmid of * terminated Vms since last interval. */ - private void fireVmStatusChangedEvents(Set active, Set started, - Set terminated) { - ArrayList registered = null; + @SuppressWarnings("unchecked") // Cast of result of clone + private void fireVmStatusChangedEvents(Set active, Set started, + Set terminated) { + ArrayList registered = null; VmStatusChangeEvent ev = null; synchronized(listeners) { registered = (ArrayList)listeners.clone(); } - for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { - HostListener l = (HostListener)i.next(); + for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { + HostListener l = i.next(); if (ev == null) { ev = new VmStatusChangeEvent(this, active, started, terminated); } @@ -186,7 +187,7 @@ public class MonitoredHostProvider extends MonitoredHost { super.run(); // save the last set of active JVMs - Set lastActiveVms = activeVms; + Set lastActiveVms = activeVms; // get the current set of active JVMs activeVms = (HashSet)vmManager.activeVms(); @@ -194,20 +195,20 @@ public class MonitoredHostProvider extends MonitoredHost { if (activeVms.isEmpty()) { return; } - Set startedVms = new HashSet(); - Set terminatedVms = new HashSet(); + Set startedVms = new HashSet<>(); + Set terminatedVms = new HashSet<>(); - for (Iterator i = activeVms.iterator(); i.hasNext(); /* empty */) { - Integer vmid = (Integer)i.next(); + for (Iterator i = activeVms.iterator(); i.hasNext(); /* empty */) { + Integer vmid = i.next(); if (!lastActiveVms.contains(vmid)) { // a new file has been detected, add to set startedVms.add(vmid); } } - for (Iterator i = lastActiveVms.iterator(); i.hasNext(); + for (Iterator i = lastActiveVms.iterator(); i.hasNext(); /* empty */) { - Object o = i.next(); + Integer o = i.next(); if (!activeVms.contains(o)) { // JVM has terminated, remove it from the active list terminatedVms.add(o); diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostProvider.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostProvider.java index 1b07c4e5fae..09467dc74ab 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostProvider.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/MonitoredHostProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -246,17 +246,18 @@ public class MonitoredHostProvider extends MonitoredHost { * Vm Identifiers of terminated JVMs since last * interval. */ - private void fireVmStatusChangedEvents(Set active, Set started, - Set terminated) { - ArrayList registered = null; + @SuppressWarnings("unchecked") // Cast of result of clone + private void fireVmStatusChangedEvents(Set active, Set started, + Set terminated) { + ArrayList registered = null; VmStatusChangeEvent ev = null; synchronized(listeners) { registered = (ArrayList)listeners.clone(); } - for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { - HostListener l = (HostListener)i.next(); + for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { + HostListener l = i.next(); if (ev == null) { ev = new VmStatusChangeEvent(this, active, started, terminated); } @@ -267,16 +268,17 @@ public class MonitoredHostProvider extends MonitoredHost { /** * Fire hostDisconnectEvent events. */ + @SuppressWarnings("unchecked") // Cast of result of clone void fireDisconnectedEvents() { - ArrayList registered = null; + ArrayList registered = null; HostEvent ev = null; synchronized(listeners) { registered = (ArrayList)listeners.clone(); } - for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { - HostListener l = (HostListener)i.next(); + for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { + HostListener l = i.next(); if (ev == null) { ev = new HostEvent(this); } @@ -292,7 +294,7 @@ public class MonitoredHostProvider extends MonitoredHost { super.run(); // save the last set of active JVMs - Set lastActiveVms = activeVms; + Set lastActiveVms = activeVms; try { // get the current set of active JVMs @@ -313,20 +315,20 @@ public class MonitoredHostProvider extends MonitoredHost { return; } - Set startedVms = new HashSet(); - Set terminatedVms = new HashSet(); + Set startedVms = new HashSet<>(); + Set terminatedVms = new HashSet<>(); - for (Iterator i = activeVms.iterator(); i.hasNext(); /* empty */ ) { - Integer vmid = (Integer)i.next(); + for (Iterator i = activeVms.iterator(); i.hasNext(); /* empty */ ) { + Integer vmid = i.next(); if (!lastActiveVms.contains(vmid)) { // a new file has been detected, add to set startedVms.add(vmid); } } - for (Iterator i = lastActiveVms.iterator(); i.hasNext(); + for (Iterator i = lastActiveVms.iterator(); i.hasNext(); /* empty */ ) { - Object o = i.next(); + Integer o = i.next(); if (!activeVms.contains(o)) { // JVM has terminated, remove it from the active list terminatedVms.add(o); diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/RemoteMonitoredVm.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/RemoteMonitoredVm.java index 72e48f2cb04..2a38e52df66 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/RemoteMonitoredVm.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/protocol/rmi/RemoteMonitoredVm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -198,16 +198,17 @@ public class RemoteMonitoredVm extends AbstractMonitoredVm { * @param inserted List of Monitor objects inserted. * @param removed List of Monitor objects removed. */ - void fireMonitorStatusChangedEvents(List inserted, List removed) { - ArrayList registered = null; + @SuppressWarnings("unchecked") // Cast of result of clone + void fireMonitorStatusChangedEvents(List inserted, List removed) { + ArrayList registered = null; MonitorStatusChangeEvent ev = null; synchronized(listeners) { registered = (ArrayList)listeners.clone(); } - for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { - VmListener l = (VmListener)i.next(); + for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { + VmListener l = i.next(); if (ev == null) { ev = new MonitorStatusChangeEvent(this, inserted, removed); } @@ -218,16 +219,17 @@ public class RemoteMonitoredVm extends AbstractMonitoredVm { /** * Fire MonitoredVmStructureChanged events. */ + @SuppressWarnings("unchecked") // Cast of result of clone void fireMonitorsUpdatedEvents() { - ArrayList registered = null; + ArrayList registered = null; VmEvent ev = null; synchronized(listeners) { registered = (ArrayList)listeners.clone(); } - for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { - VmListener l = (VmListener)i.next(); + for (Iterator i = registered.iterator(); i.hasNext(); /* empty */) { + VmListener l = i.next(); if (ev == null) { ev = new VmEvent(this); } @@ -256,8 +258,8 @@ public class RemoteMonitoredVm extends AbstractMonitoredVm { try { MonitorStatus status = getMonitorStatus(); - List inserted = status.getInserted(); - List removed = status.getRemoved(); + List inserted = status.getInserted(); + List removed = status.getRemoved(); if (!inserted.isEmpty() || !removed.isEmpty()) { fireMonitorStatusChangedEvents(inserted, removed); diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java index a065258a73f..a6eafba6954 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -47,7 +47,7 @@ public class PerfDataBuffer extends PerfDataBufferImpl { private static final boolean DEBUG = false; private static final int syncWaitMs = Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000); - private static final ArrayList EMPTY_LIST = new ArrayList(0); + private static final ArrayList EMPTY_LIST = new ArrayList(0); /* * the following constants must be kept in sync with struct @@ -190,8 +190,8 @@ public class PerfDataBuffer extends PerfDataBufferImpl { getNewMonitors(map); // current implementation doesn't support deletion or reuse of entries - ArrayList removed = EMPTY_LIST; - ArrayList inserted = insertedMonitors; + ArrayList removed = EMPTY_LIST; + ArrayList inserted = insertedMonitors; insertedMonitors = new ArrayList(); return new MonitorStatus(inserted, removed); @@ -618,14 +618,14 @@ public class PerfDataBuffer extends PerfDataBufferImpl { /** * Method to dump debugging information */ - private void dumpAll(Map map, int lvmid) { + private void dumpAll(Map map, int lvmid) { if (DEBUG) { - Set keys = map.keySet(); + Set keys = map.keySet(); System.err.println("Dump for " + lvmid); int j = 0; - for (Iterator i = keys.iterator(); i.hasNext(); j++) { - Monitor monitor = (Monitor)map.get(i.next()); + for (Iterator i = keys.iterator(); i.hasNext(); j++) { + Monitor monitor = map.get(i.next()); System.err.println(j + "\t" + monitor.getName() + "=" + monitor.getValue()); } diff --git a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java index 746145095ec..2c2a944e0d7 100644 --- a/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java +++ b/jdk/src/share/classes/sun/jvmstat/perfdata/monitor/v2_0/PerfDataBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -65,7 +65,7 @@ public class PerfDataBuffer extends PerfDataBufferImpl { private static final boolean DEBUG = false; private static final int syncWaitMs = Integer.getInteger("sun.jvmstat.perdata.syncWaitMs", 5000); - private static final ArrayList EMPTY_LIST = new ArrayList(0); + private static final ArrayList EMPTY_LIST = new ArrayList<>(0); /* * These are primarily for documentary purposes and the match up @@ -198,10 +198,10 @@ public class PerfDataBuffer extends PerfDataBufferImpl { getNewMonitors(map); // current implementation doesn't support deletion of reuse of entries - ArrayList removed = EMPTY_LIST; - ArrayList inserted = insertedMonitors; + ArrayList removed = EMPTY_LIST; + ArrayList inserted = insertedMonitors; - insertedMonitors = new ArrayList(); + insertedMonitors = new ArrayList<>(); return new MonitorStatus(inserted, removed); } @@ -524,7 +524,7 @@ public class PerfDataBuffer extends PerfDataBufferImpl { System.err.println("Dump for " + lvmid); int j = 0; - for (Iterator i = keys.iterator(); i.hasNext(); j++) { + for (Iterator i = keys.iterator(); i.hasNext(); j++) { Monitor monitor = map.get(i.next()); System.err.println(j + "\t" + monitor.getName() + "=" + monitor.getValue()); From 665f030eaf9eab7e54f9fa2174fb6f8a943187c5 Mon Sep 17 00:00:00 2001 From: Jason Uh Date: Wed, 9 Jul 2014 18:34:45 -0700 Subject: [PATCH 068/236] 7065233: To interpret case-insensitive string locale independently Reviewed-by: xuelei --- .../com/sun/crypto/provider/JceKeyStore.java | 28 ++++++------- .../com/sun/crypto/provider/PBEKey.java | 5 ++- .../sun/crypto/provider/PBEKeyFactory.java | 41 ++++++++++--------- .../sun/crypto/provider/PBKDF2KeyImpl.java | 7 ++-- .../javax/crypto/spec/SecretKeySpec.java | 6 ++- .../sun/security/pkcs12/PKCS12KeyStore.java | 4 +- .../sun/security/provider/ConfigFile.java | 4 +- .../sun/security/provider/PolicyParser.java | 4 +- .../sun/security/tools/keytool/Main.java | 2 +- 9 files changed, 53 insertions(+), 48 deletions(-) diff --git a/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java b/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java index 5d48553c25a..cbbc54e42e1 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/JceKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -107,7 +107,7 @@ public final class JceKeyStore extends KeyStoreSpi { { Key key = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (!((entry instanceof PrivateKeyEntry) || (entry instanceof SecretKeyEntry))) { @@ -150,7 +150,7 @@ public final class JceKeyStore extends KeyStoreSpi { { Certificate[] chain = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if ((entry instanceof PrivateKeyEntry) && (((PrivateKeyEntry)entry).chain != null)) { @@ -178,7 +178,7 @@ public final class JceKeyStore extends KeyStoreSpi { public Certificate engineGetCertificate(String alias) { Certificate cert = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry != null) { if (entry instanceof TrustedCertEntry) { @@ -203,7 +203,7 @@ public final class JceKeyStore extends KeyStoreSpi { public Date engineGetCreationDate(String alias) { Date date = null; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry != null) { // We have to create a new instance of java.util.Date because @@ -266,7 +266,7 @@ public final class JceKeyStore extends KeyStoreSpi { } // store the entry - entries.put(alias.toLowerCase(), entry); + entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } else { SecretKeyEntry entry = new SecretKeyEntry(); @@ -274,7 +274,7 @@ public final class JceKeyStore extends KeyStoreSpi { // seal and store the key entry.sealedKey = keyProtector.seal(key); - entries.put(alias.toLowerCase(), entry); + entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } } catch (Exception e) { @@ -322,7 +322,7 @@ public final class JceKeyStore extends KeyStoreSpi { entry.chain = null; } - entries.put(alias.toLowerCase(), entry); + entries.put(alias.toLowerCase(Locale.ENGLISH), entry); } } @@ -345,7 +345,7 @@ public final class JceKeyStore extends KeyStoreSpi { { synchronized(entries) { - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry != null) { if (entry instanceof PrivateKeyEntry) { throw new KeyStoreException("Cannot overwrite own " @@ -358,7 +358,7 @@ public final class JceKeyStore extends KeyStoreSpi { TrustedCertEntry trustedCertEntry = new TrustedCertEntry(); trustedCertEntry.cert = cert; trustedCertEntry.date = new Date(); - entries.put(alias.toLowerCase(), trustedCertEntry); + entries.put(alias.toLowerCase(Locale.ENGLISH), trustedCertEntry); } } @@ -373,7 +373,7 @@ public final class JceKeyStore extends KeyStoreSpi { throws KeyStoreException { synchronized(entries) { - entries.remove(alias.toLowerCase()); + entries.remove(alias.toLowerCase(Locale.ENGLISH)); } } @@ -394,7 +394,7 @@ public final class JceKeyStore extends KeyStoreSpi { * @return true if the alias exists, false otherwise */ public boolean engineContainsAlias(String alias) { - return entries.containsKey(alias.toLowerCase()); + return entries.containsKey(alias.toLowerCase(Locale.ENGLISH)); } /** @@ -416,7 +416,7 @@ public final class JceKeyStore extends KeyStoreSpi { public boolean engineIsKeyEntry(String alias) { boolean isKey = false; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if ((entry instanceof PrivateKeyEntry) || (entry instanceof SecretKeyEntry)) { isKey = true; @@ -434,7 +434,7 @@ public final class JceKeyStore extends KeyStoreSpi { */ public boolean engineIsCertificateEntry(String alias) { boolean isCert = false; - Object entry = entries.get(alias.toLowerCase()); + Object entry = entries.get(alias.toLowerCase(Locale.ENGLISH)); if (entry instanceof TrustedCertEntry) { isCert = true; } diff --git a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java index d954d0fe6a5..10ba5cb79f6 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -27,6 +27,7 @@ package com.sun.crypto.provider; import java.security.KeyRep; import java.security.spec.InvalidKeySpecException; +import java.util.Locale; import javax.crypto.SecretKey; import javax.crypto.spec.PBEKeySpec; @@ -91,7 +92,7 @@ final class PBEKey implements SecretKey { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= getAlgorithm().toLowerCase().hashCode()); + return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode()); } public boolean equals(Object obj) { diff --git a/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java b/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java index 26dd0867c95..0c87971876f 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -32,6 +32,7 @@ import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactorySpi; import javax.crypto.spec.PBEKeySpec; import java.util.HashSet; +import java.util.Locale; /** * This class implements a key factory for PBE keys according to PKCS#5, @@ -56,24 +57,24 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { static { validTypes = new HashSet(17); - validTypes.add("PBEWithMD5AndDES".toUpperCase()); - validTypes.add("PBEWithSHA1AndDESede".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase()); - validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase()); + validTypes.add("PBEWithMD5AndDES".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndDESede".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase(Locale.ENGLISH)); // Proprietary algorithm. - validTypes.add("PBEWithMD5AndTripleDES".toUpperCase()); - validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase()); - validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase()); - validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase()); + validTypes.add("PBEWithMD5AndTripleDES".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase(Locale.ENGLISH)); + validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase(Locale.ENGLISH)); } public static final class PBEWithMD5AndDES @@ -237,7 +238,7 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { protected KeySpec engineGetKeySpec(SecretKey key, Class keySpecCl) throws InvalidKeySpecException { if ((key instanceof SecretKey) - && (validTypes.contains(key.getAlgorithm().toUpperCase())) + && (validTypes.contains(key.getAlgorithm().toUpperCase(Locale.ENGLISH))) && (key.getFormat().equalsIgnoreCase("RAW"))) { // Check if requested key spec is amongst the valid ones @@ -279,7 +280,7 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { { try { if ((key != null) && - (validTypes.contains(key.getAlgorithm().toUpperCase())) && + (validTypes.contains(key.getAlgorithm().toUpperCase(Locale.ENGLISH))) && (key.getFormat().equalsIgnoreCase("RAW"))) { // Check if key originates from this factory diff --git a/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java b/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java index ec3bd3e7992..16756fbe5e0 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.util.Arrays; +import java.util.Locale; import java.security.KeyRep; import java.security.GeneralSecurityException; import java.security.NoSuchAlgorithmException; @@ -143,7 +144,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey { @Override public int hashCode() { return Arrays.hashCode(password) * 41 + - prf.getAlgorithm().toLowerCase().hashCode(); + prf.getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode(); } @Override public boolean equals(Object obj) { @@ -221,7 +222,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey { for (int i = 1; i < this.key.length; i++) { retval += this.key[i] * i; } - return(retval ^= getAlgorithm().toLowerCase().hashCode()); + return(retval ^= getAlgorithm().toLowerCase(Locale.ENGLISH).hashCode()); } public boolean equals(Object obj) { diff --git a/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java b/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java index aedd9ca130c..94c35e0b80d 100644 --- a/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java +++ b/jdk/src/share/classes/javax/crypto/spec/SecretKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 javax.crypto.spec; import java.security.spec.KeySpec; +import java.util.Locale; import javax.crypto.SecretKey; /** @@ -194,7 +195,8 @@ public class SecretKeySpec implements KeySpec, SecretKey { if (this.algorithm.equalsIgnoreCase("TripleDES")) return (retval ^= "desede".hashCode()); else - return (retval ^= this.algorithm.toLowerCase().hashCode()); + return (retval ^= + this.algorithm.toLowerCase(Locale.ENGLISH).hashCode()); } /** diff --git a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 35564498c0e..9861bc86bdf 100644 --- a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -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 @@ -900,7 +900,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi { private static ObjectIdentifier mapPBEAlgorithmToOID(String algorithm) throws NoSuchAlgorithmException { // Check for PBES2 algorithms - if (algorithm.toLowerCase().startsWith("pbewithhmacsha")) { + if (algorithm.toLowerCase(Locale.ENGLISH).startsWith("pbewithhmacsha")) { return pbes2_OID; } return AlgorithmId.get(algorithm).getOID(); diff --git a/jdk/src/share/classes/sun/security/provider/ConfigFile.java b/jdk/src/share/classes/sun/security/provider/ConfigFile.java index f3c041ac0b3..6e243c4a612 100644 --- a/jdk/src/share/classes/sun/security/provider/ConfigFile.java +++ b/jdk/src/share/classes/sun/security/provider/ConfigFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -451,7 +451,7 @@ public final class ConfigFile extends Configuration { // controlFlag (required, optional, etc) LoginModuleControlFlag controlFlag; - String sflag = match("controlFlag").toUpperCase(); + String sflag = match("controlFlag").toUpperCase(Locale.ENGLISH); switch (sflag) { case "REQUIRED": controlFlag = LoginModuleControlFlag.REQUIRED; diff --git a/jdk/src/share/classes/sun/security/provider/PolicyParser.java b/jdk/src/share/classes/sun/security/provider/PolicyParser.java index b13345f7c55..8d037b4bb4a 100644 --- a/jdk/src/share/classes/sun/security/provider/PolicyParser.java +++ b/jdk/src/share/classes/sun/security/provider/PolicyParser.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 @@ -707,7 +707,7 @@ public class PolicyParser { } catch (PropertyExpander.ExpandException peee) { throw new IOException(peee.getLocalizedMessage()); } - properties.put(key.toLowerCase(), value); + properties.put(key.toLowerCase(Locale.ENGLISH), value); } return properties; diff --git a/jdk/src/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/share/classes/sun/security/tools/keytool/Main.java index 2947a3081a1..1b52d51385a 100644 --- a/jdk/src/share/classes/sun/security/tools/keytool/Main.java +++ b/jdk/src/share/classes/sun/security/tools/keytool/Main.java @@ -1540,7 +1540,7 @@ public final class Main { boolean useDefaultPBEAlgorithm = true; SecretKey secKey = null; - if (keyAlgName.toUpperCase().startsWith("PBE")) { + if (keyAlgName.toUpperCase(Locale.ENGLISH).startsWith("PBE")) { SecretKeyFactory factory = SecretKeyFactory.getInstance("PBE"); // User is prompted for PBE credential From 57d0562d7c1a28166a23fc82c6d4d9a5f885a14f Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Thu, 10 Jul 2014 10:44:48 +0800 Subject: [PATCH 069/236] 8044085: Access ExtendedGSSContext.inquireSecContext() result through SASL Reviewed-by: mullan --- .../security/sasl/gsskerb/GssKrb5Base.java | 33 +++++++++++++++++++ .../javax/security/sasl/SaslClient.java | 4 +++ .../javax/security/sasl/SaslServer.java | 4 +++ .../sun/security/krb5/auto/SaslBasic.java | 10 +++++- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java index 30461e25f7c..7a7dc52a26c 100644 --- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java +++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Base.java @@ -26,11 +26,14 @@ package com.sun.security.sasl.gsskerb; +import java.util.Locale; import java.util.Map; import java.util.logging.Level; import javax.security.sasl.*; import com.sun.security.sasl.util.AbstractSaslImpl; import org.ietf.jgss.*; +import com.sun.security.jgss.ExtendedGSSContext; +import com.sun.security.jgss.InquireType; abstract class GssKrb5Base extends AbstractSaslImpl { @@ -61,6 +64,36 @@ abstract class GssKrb5Base extends AbstractSaslImpl { return "GSSAPI"; } + @Override + public Object getNegotiatedProperty(String propName) { + if (!completed) { + throw new IllegalStateException("Authentication incomplete"); + } + String xprefix = "com.sun.security.jgss.inquiretype."; + if (propName.startsWith(xprefix)) { + String type = propName.substring(xprefix.length()); + if (logger.isLoggable(Level.FINEST)) { + logger.logp(Level.FINE, "GssKrb5Base", + "getNegotiatedProperty", propName); + } + for (InquireType t: InquireType.values()) { + if (t.name().toLowerCase(Locale.US).equals(type)) { + try { + return ((ExtendedGSSContext)secCtx).inquireSecContext(t); + } catch (GSSException e) { + if (logger.isLoggable(Level.FINEST)) { + logger.log(Level.WARNING, "inquireSecContext error", e); + } + return null; + } + } + } + // No such InquireType. Although not likely to be defined + // as a property in a parent class, still try it. + } + return super.getNegotiatedProperty(propName); + } + public byte[] unwrap(byte[] incoming, int start, int len) throws SaslException { if (!completed) { diff --git a/jdk/src/share/classes/javax/security/sasl/SaslClient.java b/jdk/src/share/classes/javax/security/sasl/SaslClient.java index c7258f4007b..a488132301c 100644 --- a/jdk/src/share/classes/javax/security/sasl/SaslClient.java +++ b/jdk/src/share/classes/javax/security/sasl/SaslClient.java @@ -204,6 +204,10 @@ public abstract interface SaslClient { * This method can be called only after the authentication exchange has * completed (i.e., when {@code isComplete()} returns true); otherwise, an * {@code IllegalStateException} is thrown. + *

+ * The {@link Sasl} class includes several well-known property names + * (For example, {@link Sasl#QOP}). A SASL provider can support other + * properties which are specific to the vendor and/or a mechanism. * * @param propName The non-null property name. * @return The value of the negotiated property. If null, the property was diff --git a/jdk/src/share/classes/javax/security/sasl/SaslServer.java b/jdk/src/share/classes/javax/security/sasl/SaslServer.java index 818ae999654..a80772cff11 100644 --- a/jdk/src/share/classes/javax/security/sasl/SaslServer.java +++ b/jdk/src/share/classes/javax/security/sasl/SaslServer.java @@ -196,6 +196,10 @@ public abstract interface SaslServer { * This method can be called only after the authentication exchange has * completed (i.e., when {@code isComplete()} returns true); otherwise, an * {@code IllegalStateException} is thrown. + *

+ * The {@link Sasl} class includes several well-known property names + * (For example, {@link Sasl#QOP}). A SASL provider can support other + * properties which are specific to the vendor and/or a mechanism. * * @param propName the property * @return The value of the negotiated property. If null, the property was diff --git a/jdk/test/sun/security/krb5/auto/SaslBasic.java b/jdk/test/sun/security/krb5/auto/SaslBasic.java index ef38ab3185f..3fdd3534ed4 100644 --- a/jdk/test/sun/security/krb5/auto/SaslBasic.java +++ b/jdk/test/sun/security/krb5/auto/SaslBasic.java @@ -29,6 +29,8 @@ * @run main/othervm SaslBasic bound * @run main/othervm SaslBasic unbound */ +import com.sun.security.jgss.InquireType; + import java.io.IOException; import java.util.Arrays; import java.util.HashMap; @@ -82,11 +84,17 @@ public class SaslBasic { } } if (!bound) { - String boundName = (String)ss.getNegotiatedProperty(Sasl.BOUND_SERVER_NAME); + String boundName = (String)ss.getNegotiatedProperty( + Sasl.BOUND_SERVER_NAME); if (!boundName.equals(name)) { throw new Exception("Wrong bound server name"); } } + Object key = ss.getNegotiatedProperty( + "com.sun.security.jgss.inquiretype.krb5_get_session_key"); + if (key == null) { + throw new Exception("Extended negotiated property not read"); + } byte[] hello = "hello".getBytes(); token = sc.wrap(hello, 0, hello.length); token = ss.unwrap(token, 0, token.length); From 44c5f51ddf23d39c4924929397163d951e2c9cd1 Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Thu, 10 Jul 2014 03:07:48 +0000 Subject: [PATCH 070/236] 8041781: Need new regression tests for PBE keys Reviewed-by: xuelei --- .../provider/Cipher/PBE/PBESealedObject.java | 173 ++++++++++ .../provider/Cipher/PBE/PBKDF2Translate.java | 311 ++++++++++++++++++ .../PBE/TestCipherKeyWrapperPBEKey.java | 168 ++++++++++ 3 files changed, 652 insertions(+) create mode 100644 jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java create mode 100644 jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java create mode 100644 jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java new file mode 100644 index 00000000000..2420b9bc4a3 --- /dev/null +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2012, 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. + */ + +import java.io.PrintStream; +import java.security.AlgorithmParameters; +import java.security.InvalidKeyException; +import java.security.Provider; +import java.security.Security; +import java.security.spec.AlgorithmParameterSpec; +import java.util.Arrays; +import java.util.Random; +import java.util.StringTokenizer; +import javax.crypto.Cipher; +import javax.crypto.SealedObject; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.PBEParameterSpec; + +/** + * @test + * @bug 8041781 + * @summary test if seal/unseal works correctly with PBE algorithms + * @author Yun Ke + * @author Bill Situ + * @author Alexander Fomin + * @run main PBESealedObject + */ +public class PBESealedObject { + + private static final String[] PBEAlgorithms = { + "pbeWithMD5ANDdes", + "PBEWithMD5AndDES/CBC/PKCS5Padding", + "PBEWithMD5AndTripleDES", + "PBEWithMD5AndTripleDES/CBC/PKCS5Padding", + "PBEwithSHA1AndDESede", + "PBEwithSHA1AndDESede/CBC/PKCS5Padding", + "PBEwithSHA1AndRC2_40", + "PBEwithSHA1Andrc2_40/CBC/PKCS5Padding", + "PBEWithSHA1AndRC2_128", + "PBEWithSHA1andRC2_128/CBC/PKCS5Padding", + "PBEWithSHA1AndRC4_40", + "PBEWithsha1AndRC4_40/ECB/NoPadding", + "PBEWithSHA1AndRC4_128", + "pbeWithSHA1AndRC4_128/ECB/NoPadding", + "PBEWithHmacSHA1AndAES_128", + "PBEWithHmacSHA224AndAES_128", + "PBEWithHmacSHA256AndAES_128", + "PBEWithHmacSHA384AndAES_128", + "PBEWithHmacSHA512AndAES_128", + "PBEWithHmacSHA1AndAES_256", + "PBEWithHmacSHA224AndAES_256", + "PBEWithHmacSHA256AndAES_256", + "PBEWithHmacSHA384AndAES_256", + "PBEWithHmacSHA512AndAES_256" + }; + + public static void main(String[] args) { + PBESealedObject test = new PBESealedObject(); + Provider sunjce = Security.getProvider("SunJCE"); + + if (!test.runAll(sunjce, System.out)) { + throw new RuntimeException("One or more tests have failed...."); + } + } + + public boolean runAll(Provider p, PrintStream out) { + boolean finalResult = true; + + for (String algorithm : PBEAlgorithms) { + out.println("Running test with " + algorithm + ":"); + try { + if (!runTest(p, algorithm, out)) { + finalResult = false; + out.println("STATUS: Failed"); + } else { + out.println("STATUS: Passed"); + } + } catch (Exception ex) { + finalResult = false; + ex.printStackTrace(out); + out.println("STATUS:Failed"); + } + } + + return finalResult; + } + + // Have a generic throws Exception as it can throw many different exceptions + public boolean runTest(Provider p, String algo, PrintStream out) + throws Exception { + + byte[] salt = new byte[8]; + int ITERATION_COUNT = 1000; + AlgorithmParameters pbeParams = null; + + String baseAlgo + = new StringTokenizer(algo, "/").nextToken().toUpperCase(); + boolean isAES = baseAlgo.contains("AES"); + + try { + // Initialization + Cipher ci = Cipher.getInstance(algo, p); + new Random().nextBytes(salt); + AlgorithmParameterSpec aps = new PBEParameterSpec(salt, + ITERATION_COUNT); + SecretKeyFactory skf = SecretKeyFactory.getInstance(baseAlgo, p); + SecretKey key = skf.generateSecret( + new PBEKeySpec("Secret Lover".toCharArray())); + + // Seal + if (isAES) { + ci.init(Cipher.ENCRYPT_MODE, key); + pbeParams = ci.getParameters(); + } else { + ci.init(Cipher.ENCRYPT_MODE, key, aps); + } + + SealedObject so = new SealedObject(key, ci); + + // Unseal and compare + if (isAES) { + ci.init(Cipher.DECRYPT_MODE, key, pbeParams); + } else { + ci.init(Cipher.DECRYPT_MODE, key, aps); + } + + SecretKey unsealedKey; + + unsealedKey = (SecretKey) so.getObject(ci); + if (!Arrays.equals(unsealedKey.getEncoded(), key.getEncoded())) { + return false; + } + + unsealedKey = (SecretKey) so.getObject(key); + if (!Arrays.equals(unsealedKey.getEncoded(), key.getEncoded())) { + return false; + } + + unsealedKey = (SecretKey) so.getObject(key, "SunJCE"); + return Arrays.equals(unsealedKey.getEncoded(), key.getEncoded()); + } catch (InvalidKeyException ex) { + if (baseAlgo.endsWith("TRIPLEDES") || baseAlgo.endsWith("AES_256")) { + out.println( + "Expected exception , keyStrength > 128 within" + algo); + return true; + } + + throw ex; + } + } + +} diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java new file mode 100644 index 00000000000..36681591e46 --- /dev/null +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/PBKDF2Translate.java @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2012, 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. + */ + +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.spec.InvalidKeySpecException; +import java.util.Arrays; +import java.util.Random; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.interfaces.PBEKey; +import javax.crypto.spec.PBEKeySpec; + +/** + * @test + * @bug 8041781 + * @summary Verify if the SecretKeyFactory.translateKey() method works + * @author Alexander Fomin + * @run main PBKDF2Translate + */ +public class PBKDF2Translate { + + private static final String[] ALGO_TO_TEST = { + "PBKDF2WithHmacSHA1", + "PBKDF2WithHmacSHA224", + "PBKDF2WithHmacSHA256", + "PBKDF2WithHmacSHA384", + "PBKDF2WithHmacSHA512" + }; + + private static final String PASS_PHRASE = "some hidden string"; + private static final int ITERATION_COUNT = 1000; + private static final int KEY_SIZE = 128; + + private final String algoToTest; + private final byte[] salt = new byte[8]; + + public static void main(String[] args) throws Exception { + + boolean failed = false; + + for (String algo : ALGO_TO_TEST) { + + System.out.println("Testing " + algo + ":"); + PBKDF2Translate theTest = new PBKDF2Translate(algo); + + try { + if (!theTest.testMyOwnSecretKey() + || !theTest.generateAndTranslateKey() + || !theTest.translateSpoiledKey()) { + // we don't want to set failed to false + failed = true; + } + } catch (InvalidKeyException | NoSuchAlgorithmException | + InvalidKeySpecException e) { + e.printStackTrace(System.err); + failed = true; + } + } + + if (failed) { + throw new RuntimeException("One or more tests failed...."); + } + } + + public PBKDF2Translate(String algoToTest) { + this.algoToTest = algoToTest; + new Random().nextBytes(this.salt); + } + + /** + * The test case scenario implemented in the method: - derive PBKDF2 key + * using the given algorithm; - translate the key - check if the translated + * and original keys have the same key value. + * + * @return true if the test case passed; false - otherwise. + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + * @throws InvalidKeyException + */ + public boolean generateAndTranslateKey() throws NoSuchAlgorithmException, + InvalidKeySpecException, InvalidKeyException { + // derive PBKDF2 key + SecretKey key1 = getSecretKeyForPBKDF2(algoToTest); + + // translate key + SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToTest); + SecretKey key2 = skf.translateKey(key1); + + // check if it still the same after translation + if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) { + System.err.println("generateAndTranslateKey test case failed: the " + + "key1 and key2 values in its primary encoding format are " + + "not the same for " + algoToTest + "algorithm."); + return false; + } + + return true; + } + + /** + * The test case scenario implemented in the method: - derive Key1 for the + * given PBKDF2 algorithm - create my own secret Key2 as an instance of a + * class implements PBEKey - translate Key2 - check if the key value of the + * translated key and Key1 are the same. + * + * @return true if the test case passed; false - otherwise. + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + * @throws InvalidKeyException + */ + public boolean testMyOwnSecretKey() + throws NoSuchAlgorithmException, InvalidKeySpecException, + InvalidKeyException { + SecretKey key1 = getSecretKeyForPBKDF2(algoToTest); + SecretKey key2 = getMyOwnSecretKey(); + + // Is it actually the same? + if (!Arrays.equals(key1.getEncoded(), key2.getEncoded())) { + System.err.println("We shouldn't be here. The key1 and key2 values " + + "in its primary encoding format have to be the same!"); + return false; + } + + // Translate key + SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToTest); + SecretKey key3 = skf.translateKey(key2); + + // Check if it still the same after translation + if (!Arrays.equals(key1.getEncoded(), key3.getEncoded())) { + System.err.println("testMyOwnSecretKey test case failed: the key1 " + + "and key3 values in its primary encoding format are not " + + "the same for " + algoToTest + "algorithm."); + return false; + } + + return true; + } + + /** + * The test case scenario implemented in the method: - create my own secret + * Key2 as an instance of a class implements PBEKey - spoil the key (set + * iteration count to 0, for example) - try to translate key - + * InvalidKeyException is expected. + * + * @return true if InvalidKeyException occurred; false - otherwise. + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + */ + public boolean translateSpoiledKey() throws NoSuchAlgorithmException, + InvalidKeySpecException { + // derive the key + SecretKey key1 = getMyOwnSecretKey(); + + // spoil the key + ((MyPBKDF2SecretKey) key1).spoil(); + + // translate key + SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToTest); + try { + SecretKey key2 = skf.translateKey(key1); + } catch (InvalidKeyException ike) { + // this is expected + return true; + } + + return false; + } + + /** + * Generate a PBKDF2 secret key using given algorithm. + * + * @param algoToDeriveKey PBKDF2 algorithm + * @return PBKDF2 secret key + * @throws NoSuchAlgorithmException + * @throws InvalidKeySpecException + */ + private SecretKey getSecretKeyForPBKDF2(String algoToDeriveKey) + throws NoSuchAlgorithmException, InvalidKeySpecException { + SecretKeyFactory skf = SecretKeyFactory.getInstance(algoToDeriveKey); + + PBEKeySpec spec = new PBEKeySpec(PASS_PHRASE.toCharArray(), + this.salt, ITERATION_COUNT, KEY_SIZE); + + return skf.generateSecret(spec); + } + + /** + * Generate a secrete key as an instance of a class implements PBEKey. + * + * @return secrete key + * @throws InvalidKeySpecException + * @throws NoSuchAlgorithmException + */ + private SecretKey getMyOwnSecretKey() throws InvalidKeySpecException, + NoSuchAlgorithmException { + return new MyPBKDF2SecretKey(PASS_PHRASE, this.algoToTest, this.salt, + ITERATION_COUNT, KEY_SIZE); + } +} + +/** + * An utility class to check the SecretKeyFactory.translateKey() method. + */ +class MyPBKDF2SecretKey implements PBEKey { + + private final byte[] key; + private final byte[] salt; + private final String algorithm; + private final int keySize, keyLength; + private int itereationCount; + private final String pass; + + @Override + public String getAlgorithm() { + return algorithm; + } + + @Override + public String getFormat() { + return "RAW"; + } + + @Override + public byte[] getEncoded() { + byte[] copy = new byte[keyLength]; + System.arraycopy(this.key, 0, copy, 0, keyLength); + return copy; + } + + /** + * The key is generating by SecretKeyFactory and its value just copying in + * the key field of MySecretKey class. So, this is real key derived using + * the given algorithm. + * + * @param passPhrase some string intended to be a password + * @param algo PBKDF2 algorithm + * @param salt slat for PBKDF2 + * @param iterationCount iteration count + * @param keySize key size in bits + * @throws InvalidKeySpecException + * @throws NoSuchAlgorithmException + */ + public MyPBKDF2SecretKey(String passPhrase, String algo, byte[] salt, + int iterationCount, int keySize) + throws InvalidKeySpecException, NoSuchAlgorithmException { + this.algorithm = algo; + this.salt = salt; + this.itereationCount = iterationCount; + this.keySize = keySize; + this.pass = passPhrase; + + PBEKeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), + this.salt, iterationCount, this.keySize); + + SecretKeyFactory keyFactory + = SecretKeyFactory.getInstance(algo); + + SecretKey realKey = keyFactory.generateSecret(spec); + + this.keyLength = realKey.getEncoded().length; + + this.key = new byte[this.keyLength]; + System.arraycopy(realKey.getEncoded(), 0, this.key, 0, + this.keyLength); + } + + @Override + public int getIterationCount() { + return itereationCount; + } + + @Override + public byte[] getSalt() { + return salt; + } + + @Override + public char[] getPassword() { + return this.pass.toCharArray(); + } + + /** + * Spoil the generated key (before translation) to cause an + * InvalidKeyException + */ + public void spoil() { + this.itereationCount = -1; + } + +} diff --git a/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java new file mode 100644 index 00000000000..cc237d0549d --- /dev/null +++ b/jdk/test/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2012, 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. + */ + +import java.io.PrintStream; +import java.security.AlgorithmParameters; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.Provider; +import java.security.Security; +import java.security.spec.AlgorithmParameterSpec; +import java.util.Arrays; +import java.util.Random; +import java.util.StringTokenizer; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.SecretKeyFactory; +import javax.crypto.spec.PBEKeySpec; +import javax.crypto.spec.PBEParameterSpec; + +/** + * @test + * @bug 8041781 + * @summary Test to see if key wrapper works correctly with PBEKey + * @author Yu-Ching (Valerie) PENG + * @author Bill Situ + * @author Yun Ke + * @run main TestCipherKeyWrapperPBEKey + */ +public class TestCipherKeyWrapperPBEKey { + + private static final String[] PBEAlgorithms = { + "pbeWithMD5ANDdes", + "PBEWithMD5AndDES/CBC/PKCS5Padding", + "PBEWithMD5AndTripleDES", + "PBEWithMD5AndTripleDES/CBC/PKCS5Padding", + "PBEwithSHA1AndDESede", + "PBEwithSHA1AndDESede/CBC/PKCS5Padding", + "PBEwithSHA1AndRC2_40", + "PBEwithSHA1Andrc2_40/CBC/PKCS5Padding", + "PBEWithSHA1AndRC2_128", + "PBEWithSHA1andRC2_128/CBC/PKCS5Padding", + "PBEWithSHA1AndRC4_40", + "PBEWithsha1AndRC4_40/ECB/NoPadding", + "PBEWithSHA1AndRC4_128", + "pbeWithSHA1AndRC4_128/ECB/NoPadding", + "PBEWithHmacSHA1AndAES_128", + "PBEWithHmacSHA224AndAES_128", + "PBEWithHmacSHA256AndAES_128", + "PBEWithHmacSHA384AndAES_128", + "PBEWithHmacSHA512AndAES_128", + "PBEWithHmacSHA1AndAES_256", + "PBEWithHmacSHA224AndAES_256", + "PBEWithHmacSHA256AndAES_256", + "PBEWithHmacSHA384AndAES_256", + "PBEWithHmacSHA512AndAES_256" + }; + + public static void main(String[] args) { + + TestCipherKeyWrapperPBEKey test = new TestCipherKeyWrapperPBEKey(); + Provider sunjce = Security.getProvider("SunJCE"); + + if (!test.runAll(sunjce, System.out)) { + throw new RuntimeException("One or more tests have failed...."); + } + } + + public boolean runAll(Provider p, PrintStream out) { + boolean finalResult = true; + + for (String algorithm : PBEAlgorithms) { + out.println("Running test with " + algorithm + ":"); + try { + if (!runTest(p, algorithm, out)) { + finalResult = false; + out.println("STATUS: Failed"); + } else { + out.println("STATUS: Passed"); + } + } catch (Exception ex) { + finalResult = false; + ex.printStackTrace(out); + out.println("STATUS:Failed"); + } + } + + return finalResult; + } + + // Have a generic throws Exception as it can throw many different exceptions + public boolean runTest(Provider p, String algo, PrintStream out) + throws Exception { + + byte[] salt = new byte[8]; + int ITERATION_COUNT = 1000; + AlgorithmParameters pbeParams = null; + + String baseAlgo + = new StringTokenizer(algo, "/").nextToken().toUpperCase(); + boolean isAES = baseAlgo.contains("AES"); + + try { + // Initialization + new Random().nextBytes(salt); + AlgorithmParameterSpec aps = new PBEParameterSpec(salt, + ITERATION_COUNT); + SecretKeyFactory skf = SecretKeyFactory.getInstance(baseAlgo, p); + SecretKey key = skf.generateSecret(new PBEKeySpec( + "Secret Key".toCharArray())); + Cipher ci = Cipher.getInstance(algo); + + if (isAES) { + ci.init(Cipher.WRAP_MODE, key); + pbeParams = ci.getParameters(); + } else { + ci.init(Cipher.WRAP_MODE, key, aps); + } + + byte[] keyWrapper = ci.wrap(key); + if (isAES) { + ci.init(Cipher.UNWRAP_MODE, key, pbeParams); + } else { + ci.init(Cipher.UNWRAP_MODE, key, aps); + } + + Key unwrappedKey = ci.unwrap(keyWrapper, algo, Cipher.SECRET_KEY); + + if (baseAlgo.endsWith("TRIPLEDES") + || baseAlgo.endsWith("AES_256")) { + out.print( + "InvalidKeyException not thrown when keyStrength > 128"); + return false; + } + + return (Arrays.equals(key.getEncoded(), unwrappedKey.getEncoded())); + + } catch (InvalidKeyException ex) { + + if ((baseAlgo.endsWith("TRIPLEDES") + || baseAlgo.endsWith("AES_256"))) { + out.println("Expected InvalidKeyException, keyStrength > 128"); + return true; + } else { + throw ex; + } + } + } +} From 499b50c15b4301273edd9554a5d548999ddc0a64 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 9 Jul 2014 21:26:11 -0700 Subject: [PATCH 071/236] 8049820: Fix raw and unchecked lint warnings in sun.management Reviewed-by: mchung --- .../sun/management/DiagnosticCommandImpl.java | 12 ++++++------ .../GarbageCollectionNotifInfoCompositeData.java | 4 ++-- .../share/classes/sun/management/GcInfoBuilder.java | 4 ++-- .../classes/sun/management/GcInfoCompositeData.java | 10 +++++----- .../classes/sun/management/MappedMXBeanType.java | 7 ++++--- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java b/jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java index 27f6399337d..27730898f1b 100644 --- a/jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java +++ b/jdk/src/share/classes/sun/management/DiagnosticCommandImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -84,10 +84,10 @@ class DiagnosticCommandImpl extends NotificationEmitterSupport Exception cause = null; if (info.getPermissionClass() != null) { try { - Class c = Class.forName(info.getPermissionClass()); + Class c = Class.forName(info.getPermissionClass()); if (info.getPermissionAction() == null) { try { - Constructor constructor = c.getConstructor(String.class); + Constructor constructor = c.getConstructor(String.class); permission = (Permission) constructor.newInstance(info.getPermissionName()); } catch (InstantiationException | IllegalAccessException @@ -98,7 +98,7 @@ class DiagnosticCommandImpl extends NotificationEmitterSupport } if (permission == null) { try { - Constructor constructor = c.getConstructor(String.class, String.class); + Constructor constructor = c.getConstructor(String.class, String.class); permission = (Permission) constructor.newInstance( info.getPermissionName(), info.getPermissionAction()); @@ -158,7 +158,7 @@ class DiagnosticCommandImpl extends NotificationEmitterSupport SortedSet operations = new TreeSet<>(new OperationInfoComparator()); Map wrappersmap; if (!isSupported) { - wrappersmap = (Map) Collections.EMPTY_MAP; + wrappersmap = Collections.emptyMap(); } else { try { String[] command = getDiagnosticCommands(); @@ -189,7 +189,7 @@ class DiagnosticCommandImpl extends NotificationEmitterSupport } } } catch (IllegalArgumentException | UnsupportedOperationException e) { - wrappersmap = (Map) Collections.EMPTY_MAP; + wrappersmap = Collections.emptyMap(); } } wrappers = Collections.unmodifiableMap(wrappersmap); diff --git a/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java b/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java index 2d62ce3b0e6..722c0dfc55f 100644 --- a/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java +++ b/jdk/src/share/classes/sun/management/GarbageCollectionNotifInfoCompositeData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -65,7 +65,7 @@ public class GarbageCollectionNotifInfoCompositeData extends LazyCompositeData { final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction() { public GcInfoBuilder run() { try { - Class cl = Class.forName("com.sun.management.GcInfo"); + Class cl = Class.forName("com.sun.management.GcInfo"); Field f = cl.getDeclaredField("builder"); f.setAccessible(true); return (GcInfoBuilder)f.get(gcNotifInfo.getGcInfo()); diff --git a/jdk/src/share/classes/sun/management/GcInfoBuilder.java b/jdk/src/share/classes/sun/management/GcInfoBuilder.java index 523dcd5eee5..b503df57ad9 100644 --- a/jdk/src/share/classes/sun/management/GcInfoBuilder.java +++ b/jdk/src/share/classes/sun/management/GcInfoBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, 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 @@ -98,7 +98,7 @@ public class GcInfoBuilder { // First, fill with the attributes in the GcInfo String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames(); - OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes(); + OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes(); int numGcInfoItems = gcInfoItemNames.length; int itemCount = numGcInfoItems + gcExtItemCount; diff --git a/jdk/src/share/classes/sun/management/GcInfoCompositeData.java b/jdk/src/share/classes/sun/management/GcInfoCompositeData.java index a7730300e76..b1cb38e16b1 100644 --- a/jdk/src/share/classes/sun/management/GcInfoCompositeData.java +++ b/jdk/src/share/classes/sun/management/GcInfoCompositeData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -72,7 +72,7 @@ public class GcInfoCompositeData extends LazyCompositeData { final GcInfoBuilder builder = AccessController.doPrivileged (new PrivilegedAction() { public GcInfoBuilder run() { try { - Class cl = Class.forName("com.sun.management.GcInfo"); + Class cl = Class.forName("com.sun.management.GcInfo"); Field f = cl.getDeclaredField("builder"); f.setAccessible(true); return (GcInfoBuilder)f.get(info); @@ -84,7 +84,7 @@ public class GcInfoCompositeData extends LazyCompositeData { final Object[] extAttr = AccessController.doPrivileged (new PrivilegedAction() { public Object[] run() { try { - Class cl = Class.forName("com.sun.management.GcInfo"); + Class cl = Class.forName("com.sun.management.GcInfo"); Field f = cl.getDeclaredField("extAttributes"); f.setAccessible(true); return (Object[])f.get(info); @@ -182,8 +182,8 @@ public class GcInfoCompositeData extends LazyCompositeData { return baseGcInfoItemNames; } - private static OpenType[] baseGcInfoItemTypes = null; - static synchronized OpenType[] getBaseGcInfoItemTypes() { + private static OpenType[] baseGcInfoItemTypes = null; + static synchronized OpenType[] getBaseGcInfoItemTypes() { if (baseGcInfoItemTypes == null) { OpenType memoryUsageOpenType = memoryUsageMapType.getOpenType(); baseGcInfoItemTypes = new OpenType[] { diff --git a/jdk/src/share/classes/sun/management/MappedMXBeanType.java b/jdk/src/share/classes/sun/management/MappedMXBeanType.java index ae2055557c5..9bfcbd9c682 100644 --- a/jdk/src/share/classes/sun/management/MappedMXBeanType.java +++ b/jdk/src/share/classes/sun/management/MappedMXBeanType.java @@ -227,6 +227,7 @@ public abstract class MappedMXBeanType { // Enum <-> enum's name // static class EnumMXBeanType extends MappedMXBeanType { + @SuppressWarnings("rawtypes") final Class enumClass; EnumMXBeanType(Class c) { this.enumClass = c; @@ -754,7 +755,7 @@ public abstract class MappedMXBeanType { } } - private static class InProgress extends OpenType { + private static class InProgress extends OpenType { private static final String description = "Marker to detect recursive type use -- internal use only!"; @@ -783,7 +784,7 @@ public abstract class MappedMXBeanType { static { OpenType t; try { - t = new InProgress(); + t = new InProgress<>(); } catch (OpenDataException e) { // Should not reach here throw new AssertionError(e); @@ -791,7 +792,7 @@ public abstract class MappedMXBeanType { inProgress = t; } - private static final OpenType[] simpleTypes = { + private static final OpenType[] simpleTypes = { BIGDECIMAL, BIGINTEGER, BOOLEAN, BYTE, CHARACTER, DATE, DOUBLE, FLOAT, INTEGER, LONG, OBJECTNAME, SHORT, STRING, VOID, From 5079b7bbd486f87eab9402e10c111314e8ef6bbc Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Tue, 17 Jun 2014 13:57:01 +0100 Subject: [PATCH 072/236] 8047062: Improve diagnostic output in com/sun/jndi/ldap/LdapTimeoutTest.java Reviewed-by: duke --- .../classes/com/sun/jndi/ldap/Connection.java | 3 ++- .../com/sun/jndi/ldap/LdapTimeoutTest.java | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java index d41c94480e9..c5a957ce6d7 100644 --- a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java +++ b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java @@ -111,6 +111,7 @@ public final class Connection implements Runnable { private static final boolean debug = false; private static final int dump = 0; // > 0 r, > 1 rw + public static final long DEFAULT_READ_TIMEOUT_MILLIS = 15 * 1000; // 15 second timeout; final private Thread worker; // Initialized in constructor @@ -460,7 +461,7 @@ public final class Connection implements Runnable { // available ldr.wait(readTimeout); } else { - ldr.wait(15 * 1000); // 15 second timeout + ldr.wait(DEFAULT_READ_TIMEOUT_MILLIS); } waited = true; } else { diff --git a/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java b/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java index 39270374488..c5705bc4b74 100644 --- a/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java +++ b/jdk/test/com/sun/jndi/ldap/LdapTimeoutTest.java @@ -27,6 +27,8 @@ * @summary Timeout tests for ldap */ +import com.sun.jndi.ldap.Connection; + import java.net.Socket; import java.net.ServerSocket; import java.net.SocketTimeoutException; @@ -38,7 +40,9 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; + +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.NANOSECONDS; public class LdapTimeoutTest { private static final ScheduledExecutorService pool = @@ -85,7 +89,7 @@ public class LdapTimeoutTest { void ldapReadTimeoutTest(Hashtable env, boolean ssl) { InitialContext ctx = null; if (ssl) env.put(Context.SECURITY_PROTOCOL, "ssl"); - ScheduledFuture killer = killSwitch(5000); + ScheduledFuture killer = killSwitch(5_000); long start = System.nanoTime(); try { ctx = new InitialDirContext(env); @@ -113,7 +117,7 @@ public class LdapTimeoutTest { void simpleAuthConnectTest(Hashtable env) { InitialContext ctx = null; - ScheduledFuture killer = killSwitch(5000); + ScheduledFuture killer = killSwitch(5_000); long start = System.nanoTime(); try { ctx = new InitialDirContext(env); @@ -123,7 +127,7 @@ public class LdapTimeoutTest { } catch (NamingException e) { long end = System.nanoTime(); if (e.getCause() instanceof SocketTimeoutException) { - if (TimeUnit.NANOSECONDS.toMillis(end - start) < 2900) { + if (NANOSECONDS.toMillis(end - start) < 2_900) { pass(); } else { System.err.println("Fail: Waited too long"); @@ -142,7 +146,7 @@ public class LdapTimeoutTest { void deadServerNoTimeout(Hashtable env) { InitialContext ctx = null; - ScheduledFuture killer = killSwitch(30000); + ScheduledFuture killer = killSwitch(30_000); long start = System.nanoTime(); try { ctx = new InitialDirContext(env); @@ -154,9 +158,13 @@ public class LdapTimeoutTest { fail(); } catch (NamingException e) { long end = System.nanoTime(); - if (TimeUnit.NANOSECONDS.toMillis(end - start) < 14000) { - System.err.println("fail: timeout should be at least 15 seconds, actual time: " - + TimeUnit.NANOSECONDS.toMillis(end - start)); + long elapsed = NANOSECONDS.toMillis(end - start); + if (elapsed < Connection.DEFAULT_READ_TIMEOUT_MILLIS) { + System.err.printf( + "fail: timeout should be at least %s ms, actual time is %s ms", + Connection.DEFAULT_READ_TIMEOUT_MILLIS, + elapsed); + e.printStackTrace(); fail(); } else { pass(); @@ -184,7 +192,7 @@ public class LdapTimeoutTest { System.exit(0); return null; } - }, ms, TimeUnit.MILLISECONDS); + }, ms, MILLISECONDS); } static class Server extends Thread { From 7d153c461edc280f412c93992fc4ab19279a77bf Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 17 Jun 2014 12:54:01 -0700 Subject: [PATCH 073/236] 8046758: cleanup non-indent white space issues prior to Contended Locking cleanup bucket Checkpoint do_space_filter.ksh cleanups for Contended Locking. Reviewed-by: sspitsyn, coleenp --- hotspot/src/os/bsd/vm/os_bsd.cpp | 140 +- hotspot/src/os/linux/vm/os_linux.cpp | 148 +- hotspot/src/os/solaris/vm/os_solaris.cpp | 230 +-- hotspot/src/os/windows/vm/os_windows.cpp | 196 +-- .../src/share/vm/runtime/objectMonitor.cpp | 1314 ++++++++--------- .../src/share/vm/runtime/objectMonitor.hpp | 164 +- .../src/share/vm/runtime/sharedRuntime.cpp | 148 +- hotspot/src/share/vm/runtime/synchronizer.cpp | 486 +++--- hotspot/src/share/vm/runtime/thread.cpp | 270 ++-- hotspot/src/share/vm/runtime/thread.hpp | 94 +- 10 files changed, 1595 insertions(+), 1595 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 9d817380e3e..7facffe684d 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -786,7 +786,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { case os::java_thread: // Java threads use ThreadStackSize which default value can be // changed with the flag -Xss - assert (JavaThread::stack_size_at_create() > 0, "this should be set"); + assert(JavaThread::stack_size_at_create() > 0, "this should be set"); stack_size = JavaThread::stack_size_at_create(); break; case os::compiler_thread: @@ -1303,7 +1303,7 @@ bool os::dll_build_name(char* buffer, size_t buflen, if (pelements == NULL) { return false; } - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { // Really shouldn't be NULL, but check can't hurt if (pelements[i] == NULL || strlen(pelements[i]) == 0) { continue; // skip the empty path values @@ -1316,7 +1316,7 @@ bool os::dll_build_name(char* buffer, size_t buflen, } } // release the storage - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { if (pelements[i] != NULL) { FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal); } @@ -1467,7 +1467,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) bool failed_to_read_elf_head= (sizeof(elf_head)!= - (::read(file_descriptor, &elf_head,sizeof(elf_head)))) ; + (::read(file_descriptor, &elf_head,sizeof(elf_head)))); ::close(file_descriptor); if (failed_to_read_elf_head) { @@ -1565,7 +1565,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL}; int running_arch_index=-1; - for (unsigned int i=0 ; i < ARRAY_SIZE(arch_array) ; i++ ) { + for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) { if (running_arch_code == arch_array[i].code) { running_arch_index = i; } @@ -1596,7 +1596,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) #endif // !S390 if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) { - if ( lib_arch.name!=NULL ) { + if (lib_arch.name!=NULL) { ::snprintf(diag_msg_buf, diag_msg_max_length-1, " (Possible cause: can't load %s-bit .so on a %s-bit platform)", lib_arch.name, arch_array[running_arch_index].name); @@ -2598,7 +2598,7 @@ void os::yield() { sched_yield(); } -os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;} +os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } void os::yield_all() { // Yields to all threads, including threads with lower priorities @@ -2686,7 +2686,7 @@ static int prio_init() { } OSReturn os::set_native_priority(Thread* thread, int newpri) { - if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK; + if (!UseThreadPriorities || ThreadPriorityPolicy == 0) return OS_OK; #ifdef __OpenBSD__ // OpenBSD pthread_setprio starves low priority threads @@ -2713,7 +2713,7 @@ OSReturn os::set_native_priority(Thread* thread, int newpri) { } OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { - if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) { + if (!UseThreadPriorities || ThreadPriorityPolicy == 0) { *priority_ptr = java_to_os_priority[NormPriority]; return OS_OK; } @@ -3079,7 +3079,7 @@ bool os::Bsd::chained_handler(int sig, siginfo_t* siginfo, void* context) { } struct sigaction* os::Bsd::get_preinstalled_handler(int sig) { - if ((( (unsigned int)1 << sig ) & sigs) != 0) { + if ((((unsigned int)1 << sig) & sigs) != 0) { return &sigact[sig]; } return NULL; @@ -3300,7 +3300,7 @@ static void print_signal_handler(outputStream* st, int sig, address rh = VMError::get_resetted_sighandler(sig); // May be, handler was resetted by VMError? - if(rh != NULL) { + if (rh != NULL) { handler = rh; sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; } @@ -3309,11 +3309,11 @@ static void print_signal_handler(outputStream* st, int sig, os::Posix::print_sa_flags(st, sa.sa_flags); // Check: is it our handler? - if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || + if (handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { // It is our signal handler // check for flags, reset system-used one! - if((int)sa.sa_flags != os::Bsd::get_our_sigflags(sig)) { + if ((int)sa.sa_flags != os::Bsd::get_our_sigflags(sig)) { st->print( ", flags was changed from " PTR32_FORMAT ", consider using jsig library", os::Bsd::get_our_sigflags(sig)); @@ -3382,10 +3382,10 @@ void os::Bsd::check_signal_handler(int sig) { address thisHandler = (act.sa_flags & SA_SIGINFO) ? CAST_FROM_FN_PTR(address, act.sa_sigaction) - : CAST_FROM_FN_PTR(address, act.sa_handler) ; + : CAST_FROM_FN_PTR(address, act.sa_handler); - switch(sig) { + switch (sig) { case SIGSEGV: case SIGBUS: case SIGFPE: @@ -3515,22 +3515,22 @@ jint os::init_2(void) { // Allocate a single page and mark it as readable for safepoint polling address polling_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - guarantee( polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page" ); + guarantee(polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page"); - os::set_polling_page( polling_page ); + os::set_polling_page(polling_page); #ifndef PRODUCT - if(Verbose && PrintMiscellaneous) + if (Verbose && PrintMiscellaneous) tty->print("[SafePoint Polling address: " INTPTR_FORMAT "]\n", (intptr_t)polling_page); #endif if (!UseMembar) { address mem_serialize_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - guarantee( mem_serialize_page != MAP_FAILED, "mmap Failed for memory serialize page"); - os::set_memory_serialize_page( mem_serialize_page ); + guarantee(mem_serialize_page != MAP_FAILED, "mmap Failed for memory serialize page"); + os::set_memory_serialize_page(mem_serialize_page); #ifndef PRODUCT - if(Verbose && PrintMiscellaneous) + if (Verbose && PrintMiscellaneous) tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); #endif } @@ -3631,13 +3631,13 @@ void os::init_3(void) { } // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { - if( !guard_memory((char*)_polling_page, Bsd::page_size()) ) + if (!guard_memory((char*)_polling_page, Bsd::page_size())) fatal("Could not disable polling page"); }; // Mark the polling page as readable void os::make_polling_page_readable(void) { - if( !bsd_mprotect((char *)_polling_page, Bsd::page_size(), PROT_READ)) { + if (!bsd_mprotect((char *)_polling_page, Bsd::page_size(), PROT_READ)) { fatal("Could not enable polling page"); } }; @@ -4229,9 +4229,9 @@ static struct timespec* compute_abstime(struct timespec* abstime, jlong millis) int os::PlatformEvent::TryPark() { for (;;) { - const int v = _Event ; - guarantee ((v == 0) || (v == 1), "invariant") ; - if (Atomic::cmpxchg (0, &_Event, v) == v) return v ; + const int v = _Event; + guarantee((v == 0) || (v == 1), "invariant"); + if (Atomic::cmpxchg(0, &_Event, v) == v) return v; } } @@ -4239,18 +4239,18 @@ void os::PlatformEvent::park() { // AKA "down()" // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). // TODO: assert that _Assoc != NULL or _Assoc == Self - int v ; + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee (v >= 0, "invariant") ; + guarantee(v >= 0, "invariant"); if (v == 0) { // Do this the hard way by blocking ... int status = pthread_mutex_lock(_mutex); assert_status(status == 0, status, "mutex_lock"); - guarantee (_nParked == 0, "invariant") ; - ++ _nParked ; + guarantee(_nParked == 0, "invariant"); + ++_nParked; while (_Event < 0) { status = pthread_cond_wait(_cond, _mutex); // for some reason, under 2.7 lwp_cond_wait() may return ETIME ... @@ -4258,28 +4258,28 @@ void os::PlatformEvent::park() { // AKA "down()" if (status == ETIMEDOUT) { status = EINTR; } assert_status(status == 0 || status == EINTR, status, "cond_wait"); } - -- _nParked ; + --_nParked; - _Event = 0 ; + _Event = 0; status = pthread_mutex_unlock(_mutex); assert_status(status == 0, status, "mutex_unlock"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other. OrderAccess::fence(); } - guarantee (_Event >= 0, "invariant") ; + guarantee(_Event >= 0, "invariant"); } int os::PlatformEvent::park(jlong millis) { - guarantee (_nParked == 0, "invariant") ; + guarantee(_nParked == 0, "invariant"); - int v ; + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee (v >= 0, "invariant") ; - if (v != 0) return OS_OK ; + guarantee(v >= 0, "invariant"); + if (v != 0) return OS_OK; // We do this the hard way, by blocking the thread. // Consider enforcing a minimum timeout value. @@ -4289,8 +4289,8 @@ int os::PlatformEvent::park(jlong millis) { int ret = OS_TIMEOUT; int status = pthread_mutex_lock(_mutex); assert_status(status == 0, status, "mutex_lock"); - guarantee (_nParked == 0, "invariant") ; - ++_nParked ; + guarantee(_nParked == 0, "invariant"); + ++_nParked; // Object.wait(timo) will return because of // (a) notification @@ -4308,24 +4308,24 @@ int os::PlatformEvent::park(jlong millis) { while (_Event < 0) { status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &abst); if (status != 0 && WorkAroundNPTLTimedWaitHang) { - pthread_cond_destroy (_cond); - pthread_cond_init (_cond, NULL) ; + pthread_cond_destroy(_cond); + pthread_cond_init(_cond, NULL); } assert_status(status == 0 || status == EINTR || status == ETIMEDOUT, status, "cond_timedwait"); - if (!FilterSpuriousWakeups) break ; // previous semantics - if (status == ETIMEDOUT) break ; + if (!FilterSpuriousWakeups) break; // previous semantics + if (status == ETIMEDOUT) break; // We consume and ignore EINTR and spurious wakeups. } - --_nParked ; + --_nParked; if (_Event >= 0) { ret = OS_OK; } - _Event = 0 ; + _Event = 0; status = pthread_mutex_unlock(_mutex); assert_status(status == 0, status, "mutex_unlock"); - assert (_nParked == 0, "invariant") ; + assert(_nParked == 0, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other. OrderAccess::fence(); @@ -4409,7 +4409,7 @@ void os::PlatformEvent::unpark() { */ static void unpackTime(struct timespec* absTime, bool isAbsolute, jlong time) { - assert (time > 0, "convertTime"); + assert(time > 0, "convertTime"); struct timeval now; int status = gettimeofday(&now, NULL); @@ -4470,7 +4470,7 @@ void Parker::park(bool isAbsolute, jlong time) { // Next, demultiplex/decode time arguments struct timespec absTime; - if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all + if (time < 0 || (isAbsolute && time == 0)) { // don't wait at all return; } if (time > 0) { @@ -4492,11 +4492,11 @@ void Parker::park(bool isAbsolute, jlong time) { return; } - int status ; + int status; if (_counter > 0) { // no wait needed _counter = 0; status = pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other and Java-level accesses. OrderAccess::fence(); @@ -4516,12 +4516,12 @@ void Parker::park(bool isAbsolute, jlong time) { // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() if (time == 0) { - status = pthread_cond_wait (_cond, _mutex) ; + status = pthread_cond_wait(_cond, _mutex); } else { - status = os::Bsd::safe_cond_timedwait (_cond, _mutex, &absTime) ; + status = os::Bsd::safe_cond_timedwait(_cond, _mutex, &absTime); if (status != 0 && WorkAroundNPTLTimedWaitHang) { - pthread_cond_destroy (_cond) ; - pthread_cond_init (_cond, NULL); + pthread_cond_destroy(_cond); + pthread_cond_init(_cond, NULL); } } assert_status(status == 0 || status == EINTR || @@ -4532,9 +4532,9 @@ void Parker::park(bool isAbsolute, jlong time) { pthread_sigmask(SIG_SETMASK, &oldsigs, NULL); #endif - _counter = 0 ; - status = pthread_mutex_unlock(_mutex) ; - assert_status(status == 0, status, "invariant") ; + _counter = 0; + status = pthread_mutex_unlock(_mutex); + assert_status(status == 0, status, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other and Java-level accesses. OrderAccess::fence(); @@ -4546,26 +4546,26 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - int s, status ; + int s, status; status = pthread_mutex_lock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); s = _counter; _counter = 1; if (s < 1) { if (WorkAroundNPTLTimedWaitHang) { - status = pthread_cond_signal (_cond) ; - assert (status == 0, "invariant") ; + status = pthread_cond_signal(_cond); + assert(status == 0, "invariant"); status = pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); } else { status = pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; - status = pthread_cond_signal (_cond) ; - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); + status = pthread_cond_signal(_cond); + assert(status == 0, "invariant"); } } else { pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); } } diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 89ffc72d972..7057bcd557b 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -862,7 +862,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { case os::java_thread: // Java threads use ThreadStackSize which default value can be // changed with the flag -Xss - assert (JavaThread::stack_size_at_create() > 0, "this should be set"); + assert(JavaThread::stack_size_at_create() > 0, "this should be set"); stack_size = JavaThread::stack_size_at_create(); break; case os::compiler_thread: @@ -1097,7 +1097,7 @@ static bool find_vma(address addr, address* vma_low, address* vma_high) { if (low <= addr && addr < high) { if (vma_low) *vma_low = low; if (vma_high) *vma_high = high; - fclose (fp); + fclose(fp); return true; } } @@ -1420,7 +1420,7 @@ void os::Linux::fast_thread_clock_init() { // must return at least tp.tv_sec == 0 which means a resolution // better than 1 sec. This is extra check for reliability. - if(pthread_getcpuclockid_func && + if (pthread_getcpuclockid_func && pthread_getcpuclockid_func(_main_thread, &clockid) == 0 && sys_clock_getres(clockid, &tp) == 0 && tp.tv_sec == 0) { @@ -1630,7 +1630,7 @@ bool os::dll_build_name(char* buffer, size_t buflen, if (pelements == NULL) { return false; } - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { // Really shouldn't be NULL, but check can't hurt if (pelements[i] == NULL || strlen(pelements[i]) == 0) { continue; // skip the empty path values @@ -1642,7 +1642,7 @@ bool os::dll_build_name(char* buffer, size_t buflen, } } // release the storage - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { if (pelements[i] != NULL) { FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal); } @@ -1906,7 +1906,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) bool failed_to_read_elf_head= (sizeof(elf_head)!= - (::read(file_descriptor, &elf_head,sizeof(elf_head)))) ; + (::read(file_descriptor, &elf_head,sizeof(elf_head)))); ::close(file_descriptor); if (failed_to_read_elf_head) { @@ -1988,7 +1988,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL}; int running_arch_index=-1; - for (unsigned int i=0 ; i < ARRAY_SIZE(arch_array) ; i++ ) { + for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) { if (running_arch_code == arch_array[i].code) { running_arch_index = i; } @@ -2019,7 +2019,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) #endif // !S390 if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) { - if ( lib_arch.name!=NULL ) { + if (lib_arch.name!=NULL) { ::snprintf(diag_msg_buf, diag_msg_max_length-1, " (Possible cause: can't load %s-bit .so on a %s-bit platform)", lib_arch.name, arch_array[running_arch_index].name); @@ -3793,7 +3793,7 @@ void os::yield() { sched_yield(); } -os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;} +os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } void os::yield_all() { // Yields to all threads, including threads with lower priorities @@ -3858,14 +3858,14 @@ static int prio_init() { } OSReturn os::set_native_priority(Thread* thread, int newpri) { - if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK; + if (!UseThreadPriorities || ThreadPriorityPolicy == 0) return OS_OK; int ret = setpriority(PRIO_PROCESS, thread->osthread()->thread_id(), newpri); return (ret == 0) ? OS_OK : OS_ERR; } OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { - if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) { + if (!UseThreadPriorities || ThreadPriorityPolicy == 0) { *priority_ptr = java_to_os_priority[NormPriority]; return OS_OK; } @@ -4219,7 +4219,7 @@ bool os::Linux::chained_handler(int sig, siginfo_t* siginfo, void* context) { } struct sigaction* os::Linux::get_preinstalled_handler(int sig) { - if ((( (unsigned int)1 << sig ) & sigs) != 0) { + if ((((unsigned int)1 << sig) & sigs) != 0) { return &sigact[sig]; } return NULL; @@ -4423,7 +4423,7 @@ static void print_signal_handler(outputStream* st, int sig, address rh = VMError::get_resetted_sighandler(sig); // May be, handler was resetted by VMError? - if(rh != NULL) { + if (rh != NULL) { handler = rh; sa.sa_flags = VMError::get_resetted_sigflags(sig) & SIGNIFICANT_SIGNAL_MASK; } @@ -4432,11 +4432,11 @@ static void print_signal_handler(outputStream* st, int sig, os::Posix::print_sa_flags(st, sa.sa_flags); // Check: is it our handler? - if(handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || + if (handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)signalHandler) || handler == CAST_FROM_FN_PTR(address, (sa_sigaction_t)SR_handler)) { // It is our signal handler // check for flags, reset system-used one! - if((int)sa.sa_flags != os::Linux::get_our_sigflags(sig)) { + if ((int)sa.sa_flags != os::Linux::get_our_sigflags(sig)) { st->print( ", flags was changed from " PTR32_FORMAT ", consider using jsig library", os::Linux::get_our_sigflags(sig)); @@ -4507,10 +4507,10 @@ void os::Linux::check_signal_handler(int sig) { address thisHandler = (act.sa_flags & SA_SIGINFO) ? CAST_FROM_FN_PTR(address, act.sa_sigaction) - : CAST_FROM_FN_PTR(address, act.sa_handler) ; + : CAST_FROM_FN_PTR(address, act.sa_handler); - switch(sig) { + switch (sig) { case SIGSEGV: case SIGBUS: case SIGFPE: @@ -4662,22 +4662,22 @@ jint os::init_2(void) // Allocate a single page and mark it as readable for safepoint polling address polling_page = (address) ::mmap(NULL, Linux::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - guarantee( polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page" ); + guarantee(polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page"); - os::set_polling_page( polling_page ); + os::set_polling_page(polling_page); #ifndef PRODUCT - if(Verbose && PrintMiscellaneous) + if (Verbose && PrintMiscellaneous) tty->print("[SafePoint Polling address: " INTPTR_FORMAT "]\n", (intptr_t)polling_page); #endif if (!UseMembar) { address mem_serialize_page = (address) ::mmap(NULL, Linux::page_size(), PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); - guarantee( mem_serialize_page != MAP_FAILED, "mmap Failed for memory serialize page"); - os::set_memory_serialize_page( mem_serialize_page ); + guarantee(mem_serialize_page != MAP_FAILED, "mmap Failed for memory serialize page"); + os::set_memory_serialize_page(mem_serialize_page); #ifndef PRODUCT - if(Verbose && PrintMiscellaneous) + if (Verbose && PrintMiscellaneous) tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); #endif } @@ -4819,13 +4819,13 @@ void os::init_3(void) { // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { - if( !guard_memory((char*)_polling_page, Linux::page_size()) ) + if (!guard_memory((char*)_polling_page, Linux::page_size())) fatal("Could not disable polling page"); }; // Mark the polling page as readable void os::make_polling_page_readable(void) { - if( !linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) { + if (!linux_mprotect((char *)_polling_page, Linux::page_size(), PROT_READ)) { fatal("Could not enable polling page"); } }; @@ -5288,7 +5288,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { snprintf(proc_name, 64, "/proc/self/task/%d/stat", tid); fp = fopen(proc_name, "r"); - if ( fp == NULL ) return -1; + if (fp == NULL) return -1; statlen = fread(stat, 1, 2047, fp); stat[statlen] = '\0'; fclose(fp); @@ -5300,7 +5300,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { // We don't really need to know the command string, just find the last // occurrence of ")" and then start parsing from there. See bug 4726580. s = strrchr(stat, ')'); - if (s == NULL ) return -1; + if (s == NULL) return -1; // Skip blank chars do s++; while (isspace(*s)); @@ -5309,7 +5309,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { &cdummy, &idummy, &idummy, &idummy, &idummy, &idummy, &ldummy, &ldummy, &ldummy, &ldummy, &ldummy, &user_time, &sys_time); - if ( count != 13 ) return -1; + if (count != 13) return -1; if (user_sys_cpu_time) { return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec); } else { @@ -5468,9 +5468,9 @@ static struct timespec* compute_abstime(timespec* abstime, jlong millis) { int os::PlatformEvent::TryPark() { for (;;) { - const int v = _Event ; - guarantee ((v == 0) || (v == 1), "invariant") ; - if (Atomic::cmpxchg (0, &_Event, v) == v) return v ; + const int v = _Event; + guarantee((v == 0) || (v == 1), "invariant"); + if (Atomic::cmpxchg(0, &_Event, v) == v) return v; } } @@ -5478,18 +5478,18 @@ void os::PlatformEvent::park() { // AKA "down()" // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). // TODO: assert that _Assoc != NULL or _Assoc == Self - int v ; + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee (v >= 0, "invariant") ; + guarantee(v >= 0, "invariant"); if (v == 0) { // Do this the hard way by blocking ... int status = pthread_mutex_lock(_mutex); assert_status(status == 0, status, "mutex_lock"); - guarantee (_nParked == 0, "invariant") ; - ++ _nParked ; + guarantee(_nParked == 0, "invariant"); + ++_nParked; while (_Event < 0) { status = pthread_cond_wait(_cond, _mutex); // for some reason, under 2.7 lwp_cond_wait() may return ETIME ... @@ -5497,28 +5497,28 @@ void os::PlatformEvent::park() { // AKA "down()" if (status == ETIME) { status = EINTR; } assert_status(status == 0 || status == EINTR, status, "cond_wait"); } - -- _nParked ; + --_nParked; - _Event = 0 ; + _Event = 0; status = pthread_mutex_unlock(_mutex); assert_status(status == 0, status, "mutex_unlock"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other. OrderAccess::fence(); } - guarantee (_Event >= 0, "invariant") ; + guarantee(_Event >= 0, "invariant"); } int os::PlatformEvent::park(jlong millis) { - guarantee (_nParked == 0, "invariant") ; + guarantee(_nParked == 0, "invariant"); - int v ; + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee (v >= 0, "invariant") ; - if (v != 0) return OS_OK ; + guarantee(v >= 0, "invariant"); + if (v != 0) return OS_OK; // We do this the hard way, by blocking the thread. // Consider enforcing a minimum timeout value. @@ -5528,8 +5528,8 @@ int os::PlatformEvent::park(jlong millis) { int ret = OS_TIMEOUT; int status = pthread_mutex_lock(_mutex); assert_status(status == 0, status, "mutex_lock"); - guarantee (_nParked == 0, "invariant") ; - ++_nParked ; + guarantee(_nParked == 0, "invariant"); + ++_nParked; // Object.wait(timo) will return because of // (a) notification @@ -5547,24 +5547,24 @@ int os::PlatformEvent::park(jlong millis) { while (_Event < 0) { status = os::Linux::safe_cond_timedwait(_cond, _mutex, &abst); if (status != 0 && WorkAroundNPTLTimedWaitHang) { - pthread_cond_destroy (_cond); - pthread_cond_init (_cond, os::Linux::condAttr()) ; + pthread_cond_destroy(_cond); + pthread_cond_init(_cond, os::Linux::condAttr()); } assert_status(status == 0 || status == EINTR || status == ETIME || status == ETIMEDOUT, status, "cond_timedwait"); - if (!FilterSpuriousWakeups) break ; // previous semantics - if (status == ETIME || status == ETIMEDOUT) break ; + if (!FilterSpuriousWakeups) break; // previous semantics + if (status == ETIME || status == ETIMEDOUT) break; // We consume and ignore EINTR and spurious wakeups. } - --_nParked ; + --_nParked; if (_Event >= 0) { ret = OS_OK; } - _Event = 0 ; + _Event = 0; status = pthread_mutex_unlock(_mutex); assert_status(status == 0, status, "mutex_unlock"); - assert (_nParked == 0, "invariant") ; + assert(_nParked == 0, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other. OrderAccess::fence(); @@ -5647,7 +5647,7 @@ void os::PlatformEvent::unpark() { */ static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) { - assert (time > 0, "convertTime"); + assert(time > 0, "convertTime"); time_t max_secs = 0; if (!os::supports_monotonic_clock() || isAbsolute) { @@ -5726,7 +5726,7 @@ void Parker::park(bool isAbsolute, jlong time) { // Next, demultiplex/decode time arguments timespec absTime; - if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all + if (time < 0 || (isAbsolute && time == 0)) { // don't wait at all return; } if (time > 0) { @@ -5748,11 +5748,11 @@ void Parker::park(bool isAbsolute, jlong time) { return; } - int status ; + int status; if (_counter > 0) { // no wait needed _counter = 0; status = pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other and Java-level accesses. OrderAccess::fence(); @@ -5774,13 +5774,13 @@ void Parker::park(bool isAbsolute, jlong time) { assert(_cur_index == -1, "invariant"); if (time == 0) { _cur_index = REL_INDEX; // arbitrary choice when not timed - status = pthread_cond_wait (&_cond[_cur_index], _mutex) ; + status = pthread_cond_wait(&_cond[_cur_index], _mutex); } else { _cur_index = isAbsolute ? ABS_INDEX : REL_INDEX; - status = os::Linux::safe_cond_timedwait (&_cond[_cur_index], _mutex, &absTime) ; + status = os::Linux::safe_cond_timedwait(&_cond[_cur_index], _mutex, &absTime); if (status != 0 && WorkAroundNPTLTimedWaitHang) { - pthread_cond_destroy (&_cond[_cur_index]) ; - pthread_cond_init (&_cond[_cur_index], isAbsolute ? NULL : os::Linux::condAttr()); + pthread_cond_destroy(&_cond[_cur_index]); + pthread_cond_init(&_cond[_cur_index], isAbsolute ? NULL : os::Linux::condAttr()); } } _cur_index = -1; @@ -5792,9 +5792,9 @@ void Parker::park(bool isAbsolute, jlong time) { pthread_sigmask(SIG_SETMASK, &oldsigs, NULL); #endif - _counter = 0 ; - status = pthread_mutex_unlock(_mutex) ; - assert_status(status == 0, status, "invariant") ; + _counter = 0; + status = pthread_mutex_unlock(_mutex); + assert_status(status == 0, status, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other and Java-level accesses. OrderAccess::fence(); @@ -5806,9 +5806,9 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - int s, status ; + int s, status; status = pthread_mutex_lock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); s = _counter; _counter = 1; if (s < 1) { @@ -5817,22 +5817,22 @@ void Parker::unpark() { // thread is definitely parked if (WorkAroundNPTLTimedWaitHang) { status = pthread_cond_signal (&_cond[_cur_index]); - assert (status == 0, "invariant"); + assert(status == 0, "invariant"); status = pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant"); + assert(status == 0, "invariant"); } else { status = pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant"); + assert(status == 0, "invariant"); status = pthread_cond_signal (&_cond[_cur_index]); - assert (status == 0, "invariant"); + assert(status == 0, "invariant"); } } else { pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); } } else { pthread_mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); } } diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 5272029561b..77cc8abb192 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -212,13 +212,13 @@ Thread* ThreadLocalStorage::get_thread_via_cache_slowly(uintptr_t raw_id, "sp must be inside of selected thread stack"); thread->set_self_raw_id(raw_id); // mark for quick retrieval - _get_thread_cache[ index ] = thread; + _get_thread_cache[index] = thread; } return thread; } -static const double all_zero[ sizeof(Thread) / sizeof(double) + 1 ] = {0}; +static const double all_zero[sizeof(Thread) / sizeof(double) + 1] = {0}; #define NO_CACHED_THREAD ((Thread*)all_zero) void ThreadLocalStorage::pd_set_thread(Thread* thread) { @@ -270,8 +270,8 @@ static inline stack_t get_stack_info() { } address os::current_stack_base() { - int r = thr_main() ; - guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ; + int r = thr_main(); + guarantee(r == 0 || r == 1, "CR6501650 or CR6493689"); bool is_primordial_thread = r; // Workaround 4352906, avoid calls to thr_stksegment by @@ -293,9 +293,9 @@ address os::current_stack_base() { size_t os::current_stack_size() { size_t size; - int r = thr_main() ; - guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ; - if(!r) { + int r = thr_main(); + guarantee(r == 0 || r == 1, "CR6501650 or CR6493689"); + if (!r) { size = get_stack_info().ss_size; } else { struct rlimit limits; @@ -409,7 +409,7 @@ static bool find_processors_in_pset(psetid_t pset, static bool find_processors_online(processorid_t** id_array, uint* id_length) { - const processorid_t MAX_PROCESSOR_ID = 100000 ; + const processorid_t MAX_PROCESSOR_ID = 100000; // Find the number of processors online. *id_length = sysconf(_SC_NPROCESSORS_ONLN); // Make up an array to hold their ids. @@ -436,7 +436,7 @@ static bool find_processors_online(processorid_t** id_array, // we've got. Note that in the worst case find_processors_online() could // return an empty set. (As a fall-back in the case of the empty set we // could just return the ID of the current processor). - *id_length = found ; + *id_length = found; } return true; @@ -552,13 +552,13 @@ bool os::bind_to_processor(uint processor_id) { } bool os::getenv(const char* name, char* buffer, int len) { - char* val = ::getenv( name ); - if ( val == NULL + char* val = ::getenv(name); + if (val == NULL || strlen(val) + 1 > len ) { if (len > 0) buffer[0] = 0; // return a null string return false; } - strcpy( buffer, val ); + strcpy(buffer, val); return true; } @@ -672,7 +672,7 @@ void os::init_system_properties_values() { // Determine search path count and required buffer size. if (dlinfo(RTLD_SELF, RTLD_DI_SERINFOSIZE, (void *)info) == -1) { - FREE_C_HEAP_ARRAY(char, buf, mtInternal); + FREE_C_HEAP_ARRAY(char, buf, mtInternal); vm_exit_during_initialization("dlinfo SERINFOSIZE request", dlerror()); } @@ -683,7 +683,7 @@ void os::init_system_properties_values() { // Obtain search path information. if (dlinfo(RTLD_SELF, RTLD_DI_SERINFO, (void *)info) == -1) { - FREE_C_HEAP_ARRAY(char, buf, mtInternal); + FREE_C_HEAP_ARRAY(char, buf, mtInternal); FREE_C_HEAP_ARRAY(char, info, mtInternal); vm_exit_during_initialization("dlinfo SERINFO request", dlerror()); } @@ -794,7 +794,7 @@ bool os::obsolete_option(const JavaVMOption *option) bool os::Solaris::valid_stack_address(Thread* thread, address sp) { address stackStart = (address)thread->stack_base(); address stackEnd = (address)(stackStart - (address)thread->stack_size()); - if (sp < stackStart && sp >= stackEnd ) return true; + if (sp < stackStart && sp >= stackEnd) return true; return false; } @@ -819,8 +819,8 @@ extern "C" void* java_start(void* thread_addr) { Thread* thread = (Thread*)thread_addr; OSThread* osthr = thread->osthread(); - osthr->set_lwp_id( _lwp_self() ); // Store lwp in case we are bound - thread->_schedctl = (void *) schedctl_init () ; + osthr->set_lwp_id(_lwp_self()); // Store lwp in case we are bound + thread->_schedctl = (void *) schedctl_init(); if (UseNUMA) { int lgrp_id = os::numa_get_group_id(); @@ -839,8 +839,8 @@ extern "C" void* java_start(void* thread_addr) { // in java_to_os_priority. So we save the native priority // in the osThread and recall it here. - if ( osthr->thread_id() != -1 ) { - if ( UseThreadPriorities ) { + if (osthr->thread_id() != -1) { + if (UseThreadPriorities) { int prio = osthr->native_priority(); if (ThreadPriorityVerbose) { tty->print_cr("Starting Thread " INTPTR_FORMAT ", LWP is " @@ -882,7 +882,7 @@ static OSThread* create_os_thread(Thread* thread, thread_t thread_id) { // Store info on the Solaris thread into the OSThread osthread->set_thread_id(thread_id); osthread->set_lwp_id(_lwp_self()); - thread->_schedctl = (void *) schedctl_init () ; + thread->_schedctl = (void *) schedctl_init(); if (UseNUMA) { int lgrp_id = os::numa_get_group_id(); @@ -891,9 +891,9 @@ static OSThread* create_os_thread(Thread* thread, thread_t thread_id) { } } - if ( ThreadPriorityVerbose ) { + if (ThreadPriorityVerbose) { tty->print_cr("In create_os_thread, Thread " INTPTR_FORMAT ", LWP is " INTPTR_FORMAT "\n", - osthread->thread_id(), osthread->lwp_id() ); + osthread->thread_id(), osthread->lwp_id()); } // Initial thread state is INITIALIZED, not SUSPENDED @@ -974,9 +974,9 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { return false; } - if ( ThreadPriorityVerbose ) { + if (ThreadPriorityVerbose) { char *thrtyp; - switch ( thr_type ) { + switch (thr_type) { case vm_thread: thrtyp = (char *)"vm"; break; @@ -1207,11 +1207,11 @@ void _handle_uncaught_cxx_exception() { // First crack at OS-specific initialization, from inside the new thread. void os::initialize_thread(Thread* thr) { - int r = thr_main() ; - guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ; + int r = thr_main(); + guarantee(r == 0 || r == 1, "CR6501650 or CR6493689"); if (r) { JavaThread* jt = (JavaThread *)thr; - assert(jt != NULL,"Sanity check"); + assert(jt != NULL, "Sanity check"); size_t stack_size; address base = jt->stack_base(); if (Arguments::created_by_java_launcher()) { @@ -1322,7 +1322,7 @@ int os::allocate_thread_local_storage() { // JavaThread in Java code, and have stubs simply // treat %g2 as a caller-save register, preserving it in a %lN. thread_key_t tk; - if (thr_keycreate( &tk, NULL ) ) + if (thr_keycreate( &tk, NULL)) fatal(err_msg("os::allocate_thread_local_storage: thr_keycreate failed " "(%s)", strerror(errno))); return int(tk); @@ -1347,7 +1347,7 @@ void os::thread_local_storage_at_put(int index, void* value) { "(%s)", strerror(errno))); } } else { - ThreadLocalStorage::set_thread_in_slot ((Thread *) value) ; + ThreadLocalStorage::set_thread_in_slot((Thread *) value); } } @@ -1579,7 +1579,7 @@ bool os::dll_build_name(char* buffer, size_t buflen, if (pelements == NULL) { return false; } - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { // really shouldn't be NULL but what the heck, check can't hurt if (pelements[i] == NULL || strlen(pelements[i]) == 0) { continue; // skip the empty path values @@ -1591,7 +1591,7 @@ bool os::dll_build_name(char* buffer, size_t buflen, } } // release the storage - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { if (pelements[i] != NULL) { FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal); } @@ -1795,7 +1795,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) bool failed_to_read_elf_head= (sizeof(elf_head)!= - (::read(file_descriptor, &elf_head,sizeof(elf_head)))) ; + (::read(file_descriptor, &elf_head,sizeof(elf_head)))); ::close(file_descriptor); if (failed_to_read_elf_head) { @@ -1851,7 +1851,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL}; int running_arch_index=-1; - for (unsigned int i=0 ; i < ARRAY_SIZE(arch_array) ; i++ ) { + for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) { if (running_arch_code == arch_array[i].code) { running_arch_index = i; } @@ -1880,7 +1880,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) } if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) { - if ( lib_arch.name!=NULL ) { + if (lib_arch.name!=NULL) { ::snprintf(diag_msg_buf, diag_msg_max_length-1, " (Possible cause: can't load %s-bit .so on a %s-bit platform)", lib_arch.name, arch_array[running_arch_index].name); @@ -1969,7 +1969,7 @@ static bool check_addr0(outputStream* st) { int fd = ::open("/proc/self/map",O_RDONLY); if (fd >= 0) { prmap_t p; - while(::read(fd, &p, sizeof(p)) > 0) { + while (::read(fd, &p, sizeof(p)) > 0) { if (p.pr_vaddr == 0x0) { st->print("Warning: Address: 0x%x, Size: %dK, ",p.pr_vaddr, p.pr_size/1024, p.pr_mapname); st->print("Mapped file: %s, ", p.pr_mapname[0] == '\0' ? "None" : p.pr_mapname); @@ -2079,7 +2079,7 @@ static void print_signal_handler(outputStream* st, int sig, address rh = VMError::get_resetted_sighandler(sig); // May be, handler was resetted by VMError? - if(rh != NULL) { + if (rh != NULL) { handler = rh; sa.sa_flags = VMError::get_resetted_sigflags(sig); } @@ -2088,11 +2088,11 @@ static void print_signal_handler(outputStream* st, int sig, os::Posix::print_sa_flags(st, sa.sa_flags); // Check: is it our handler? - if(handler == CAST_FROM_FN_PTR(address, signalHandler) || + if (handler == CAST_FROM_FN_PTR(address, signalHandler) || handler == CAST_FROM_FN_PTR(address, sigINTRHandler)) { // It is our signal handler // check for flags - if(sa.sa_flags != os::Solaris::get_our_sigflags(sig)) { + if (sa.sa_flags != os::Solaris::get_our_sigflags(sig)) { st->print( ", flags was changed from " PTR32_FORMAT ", consider using jsig library", os::Solaris::get_our_sigflags(sig)); @@ -2403,7 +2403,7 @@ static int check_pending_signals(bool wait_for_signal) { do { thread->set_suspend_equivalent(); // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() - while((ret = ::sema_wait(&sig_sem)) == EINTR) + while ((ret = ::sema_wait(&sig_sem)) == EINTR) ; assert(ret == 0, "sema_wait() failed"); @@ -2635,7 +2635,7 @@ size_t os::numa_get_leaf_groups(int *ids, size_t size) { } if (!r) { // That's a leaf node. - assert (bottom <= cur, "Sanity check"); + assert(bottom <= cur, "Sanity check"); // Check if the node has memory if (Solaris::lgrp_resources(Solaris::lgrp_cookie(), ids[cur], NULL, 0, LGRP_RSRC_MEM) > 0) { @@ -3051,7 +3051,7 @@ bool os::Solaris::mpss_sanity_check(bool warn, size_t* page_size) { const size_t size_limit = FLAG_IS_DEFAULT(LargePageSizeInBytes) ? 4 * M : LargePageSizeInBytes; int beg; - for (beg = 0; beg < n && _page_sizes[beg] > size_limit; ++beg) /* empty */ ; + for (beg = 0; beg < n && _page_sizes[beg] > size_limit; ++beg) /* empty */; const int end = MIN2((int)usable_count, n) - 1; for (int cur = 0; cur < end; ++cur, ++beg) { _page_sizes[cur] = _page_sizes[beg]; @@ -3264,7 +3264,7 @@ static int java_MaxPriority_to_os_priority = 0; // Saved mapping // // Return errno or 0 if OK. // -static int lwp_priocntl_init () { +static int lwp_priocntl_init() { int rslt; pcinfo_t ClassInfo; pcparms_t ParmInfo; @@ -3274,7 +3274,7 @@ static int lwp_priocntl_init () { // If ThreadPriorityPolicy is 1, switch tables if (ThreadPriorityPolicy == 1) { - for (i = 0 ; i < CriticalPriority+1; i++) + for (i = 0; i < CriticalPriority+1; i++) os::java_to_os_priority[i] = prio_policy1[i]; } if (UseCriticalJavaThreadPriority) { @@ -3373,12 +3373,12 @@ static int lwp_priocntl_init () { } else { // No clue - punt if (ThreadPriorityVerbose) - tty->print_cr ("Unknown scheduling class: %s ... \n", ClassInfo.pc_clname); + tty->print_cr("Unknown scheduling class: %s ... \n", ClassInfo.pc_clname); return EINVAL; // no clue, punt } if (ThreadPriorityVerbose) { - tty->print_cr ("Thread priority Range: [%d..%d]\n", myMin, myMax); + tty->print_cr("Thread priority Range: [%d..%d]\n", myMin, myMax); } priocntl_enable = true; // Enable changing priorities @@ -3424,7 +3424,7 @@ int set_lwp_class_and_priority(int ThreadID, int lwpid, // TODO: elide set-to-same-value // If something went wrong on init, don't change priorities. - if ( !priocntl_enable ) { + if (!priocntl_enable) { if (ThreadPriorityVerbose) tty->print_cr("Trying to set priority but init failed, ignoring"); return EINVAL; @@ -3432,9 +3432,9 @@ int set_lwp_class_and_priority(int ThreadID, int lwpid, // If lwp hasn't started yet, just return // the _start routine will call us again. - if ( lwpid <= 0 ) { + if (lwpid <= 0) { if (ThreadPriorityVerbose) { - tty->print_cr ("deferring the set_lwp_class_and_priority of thread " + tty->print_cr("deferring the set_lwp_class_and_priority of thread " INTPTR_FORMAT " to %d, lwpid not set", ThreadID, newPrio); } @@ -3653,7 +3653,7 @@ OSReturn os::set_native_priority(Thread* thread, int newpri) { OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { int p; - if ( !UseThreadPriorities ) { + if (!UseThreadPriorities) { *priority_ptr = NormalPriority; return OS_OK; } @@ -4099,7 +4099,7 @@ void os::Solaris::set_signal_handler(int sig, bool set_installed, bool oktochain void os::run_periodic_checks() { // A big source of grief is hijacking virt. addr 0x0 on Solaris, // thereby preventing a NULL checks. - if(!check_addr0_done) check_addr0_done = check_addr0(tty); + if (!check_addr0_done) check_addr0_done = check_addr0(tty); if (check_signals == false) return; @@ -4148,10 +4148,10 @@ void os::Solaris::check_signal_handler(int sig) { address thisHandler = (act.sa_flags & SA_SIGINFO) ? CAST_FROM_FN_PTR(address, act.sa_sigaction) - : CAST_FROM_FN_PTR(address, act.sa_handler) ; + : CAST_FROM_FN_PTR(address, act.sa_handler); - switch(sig) { + switch (sig) { case SIGSEGV: case SIGBUS: case SIGFPE: @@ -4332,7 +4332,7 @@ os::Solaris::meminfo_func_t os::Solaris::_meminfo = 0; static address resolve_symbol_lazy(const char* name) { address addr = (address) dlsym(RTLD_DEFAULT, name); - if(addr == NULL) { + if (addr == NULL) { // RTLD_DEFAULT was not defined on some early versions of 2.5.1 addr = (address) dlsym(RTLD_NEXT, name); } @@ -4341,7 +4341,7 @@ static address resolve_symbol_lazy(const char* name) { static address resolve_symbol(const char* name) { address addr = resolve_symbol_lazy(name); - if(addr == NULL) { + if (addr == NULL) { fatal(dlerror()); } return addr; @@ -4353,7 +4353,7 @@ void os::Solaris::libthread_init() { lwp_priocntl_init(); // RTLD_DEFAULT was not defined on some early versions of 5.5.1 - if(func == NULL) { + if (func == NULL) { func = (address) dlsym(RTLD_NEXT, "_thr_suspend_allmutators"); // Guarantee that this VM is running on an new enough OS (5.6 or // later) that it will have a new enough libthread.so. @@ -4384,7 +4384,7 @@ int_fnP_cond_tP os::Solaris::_cond_destroy; int os::Solaris::_cond_scope = USYNC_THREAD; void os::Solaris::synchronization_init() { - if(UseLWPSynchronization) { + if (UseLWPSynchronization) { os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("_lwp_mutex_lock"))); os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("_lwp_mutex_trylock"))); os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("_lwp_mutex_unlock"))); @@ -4404,7 +4404,7 @@ void os::Solaris::synchronization_init() { os::Solaris::set_mutex_scope(USYNC_THREAD); os::Solaris::set_cond_scope(USYNC_THREAD); - if(UsePthreads) { + if (UsePthreads) { os::Solaris::set_mutex_lock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_lock"))); os::Solaris::set_mutex_trylock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_trylock"))); os::Solaris::set_mutex_unlock(CAST_TO_FN_PTR(int_fnP_mutex_tP, resolve_symbol("pthread_mutex_unlock"))); @@ -4576,17 +4576,17 @@ jint os::init_2(void) { os::set_polling_page(polling_page); #ifndef PRODUCT - if( Verbose && PrintMiscellaneous ) + if (Verbose && PrintMiscellaneous) tty->print("[SafePoint Polling address: " INTPTR_FORMAT "]\n", (intptr_t)polling_page); #endif if (!UseMembar) { - address mem_serialize_page = (address)Solaris::mmap_chunk( NULL, page_size, MAP_PRIVATE, PROT_READ | PROT_WRITE ); - guarantee( mem_serialize_page != NULL, "mmap Failed for memory serialize page"); - os::set_memory_serialize_page( mem_serialize_page ); + address mem_serialize_page = (address)Solaris::mmap_chunk(NULL, page_size, MAP_PRIVATE, PROT_READ | PROT_WRITE); + guarantee(mem_serialize_page != NULL, "mmap Failed for memory serialize page"); + os::set_memory_serialize_page(mem_serialize_page); #ifndef PRODUCT - if(Verbose && PrintMiscellaneous) + if (Verbose && PrintMiscellaneous) tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); #endif } @@ -4725,13 +4725,13 @@ void os::init_3(void) { // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { - if( mprotect((char *)_polling_page, page_size, PROT_NONE) != 0 ) + if (mprotect((char *)_polling_page, page_size, PROT_NONE) != 0) fatal("Could not disable polling page"); }; // Mark the polling page as readable void os::make_polling_page_readable(void) { - if( mprotect((char *)_polling_page, page_size, PROT_READ) != 0 ) + if (mprotect((char *)_polling_page, page_size, PROT_READ) != 0) fatal("Could not enable polling page"); }; @@ -5221,7 +5221,7 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { getpid(), thread->osthread()->lwp_id()); fd = ::open(proc_name, O_RDONLY); - if ( fd == -1 ) return -1; + if (fd == -1) return -1; do { count = ::pread(fd, @@ -5230,7 +5230,7 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { thr_time_off); } while (count < 0 && errno == EINTR); ::close(fd); - if ( count < 0 ) return -1; + if (count < 0) return -1; if (user_sys_cpu_time) { // user + system CPU time @@ -5244,7 +5244,7 @@ jlong os::thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { (jlong)prusage.pr_utime.tv_nsec; } - return(lwp_time); + return (lwp_time); } void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { @@ -5448,43 +5448,43 @@ static timestruc_t* compute_abstime(timestruc_t* abstime, jlong millis) { int os::PlatformEvent::TryPark() { for (;;) { - const int v = _Event ; - guarantee ((v == 0) || (v == 1), "invariant") ; - if (Atomic::cmpxchg (0, &_Event, v) == v) return v ; + const int v = _Event; + guarantee((v == 0) || (v == 1), "invariant"); + if (Atomic::cmpxchg(0, &_Event, v) == v) return v; } } void os::PlatformEvent::park() { // AKA: down() // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). - int v ; + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee (v >= 0, "invariant") ; + guarantee(v >= 0, "invariant"); if (v == 0) { // Do this the hard way by blocking ... // See http://monaco.sfbay/detail.jsf?cr=5094058. // TODO-FIXME: for Solaris SPARC set fprs.FEF=0 prior to parking. // Only for SPARC >= V8PlusA #if defined(__sparc) && defined(COMPILER2) - if (ClearFPUAtPark) { _mark_fpu_nosave() ; } + if (ClearFPUAtPark) { _mark_fpu_nosave(); } #endif int status = os::Solaris::mutex_lock(_mutex); - assert_status(status == 0, status, "mutex_lock"); - guarantee (_nParked == 0, "invariant") ; - ++ _nParked ; + assert_status(status == 0, status, "mutex_lock"); + guarantee(_nParked == 0, "invariant"); + ++_nParked; while (_Event < 0) { // for some reason, under 2.7 lwp_cond_wait() may return ETIME ... // Treat this the same as if the wait was interrupted // With usr/lib/lwp going to kernel, always handle ETIME status = os::Solaris::cond_wait(_cond, _mutex); - if (status == ETIME) status = EINTR ; + if (status == ETIME) status = EINTR; assert_status(status == 0 || status == EINTR, status, "cond_wait"); } - -- _nParked ; - _Event = 0 ; + --_nParked; + _Event = 0; status = os::Solaris::mutex_unlock(_mutex); assert_status(status == 0, status, "mutex_unlock"); // Paranoia to ensure our locked and lock-free paths interact @@ -5494,41 +5494,41 @@ void os::PlatformEvent::park() { // AKA: down() } int os::PlatformEvent::park(jlong millis) { - guarantee (_nParked == 0, "invariant") ; - int v ; + guarantee(_nParked == 0, "invariant"); + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee (v >= 0, "invariant") ; - if (v != 0) return OS_OK ; + guarantee(v >= 0, "invariant"); + if (v != 0) return OS_OK; int ret = OS_TIMEOUT; timestruc_t abst; - compute_abstime (&abst, millis); + compute_abstime(&abst, millis); // See http://monaco.sfbay/detail.jsf?cr=5094058. // For Solaris SPARC set fprs.FEF=0 prior to parking. // Only for SPARC >= V8PlusA #if defined(__sparc) && defined(COMPILER2) - if (ClearFPUAtPark) { _mark_fpu_nosave() ; } + if (ClearFPUAtPark) { _mark_fpu_nosave(); } #endif int status = os::Solaris::mutex_lock(_mutex); assert_status(status == 0, status, "mutex_lock"); - guarantee (_nParked == 0, "invariant") ; - ++ _nParked ; + guarantee(_nParked == 0, "invariant"); + ++_nParked; while (_Event < 0) { int status = os::Solaris::cond_timedwait(_cond, _mutex, &abst); assert_status(status == 0 || status == EINTR || status == ETIME || status == ETIMEDOUT, status, "cond_timedwait"); - if (!FilterSpuriousWakeups) break ; // previous semantics - if (status == ETIME || status == ETIMEDOUT) break ; + if (!FilterSpuriousWakeups) break; // previous semantics + if (status == ETIME || status == ETIMEDOUT) break; // We consume and ignore EINTR and spurious wakeups. } - -- _nParked ; - if (_Event >= 0) ret = OS_OK ; - _Event = 0 ; + --_nParked; + if (_Event >= 0) ret = OS_OK; + _Event = 0; status = os::Solaris::mutex_unlock(_mutex); assert_status(status == 0, status, "mutex_unlock"); // Paranoia to ensure our locked and lock-free paths interact @@ -5605,7 +5605,7 @@ void os::PlatformEvent::unpark() { * years from "now". */ static void unpackTime(timespec* absTime, bool isAbsolute, jlong time) { - assert (time > 0, "convertTime"); + assert(time > 0, "convertTime"); struct timeval now; int status = gettimeofday(&now, NULL); @@ -5664,7 +5664,7 @@ void Parker::park(bool isAbsolute, jlong time) { // First, demultiplex/decode time arguments timespec absTime; - if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all + if (time < 0 || (isAbsolute && time == 0)) { // don't wait at all return; } if (time > 0) { @@ -5688,12 +5688,12 @@ void Parker::park(bool isAbsolute, jlong time) { return; } - int status ; + int status; if (_counter > 0) { // no wait needed _counter = 0; status = os::Solaris::mutex_unlock(_mutex); - assert (status == 0, "invariant") ; + assert(status == 0, "invariant"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other and Java-level accesses. OrderAccess::fence(); @@ -5717,11 +5717,11 @@ void Parker::park(bool isAbsolute, jlong time) { // TODO-FIXME: for Solaris SPARC set fprs.FEF=0 prior to parking. // Only for SPARC >= V8PlusA #if defined(__sparc) && defined(COMPILER2) - if (ClearFPUAtPark) { _mark_fpu_nosave() ; } + if (ClearFPUAtPark) { _mark_fpu_nosave(); } #endif if (time == 0) { - status = os::Solaris::cond_wait (_cond, _mutex) ; + status = os::Solaris::cond_wait(_cond, _mutex); } else { status = os::Solaris::cond_timedwait (_cond, _mutex, &absTime); } @@ -5734,9 +5734,9 @@ void Parker::park(bool isAbsolute, jlong time) { #ifdef ASSERT thr_sigsetmask(SIG_SETMASK, &oldsigs, NULL); #endif - _counter = 0 ; + _counter = 0; status = os::Solaris::mutex_unlock(_mutex); - assert_status(status == 0, status, "mutex_unlock") ; + assert_status(status == 0, status, "mutex_unlock"); // Paranoia to ensure our locked and lock-free paths interact // correctly with each other and Java-level accesses. OrderAccess::fence(); @@ -5748,17 +5748,17 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - int s, status ; - status = os::Solaris::mutex_lock (_mutex) ; - assert (status == 0, "invariant") ; + int s, status; + status = os::Solaris::mutex_lock(_mutex); + assert(status == 0, "invariant"); s = _counter; _counter = 1; - status = os::Solaris::mutex_unlock (_mutex) ; - assert (status == 0, "invariant") ; + status = os::Solaris::mutex_unlock(_mutex); + assert(status == 0, "invariant"); if (s < 1) { - status = os::Solaris::cond_signal (_cond) ; - assert (status == 0, "invariant") ; + status = os::Solaris::cond_signal(_cond); + assert(status == 0, "invariant"); } } @@ -5925,14 +5925,14 @@ int os::timeout(int fd, long timeout) { gettimeofday(&t, &aNull); prevtime = ((julong)t.tv_sec * 1000) + t.tv_usec / 1000; - for(;;) { + for (;;) { res = ::poll(&pfd, 1, timeout); - if(res == OS_ERR && errno == EINTR) { - if(timeout != -1) { + if (res == OS_ERR && errno == EINTR) { + if (timeout != -1) { gettimeofday(&t, &aNull); newtime = ((julong)t.tv_sec * 1000) + t.tv_usec /1000; timeout -= newtime - prevtime; - if(timeout <= 0) + if (timeout <= 0) return OS_OK; prevtime = newtime; } diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 04b72a9d37d..e3ca08a747e 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -125,11 +125,11 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { switch (reason) { case DLL_PROCESS_ATTACH: vm_lib_handle = hinst; - if(ForceTimeHighResolution) + if (ForceTimeHighResolution) timeBeginPeriod(1L); break; case DLL_PROCESS_DETACH: - if(ForceTimeHighResolution) + if (ForceTimeHighResolution) timeEndPeriod(1L); // Workaround for issue when a custom launcher doesn't call @@ -318,7 +318,7 @@ extern "C" void breakpoint() { */ address os::get_caller_pc(int n) { #ifdef _NMT_NOINLINE_ - n ++; + n++; #endif address pc; if (os::Kernel32Dll::RtlCaptureStackBackTrace(n + 1, 1, (PVOID*)&pc, NULL) == 1) { @@ -345,10 +345,10 @@ address os::current_stack_base() { // Add up the sizes of all the regions with the same // AllocationBase. - while( 1 ) + while (1) { VirtualQuery(stack_bottom+stack_size, &minfo, sizeof(minfo)); - if ( stack_bottom == (address)minfo.AllocationBase ) + if (stack_bottom == (address)minfo.AllocationBase) stack_size += minfo.RegionSize; else break; @@ -644,7 +644,7 @@ static jlong performance_frequency; jlong as_long(LARGE_INTEGER x) { jlong result = 0; // initialization to avoid warning set_high(&result, x.HighPart); - set_low(&result, x.LowPart); + set_low(&result, x.LowPart); return result; } @@ -999,7 +999,7 @@ void os::check_or_create_dump(void* exceptionRecord, void* contextRecord, char* #endif cwd = get_current_directory(NULL, 0); - jio_snprintf(buffer, bufferSize, "%s\\hs_err_pid%u.mdmp",cwd, current_process_id()); + jio_snprintf(buffer, bufferSize, "%s\\hs_err_pid%u.mdmp", cwd, current_process_id()); dumpFile = CreateFile(buffer, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (dumpFile == INVALID_HANDLE_VALUE) { @@ -1217,7 +1217,7 @@ bool os::dll_build_name(char *buffer, size_t buflen, if (pelements == NULL) { return false; } - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { char* path = pelements[i]; // Really shouldn't be NULL, but check can't hurt size_t plen = (path == NULL) ? 0 : strlen(path); @@ -1236,7 +1236,7 @@ bool os::dll_build_name(char *buffer, size_t buflen, } } // release the storage - for (int i = 0 ; i < n ; i++) { + for (int i = 0; i < n; i++) { if (pelements[i] != NULL) { FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal); } @@ -1271,12 +1271,12 @@ static bool _addr_in_ntdll( address addr ) MODULEINFO minfo; hmod = GetModuleHandle("NTDLL.DLL"); - if ( hmod == NULL ) return false; - if ( !os::PSApiDll::GetModuleInformation( GetCurrentProcess(), hmod, + if (hmod == NULL) return false; + if (!os::PSApiDll::GetModuleInformation( GetCurrentProcess(), hmod, &minfo, sizeof(MODULEINFO)) ) return false; - if ( (addr >= minfo.lpBaseOfDll) && + if ((addr >= minfo.lpBaseOfDll) && (addr < (address)((uintptr_t)minfo.lpBaseOfDll + (uintptr_t)minfo.SizeOfImage))) return true; else @@ -1304,11 +1304,11 @@ typedef int (*EnumModulesCallbackFunc)(int, char *, address, unsigned, void *); // enumerate_modules for Windows NT, using PSAPI static int _enumerate_modules_winnt( int pid, EnumModulesCallbackFunc func, void * param) { - HANDLE hProcess ; + HANDLE hProcess; # define MAX_NUM_MODULES 128 HMODULE modules[MAX_NUM_MODULES]; - static char filename[ MAX_PATH ]; + static char filename[MAX_PATH]; int result = 0; if (!os::PSApiDll::PSApiAvailable()) { @@ -1316,13 +1316,13 @@ static int _enumerate_modules_winnt( int pid, EnumModulesCallbackFunc func, void } hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, - FALSE, pid ) ; + FALSE, pid); if (hProcess == NULL) return 0; DWORD size_needed; if (!os::PSApiDll::EnumProcessModules(hProcess, modules, sizeof(modules), &size_needed)) { - CloseHandle( hProcess ); + CloseHandle(hProcess); return 0; } @@ -1331,7 +1331,7 @@ static int _enumerate_modules_winnt( int pid, EnumModulesCallbackFunc func, void for (int i = 0; i < MIN2(num_modules, MAX_NUM_MODULES); i++) { // Get Full pathname: - if(!os::PSApiDll::GetModuleFileNameEx(hProcess, modules[i], + if (!os::PSApiDll::GetModuleFileNameEx(hProcess, modules[i], filename, sizeof(filename))) { filename[0] = '\0'; } @@ -1349,7 +1349,7 @@ static int _enumerate_modules_winnt( int pid, EnumModulesCallbackFunc func, void if (result) break; } - CloseHandle( hProcess ) ; + CloseHandle(hProcess); return result; } @@ -1357,8 +1357,8 @@ static int _enumerate_modules_winnt( int pid, EnumModulesCallbackFunc func, void // enumerate_modules for Windows 95/98/ME, using TOOLHELP static int _enumerate_modules_windows( int pid, EnumModulesCallbackFunc func, void *param) { - HANDLE hSnapShot ; - static MODULEENTRY32 modentry ; + HANDLE hSnapShot; + static MODULEENTRY32 modentry; int result = 0; if (!os::Kernel32Dll::HelpToolsAvailable()) { @@ -1366,22 +1366,22 @@ static int _enumerate_modules_windows( int pid, EnumModulesCallbackFunc func, vo } // Get a handle to a Toolhelp snapshot of the system - hSnapShot = os::Kernel32Dll::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid ) ; - if( hSnapShot == INVALID_HANDLE_VALUE ) { - return FALSE ; + hSnapShot = os::Kernel32Dll::CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid); + if (hSnapShot == INVALID_HANDLE_VALUE) { + return FALSE; } // iterate through all modules - modentry.dwSize = sizeof(MODULEENTRY32) ; + modentry.dwSize = sizeof(MODULEENTRY32); bool not_done = os::Kernel32Dll::Module32First( hSnapShot, &modentry ) != 0; - while( not_done ) { + while (not_done) { // invoke the callback result=func(pid, modentry.szExePath, (address)modentry.modBaseAddr, modentry.modBaseSize, param); if (result) break; - modentry.dwSize = sizeof(MODULEENTRY32) ; + modentry.dwSize = sizeof(MODULEENTRY32); not_done = os::Kernel32Dll::Module32Next( hSnapShot, &modentry ) != 0; } @@ -1941,7 +1941,7 @@ void os::signal_raise(int signal_number) { // that raises SIGTERM for the latter cases. // static BOOL WINAPI consoleHandler(DWORD event) { - switch(event) { + switch (event) { case CTRL_C_EVENT: if (is_error_reported()) { // Ctrl-C is pressed during error reporting, likely because the error @@ -1965,7 +1965,7 @@ static BOOL WINAPI consoleHandler(DWORD event) { HANDLE handle = GetProcessWindowStation(); if (handle != NULL && GetUserObjectInformation(handle, UOI_FLAGS, &flags, - sizeof( USEROBJECTFLAGS), NULL)) { + sizeof(USEROBJECTFLAGS), NULL)) { // If it is a non-interactive session, let next handler to deal // with it. if ((flags.dwFlags & WSF_VISIBLE) == 0) { @@ -1991,7 +1991,7 @@ static BOOL WINAPI consoleHandler(DWORD event) { // Return maximum OS signal used + 1 for internal use only // Used as exit signal for signal_thread -int os::sigexitnum_pd(){ +int os::sigexitnum_pd() { return NSIG; } @@ -2422,11 +2422,11 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // process of write protecting the memory serialization page. // It write enables the page immediately after protecting it // so just return. - if ( exception_code == EXCEPTION_ACCESS_VIOLATION ) { + if (exception_code == EXCEPTION_ACCESS_VIOLATION) { JavaThread* thread = (JavaThread*) t; PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; - if ( os::is_memory_serialize_page(thread, addr) ) { + if (os::is_memory_serialize_page(thread, addr)) { // Block current thread until the memory serialize page permission restored. os::block_on_serialize_page_trap(); return EXCEPTION_CONTINUE_EXECUTION; @@ -2543,7 +2543,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; - if (addr > thread->stack_yellow_zone_base() && addr < thread->stack_base() ) { + if (addr > thread->stack_yellow_zone_base() && addr < thread->stack_base()) { addr = (address)((uintptr_t)addr & (~((uintptr_t)os::vm_page_size() - (uintptr_t)1))); os::commit_memory((char *)addr, thread->stack_base() - addr, @@ -2623,7 +2623,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) { // Compiled method patched to be non entrant? Following conditions must apply: // 1. must be first instruction in bundle // 2. must be a break instruction with appropriate code - if((((uint64_t) pc & 0x0F) == 0) && + if ((((uint64_t) pc & 0x0F) == 0) && (((IPF_Bundle*) pc)->get_slot0() == handle_wrong_method_break.bits())) { return Handle_Exception(exceptionInfo, (address)SharedRuntime::get_handle_wrong_method_stub()); @@ -2794,7 +2794,7 @@ public: return (_numa_used_node_count > 1); } - int get_count() {return _numa_used_node_count;} + int get_count() { return _numa_used_node_count; } int get_node_list_entry(int n) { // for indexes out of range, returns -1 return (n < _numa_used_node_count ? _numa_used_node_list[n] : -1); @@ -3112,14 +3112,14 @@ char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) { res = (char*)VirtualAlloc(addr, bytes, MEM_RESERVE, PAGE_READWRITE); } else { elapsedTimer reserveTimer; - if( Verbose && PrintMiscellaneous ) reserveTimer.start(); + if (Verbose && PrintMiscellaneous) reserveTimer.start(); // in numa interleaving, we have to allocate pages individually // (well really chunks of NUMAInterleaveGranularity size) res = allocate_pages_individually(bytes, addr, MEM_RESERVE, PAGE_READWRITE); if (res == NULL) { warning("NUMA page allocation failed"); } - if( Verbose && PrintMiscellaneous ) { + if (Verbose && PrintMiscellaneous) { reserveTimer.stop(); tty->print_cr("reserve_memory of %Ix bytes took " JLONG_FORMAT " ms (" JLONG_FORMAT " ticks)", bytes, reserveTimer.milliseconds(), reserveTimer.ticks()); @@ -3450,14 +3450,14 @@ public: int os::sleep(Thread* thread, jlong ms, bool interruptable) { jlong limit = (jlong) MAXDWORD; - while(ms > limit) { + while (ms > limit) { int res; if ((res = sleep(thread, limit, interruptable)) != OS_TIMEOUT) return res; ms -= limit; } - assert(thread == Thread::current(), "thread consistency check"); + assert(thread == Thread::current(), "thread consistency check"); OSThread* osthread = thread->osthread(); OSThreadWaitState osts(osthread, false /* not Object.wait() */); int result; @@ -3473,8 +3473,8 @@ int os::sleep(Thread* thread, jlong ms, bool interruptable) { HANDLE events[1]; events[0] = osthread->interrupt_event(); HighResolutionInterval *phri=NULL; - if(!ForceTimeHighResolution) - phri = new HighResolutionInterval( ms ); + if (!ForceTimeHighResolution) + phri = new HighResolutionInterval(ms); if (WaitForMultipleObjects(1, events, FALSE, (DWORD)ms) == WAIT_TIMEOUT) { result = OS_TIMEOUT; } else { @@ -3511,17 +3511,17 @@ void os::infinite_sleep() { } } -typedef BOOL (WINAPI * STTSignature)(void) ; +typedef BOOL (WINAPI * STTSignature)(void); os::YieldResult os::NakedYield() { // Use either SwitchToThread() or Sleep(0) // Consider passing back the return value from SwitchToThread(). if (os::Kernel32Dll::SwitchToThreadAvailable()) { - return SwitchToThread() ? os::YIELD_SWITCHED : os::YIELD_NONEREADY ; + return SwitchToThread() ? os::YIELD_SWITCHED : os::YIELD_NONEREADY; } else { Sleep(0); } - return os::YIELD_UNKNOWN ; + return os::YIELD_UNKNOWN; } void os::yield() { os::NakedYield(); } @@ -3574,7 +3574,7 @@ static int prio_init() { } } if (UseCriticalJavaThreadPriority) { - os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority] ; + os::java_to_os_priority[MaxPriority] = os::java_to_os_priority[CriticalPriority]; } return 0; } @@ -3586,7 +3586,7 @@ OSReturn os::set_native_priority(Thread* thread, int priority) { } OSReturn os::get_native_priority(const Thread* const thread, int* priority_ptr) { - if ( !UseThreadPriorities ) { + if (!UseThreadPriorities) { *priority_ptr = java_to_os_priority[NormPriority]; return OS_OK; } @@ -3620,8 +3620,8 @@ void os::interrupt(Thread* thread) { if (thread->is_Java_thread()) ((JavaThread*)thread)->parker()->unpark(); - ParkEvent * ev = thread->_ParkEvent ; - if (ev != NULL) ev->unpark() ; + ParkEvent * ev = thread->_ParkEvent; + if (ev != NULL) ev->unpark(); } @@ -3715,7 +3715,7 @@ void os::win32::initialize_system_info() { OSVERSIONINFOEX oi; oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); GetVersionEx((OSVERSIONINFO*)&oi); - switch(oi.dwPlatformId) { + switch (oi.dwPlatformId) { case VER_PLATFORM_WIN32_WINDOWS: _is_nt = false; break; case VER_PLATFORM_WIN32_NT: _is_nt = true; @@ -3898,29 +3898,29 @@ static jint initSock(); jint os::init_2(void) { // Allocate a single page and mark it as readable for safepoint polling address polling_page = (address)VirtualAlloc(NULL, os::vm_page_size(), MEM_RESERVE, PAGE_READONLY); - guarantee( polling_page != NULL, "Reserve Failed for polling page"); + guarantee(polling_page != NULL, "Reserve Failed for polling page"); address return_page = (address)VirtualAlloc(polling_page, os::vm_page_size(), MEM_COMMIT, PAGE_READONLY); - guarantee( return_page != NULL, "Commit Failed for polling page"); + guarantee(return_page != NULL, "Commit Failed for polling page"); - os::set_polling_page( polling_page ); + os::set_polling_page(polling_page); #ifndef PRODUCT - if( Verbose && PrintMiscellaneous ) + if (Verbose && PrintMiscellaneous) tty->print("[SafePoint Polling address: " INTPTR_FORMAT "]\n", (intptr_t)polling_page); #endif if (!UseMembar) { address mem_serialize_page = (address)VirtualAlloc(NULL, os::vm_page_size(), MEM_RESERVE, PAGE_READWRITE); - guarantee( mem_serialize_page != NULL, "Reserve Failed for memory serialize page"); + guarantee(mem_serialize_page != NULL, "Reserve Failed for memory serialize page"); return_page = (address)VirtualAlloc(mem_serialize_page, os::vm_page_size(), MEM_COMMIT, PAGE_READWRITE); - guarantee( return_page != NULL, "Commit Failed for memory serialize page"); + guarantee(return_page != NULL, "Commit Failed for memory serialize page"); - os::set_memory_serialize_page( mem_serialize_page ); + os::set_memory_serialize_page(mem_serialize_page); #ifndef PRODUCT - if(Verbose && PrintMiscellaneous) + if (Verbose && PrintMiscellaneous) tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); #endif } @@ -4036,14 +4036,14 @@ void os::init_3(void) { // Mark the polling page as unreadable void os::make_polling_page_unreadable(void) { DWORD old_status; - if( !VirtualProtect((char *)_polling_page, os::vm_page_size(), PAGE_NOACCESS, &old_status) ) + if (!VirtualProtect((char *)_polling_page, os::vm_page_size(), PAGE_NOACCESS, &old_status)) fatal("Could not disable polling page"); }; // Mark the polling page as readable void os::make_polling_page_readable(void) { DWORD old_status; - if( !VirtualProtect((char *)_polling_page, os::vm_page_size(), PAGE_READONLY, &old_status) ) + if (!VirtualProtect((char *)_polling_page, os::vm_page_size(), PAGE_READONLY, &old_status)) fatal("Could not enable polling page"); }; @@ -4121,7 +4121,7 @@ jlong os::thread_cpu_time(Thread* thread, bool user_sys_cpu_time) { FILETIME KernelTime; FILETIME UserTime; - if ( GetThreadTimes(thread->osthread()->thread_handle(), + if (GetThreadTimes(thread->osthread()->thread_handle(), &CreationTime, &ExitTime, &KernelTime, &UserTime) == 0) return -1; else @@ -4157,7 +4157,7 @@ bool os::is_thread_cpu_time_supported() { FILETIME KernelTime; FILETIME UserTime; - if ( GetThreadTimes(GetCurrentThread(), + if (GetThreadTimes(GetCurrentThread(), &CreationTime, &ExitTime, &KernelTime, &UserTime) == 0) return false; else @@ -4391,7 +4391,7 @@ int os::ftruncate(int fd, jlong length) { int os::fsync(int fd) { HANDLE handle = (HANDLE)::_get_osfhandle(fd); - if ( (!::FlushFileBuffers(handle)) && + if ((!::FlushFileBuffers(handle)) && (GetLastError() != ERROR_ACCESS_DENIED) ) { /* from winerror.h */ return -1; @@ -4512,7 +4512,7 @@ static int stdinAvailable(int fd, long *pbytes) { } /* Examine input records for the number of bytes available */ - for(i=0; i 0 , "Invariant") ; - int v ; + guarantee(_ParkHandle != NULL , "Invariant"); + guarantee(Millis > 0 , "Invariant"); + int v; // CONSIDER: defer assigning a CreateEvent() handle to the Event until // the initial park() operation. for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee ((v == 0) || (v == 1), "invariant") ; - if (v != 0) return OS_OK ; + guarantee((v == 0) || (v == 1), "invariant"); + if (v != 0) return OS_OK; // Do this the hard way by blocking ... // TODO: consider a brief spin here, gated on the success of recent @@ -4820,59 +4820,59 @@ int os::PlatformEvent::park (jlong Millis) { // In the future, however, we might want to track the accumulated wait time and // adjust Millis accordingly if we encounter a spurious wakeup. - const int MAXTIMEOUT = 0x10000000 ; - DWORD rv = WAIT_TIMEOUT ; + const int MAXTIMEOUT = 0x10000000; + DWORD rv = WAIT_TIMEOUT; while (_Event < 0 && Millis > 0) { - DWORD prd = Millis ; // set prd = MAX (Millis, MAXTIMEOUT) + DWORD prd = Millis; // set prd = MAX (Millis, MAXTIMEOUT) if (Millis > MAXTIMEOUT) { - prd = MAXTIMEOUT ; + prd = MAXTIMEOUT; } - rv = ::WaitForSingleObject (_ParkHandle, prd) ; - assert (rv == WAIT_OBJECT_0 || rv == WAIT_TIMEOUT, "WaitForSingleObject failed") ; + rv = ::WaitForSingleObject(_ParkHandle, prd); + assert(rv == WAIT_OBJECT_0 || rv == WAIT_TIMEOUT, "WaitForSingleObject failed"); if (rv == WAIT_TIMEOUT) { - Millis -= prd ; + Millis -= prd; } } - v = _Event ; - _Event = 0 ; + v = _Event; + _Event = 0; // see comment at end of os::PlatformEvent::park() below: - OrderAccess::fence() ; + OrderAccess::fence(); // If we encounter a nearly simultanous timeout expiry and unpark() // we return OS_OK indicating we awoke via unpark(). // Implementor's license -- returning OS_TIMEOUT would be equally valid, however. - return (v >= 0) ? OS_OK : OS_TIMEOUT ; + return (v >= 0) ? OS_OK : OS_TIMEOUT; } -void os::PlatformEvent::park () { - guarantee (_ParkHandle != NULL, "Invariant") ; +void os::PlatformEvent::park() { + guarantee(_ParkHandle != NULL, "Invariant"); // Invariant: Only the thread associated with the Event/PlatformEvent // may call park(). - int v ; + int v; for (;;) { - v = _Event ; - if (Atomic::cmpxchg (v-1, &_Event, v) == v) break ; + v = _Event; + if (Atomic::cmpxchg(v-1, &_Event, v) == v) break; } - guarantee ((v == 0) || (v == 1), "invariant") ; - if (v != 0) return ; + guarantee((v == 0) || (v == 1), "invariant"); + if (v != 0) return; // Do this the hard way by blocking ... // TODO: consider a brief spin here, gated on the success of recent // spin attempts by this thread. while (_Event < 0) { - DWORD rv = ::WaitForSingleObject (_ParkHandle, INFINITE) ; - assert (rv == WAIT_OBJECT_0, "WaitForSingleObject failed") ; + DWORD rv = ::WaitForSingleObject(_ParkHandle, INFINITE); + assert(rv == WAIT_OBJECT_0, "WaitForSingleObject failed"); } // Usually we'll find _Event == 0 at this point, but as // an optional optimization we clear it, just in case can // multiple unpark() operations drove _Event up to 1. - _Event = 0 ; - OrderAccess::fence() ; - guarantee (_Event >= 0, "invariant") ; + _Event = 0; + OrderAccess::fence(); + guarantee(_Event >= 0, "invariant"); } void os::PlatformEvent::unpark() { - guarantee (_ParkHandle != NULL, "Invariant") ; + guarantee(_ParkHandle != NULL, "Invariant"); // Transitions for _Event: // 0 :=> 1 @@ -4907,7 +4907,7 @@ void os::PlatformEvent::unpark() { void Parker::park(bool isAbsolute, jlong time) { - guarantee (_ParkEvent != NULL, "invariant") ; + guarantee(_ParkEvent != NULL, "invariant"); // First, demultiplex/decode time arguments if (time < 0) { // don't wait return; @@ -4941,7 +4941,7 @@ void Parker::park(bool isAbsolute, jlong time) { OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */); jt->set_suspend_equivalent(); - WaitForSingleObject(_ParkEvent, time); + WaitForSingleObject(_ParkEvent, time); ResetEvent(_ParkEvent); // If externally suspended while waiting, re-suspend @@ -4952,7 +4952,7 @@ void Parker::park(bool isAbsolute, jlong time) { } void Parker::unpark() { - guarantee (_ParkEvent != NULL, "invariant") ; + guarantee(_ParkEvent != NULL, "invariant"); SetEvent(_ParkEvent); } @@ -5040,7 +5040,7 @@ bool os::find(address addr, outputStream* st) { LONG WINAPI os::win32::serialize_fault_filter(struct _EXCEPTION_POINTERS* e) { DWORD exception_code = e->ExceptionRecord->ExceptionCode; - if ( exception_code == EXCEPTION_ACCESS_VIOLATION ) { + if (exception_code == EXCEPTION_ACCESS_VIOLATION) { JavaThread* thread = (JavaThread*)ThreadLocalStorage::get_thread_slow(); PEXCEPTION_RECORD exceptionRecord = e->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; diff --git a/hotspot/src/share/vm/runtime/objectMonitor.cpp b/hotspot/src/share/vm/runtime/objectMonitor.cpp index 6f2323c8668..d9682ebf601 100644 --- a/hotspot/src/share/vm/runtime/objectMonitor.cpp +++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp @@ -114,38 +114,38 @@ // The knob* variables are effectively final. Once set they should // never be modified hence. Consider using __read_mostly with GCC. -int ObjectMonitor::Knob_Verbose = 0 ; -int ObjectMonitor::Knob_SpinLimit = 5000 ; // derived by an external tool - -static int Knob_LogSpins = 0 ; // enable jvmstat tally for spins -static int Knob_HandOff = 0 ; -static int Knob_ReportSettings = 0 ; +int ObjectMonitor::Knob_Verbose = 0; +int ObjectMonitor::Knob_SpinLimit = 5000; // derived by an external tool - +static int Knob_LogSpins = 0; // enable jvmstat tally for spins +static int Knob_HandOff = 0; +static int Knob_ReportSettings = 0; -static int Knob_SpinBase = 0 ; // Floor AKA SpinMin -static int Knob_SpinBackOff = 0 ; // spin-loop backoff -static int Knob_CASPenalty = -1 ; // Penalty for failed CAS -static int Knob_OXPenalty = -1 ; // Penalty for observed _owner change -static int Knob_SpinSetSucc = 1 ; // spinners set the _succ field -static int Knob_SpinEarly = 1 ; -static int Knob_SuccEnabled = 1 ; // futile wake throttling -static int Knob_SuccRestrict = 0 ; // Limit successors + spinners to at-most-one -static int Knob_MaxSpinners = -1 ; // Should be a function of # CPUs -static int Knob_Bonus = 100 ; // spin success bonus -static int Knob_BonusB = 100 ; // spin success bonus -static int Knob_Penalty = 200 ; // spin failure penalty -static int Knob_Poverty = 1000 ; -static int Knob_SpinAfterFutile = 1 ; // Spin after returning from park() -static int Knob_FixedSpin = 0 ; -static int Knob_OState = 3 ; // Spinner checks thread state of _owner -static int Knob_UsePause = 1 ; -static int Knob_ExitPolicy = 0 ; -static int Knob_PreSpin = 10 ; // 20-100 likely better -static int Knob_ResetEvent = 0 ; -static int BackOffMask = 0 ; +static int Knob_SpinBase = 0; // Floor AKA SpinMin +static int Knob_SpinBackOff = 0; // spin-loop backoff +static int Knob_CASPenalty = -1; // Penalty for failed CAS +static int Knob_OXPenalty = -1; // Penalty for observed _owner change +static int Knob_SpinSetSucc = 1; // spinners set the _succ field +static int Knob_SpinEarly = 1; +static int Knob_SuccEnabled = 1; // futile wake throttling +static int Knob_SuccRestrict = 0; // Limit successors + spinners to at-most-one +static int Knob_MaxSpinners = -1; // Should be a function of # CPUs +static int Knob_Bonus = 100; // spin success bonus +static int Knob_BonusB = 100; // spin success bonus +static int Knob_Penalty = 200; // spin failure penalty +static int Knob_Poverty = 1000; +static int Knob_SpinAfterFutile = 1; // Spin after returning from park() +static int Knob_FixedSpin = 0; +static int Knob_OState = 3; // Spinner checks thread state of _owner +static int Knob_UsePause = 1; +static int Knob_ExitPolicy = 0; +static int Knob_PreSpin = 10; // 20-100 likely better +static int Knob_ResetEvent = 0; +static int BackOffMask = 0; -static int Knob_FastHSSEC = 0 ; -static int Knob_MoveNotifyee = 2 ; // notify() - disposition of notifyee -static int Knob_QMode = 0 ; // EntryList-cxq policy - queue discipline -static volatile int InitDone = 0 ; +static int Knob_FastHSSEC = 0; +static int Knob_MoveNotifyee = 2; // notify() - disposition of notifyee +static int Knob_QMode = 0; // EntryList-cxq policy - queue discipline +static volatile int InitDone = 0; #define TrySpin TrySpin_VaryDuration @@ -265,9 +265,9 @@ bool ObjectMonitor::try_enter(Thread* THREAD) { if (THREAD != _owner) { if (THREAD->is_lock_owned ((address)_owner)) { assert(_recursions == 0, "internal state error"); - _owner = THREAD ; - _recursions = 1 ; - OwnerIsThread = 1 ; + _owner = THREAD; + _recursions = 1; + OwnerIsThread = 1; return true; } if (Atomic::cmpxchg_ptr (THREAD, &_owner, NULL) != NULL) { @@ -283,37 +283,37 @@ bool ObjectMonitor::try_enter(Thread* THREAD) { void ATTR ObjectMonitor::enter(TRAPS) { // The following code is ordered to check the most common cases first // and to reduce RTS->RTO cache line upgrades on SPARC and IA32 processors. - Thread * const Self = THREAD ; - void * cur ; + Thread * const Self = THREAD; + void * cur; - cur = Atomic::cmpxchg_ptr (Self, &_owner, NULL) ; + cur = Atomic::cmpxchg_ptr(Self, &_owner, NULL); if (cur == NULL) { // Either ASSERT _recursions == 0 or explicitly set _recursions = 0. - assert (_recursions == 0 , "invariant") ; - assert (_owner == Self, "invariant") ; + assert(_recursions == 0 , "invariant"); + assert(_owner == Self, "invariant"); // CONSIDER: set or assert OwnerIsThread == 1 - return ; + return; } if (cur == Self) { // TODO-FIXME: check for integer overflow! BUGID 6557169. - _recursions ++ ; - return ; + _recursions++; + return; } if (Self->is_lock_owned ((address)cur)) { - assert (_recursions == 0, "internal state error"); - _recursions = 1 ; + assert(_recursions == 0, "internal state error"); + _recursions = 1; // Commute owner from a thread-specific on-stack BasicLockObject address to // a full-fledged "Thread *". - _owner = Self ; - OwnerIsThread = 1 ; - return ; + _owner = Self; + OwnerIsThread = 1; + return; } // We've encountered genuine contention. - assert (Self->_Stalled == 0, "invariant") ; - Self->_Stalled = intptr_t(this) ; + assert(Self->_Stalled == 0, "invariant"); + Self->_Stalled = intptr_t(this); // Try one round of spinning *before* enqueueing Self // and before going through the awkward and expensive state @@ -321,21 +321,21 @@ void ATTR ObjectMonitor::enter(TRAPS) { // Note that if we acquire the monitor from an initial spin // we forgo posting JVMTI events and firing DTRACE probes. if (Knob_SpinEarly && TrySpin (Self) > 0) { - assert (_owner == Self , "invariant") ; - assert (_recursions == 0 , "invariant") ; - assert (((oop)(object()))->mark() == markOopDesc::encode(this), "invariant") ; - Self->_Stalled = 0 ; - return ; + assert(_owner == Self , "invariant"); + assert(_recursions == 0 , "invariant"); + assert(((oop)(object()))->mark() == markOopDesc::encode(this), "invariant"); + Self->_Stalled = 0; + return; } - assert (_owner != Self , "invariant") ; - assert (_succ != Self , "invariant") ; - assert (Self->is_Java_thread() , "invariant") ; - JavaThread * jt = (JavaThread *) Self ; - assert (!SafepointSynchronize::is_at_safepoint(), "invariant") ; - assert (jt->thread_state() != _thread_blocked , "invariant") ; - assert (this->object() != NULL , "invariant") ; - assert (_count >= 0, "invariant") ; + assert(_owner != Self , "invariant"); + assert(_succ != Self , "invariant"); + assert(Self->is_Java_thread() , "invariant"); + JavaThread * jt = (JavaThread *) Self; + assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); + assert(jt->thread_state() != _thread_blocked , "invariant"); + assert(this->object() != NULL , "invariant"); + assert(_count >= 0, "invariant"); // Prevent deflation at STW-time. See deflate_idle_monitors() and is_busy(). // Ensure the object-monitor relationship remains stable while there's contention. @@ -368,9 +368,9 @@ void ATTR ObjectMonitor::enter(TRAPS) { // cleared by handle_special_suspend_equivalent_condition() // or java_suspend_self() - EnterI (THREAD) ; + EnterI(THREAD); - if (!ExitSuspendEquivalent(jt)) break ; + if (!ExitSuspendEquivalent(jt)) break; // // We have acquired the contended monitor, but while we were @@ -378,9 +378,9 @@ void ATTR ObjectMonitor::enter(TRAPS) { // the monitor while suspended because that would surprise the // thread that suspended us. // - _recursions = 0 ; - _succ = NULL ; - exit (false, Self) ; + _recursions = 0; + _succ = NULL; + exit(false, Self); jt->java_suspend_self(); } @@ -397,14 +397,14 @@ void ATTR ObjectMonitor::enter(TRAPS) { } Atomic::dec_ptr(&_count); - assert (_count >= 0, "invariant") ; - Self->_Stalled = 0 ; + assert(_count >= 0, "invariant"); + Self->_Stalled = 0; // Must either set _recursions = 0 or ASSERT _recursions == 0. - assert (_recursions == 0 , "invariant") ; - assert (_owner == Self , "invariant") ; - assert (_succ != Self , "invariant") ; - assert (((oop)(object()))->mark() == markOopDesc::encode(this), "invariant") ; + assert(_recursions == 0 , "invariant"); + assert(_owner == Self , "invariant"); + assert(_succ != Self , "invariant"); + assert(((oop)(object()))->mark() == markOopDesc::encode(this), "invariant"); // The thread -- now the owner -- is back in vm mode. // Report the glorious news via TI,DTrace and jvmstat. @@ -437,7 +437,7 @@ void ATTR ObjectMonitor::enter(TRAPS) { } if (ObjectMonitor::_sync_ContendedLockAttempts != NULL) { - ObjectMonitor::_sync_ContendedLockAttempts->inc() ; + ObjectMonitor::_sync_ContendedLockAttempts->inc(); } } @@ -447,37 +447,37 @@ void ATTR ObjectMonitor::enter(TRAPS) { int ObjectMonitor::TryLock (Thread * Self) { for (;;) { - void * own = _owner ; - if (own != NULL) return 0 ; + void * own = _owner; + if (own != NULL) return 0; if (Atomic::cmpxchg_ptr (Self, &_owner, NULL) == NULL) { // Either guarantee _recursions == 0 or set _recursions = 0. - assert (_recursions == 0, "invariant") ; - assert (_owner == Self, "invariant") ; + assert(_recursions == 0, "invariant"); + assert(_owner == Self, "invariant"); // CONSIDER: set or assert that OwnerIsThread == 1 - return 1 ; + return 1; } // The lock had been free momentarily, but we lost the race to the lock. // Interference -- the CAS failed. // We can either return -1 or retry. // Retry doesn't make as much sense because the lock was just acquired. - if (true) return -1 ; + if (true) return -1; } } void ATTR ObjectMonitor::EnterI (TRAPS) { - Thread * Self = THREAD ; - assert (Self->is_Java_thread(), "invariant") ; - assert (((JavaThread *) Self)->thread_state() == _thread_blocked , "invariant") ; + Thread * Self = THREAD; + assert(Self->is_Java_thread(), "invariant"); + assert(((JavaThread *) Self)->thread_state() == _thread_blocked , "invariant"); // Try the lock - TATAS if (TryLock (Self) > 0) { - assert (_succ != Self , "invariant") ; - assert (_owner == Self , "invariant") ; - assert (_Responsible != Self , "invariant") ; - return ; + assert(_succ != Self , "invariant"); + assert(_owner == Self , "invariant"); + assert(_Responsible != Self , "invariant"); + return; } - DeferredInitialize () ; + DeferredInitialize(); // We try one round of spinning *before* enqueueing Self. // @@ -487,16 +487,16 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // effects. if (TrySpin (Self) > 0) { - assert (_owner == Self , "invariant") ; - assert (_succ != Self , "invariant") ; - assert (_Responsible != Self , "invariant") ; - return ; + assert(_owner == Self , "invariant"); + assert(_succ != Self , "invariant"); + assert(_Responsible != Self , "invariant"); + return; } // The Spin failed -- Enqueue and park the thread ... - assert (_succ != Self , "invariant") ; - assert (_owner != Self , "invariant") ; - assert (_Responsible != Self , "invariant") ; + assert(_succ != Self , "invariant"); + assert(_owner != Self , "invariant"); + assert(_Responsible != Self , "invariant"); // Enqueue "Self" on ObjectMonitor's _cxq. // @@ -508,27 +508,27 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // TODO: eliminate ObjectWaiter and enqueue either Threads or Events. // - ObjectWaiter node(Self) ; - Self->_ParkEvent->reset() ; - node._prev = (ObjectWaiter *) 0xBAD ; - node.TState = ObjectWaiter::TS_CXQ ; + ObjectWaiter node(Self); + Self->_ParkEvent->reset(); + node._prev = (ObjectWaiter *) 0xBAD; + node.TState = ObjectWaiter::TS_CXQ; // Push "Self" onto the front of the _cxq. // Once on cxq/EntryList, Self stays on-queue until it acquires the lock. // Note that spinning tends to reduce the rate at which threads // enqueue and dequeue on EntryList|cxq. - ObjectWaiter * nxt ; + ObjectWaiter * nxt; for (;;) { - node._next = nxt = _cxq ; - if (Atomic::cmpxchg_ptr (&node, &_cxq, nxt) == nxt) break ; + node._next = nxt = _cxq; + if (Atomic::cmpxchg_ptr(&node, &_cxq, nxt) == nxt) break; // Interference - the CAS failed because _cxq changed. Just retry. // As an optional optimization we retry the lock. if (TryLock (Self) > 0) { - assert (_succ != Self , "invariant") ; - assert (_owner == Self , "invariant") ; - assert (_Responsible != Self , "invariant") ; - return ; + assert(_succ != Self , "invariant"); + assert(_owner == Self , "invariant"); + assert(_Responsible != Self , "invariant"); + return; } } @@ -558,7 +558,7 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { if ((SyncFlags & 16) == 0 && nxt == NULL && _EntryList == NULL) { // Try to assume the role of responsible thread for the monitor. // CONSIDER: ST vs CAS vs { if (Responsible==null) Responsible=Self } - Atomic::cmpxchg_ptr (Self, &_Responsible, NULL) ; + Atomic::cmpxchg_ptr(Self, &_Responsible, NULL); } // The lock have been released while this thread was occupied queueing @@ -572,49 +572,49 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // to defer the state transitions until absolutely necessary, // and in doing so avoid some transitions ... - TEVENT (Inflated enter - Contention) ; - int nWakeups = 0 ; - int RecheckInterval = 1 ; + TEVENT(Inflated enter - Contention); + int nWakeups = 0; + int RecheckInterval = 1; for (;;) { - if (TryLock (Self) > 0) break ; - assert (_owner != Self, "invariant") ; + if (TryLock(Self) > 0) break; + assert(_owner != Self, "invariant"); if ((SyncFlags & 2) && _Responsible == NULL) { - Atomic::cmpxchg_ptr (Self, &_Responsible, NULL) ; + Atomic::cmpxchg_ptr(Self, &_Responsible, NULL); } // park self if (_Responsible == Self || (SyncFlags & 1)) { - TEVENT (Inflated enter - park TIMED) ; - Self->_ParkEvent->park ((jlong) RecheckInterval) ; + TEVENT(Inflated enter - park TIMED); + Self->_ParkEvent->park((jlong) RecheckInterval); // Increase the RecheckInterval, but clamp the value. - RecheckInterval *= 8 ; - if (RecheckInterval > 1000) RecheckInterval = 1000 ; + RecheckInterval *= 8; + if (RecheckInterval > 1000) RecheckInterval = 1000; } else { - TEVENT (Inflated enter - park UNTIMED) ; - Self->_ParkEvent->park() ; + TEVENT(Inflated enter - park UNTIMED); + Self->_ParkEvent->park(); } - if (TryLock(Self) > 0) break ; + if (TryLock(Self) > 0) break; // The lock is still contested. // Keep a tally of the # of futile wakeups. // Note that the counter is not protected by a lock or updated by atomics. // That is by design - we trade "lossy" counters which are exposed to // races during updates for a lower probe effect. - TEVENT (Inflated enter - Futile wakeup) ; + TEVENT(Inflated enter - Futile wakeup); if (ObjectMonitor::_sync_FutileWakeups != NULL) { - ObjectMonitor::_sync_FutileWakeups->inc() ; + ObjectMonitor::_sync_FutileWakeups->inc(); } - ++ nWakeups ; + ++nWakeups; // Assuming this is not a spurious wakeup we'll normally find _succ == Self. // We can defer clearing _succ until after the spin completes // TrySpin() must tolerate being called with _succ == Self. // Try yet another round of adaptive spinning. - if ((Knob_SpinAfterFutile & 1) && TrySpin (Self) > 0) break ; + if ((Knob_SpinAfterFutile & 1) && TrySpin(Self) > 0) break; // We can find that we were unpark()ed and redesignated _succ while // we were spinning. That's harmless. If we iterate and call park(), @@ -625,13 +625,13 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // in the next iteration. if ((Knob_ResetEvent & 1) && Self->_ParkEvent->fired()) { - Self->_ParkEvent->reset() ; - OrderAccess::fence() ; + Self->_ParkEvent->reset(); + OrderAccess::fence(); } - if (_succ == Self) _succ = NULL ; + if (_succ == Self) _succ = NULL; // Invariant: after clearing _succ a thread *must* retry _owner before parking. - OrderAccess::fence() ; + OrderAccess::fence(); } // Egress : @@ -642,18 +642,18 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // The head of cxq is volatile but the interior is stable. // In addition, Self.TState is stable. - assert (_owner == Self , "invariant") ; - assert (object() != NULL , "invariant") ; + assert(_owner == Self , "invariant"); + assert(object() != NULL , "invariant"); // I'd like to write: // guarantee (((oop)(object()))->mark() == markOopDesc::encode(this), "invariant") ; // but as we're at a safepoint that's not safe. - UnlinkAfterAcquire (Self, &node) ; - if (_succ == Self) _succ = NULL ; + UnlinkAfterAcquire(Self, &node); + if (_succ == Self) _succ = NULL; - assert (_succ != Self, "invariant") ; + assert(_succ != Self, "invariant"); if (_Responsible == Self) { - _Responsible = NULL ; + _Responsible = NULL; OrderAccess::fence(); // Dekker pivot-point // We may leave threads on cxq|EntryList without a designated @@ -700,9 +700,9 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // execute a serializing instruction. if (SyncFlags & 8) { - OrderAccess::fence() ; + OrderAccess::fence(); } - return ; + return; } // ReenterI() is a specialized inline form of the latter half of the @@ -714,24 +714,24 @@ void ATTR ObjectMonitor::EnterI (TRAPS) { // loop accordingly. void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { - assert (Self != NULL , "invariant") ; - assert (SelfNode != NULL , "invariant") ; - assert (SelfNode->_thread == Self , "invariant") ; - assert (_waiters > 0 , "invariant") ; - assert (((oop)(object()))->mark() == markOopDesc::encode(this) , "invariant") ; - assert (((JavaThread *)Self)->thread_state() != _thread_blocked, "invariant") ; - JavaThread * jt = (JavaThread *) Self ; + assert(Self != NULL , "invariant"); + assert(SelfNode != NULL , "invariant"); + assert(SelfNode->_thread == Self , "invariant"); + assert(_waiters > 0 , "invariant"); + assert(((oop)(object()))->mark() == markOopDesc::encode(this) , "invariant"); + assert(((JavaThread *)Self)->thread_state() != _thread_blocked, "invariant"); + JavaThread * jt = (JavaThread *) Self; - int nWakeups = 0 ; + int nWakeups = 0; for (;;) { - ObjectWaiter::TStates v = SelfNode->TState ; - guarantee (v == ObjectWaiter::TS_ENTER || v == ObjectWaiter::TS_CXQ, "invariant") ; - assert (_owner != Self, "invariant") ; + ObjectWaiter::TStates v = SelfNode->TState; + guarantee(v == ObjectWaiter::TS_ENTER || v == ObjectWaiter::TS_CXQ, "invariant"); + assert(_owner != Self, "invariant"); - if (TryLock (Self) > 0) break ; - if (TrySpin (Self) > 0) break ; + if (TryLock(Self) > 0) break; + if (TrySpin(Self) > 0) break; - TEVENT (Wait Reentry - parking) ; + TEVENT(Wait Reentry - parking); // State transition wrappers around park() ... // ReenterI() wisely defers state transitions until @@ -744,14 +744,14 @@ void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { // or java_suspend_self() jt->set_suspend_equivalent(); if (SyncFlags & 1) { - Self->_ParkEvent->park ((jlong)1000) ; + Self->_ParkEvent->park((jlong)1000); } else { - Self->_ParkEvent->park () ; + Self->_ParkEvent->park(); } // were we externally suspended while we were waiting? for (;;) { - if (!ExitSuspendEquivalent (jt)) break ; + if (!ExitSuspendEquivalent(jt)) break; if (_succ == Self) { _succ = NULL; OrderAccess::fence(); } jt->java_suspend_self(); jt->set_suspend_equivalent(); @@ -761,26 +761,26 @@ void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { // Try again, but just so we distinguish between futile wakeups and // successful wakeups. The following test isn't algorithmically // necessary, but it helps us maintain sensible statistics. - if (TryLock(Self) > 0) break ; + if (TryLock(Self) > 0) break; // The lock is still contested. // Keep a tally of the # of futile wakeups. // Note that the counter is not protected by a lock or updated by atomics. // That is by design - we trade "lossy" counters which are exposed to // races during updates for a lower probe effect. - TEVENT (Wait Reentry - futile wakeup) ; - ++ nWakeups ; + TEVENT(Wait Reentry - futile wakeup); + ++nWakeups; // Assuming this is not a spurious wakeup we'll normally // find that _succ == Self. - if (_succ == Self) _succ = NULL ; + if (_succ == Self) _succ = NULL; // Invariant: after clearing _succ a contending thread // *must* retry _owner before parking. - OrderAccess::fence() ; + OrderAccess::fence(); if (ObjectMonitor::_sync_FutileWakeups != NULL) { - ObjectMonitor::_sync_FutileWakeups->inc() ; + ObjectMonitor::_sync_FutileWakeups->inc(); } } @@ -792,13 +792,13 @@ void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { // The head of cxq is volatile but the interior is stable. // In addition, Self.TState is stable. - assert (_owner == Self, "invariant") ; - assert (((oop)(object()))->mark() == markOopDesc::encode(this), "invariant") ; - UnlinkAfterAcquire (Self, SelfNode) ; - if (_succ == Self) _succ = NULL ; - assert (_succ != Self, "invariant") ; - SelfNode->TState = ObjectWaiter::TS_RUN ; - OrderAccess::fence() ; // see comments at the end of EnterI() + assert(_owner == Self, "invariant"); + assert(((oop)(object()))->mark() == markOopDesc::encode(this), "invariant"); + UnlinkAfterAcquire(Self, SelfNode); + if (_succ == Self) _succ = NULL; + assert(_succ != Self, "invariant"); + SelfNode->TState = ObjectWaiter::TS_RUN; + OrderAccess::fence(); // see comments at the end of EnterI() } // after the thread acquires the lock in ::enter(). Equally, we could defer @@ -806,22 +806,22 @@ void ATTR ObjectMonitor::ReenterI (Thread * Self, ObjectWaiter * SelfNode) { void ObjectMonitor::UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) { - assert (_owner == Self, "invariant") ; - assert (SelfNode->_thread == Self, "invariant") ; + assert(_owner == Self, "invariant"); + assert(SelfNode->_thread == Self, "invariant"); if (SelfNode->TState == ObjectWaiter::TS_ENTER) { // Normal case: remove Self from the DLL EntryList . // This is a constant-time operation. - ObjectWaiter * nxt = SelfNode->_next ; - ObjectWaiter * prv = SelfNode->_prev ; - if (nxt != NULL) nxt->_prev = prv ; - if (prv != NULL) prv->_next = nxt ; - if (SelfNode == _EntryList ) _EntryList = nxt ; - assert (nxt == NULL || nxt->TState == ObjectWaiter::TS_ENTER, "invariant") ; - assert (prv == NULL || prv->TState == ObjectWaiter::TS_ENTER, "invariant") ; - TEVENT (Unlink from EntryList) ; + ObjectWaiter * nxt = SelfNode->_next; + ObjectWaiter * prv = SelfNode->_prev; + if (nxt != NULL) nxt->_prev = prv; + if (prv != NULL) prv->_next = nxt; + if (SelfNode == _EntryList) _EntryList = nxt; + assert(nxt == NULL || nxt->TState == ObjectWaiter::TS_ENTER, "invariant"); + assert(prv == NULL || prv->TState == ObjectWaiter::TS_ENTER, "invariant"); + TEVENT(Unlink from EntryList); } else { - guarantee (SelfNode->TState == ObjectWaiter::TS_CXQ, "invariant") ; + guarantee(SelfNode->TState == ObjectWaiter::TS_CXQ, "invariant"); // Inopportune interleaving -- Self is still on the cxq. // This usually means the enqueue of self raced an exiting thread. // Normally we'll find Self near the front of the cxq, so @@ -835,36 +835,36 @@ void ObjectMonitor::UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) // and then unlink Self from EntryList. We have to drain eventually, // so it might as well be now. - ObjectWaiter * v = _cxq ; - assert (v != NULL, "invariant") ; + ObjectWaiter * v = _cxq; + assert(v != NULL, "invariant"); if (v != SelfNode || Atomic::cmpxchg_ptr (SelfNode->_next, &_cxq, v) != v) { // The CAS above can fail from interference IFF a "RAT" arrived. // In that case Self must be in the interior and can no longer be // at the head of cxq. if (v == SelfNode) { - assert (_cxq != v, "invariant") ; - v = _cxq ; // CAS above failed - start scan at head of list + assert(_cxq != v, "invariant"); + v = _cxq; // CAS above failed - start scan at head of list } - ObjectWaiter * p ; - ObjectWaiter * q = NULL ; - for (p = v ; p != NULL && p != SelfNode; p = p->_next) { - q = p ; - assert (p->TState == ObjectWaiter::TS_CXQ, "invariant") ; + ObjectWaiter * p; + ObjectWaiter * q = NULL; + for (p = v; p != NULL && p != SelfNode; p = p->_next) { + q = p; + assert(p->TState == ObjectWaiter::TS_CXQ, "invariant"); } - assert (v != SelfNode, "invariant") ; - assert (p == SelfNode, "Node not found on cxq") ; - assert (p != _cxq, "invariant") ; - assert (q != NULL, "invariant") ; - assert (q->_next == p, "invariant") ; - q->_next = p->_next ; + assert(v != SelfNode, "invariant"); + assert(p == SelfNode, "Node not found on cxq"); + assert(p != _cxq, "invariant"); + assert(q != NULL, "invariant"); + assert(q->_next == p, "invariant"); + q->_next = p->_next; } - TEVENT (Unlink from cxq) ; + TEVENT(Unlink from cxq); } // Diagnostic hygiene ... - SelfNode->_prev = (ObjectWaiter *) 0xBAD ; - SelfNode->_next = (ObjectWaiter *) 0xBAD ; - SelfNode->TState = ObjectWaiter::TS_RUN ; + SelfNode->_prev = (ObjectWaiter *) 0xBAD; + SelfNode->_next = (ObjectWaiter *) 0xBAD; + SelfNode->TState = ObjectWaiter::TS_RUN; } // ----------------------------------------------------------------------------- @@ -919,22 +919,22 @@ void ObjectMonitor::UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) // a monitor will use a timer. void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { - Thread * Self = THREAD ; + Thread * Self = THREAD; if (THREAD != _owner) { if (THREAD->is_lock_owned((address) _owner)) { // Transmute _owner from a BasicLock pointer to a Thread address. // We don't need to hold _mutex for this transition. // Non-null to Non-null is safe as long as all readers can // tolerate either flavor. - assert (_recursions == 0, "invariant") ; - _owner = THREAD ; - _recursions = 0 ; - OwnerIsThread = 1 ; + assert(_recursions == 0, "invariant"); + _owner = THREAD; + _recursions = 0; + OwnerIsThread = 1; } else { // NOTE: we need to handle unbalanced monitor enter/exit // in native code by throwing an exception. // TODO: Throw an IllegalMonitorStateException ? - TEVENT (Exit - Throw IMSX) ; + TEVENT(Exit - Throw IMSX); assert(false, "Non-balanced monitor enter/exit!"); if (false) { THROW(vmSymbols::java_lang_IllegalMonitorStateException()); @@ -945,14 +945,14 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { if (_recursions != 0) { _recursions--; // this is simple recursive enter - TEVENT (Inflated exit - recursive) ; - return ; + TEVENT(Inflated exit - recursive); + return; } // Invariant: after setting Responsible=null an thread must execute // a MEMBAR or other serializing instruction before fetching EntryList|cxq. if ((SyncFlags & 4) == 0) { - _Responsible = NULL ; + _Responsible = NULL; } #if INCLUDE_TRACE @@ -964,7 +964,7 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { #endif for (;;) { - assert (THREAD == _owner, "invariant") ; + assert(THREAD == _owner, "invariant"); if (Knob_ExitPolicy == 0) { @@ -980,13 +980,13 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // in massive wasteful coherency traffic on classic SMP systems. // Instead, I use release_store(), which is implemented as just a simple // ST on x64, x86 and SPARC. - OrderAccess::release_store_ptr (&_owner, NULL) ; // drop the lock - OrderAccess::storeload() ; // See if we need to wake a successor + OrderAccess::release_store_ptr(&_owner, NULL); // drop the lock + OrderAccess::storeload(); // See if we need to wake a successor if ((intptr_t(_EntryList)|intptr_t(_cxq)) == 0 || _succ != NULL) { - TEVENT (Inflated exit - simple egress) ; - return ; + TEVENT(Inflated exit - simple egress); + return; } - TEVENT (Inflated exit - complex egress) ; + TEVENT(Inflated exit - complex egress); // Normally the exiting thread is responsible for ensuring succession, // but if other successors are ready or other entering threads are spinning @@ -1026,17 +1026,17 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // falls to the new owner. // if (Atomic::cmpxchg_ptr (THREAD, &_owner, NULL) != NULL) { - return ; + return; } - TEVENT (Exit - Reacquired) ; + TEVENT(Exit - Reacquired); } else { if ((intptr_t(_EntryList)|intptr_t(_cxq)) == 0 || _succ != NULL) { - OrderAccess::release_store_ptr (&_owner, NULL) ; // drop the lock - OrderAccess::storeload() ; + OrderAccess::release_store_ptr(&_owner, NULL); // drop the lock + OrderAccess::storeload(); // Ratify the previously observed values. if (_cxq == NULL || _succ != NULL) { - TEVENT (Inflated exit - simple egress) ; - return ; + TEVENT(Inflated exit - simple egress); + return; } // inopportune interleaving -- the exiting thread (this thread) @@ -1051,29 +1051,29 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // we could simply unpark() the lead thread and return // without having set _succ. if (Atomic::cmpxchg_ptr (THREAD, &_owner, NULL) != NULL) { - TEVENT (Inflated exit - reacquired succeeded) ; - return ; + TEVENT(Inflated exit - reacquired succeeded); + return; } - TEVENT (Inflated exit - reacquired failed) ; + TEVENT(Inflated exit - reacquired failed); } else { - TEVENT (Inflated exit - complex egress) ; + TEVENT(Inflated exit - complex egress); } } - guarantee (_owner == THREAD, "invariant") ; + guarantee(_owner == THREAD, "invariant"); - ObjectWaiter * w = NULL ; - int QMode = Knob_QMode ; + ObjectWaiter * w = NULL; + int QMode = Knob_QMode; if (QMode == 2 && _cxq != NULL) { // QMode == 2 : cxq has precedence over EntryList. // Try to directly wake a successor from the cxq. // If successful, the successor will need to unlink itself from cxq. - w = _cxq ; - assert (w != NULL, "invariant") ; - assert (w->TState == ObjectWaiter::TS_CXQ, "Invariant") ; - ExitEpilog (Self, w) ; - return ; + w = _cxq; + assert(w != NULL, "invariant"); + assert(w->TState == ObjectWaiter::TS_CXQ, "Invariant"); + ExitEpilog(Self, w); + return; } if (QMode == 3 && _cxq != NULL) { @@ -1082,33 +1082,33 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // Drain _cxq into EntryList - bulk transfer. // First, detach _cxq. // The following loop is tantamount to: w = swap (&cxq, NULL) - w = _cxq ; + w = _cxq; for (;;) { - assert (w != NULL, "Invariant") ; - ObjectWaiter * u = (ObjectWaiter *) Atomic::cmpxchg_ptr (NULL, &_cxq, w) ; - if (u == w) break ; - w = u ; + assert(w != NULL, "Invariant"); + ObjectWaiter * u = (ObjectWaiter *) Atomic::cmpxchg_ptr(NULL, &_cxq, w); + if (u == w) break; + w = u; } - assert (w != NULL , "invariant") ; + assert(w != NULL , "invariant"); - ObjectWaiter * q = NULL ; - ObjectWaiter * p ; - for (p = w ; p != NULL ; p = p->_next) { - guarantee (p->TState == ObjectWaiter::TS_CXQ, "Invariant") ; - p->TState = ObjectWaiter::TS_ENTER ; - p->_prev = q ; - q = p ; + ObjectWaiter * q = NULL; + ObjectWaiter * p; + for (p = w; p != NULL; p = p->_next) { + guarantee(p->TState == ObjectWaiter::TS_CXQ, "Invariant"); + p->TState = ObjectWaiter::TS_ENTER; + p->_prev = q; + q = p; } // Append the RATs to the EntryList // TODO: organize EntryList as a CDLL so we can locate the tail in constant-time. - ObjectWaiter * Tail ; - for (Tail = _EntryList ; Tail != NULL && Tail->_next != NULL ; Tail = Tail->_next) ; + ObjectWaiter * Tail; + for (Tail = _EntryList; Tail != NULL && Tail->_next != NULL; Tail = Tail->_next); if (Tail == NULL) { - _EntryList = w ; + _EntryList = w; } else { - Tail->_next = w ; - w->_prev = Tail ; + Tail->_next = w; + w->_prev = Tail; } // Fall thru into code that tries to wake a successor from EntryList @@ -1121,35 +1121,35 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // Drain _cxq into EntryList - bulk transfer. // First, detach _cxq. // The following loop is tantamount to: w = swap (&cxq, NULL) - w = _cxq ; + w = _cxq; for (;;) { - assert (w != NULL, "Invariant") ; - ObjectWaiter * u = (ObjectWaiter *) Atomic::cmpxchg_ptr (NULL, &_cxq, w) ; - if (u == w) break ; - w = u ; + assert(w != NULL, "Invariant"); + ObjectWaiter * u = (ObjectWaiter *) Atomic::cmpxchg_ptr(NULL, &_cxq, w); + if (u == w) break; + w = u; } - assert (w != NULL , "invariant") ; + assert(w != NULL , "invariant"); - ObjectWaiter * q = NULL ; - ObjectWaiter * p ; - for (p = w ; p != NULL ; p = p->_next) { - guarantee (p->TState == ObjectWaiter::TS_CXQ, "Invariant") ; - p->TState = ObjectWaiter::TS_ENTER ; - p->_prev = q ; - q = p ; + ObjectWaiter * q = NULL; + ObjectWaiter * p; + for (p = w; p != NULL; p = p->_next) { + guarantee(p->TState == ObjectWaiter::TS_CXQ, "Invariant"); + p->TState = ObjectWaiter::TS_ENTER; + p->_prev = q; + q = p; } // Prepend the RATs to the EntryList if (_EntryList != NULL) { - q->_next = _EntryList ; - _EntryList->_prev = q ; + q->_next = _EntryList; + _EntryList->_prev = q; } - _EntryList = w ; + _EntryList = w; // Fall thru into code that tries to wake a successor from EntryList } - w = _EntryList ; + w = _EntryList; if (w != NULL) { // I'd like to write: guarantee (w->_thread != Self). // But in practice an exiting thread may find itself on the EntryList. @@ -1162,29 +1162,29 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // reacquires the lock and then finds itself on the EntryList. // Given all that, we have to tolerate the circumstance where "w" is // associated with Self. - assert (w->TState == ObjectWaiter::TS_ENTER, "invariant") ; - ExitEpilog (Self, w) ; - return ; + assert(w->TState == ObjectWaiter::TS_ENTER, "invariant"); + ExitEpilog(Self, w); + return; } // If we find that both _cxq and EntryList are null then just // re-run the exit protocol from the top. - w = _cxq ; - if (w == NULL) continue ; + w = _cxq; + if (w == NULL) continue; // Drain _cxq into EntryList - bulk transfer. // First, detach _cxq. // The following loop is tantamount to: w = swap (&cxq, NULL) for (;;) { - assert (w != NULL, "Invariant") ; - ObjectWaiter * u = (ObjectWaiter *) Atomic::cmpxchg_ptr (NULL, &_cxq, w) ; - if (u == w) break ; - w = u ; + assert(w != NULL, "Invariant"); + ObjectWaiter * u = (ObjectWaiter *) Atomic::cmpxchg_ptr(NULL, &_cxq, w); + if (u == w) break; + w = u; } - TEVENT (Inflated exit - drain cxq into EntryList) ; + TEVENT(Inflated exit - drain cxq into EntryList); - assert (w != NULL , "invariant") ; - assert (_EntryList == NULL , "invariant") ; + assert(w != NULL , "invariant"); + assert(_EntryList == NULL , "invariant"); // Convert the LIFO SLL anchored by _cxq into a DLL. // The list reorganization step operates in O(LENGTH(w)) time. @@ -1198,30 +1198,30 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { if (QMode == 1) { // QMode == 1 : drain cxq to EntryList, reversing order // We also reverse the order of the list. - ObjectWaiter * s = NULL ; - ObjectWaiter * t = w ; - ObjectWaiter * u = NULL ; + ObjectWaiter * s = NULL; + ObjectWaiter * t = w; + ObjectWaiter * u = NULL; while (t != NULL) { - guarantee (t->TState == ObjectWaiter::TS_CXQ, "invariant") ; - t->TState = ObjectWaiter::TS_ENTER ; - u = t->_next ; - t->_prev = u ; - t->_next = s ; + guarantee(t->TState == ObjectWaiter::TS_CXQ, "invariant"); + t->TState = ObjectWaiter::TS_ENTER; + u = t->_next; + t->_prev = u; + t->_next = s; s = t; - t = u ; + t = u; } - _EntryList = s ; - assert (s != NULL, "invariant") ; + _EntryList = s; + assert(s != NULL, "invariant"); } else { // QMode == 0 or QMode == 2 - _EntryList = w ; - ObjectWaiter * q = NULL ; - ObjectWaiter * p ; - for (p = w ; p != NULL ; p = p->_next) { - guarantee (p->TState == ObjectWaiter::TS_CXQ, "Invariant") ; - p->TState = ObjectWaiter::TS_ENTER ; - p->_prev = q ; - q = p ; + _EntryList = w; + ObjectWaiter * q = NULL; + ObjectWaiter * p; + for (p = w; p != NULL; p = p->_next) { + guarantee(p->TState == ObjectWaiter::TS_CXQ, "Invariant"); + p->TState = ObjectWaiter::TS_ENTER; + p->_prev = q; + q = p; } } @@ -1233,11 +1233,11 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { // context-switch rate. if (_succ != NULL) continue; - w = _EntryList ; + w = _EntryList; if (w != NULL) { - guarantee (w->TState == ObjectWaiter::TS_ENTER, "invariant") ; - ExitEpilog (Self, w) ; - return ; + guarantee(w->TState == ObjectWaiter::TS_ENTER, "invariant"); + ExitEpilog(Self, w); + return; } } } @@ -1275,22 +1275,22 @@ void ATTR ObjectMonitor::exit(bool not_suspended, TRAPS) { bool ObjectMonitor::ExitSuspendEquivalent (JavaThread * jSelf) { - int Mode = Knob_FastHSSEC ; + int Mode = Knob_FastHSSEC; if (Mode && !jSelf->is_external_suspend()) { - assert (jSelf->is_suspend_equivalent(), "invariant") ; - jSelf->clear_suspend_equivalent() ; - if (2 == Mode) OrderAccess::storeload() ; - if (!jSelf->is_external_suspend()) return false ; + assert(jSelf->is_suspend_equivalent(), "invariant"); + jSelf->clear_suspend_equivalent(); + if (2 == Mode) OrderAccess::storeload(); + if (!jSelf->is_external_suspend()) return false; // We raced a suspension -- fall thru into the slow path - TEVENT (ExitSuspendEquivalent - raced) ; - jSelf->set_suspend_equivalent() ; + TEVENT(ExitSuspendEquivalent - raced); + jSelf->set_suspend_equivalent(); } - return jSelf->handle_special_suspend_equivalent_condition() ; + return jSelf->handle_special_suspend_equivalent_condition(); } void ObjectMonitor::ExitEpilog (Thread * Self, ObjectWaiter * Wakee) { - assert (_owner == Self, "invariant") ; + assert(_owner == Self, "invariant"); // Exit protocol: // 1. ST _succ = wakee @@ -1298,28 +1298,28 @@ void ObjectMonitor::ExitEpilog (Thread * Self, ObjectWaiter * Wakee) { // 2. ST _owner = NULL // 3. unpark(wakee) - _succ = Knob_SuccEnabled ? Wakee->_thread : NULL ; - ParkEvent * Trigger = Wakee->_event ; + _succ = Knob_SuccEnabled ? Wakee->_thread : NULL; + ParkEvent * Trigger = Wakee->_event; // Hygiene -- once we've set _owner = NULL we can't safely dereference Wakee again. // The thread associated with Wakee may have grabbed the lock and "Wakee" may be // out-of-scope (non-extant). - Wakee = NULL ; + Wakee = NULL; // Drop the lock - OrderAccess::release_store_ptr (&_owner, NULL) ; - OrderAccess::fence() ; // ST _owner vs LD in unpark() + OrderAccess::release_store_ptr(&_owner, NULL); + OrderAccess::fence(); // ST _owner vs LD in unpark() if (SafepointSynchronize::do_call_back()) { - TEVENT (unpark before SAFEPOINT) ; + TEVENT(unpark before SAFEPOINT); } DTRACE_MONITOR_PROBE(contended__exit, this, object(), Self); - Trigger->unpark() ; + Trigger->unpark(); // Maintain stats and report events to JVMTI if (ObjectMonitor::_sync_Parks != NULL) { - ObjectMonitor::_sync_Parks->inc() ; + ObjectMonitor::_sync_Parks->inc(); } } @@ -1343,17 +1343,17 @@ intptr_t ObjectMonitor::complete_exit(TRAPS) { if (THREAD != _owner) { if (THREAD->is_lock_owned ((address)_owner)) { assert(_recursions == 0, "internal state error"); - _owner = THREAD ; /* Convert from basiclock addr to Thread addr */ - _recursions = 0 ; - OwnerIsThread = 1 ; + _owner = THREAD; /* Convert from basiclock addr to Thread addr */ + _recursions = 0; + OwnerIsThread = 1; } } guarantee(Self == _owner, "complete_exit not owner"); intptr_t save = _recursions; // record the old recursion count _recursions = 0; // set the recursion level to be 0 - exit (true, Self) ; // exit the monitor - guarantee (_owner != Self, "invariant"); + exit(true, Self); // exit the monitor + guarantee(_owner != Self, "invariant"); return save; } @@ -1365,8 +1365,8 @@ void ObjectMonitor::reenter(intptr_t recursions, TRAPS) { JavaThread *jt = (JavaThread *)THREAD; guarantee(_owner != Self, "reenter already owner"); - enter (THREAD); // enter the monitor - guarantee (_recursions == 0, "reenter recursion"); + enter(THREAD); // enter the monitor + guarantee(_recursions == 0, "reenter recursion"); _recursions = recursions; return; } @@ -1382,11 +1382,11 @@ void ObjectMonitor::reenter(intptr_t recursions, TRAPS) { do { \ if (THREAD != _owner) { \ if (THREAD->is_lock_owned((address) _owner)) { \ - _owner = THREAD ; /* Convert from basiclock addr to Thread addr */ \ + _owner = THREAD; /* Convert from basiclock addr to Thread addr */ \ _recursions = 0; \ - OwnerIsThread = 1 ; \ + OwnerIsThread = 1; \ } else { \ - TEVENT (Throw IMSX) ; \ + TEVENT(Throw IMSX); \ THROW(vmSymbols::java_lang_IllegalMonitorStateException()); \ } \ } \ @@ -1396,15 +1396,15 @@ void ObjectMonitor::reenter(intptr_t recursions, TRAPS) { // TODO-FIXME: remove check_slow() -- it's likely dead. void ObjectMonitor::check_slow(TRAPS) { - TEVENT (check_slow - throw IMSX) ; + TEVENT(check_slow - throw IMSX); assert(THREAD != _owner && !THREAD->is_lock_owned((address) _owner), "must not be owner"); THROW_MSG(vmSymbols::java_lang_IllegalMonitorStateException(), "current thread not owner"); } static int Adjust (volatile int * adr, int dx) { - int v ; - for (v = *adr ; Atomic::cmpxchg (v + dx, adr, v) != v; v = *adr) ; - return v ; + int v; + for (v = *adr; Atomic::cmpxchg(v + dx, adr, v) != v; v = *adr); + return v; } // helper method for posting a monitor wait event @@ -1426,11 +1426,11 @@ void ObjectMonitor::post_monitor_wait_event(EventJavaMonitorWait* event, // Note: a subset of changes to ObjectMonitor::wait() // will need to be replicated in complete_exit above void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { - Thread * const Self = THREAD ; + Thread * const Self = THREAD; assert(Self->is_Java_thread(), "Must be Java thread!"); JavaThread *jt = (JavaThread *)THREAD; - DeferredInitialize () ; + DeferredInitialize(); // Throw IMSX or IEX. CHECK_OWNER(); @@ -1456,23 +1456,23 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { if (event.should_commit()) { post_monitor_wait_event(&event, 0, millis, false); } - TEVENT (Wait - Throw IEX) ; + TEVENT(Wait - Throw IEX); THROW(vmSymbols::java_lang_InterruptedException()); - return ; + return; } - TEVENT (Wait) ; + TEVENT(Wait); - assert (Self->_Stalled == 0, "invariant") ; - Self->_Stalled = intptr_t(this) ; + assert(Self->_Stalled == 0, "invariant"); + Self->_Stalled = intptr_t(this); jt->set_current_waiting_monitor(this); // create a node to be put into the queue // Critically, after we reset() the event but prior to park(), we must check // for a pending interrupt. ObjectWaiter node(Self); - node.TState = ObjectWaiter::TS_WAIT ; - Self->_ParkEvent->reset() ; + node.TState = ObjectWaiter::TS_WAIT; + Self->_ParkEvent->reset(); OrderAccess::fence(); // ST into Event; membar ; LD interrupted-flag // Enter the waiting queue, which is a circular doubly linked list in this case @@ -1482,18 +1482,18 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { // returns because of a timeout of interrupt. Contention is exceptionally rare // so we use a simple spin-lock instead of a heavier-weight blocking lock. - Thread::SpinAcquire (&_WaitSetLock, "WaitSet - add") ; - AddWaiter (&node) ; - Thread::SpinRelease (&_WaitSetLock) ; + Thread::SpinAcquire(&_WaitSetLock, "WaitSet - add"); + AddWaiter(&node); + Thread::SpinRelease(&_WaitSetLock); if ((SyncFlags & 4) == 0) { - _Responsible = NULL ; + _Responsible = NULL; } intptr_t save = _recursions; // record the old recursion count _waiters++; // increment the number of waiters _recursions = 0; // set the recursion level to be 1 - exit (true, Self) ; // exit the monitor - guarantee (_owner != Self, "invariant") ; + exit(true, Self); // exit the monitor + guarantee(_owner != Self, "invariant"); // The thread is on the WaitSet list - now park() it. // On MP systems it's conceivable that a brief spin before we park @@ -1502,8 +1502,8 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { // TODO-FIXME: change the following logic to a loop of the form // while (!timeout && !interrupted && _notified == 0) park() - int ret = OS_OK ; - int WasNotified = 0 ; + int ret = OS_OK; + int WasNotified = 0; { // State transition wrappers OSThread* osthread = Self->osthread(); OSThreadWaitState osts(osthread, true); @@ -1517,9 +1517,9 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { } else if (node._notified == 0) { if (millis <= 0) { - Self->_ParkEvent->park () ; + Self->_ParkEvent->park(); } else { - ret = Self->_ParkEvent->park (millis) ; + ret = Self->_ParkEvent->park(millis); } } @@ -1548,23 +1548,23 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { // That is, we fail toward safety. if (node.TState == ObjectWaiter::TS_WAIT) { - Thread::SpinAcquire (&_WaitSetLock, "WaitSet - unlink") ; + Thread::SpinAcquire(&_WaitSetLock, "WaitSet - unlink"); if (node.TState == ObjectWaiter::TS_WAIT) { - DequeueSpecificWaiter (&node) ; // unlink from WaitSet + DequeueSpecificWaiter(&node); // unlink from WaitSet assert(node._notified == 0, "invariant"); - node.TState = ObjectWaiter::TS_RUN ; + node.TState = ObjectWaiter::TS_RUN; } - Thread::SpinRelease (&_WaitSetLock) ; + Thread::SpinRelease(&_WaitSetLock); } // The thread is now either on off-list (TS_RUN), // on the EntryList (TS_ENTER), or on the cxq (TS_CXQ). // The Node's TState variable is stable from the perspective of this thread. // No other threads will asynchronously modify TState. - guarantee (node.TState != ObjectWaiter::TS_WAIT, "invariant") ; - OrderAccess::loadload() ; - if (_succ == Self) _succ = NULL ; - WasNotified = node._notified ; + guarantee(node.TState != ObjectWaiter::TS_WAIT, "invariant"); + OrderAccess::loadload(); + if (_succ == Self) _succ = NULL; + WasNotified = node._notified; // Reentry phase -- reacquire the monitor. // re-enter contended monitor after object.wait(). @@ -1601,18 +1601,18 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { post_monitor_wait_event(&event, node._notifier_tid, millis, ret == OS_TIMEOUT); } - OrderAccess::fence() ; + OrderAccess::fence(); - assert (Self->_Stalled != 0, "invariant") ; - Self->_Stalled = 0 ; + assert(Self->_Stalled != 0, "invariant"); + Self->_Stalled = 0; - assert (_owner != Self, "invariant") ; - ObjectWaiter::TStates v = node.TState ; + assert(_owner != Self, "invariant"); + ObjectWaiter::TStates v = node.TState; if (v == ObjectWaiter::TS_RUN) { - enter (Self) ; + enter(Self); } else { - guarantee (v == ObjectWaiter::TS_ENTER || v == ObjectWaiter::TS_CXQ, "invariant") ; - ReenterI (Self, &node) ; + guarantee(v == ObjectWaiter::TS_ENTER || v == ObjectWaiter::TS_CXQ, "invariant"); + ReenterI(Self, &node); node.wait_reenter_end(this); } @@ -1620,24 +1620,24 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { // Lifecycle - the node representing Self must not appear on any queues. // Node is about to go out-of-scope, but even if it were immortal we wouldn't // want residual elements associated with this thread left on any lists. - guarantee (node.TState == ObjectWaiter::TS_RUN, "invariant") ; - assert (_owner == Self, "invariant") ; - assert (_succ != Self , "invariant") ; + guarantee(node.TState == ObjectWaiter::TS_RUN, "invariant"); + assert(_owner == Self, "invariant"); + assert(_succ != Self , "invariant"); } // OSThreadWaitState() jt->set_current_waiting_monitor(NULL); - guarantee (_recursions == 0, "invariant") ; + guarantee(_recursions == 0, "invariant"); _recursions = save; // restore the old recursion count _waiters--; // decrement the number of waiters // Verify a few postconditions - assert (_owner == Self , "invariant") ; - assert (_succ != Self , "invariant") ; - assert (((oop)(object()))->mark() == markOopDesc::encode(this), "invariant") ; + assert(_owner == Self , "invariant"); + assert(_succ != Self , "invariant"); + assert(((oop)(object()))->mark() == markOopDesc::encode(this), "invariant"); if (SyncFlags & 32) { - OrderAccess::fence() ; + OrderAccess::fence(); } // check if the notification happened @@ -1645,7 +1645,7 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { // no, it could be timeout or Thread.interrupt() or both // check for interrupt event, otherwise it is timeout if (interruptible && Thread::is_interrupted(Self, true) && !HAS_PENDING_EXCEPTION) { - TEVENT (Wait - throw IEX from epilog) ; + TEVENT(Wait - throw IEX from epilog); THROW(vmSymbols::java_lang_InterruptedException()); } } @@ -1663,99 +1663,99 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { void ObjectMonitor::notify(TRAPS) { CHECK_OWNER(); if (_WaitSet == NULL) { - TEVENT (Empty-Notify) ; - return ; + TEVENT(Empty-Notify); + return; } DTRACE_MONITOR_PROBE(notify, this, object(), THREAD); - int Policy = Knob_MoveNotifyee ; + int Policy = Knob_MoveNotifyee; - Thread::SpinAcquire (&_WaitSetLock, "WaitSet - notify") ; - ObjectWaiter * iterator = DequeueWaiter() ; + Thread::SpinAcquire(&_WaitSetLock, "WaitSet - notify"); + ObjectWaiter * iterator = DequeueWaiter(); if (iterator != NULL) { - TEVENT (Notify1 - Transfer) ; - guarantee (iterator->TState == ObjectWaiter::TS_WAIT, "invariant") ; - guarantee (iterator->_notified == 0, "invariant") ; + TEVENT(Notify1 - Transfer); + guarantee(iterator->TState == ObjectWaiter::TS_WAIT, "invariant"); + guarantee(iterator->_notified == 0, "invariant"); if (Policy != 4) { - iterator->TState = ObjectWaiter::TS_ENTER ; + iterator->TState = ObjectWaiter::TS_ENTER; } - iterator->_notified = 1 ; + iterator->_notified = 1; Thread * Self = THREAD; iterator->_notifier_tid = Self->osthread()->thread_id(); - ObjectWaiter * List = _EntryList ; + ObjectWaiter * List = _EntryList; if (List != NULL) { - assert (List->_prev == NULL, "invariant") ; - assert (List->TState == ObjectWaiter::TS_ENTER, "invariant") ; - assert (List != iterator, "invariant") ; + assert(List->_prev == NULL, "invariant"); + assert(List->TState == ObjectWaiter::TS_ENTER, "invariant"); + assert(List != iterator, "invariant"); } if (Policy == 0) { // prepend to EntryList if (List == NULL) { - iterator->_next = iterator->_prev = NULL ; - _EntryList = iterator ; + iterator->_next = iterator->_prev = NULL; + _EntryList = iterator; } else { - List->_prev = iterator ; - iterator->_next = List ; - iterator->_prev = NULL ; - _EntryList = iterator ; + List->_prev = iterator; + iterator->_next = List; + iterator->_prev = NULL; + _EntryList = iterator; } } else if (Policy == 1) { // append to EntryList if (List == NULL) { - iterator->_next = iterator->_prev = NULL ; - _EntryList = iterator ; + iterator->_next = iterator->_prev = NULL; + _EntryList = iterator; } else { // CONSIDER: finding the tail currently requires a linear-time walk of // the EntryList. We can make tail access constant-time by converting to // a CDLL instead of using our current DLL. - ObjectWaiter * Tail ; - for (Tail = List ; Tail->_next != NULL ; Tail = Tail->_next) ; - assert (Tail != NULL && Tail->_next == NULL, "invariant") ; - Tail->_next = iterator ; - iterator->_prev = Tail ; - iterator->_next = NULL ; + ObjectWaiter * Tail; + for (Tail = List; Tail->_next != NULL; Tail = Tail->_next); + assert(Tail != NULL && Tail->_next == NULL, "invariant"); + Tail->_next = iterator; + iterator->_prev = Tail; + iterator->_next = NULL; } } else if (Policy == 2) { // prepend to cxq // prepend to cxq if (List == NULL) { - iterator->_next = iterator->_prev = NULL ; - _EntryList = iterator ; + iterator->_next = iterator->_prev = NULL; + _EntryList = iterator; } else { - iterator->TState = ObjectWaiter::TS_CXQ ; + iterator->TState = ObjectWaiter::TS_CXQ; for (;;) { - ObjectWaiter * Front = _cxq ; - iterator->_next = Front ; + ObjectWaiter * Front = _cxq; + iterator->_next = Front; if (Atomic::cmpxchg_ptr (iterator, &_cxq, Front) == Front) { - break ; + break; } } } } else if (Policy == 3) { // append to cxq - iterator->TState = ObjectWaiter::TS_CXQ ; + iterator->TState = ObjectWaiter::TS_CXQ; for (;;) { - ObjectWaiter * Tail ; - Tail = _cxq ; + ObjectWaiter * Tail; + Tail = _cxq; if (Tail == NULL) { - iterator->_next = NULL ; + iterator->_next = NULL; if (Atomic::cmpxchg_ptr (iterator, &_cxq, NULL) == NULL) { - break ; + break; } } else { - while (Tail->_next != NULL) Tail = Tail->_next ; - Tail->_next = iterator ; - iterator->_prev = Tail ; - iterator->_next = NULL ; - break ; + while (Tail->_next != NULL) Tail = Tail->_next; + Tail->_next = iterator; + iterator->_prev = Tail; + iterator->_next = NULL; + break; } } } else { - ParkEvent * ev = iterator->_event ; - iterator->TState = ObjectWaiter::TS_RUN ; - OrderAccess::fence() ; - ev->unpark() ; + ParkEvent * ev = iterator->_event; + iterator->TState = ObjectWaiter::TS_RUN; + OrderAccess::fence(); + ev->unpark(); } if (Policy < 4) { @@ -1771,10 +1771,10 @@ void ObjectMonitor::notify(TRAPS) { // critical section. } - Thread::SpinRelease (&_WaitSetLock) ; + Thread::SpinRelease(&_WaitSetLock); if (iterator != NULL && ObjectMonitor::_sync_Notifications != NULL) { - ObjectMonitor::_sync_Notifications->inc() ; + ObjectMonitor::_sync_Notifications->inc(); } } @@ -1783,103 +1783,103 @@ void ObjectMonitor::notifyAll(TRAPS) { CHECK_OWNER(); ObjectWaiter* iterator; if (_WaitSet == NULL) { - TEVENT (Empty-NotifyAll) ; - return ; + TEVENT(Empty-NotifyAll); + return; } DTRACE_MONITOR_PROBE(notifyAll, this, object(), THREAD); - int Policy = Knob_MoveNotifyee ; - int Tally = 0 ; - Thread::SpinAcquire (&_WaitSetLock, "WaitSet - notifyall") ; + int Policy = Knob_MoveNotifyee; + int Tally = 0; + Thread::SpinAcquire(&_WaitSetLock, "WaitSet - notifyall"); for (;;) { - iterator = DequeueWaiter () ; - if (iterator == NULL) break ; - TEVENT (NotifyAll - Transfer1) ; - ++Tally ; + iterator = DequeueWaiter(); + if (iterator == NULL) break; + TEVENT(NotifyAll - Transfer1); + ++Tally; // Disposition - what might we do with iterator ? // a. add it directly to the EntryList - either tail or head. // b. push it onto the front of the _cxq. // For now we use (a). - guarantee (iterator->TState == ObjectWaiter::TS_WAIT, "invariant") ; - guarantee (iterator->_notified == 0, "invariant") ; - iterator->_notified = 1 ; + guarantee(iterator->TState == ObjectWaiter::TS_WAIT, "invariant"); + guarantee(iterator->_notified == 0, "invariant"); + iterator->_notified = 1; Thread * Self = THREAD; iterator->_notifier_tid = Self->osthread()->thread_id(); if (Policy != 4) { - iterator->TState = ObjectWaiter::TS_ENTER ; + iterator->TState = ObjectWaiter::TS_ENTER; } - ObjectWaiter * List = _EntryList ; + ObjectWaiter * List = _EntryList; if (List != NULL) { - assert (List->_prev == NULL, "invariant") ; - assert (List->TState == ObjectWaiter::TS_ENTER, "invariant") ; - assert (List != iterator, "invariant") ; + assert(List->_prev == NULL, "invariant"); + assert(List->TState == ObjectWaiter::TS_ENTER, "invariant"); + assert(List != iterator, "invariant"); } if (Policy == 0) { // prepend to EntryList if (List == NULL) { - iterator->_next = iterator->_prev = NULL ; - _EntryList = iterator ; + iterator->_next = iterator->_prev = NULL; + _EntryList = iterator; } else { - List->_prev = iterator ; - iterator->_next = List ; - iterator->_prev = NULL ; - _EntryList = iterator ; + List->_prev = iterator; + iterator->_next = List; + iterator->_prev = NULL; + _EntryList = iterator; } } else if (Policy == 1) { // append to EntryList if (List == NULL) { - iterator->_next = iterator->_prev = NULL ; - _EntryList = iterator ; + iterator->_next = iterator->_prev = NULL; + _EntryList = iterator; } else { // CONSIDER: finding the tail currently requires a linear-time walk of // the EntryList. We can make tail access constant-time by converting to // a CDLL instead of using our current DLL. - ObjectWaiter * Tail ; - for (Tail = List ; Tail->_next != NULL ; Tail = Tail->_next) ; - assert (Tail != NULL && Tail->_next == NULL, "invariant") ; - Tail->_next = iterator ; - iterator->_prev = Tail ; - iterator->_next = NULL ; + ObjectWaiter * Tail; + for (Tail = List; Tail->_next != NULL; Tail = Tail->_next); + assert(Tail != NULL && Tail->_next == NULL, "invariant"); + Tail->_next = iterator; + iterator->_prev = Tail; + iterator->_next = NULL; } } else if (Policy == 2) { // prepend to cxq // prepend to cxq - iterator->TState = ObjectWaiter::TS_CXQ ; + iterator->TState = ObjectWaiter::TS_CXQ; for (;;) { - ObjectWaiter * Front = _cxq ; - iterator->_next = Front ; + ObjectWaiter * Front = _cxq; + iterator->_next = Front; if (Atomic::cmpxchg_ptr (iterator, &_cxq, Front) == Front) { - break ; + break; } } } else if (Policy == 3) { // append to cxq - iterator->TState = ObjectWaiter::TS_CXQ ; + iterator->TState = ObjectWaiter::TS_CXQ; for (;;) { - ObjectWaiter * Tail ; - Tail = _cxq ; + ObjectWaiter * Tail; + Tail = _cxq; if (Tail == NULL) { - iterator->_next = NULL ; + iterator->_next = NULL; if (Atomic::cmpxchg_ptr (iterator, &_cxq, NULL) == NULL) { - break ; + break; } } else { - while (Tail->_next != NULL) Tail = Tail->_next ; - Tail->_next = iterator ; - iterator->_prev = Tail ; - iterator->_next = NULL ; - break ; + while (Tail->_next != NULL) Tail = Tail->_next; + Tail->_next = iterator; + iterator->_prev = Tail; + iterator->_next = NULL; + break; } } } else { - ParkEvent * ev = iterator->_event ; - iterator->TState = ObjectWaiter::TS_RUN ; - OrderAccess::fence() ; - ev->unpark() ; + ParkEvent * ev = iterator->_event; + iterator->TState = ObjectWaiter::TS_RUN; + OrderAccess::fence(); + ev->unpark(); } if (Policy < 4) { @@ -1895,10 +1895,10 @@ void ObjectMonitor::notifyAll(TRAPS) { // critical section. } - Thread::SpinRelease (&_WaitSetLock) ; + Thread::SpinRelease(&_WaitSetLock); if (Tally != 0 && ObjectMonitor::_sync_Notifications != NULL) { - ObjectMonitor::_sync_Notifications->inc(Tally) ; + ObjectMonitor::_sync_Notifications->inc(Tally); } } @@ -1968,8 +1968,8 @@ void ObjectMonitor::notifyAll(TRAPS) { // not spinning. // -intptr_t ObjectMonitor::SpinCallbackArgument = 0 ; -int (*ObjectMonitor::SpinCallbackFunction)(intptr_t, int) = NULL ; +intptr_t ObjectMonitor::SpinCallbackArgument = 0; +int (*ObjectMonitor::SpinCallbackFunction)(intptr_t, int) = NULL; // Spinning: Fixed frequency (100%), vary duration @@ -1977,28 +1977,28 @@ int (*ObjectMonitor::SpinCallbackFunction)(intptr_t, int) = NULL ; int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // Dumb, brutal spin. Good for comparative measurements against adaptive spinning. - int ctr = Knob_FixedSpin ; + int ctr = Knob_FixedSpin; if (ctr != 0) { while (--ctr >= 0) { - if (TryLock (Self) > 0) return 1 ; - SpinPause () ; + if (TryLock(Self) > 0) return 1; + SpinPause(); } - return 0 ; + return 0; } - for (ctr = Knob_PreSpin + 1; --ctr >= 0 ; ) { + for (ctr = Knob_PreSpin + 1; --ctr >= 0;) { if (TryLock(Self) > 0) { // Increase _SpinDuration ... // Note that we don't clamp SpinDuration precisely at SpinLimit. // Raising _SpurDuration to the poverty line is key. - int x = _SpinDuration ; + int x = _SpinDuration; if (x < Knob_SpinLimit) { - if (x < Knob_Poverty) x = Knob_Poverty ; - _SpinDuration = x + Knob_BonusB ; + if (x < Knob_Poverty) x = Knob_Poverty; + _SpinDuration = x + Knob_BonusB; } - return 1 ; + return 1; } - SpinPause () ; + SpinPause(); } // Admission control - verify preconditions for spinning @@ -2015,37 +2015,37 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // This takes us into the realm of 1-out-of-N spinning, where we // hold the duration constant but vary the frequency. - ctr = _SpinDuration ; - if (ctr < Knob_SpinBase) ctr = Knob_SpinBase ; - if (ctr <= 0) return 0 ; + ctr = _SpinDuration; + if (ctr < Knob_SpinBase) ctr = Knob_SpinBase; + if (ctr <= 0) return 0; - if (Knob_SuccRestrict && _succ != NULL) return 0 ; + if (Knob_SuccRestrict && _succ != NULL) return 0; if (Knob_OState && NotRunnable (Self, (Thread *) _owner)) { - TEVENT (Spin abort - notrunnable [TOP]); - return 0 ; + TEVENT(Spin abort - notrunnable [TOP]); + return 0; } - int MaxSpin = Knob_MaxSpinners ; + int MaxSpin = Knob_MaxSpinners; if (MaxSpin >= 0) { if (_Spinner > MaxSpin) { - TEVENT (Spin abort -- too many spinners) ; - return 0 ; + TEVENT(Spin abort -- too many spinners); + return 0; } // Slightly racy, but benign ... - Adjust (&_Spinner, 1) ; + Adjust(&_Spinner, 1); } // We're good to spin ... spin ingress. // CONSIDER: use Prefetch::write() to avoid RTS->RTO upgrades // when preparing to LD...CAS _owner, etc and the CAS is likely // to succeed. - int hits = 0 ; - int msk = 0 ; - int caspty = Knob_CASPenalty ; - int oxpty = Knob_OXPenalty ; - int sss = Knob_SpinSetSucc ; - if (sss && _succ == NULL ) _succ = Self ; - Thread * prv = NULL ; + int hits = 0; + int msk = 0; + int caspty = Knob_CASPenalty; + int oxpty = Knob_OXPenalty; + int sss = Knob_SpinSetSucc; + if (sss && _succ == NULL) _succ = Self; + Thread * prv = NULL; // There are three ways to exit the following loop: // 1. A successful spin where this thread has acquired the lock. @@ -2065,18 +2065,18 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // We periodically check to see if there's a safepoint pending. if ((ctr & 0xFF) == 0) { if (SafepointSynchronize::do_call_back()) { - TEVENT (Spin: safepoint) ; - goto Abort ; // abrupt spin egress + TEVENT(Spin: safepoint); + goto Abort; // abrupt spin egress } - if (Knob_UsePause & 1) SpinPause () ; + if (Knob_UsePause & 1) SpinPause(); - int (*scb)(intptr_t,int) = SpinCallbackFunction ; + int (*scb)(intptr_t,int) = SpinCallbackFunction; if (hits > 50 && scb != NULL) { - int abend = (*scb)(SpinCallbackArgument, 0) ; + int abend = (*scb)(SpinCallbackArgument, 0); } } - if (Knob_UsePause & 2) SpinPause() ; + if (Knob_UsePause & 2) SpinPause(); // Exponential back-off ... Stay off the bus to reduce coherency traffic. // This is useful on classic SMP systems, but is of less utility on @@ -2093,12 +2093,12 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // coherency bandwidth. Relatedly, if we _oversample _owner we // can inadvertently interfere with the the ST m->owner=null. // executed by the lock owner. - if (ctr & msk) continue ; - ++hits ; + if (ctr & msk) continue; + ++hits; if ((hits & 0xF) == 0) { // The 0xF, above, corresponds to the exponent. // Consider: (msk+1)|msk - msk = ((msk << 2)|3) & BackOffMask ; + msk = ((msk << 2)|3) & BackOffMask; } // Probe _owner with TATAS @@ -2111,16 +2111,16 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // the spin without prejudice or apply a "penalty" to the // spin count-down variable "ctr", reducing it by 100, say. - Thread * ox = (Thread *) _owner ; + Thread * ox = (Thread *) _owner; if (ox == NULL) { - ox = (Thread *) Atomic::cmpxchg_ptr (Self, &_owner, NULL) ; + ox = (Thread *) Atomic::cmpxchg_ptr(Self, &_owner, NULL); if (ox == NULL) { // The CAS succeeded -- this thread acquired ownership // Take care of some bookkeeping to exit spin state. if (sss && _succ == Self) { - _succ = NULL ; + _succ = NULL; } - if (MaxSpin > 0) Adjust (&_Spinner, -1) ; + if (MaxSpin > 0) Adjust(&_Spinner, -1); // Increase _SpinDuration : // The spin was successful (profitable) so we tend toward @@ -2129,12 +2129,12 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // If we acquired the lock early in the spin cycle it // makes sense to increase _SpinDuration proportionally. // Note that we don't clamp SpinDuration precisely at SpinLimit. - int x = _SpinDuration ; + int x = _SpinDuration; if (x < Knob_SpinLimit) { - if (x < Knob_Poverty) x = Knob_Poverty ; - _SpinDuration = x + Knob_Bonus ; + if (x < Knob_Poverty) x = Knob_Poverty; + _SpinDuration = x + Knob_Bonus; } - return 1 ; + return 1; } // The CAS failed ... we can take any of the following actions: @@ -2142,61 +2142,61 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { // * exit spin with prejudice -- goto Abort; // * exit spin without prejudice. // * Since CAS is high-latency, retry again immediately. - prv = ox ; - TEVENT (Spin: cas failed) ; - if (caspty == -2) break ; - if (caspty == -1) goto Abort ; - ctr -= caspty ; - continue ; + prv = ox; + TEVENT(Spin: cas failed); + if (caspty == -2) break; + if (caspty == -1) goto Abort; + ctr -= caspty; + continue; } // Did lock ownership change hands ? - if (ox != prv && prv != NULL ) { - TEVENT (spin: Owner changed) - if (oxpty == -2) break ; - if (oxpty == -1) goto Abort ; - ctr -= oxpty ; + if (ox != prv && prv != NULL) { + TEVENT(spin: Owner changed) + if (oxpty == -2) break; + if (oxpty == -1) goto Abort; + ctr -= oxpty; } - prv = ox ; + prv = ox; // Abort the spin if the owner is not executing. // The owner must be executing in order to drop the lock. // Spinning while the owner is OFFPROC is idiocy. // Consider: ctr -= RunnablePenalty ; if (Knob_OState && NotRunnable (Self, ox)) { - TEVENT (Spin abort - notrunnable); - goto Abort ; + TEVENT(Spin abort - notrunnable); + goto Abort; } - if (sss && _succ == NULL ) _succ = Self ; + if (sss && _succ == NULL) _succ = Self; } // Spin failed with prejudice -- reduce _SpinDuration. // TODO: Use an AIMD-like policy to adjust _SpinDuration. // AIMD is globally stable. - TEVENT (Spin failure) ; + TEVENT(Spin failure); { - int x = _SpinDuration ; + int x = _SpinDuration; if (x > 0) { // Consider an AIMD scheme like: x -= (x >> 3) + 100 // This is globally sample and tends to damp the response. - x -= Knob_Penalty ; - if (x < 0) x = 0 ; - _SpinDuration = x ; + x -= Knob_Penalty; + if (x < 0) x = 0; + _SpinDuration = x; } } Abort: - if (MaxSpin >= 0) Adjust (&_Spinner, -1) ; + if (MaxSpin >= 0) Adjust(&_Spinner, -1); if (sss && _succ == Self) { - _succ = NULL ; + _succ = NULL; // Invariant: after setting succ=null a contending thread // must recheck-retry _owner before parking. This usually happens // in the normal usage of TrySpin(), but it's safest // to make TrySpin() as foolproof as possible. - OrderAccess::fence() ; - if (TryLock(Self) > 0) return 1 ; + OrderAccess::fence(); + if (TryLock(Self) > 0) return 1; } - return 0 ; + return 0; } // NotRunnable() -- informed spinning @@ -2240,9 +2240,9 @@ int ObjectMonitor::TrySpin_VaryDuration (Thread * Self) { int ObjectMonitor::NotRunnable (Thread * Self, Thread * ox) { // Check either OwnerIsThread or ox->TypeTag == 2BAD. - if (!OwnerIsThread) return 0 ; + if (!OwnerIsThread) return 0; - if (ox == NULL) return 0 ; + if (ox == NULL) return 0; // Avoid transitive spinning ... // Say T1 spins or blocks trying to acquire L. T1._Stalled is set to L. @@ -2251,17 +2251,17 @@ int ObjectMonitor::NotRunnable (Thread * Self, Thread * ox) { // This occurs transiently after T1 acquired L but before // T1 managed to clear T1.Stalled. T2 does not need to abort // its spin in this circumstance. - intptr_t BlockedOn = SafeFetchN ((intptr_t *) &ox->_Stalled, intptr_t(1)) ; + intptr_t BlockedOn = SafeFetchN((intptr_t *) &ox->_Stalled, intptr_t(1)); - if (BlockedOn == 1) return 1 ; + if (BlockedOn == 1) return 1; if (BlockedOn != 0) { - return BlockedOn != intptr_t(this) && _owner == ox ; + return BlockedOn != intptr_t(this) && _owner == ox; } - assert (sizeof(((JavaThread *)ox)->_thread_state == sizeof(int)), "invariant") ; - int jst = SafeFetch32 ((int *) &((JavaThread *) ox)->_thread_state, -1) ; ; + assert(sizeof(((JavaThread *)ox)->_thread_state == sizeof(int)), "invariant"); + int jst = SafeFetch32((int *) &((JavaThread *) ox)->_thread_state, -1);; // consider also: jst != _thread_in_Java -- but that's overspecific. - return jst == _thread_blocked || jst == _thread_in_native ; + return jst == _thread_blocked || jst == _thread_in_native; } @@ -2272,11 +2272,11 @@ ObjectWaiter::ObjectWaiter(Thread* thread) { _next = NULL; _prev = NULL; _notified = 0; - TState = TS_RUN ; + TState = TS_RUN; _thread = thread; - _event = thread->_ParkEvent ; + _event = thread->_ParkEvent; _active = false; - assert (_event != NULL, "invariant") ; + assert(_event != NULL, "invariant"); } void ObjectWaiter::wait_reenter_begin(ObjectMonitor *mon) { @@ -2299,7 +2299,7 @@ inline void ObjectMonitor::AddWaiter(ObjectWaiter* node) { node->_prev = node; node->_next = node; } else { - ObjectWaiter* head = _WaitSet ; + ObjectWaiter* head = _WaitSet; ObjectWaiter* tail = head->_prev; assert(tail->_next == head, "invariant check"); tail->_next = node; @@ -2345,56 +2345,56 @@ inline void ObjectMonitor::DequeueSpecificWaiter(ObjectWaiter* node) { // ----------------------------------------------------------------------------- // PerfData support -PerfCounter * ObjectMonitor::_sync_ContendedLockAttempts = NULL ; -PerfCounter * ObjectMonitor::_sync_FutileWakeups = NULL ; -PerfCounter * ObjectMonitor::_sync_Parks = NULL ; -PerfCounter * ObjectMonitor::_sync_EmptyNotifications = NULL ; -PerfCounter * ObjectMonitor::_sync_Notifications = NULL ; -PerfCounter * ObjectMonitor::_sync_PrivateA = NULL ; -PerfCounter * ObjectMonitor::_sync_PrivateB = NULL ; -PerfCounter * ObjectMonitor::_sync_SlowExit = NULL ; -PerfCounter * ObjectMonitor::_sync_SlowEnter = NULL ; -PerfCounter * ObjectMonitor::_sync_SlowNotify = NULL ; -PerfCounter * ObjectMonitor::_sync_SlowNotifyAll = NULL ; -PerfCounter * ObjectMonitor::_sync_FailedSpins = NULL ; -PerfCounter * ObjectMonitor::_sync_SuccessfulSpins = NULL ; -PerfCounter * ObjectMonitor::_sync_MonInCirculation = NULL ; -PerfCounter * ObjectMonitor::_sync_MonScavenged = NULL ; -PerfCounter * ObjectMonitor::_sync_Inflations = NULL ; -PerfCounter * ObjectMonitor::_sync_Deflations = NULL ; -PerfLongVariable * ObjectMonitor::_sync_MonExtant = NULL ; +PerfCounter * ObjectMonitor::_sync_ContendedLockAttempts = NULL; +PerfCounter * ObjectMonitor::_sync_FutileWakeups = NULL; +PerfCounter * ObjectMonitor::_sync_Parks = NULL; +PerfCounter * ObjectMonitor::_sync_EmptyNotifications = NULL; +PerfCounter * ObjectMonitor::_sync_Notifications = NULL; +PerfCounter * ObjectMonitor::_sync_PrivateA = NULL; +PerfCounter * ObjectMonitor::_sync_PrivateB = NULL; +PerfCounter * ObjectMonitor::_sync_SlowExit = NULL; +PerfCounter * ObjectMonitor::_sync_SlowEnter = NULL; +PerfCounter * ObjectMonitor::_sync_SlowNotify = NULL; +PerfCounter * ObjectMonitor::_sync_SlowNotifyAll = NULL; +PerfCounter * ObjectMonitor::_sync_FailedSpins = NULL; +PerfCounter * ObjectMonitor::_sync_SuccessfulSpins = NULL; +PerfCounter * ObjectMonitor::_sync_MonInCirculation = NULL; +PerfCounter * ObjectMonitor::_sync_MonScavenged = NULL; +PerfCounter * ObjectMonitor::_sync_Inflations = NULL; +PerfCounter * ObjectMonitor::_sync_Deflations = NULL; +PerfLongVariable * ObjectMonitor::_sync_MonExtant = NULL; // One-shot global initialization for the sync subsystem. // We could also defer initialization and initialize on-demand // the first time we call inflate(). Initialization would // be protected - like so many things - by the MonitorCache_lock. -void ObjectMonitor::Initialize () { - static int InitializationCompleted = 0 ; - assert (InitializationCompleted == 0, "invariant") ; - InitializationCompleted = 1 ; +void ObjectMonitor::Initialize() { + static int InitializationCompleted = 0; + assert(InitializationCompleted == 0, "invariant"); + InitializationCompleted = 1; if (UsePerfData) { - EXCEPTION_MARK ; + EXCEPTION_MARK; #define NEWPERFCOUNTER(n) {n = PerfDataManager::create_counter(SUN_RT, #n, PerfData::U_Events,CHECK); } #define NEWPERFVARIABLE(n) {n = PerfDataManager::create_variable(SUN_RT, #n, PerfData::U_Events,CHECK); } - NEWPERFCOUNTER(_sync_Inflations) ; - NEWPERFCOUNTER(_sync_Deflations) ; - NEWPERFCOUNTER(_sync_ContendedLockAttempts) ; - NEWPERFCOUNTER(_sync_FutileWakeups) ; - NEWPERFCOUNTER(_sync_Parks) ; - NEWPERFCOUNTER(_sync_EmptyNotifications) ; - NEWPERFCOUNTER(_sync_Notifications) ; - NEWPERFCOUNTER(_sync_SlowEnter) ; - NEWPERFCOUNTER(_sync_SlowExit) ; - NEWPERFCOUNTER(_sync_SlowNotify) ; - NEWPERFCOUNTER(_sync_SlowNotifyAll) ; - NEWPERFCOUNTER(_sync_FailedSpins) ; - NEWPERFCOUNTER(_sync_SuccessfulSpins) ; - NEWPERFCOUNTER(_sync_PrivateA) ; - NEWPERFCOUNTER(_sync_PrivateB) ; - NEWPERFCOUNTER(_sync_MonInCirculation) ; - NEWPERFCOUNTER(_sync_MonScavenged) ; - NEWPERFVARIABLE(_sync_MonExtant) ; + NEWPERFCOUNTER(_sync_Inflations); + NEWPERFCOUNTER(_sync_Deflations); + NEWPERFCOUNTER(_sync_ContendedLockAttempts); + NEWPERFCOUNTER(_sync_FutileWakeups); + NEWPERFCOUNTER(_sync_Parks); + NEWPERFCOUNTER(_sync_EmptyNotifications); + NEWPERFCOUNTER(_sync_Notifications); + NEWPERFCOUNTER(_sync_SlowEnter); + NEWPERFCOUNTER(_sync_SlowExit); + NEWPERFCOUNTER(_sync_SlowNotify); + NEWPERFCOUNTER(_sync_SlowNotifyAll); + NEWPERFCOUNTER(_sync_FailedSpins); + NEWPERFCOUNTER(_sync_SuccessfulSpins); + NEWPERFCOUNTER(_sync_PrivateA); + NEWPERFCOUNTER(_sync_PrivateB); + NEWPERFCOUNTER(_sync_MonInCirculation); + NEWPERFCOUNTER(_sync_MonScavenged); + NEWPERFVARIABLE(_sync_MonExtant); #undef NEWPERFCOUNTER } } @@ -2414,33 +2414,33 @@ void ObjectMonitor::ctAsserts() { static char * kvGet (char * kvList, const char * Key) { - if (kvList == NULL) return NULL ; - size_t n = strlen (Key) ; - char * Search ; - for (Search = kvList ; *Search ; Search += strlen(Search) + 1) { + if (kvList == NULL) return NULL; + size_t n = strlen(Key); + char * Search; + for (Search = kvList; *Search; Search += strlen(Search) + 1) { if (strncmp (Search, Key, n) == 0) { - if (Search[n] == '=') return Search + n + 1 ; - if (Search[n] == 0) return (char *) "1" ; + if (Search[n] == '=') return Search + n + 1; + if (Search[n] == 0) return(char *) "1"; } } - return NULL ; + return NULL; } static int kvGetInt (char * kvList, const char * Key, int Default) { - char * v = kvGet (kvList, Key) ; - int rslt = v ? ::strtol (v, NULL, 0) : Default ; + char * v = kvGet(kvList, Key); + int rslt = v ? ::strtol(v, NULL, 0) : Default; if (Knob_ReportSettings && v != NULL) { ::printf (" SyncKnob: %s %d(%d)\n", Key, rslt, Default) ; - ::fflush (stdout) ; + ::fflush(stdout); } - return rslt ; + return rslt; } -void ObjectMonitor::DeferredInitialize () { - if (InitDone > 0) return ; +void ObjectMonitor::DeferredInitialize() { + if (InitDone > 0) return; if (Atomic::cmpxchg (-1, &InitDone, 0) != 0) { - while (InitDone != 1) ; - return ; + while (InitDone != 1); + return; } // One-shot global initialization ... @@ -2449,68 +2449,68 @@ void ObjectMonitor::DeferredInitialize () { // SyncKnobs consist of = pairs in the style // of environment variables. Start by converting ':' to NUL. - if (SyncKnobs == NULL) SyncKnobs = "" ; + if (SyncKnobs == NULL) SyncKnobs = ""; - size_t sz = strlen (SyncKnobs) ; - char * knobs = (char *) malloc (sz + 2) ; + size_t sz = strlen(SyncKnobs); + char * knobs = (char *) malloc(sz + 2); if (knobs == NULL) { - vm_exit_out_of_memory (sz + 2, OOM_MALLOC_ERROR, "Parse SyncKnobs") ; - guarantee (0, "invariant") ; + vm_exit_out_of_memory(sz + 2, OOM_MALLOC_ERROR, "Parse SyncKnobs"); + guarantee(0, "invariant"); } - strcpy (knobs, SyncKnobs) ; - knobs[sz+1] = 0 ; - for (char * p = knobs ; *p ; p++) { - if (*p == ':') *p = 0 ; + strcpy(knobs, SyncKnobs); + knobs[sz+1] = 0; + for (char * p = knobs; *p; p++) { + if (*p == ':') *p = 0; } #define SETKNOB(x) { Knob_##x = kvGetInt (knobs, #x, Knob_##x); } - SETKNOB(ReportSettings) ; - SETKNOB(Verbose) ; - SETKNOB(FixedSpin) ; - SETKNOB(SpinLimit) ; - SETKNOB(SpinBase) ; + SETKNOB(ReportSettings); + SETKNOB(Verbose); + SETKNOB(FixedSpin); + SETKNOB(SpinLimit); + SETKNOB(SpinBase); SETKNOB(SpinBackOff); - SETKNOB(CASPenalty) ; - SETKNOB(OXPenalty) ; - SETKNOB(LogSpins) ; - SETKNOB(SpinSetSucc) ; - SETKNOB(SuccEnabled) ; - SETKNOB(SuccRestrict) ; - SETKNOB(Penalty) ; - SETKNOB(Bonus) ; - SETKNOB(BonusB) ; - SETKNOB(Poverty) ; - SETKNOB(SpinAfterFutile) ; - SETKNOB(UsePause) ; - SETKNOB(SpinEarly) ; - SETKNOB(OState) ; - SETKNOB(MaxSpinners) ; - SETKNOB(PreSpin) ; - SETKNOB(ExitPolicy) ; + SETKNOB(CASPenalty); + SETKNOB(OXPenalty); + SETKNOB(LogSpins); + SETKNOB(SpinSetSucc); + SETKNOB(SuccEnabled); + SETKNOB(SuccRestrict); + SETKNOB(Penalty); + SETKNOB(Bonus); + SETKNOB(BonusB); + SETKNOB(Poverty); + SETKNOB(SpinAfterFutile); + SETKNOB(UsePause); + SETKNOB(SpinEarly); + SETKNOB(OState); + SETKNOB(MaxSpinners); + SETKNOB(PreSpin); + SETKNOB(ExitPolicy); SETKNOB(QMode); - SETKNOB(ResetEvent) ; - SETKNOB(MoveNotifyee) ; - SETKNOB(FastHSSEC) ; + SETKNOB(ResetEvent); + SETKNOB(MoveNotifyee); + SETKNOB(FastHSSEC); #undef SETKNOB if (os::is_MP()) { - BackOffMask = (1 << Knob_SpinBackOff) - 1 ; - if (Knob_ReportSettings) ::printf ("BackOffMask=%X\n", BackOffMask) ; + BackOffMask = (1 << Knob_SpinBackOff) - 1; + if (Knob_ReportSettings) ::printf("BackOffMask=%X\n", BackOffMask); // CONSIDER: BackOffMask = ROUNDUP_NEXT_POWER2 (ncpus-1) } else { - Knob_SpinLimit = 0 ; - Knob_SpinBase = 0 ; - Knob_PreSpin = 0 ; - Knob_FixedSpin = -1 ; + Knob_SpinLimit = 0; + Knob_SpinBase = 0; + Knob_PreSpin = 0; + Knob_FixedSpin = -1; } if (Knob_LogSpins == 0) { - ObjectMonitor::_sync_FailedSpins = NULL ; + ObjectMonitor::_sync_FailedSpins = NULL; } - free (knobs) ; - OrderAccess::fence() ; - InitDone = 1 ; + free(knobs); + OrderAccess::fence(); + InitDone = 1; } #ifndef PRODUCT diff --git a/hotspot/src/share/vm/runtime/objectMonitor.hpp b/hotspot/src/share/vm/runtime/objectMonitor.hpp index 5a2756826cb..9feaf7b8a90 100644 --- a/hotspot/src/share/vm/runtime/objectMonitor.hpp +++ b/hotspot/src/share/vm/runtime/objectMonitor.hpp @@ -37,17 +37,17 @@ class ObjectWaiter : public StackObj { public: - enum TStates { TS_UNDEF, TS_READY, TS_RUN, TS_WAIT, TS_ENTER, TS_CXQ } ; - enum Sorted { PREPEND, APPEND, SORTED } ; + enum TStates { TS_UNDEF, TS_READY, TS_RUN, TS_WAIT, TS_ENTER, TS_CXQ }; + enum Sorted { PREPEND, APPEND, SORTED }; ObjectWaiter * volatile _next; ObjectWaiter * volatile _prev; Thread* _thread; jlong _notifier_tid; ParkEvent * _event; - volatile int _notified ; - volatile TStates TState ; - Sorted _Sorted ; // List placement disposition - bool _active ; // Contention monitoring is enabled + volatile int _notified; + volatile TStates TState; + Sorted _Sorted; // List placement disposition + bool _active; // Contention monitoring is enabled public: ObjectWaiter(Thread* thread); @@ -92,19 +92,19 @@ class ObjectMonitor { static int owner_offset_in_bytes() { return offset_of(ObjectMonitor, _owner); } static int count_offset_in_bytes() { return offset_of(ObjectMonitor, _count); } static int recursions_offset_in_bytes() { return offset_of(ObjectMonitor, _recursions); } - static int cxq_offset_in_bytes() { return offset_of(ObjectMonitor, _cxq) ; } - static int succ_offset_in_bytes() { return offset_of(ObjectMonitor, _succ) ; } + static int cxq_offset_in_bytes() { return offset_of(ObjectMonitor, _cxq); } + static int succ_offset_in_bytes() { return offset_of(ObjectMonitor, _succ); } static int EntryList_offset_in_bytes() { return offset_of(ObjectMonitor, _EntryList); } static int FreeNext_offset_in_bytes() { return offset_of(ObjectMonitor, FreeNext); } - static int WaitSet_offset_in_bytes() { return offset_of(ObjectMonitor, _WaitSet) ; } - static int Responsible_offset_in_bytes() { return offset_of(ObjectMonitor, _Responsible);} + static int WaitSet_offset_in_bytes() { return offset_of(ObjectMonitor, _WaitSet); } + static int Responsible_offset_in_bytes() { return offset_of(ObjectMonitor, _Responsible); } static int Spinner_offset_in_bytes() { return offset_of(ObjectMonitor, _Spinner); } public: // Eventually we'll make provisions for multiple callbacks, but // now one will suffice. - static int (*SpinCallbackFunction)(intptr_t, int) ; - static intptr_t SpinCallbackArgument ; + static int (*SpinCallbackFunction)(intptr_t, int); + static intptr_t SpinCallbackArgument; public: @@ -115,7 +115,7 @@ class ObjectMonitor { // TODO-FIXME: merge _count and _waiters. // TODO-FIXME: assert _owner == null implies _recursions = 0 // TODO-FIXME: assert _WaitSet != null implies _count > 0 - return _count|_waiters|intptr_t(_owner)|intptr_t(_cxq)|intptr_t(_EntryList ) ; + return _count|_waiters|intptr_t(_owner)|intptr_t(_cxq)|intptr_t(_EntryList); } intptr_t is_entered(Thread* current) const; @@ -127,7 +127,7 @@ class ObjectMonitor { intptr_t count() const; void set_count(intptr_t count); - intptr_t contentions() const ; + intptr_t contentions() const; intptr_t recursions() const { return _recursions; } // JVM/DI GetMonitorInfo() needs this @@ -145,15 +145,15 @@ class ObjectMonitor { _object = NULL; _owner = NULL; _WaitSet = NULL; - _WaitSetLock = 0 ; - _Responsible = NULL ; - _succ = NULL ; - _cxq = NULL ; - FreeNext = NULL ; - _EntryList = NULL ; - _SpinFreq = 0 ; - _SpinClock = 0 ; - OwnerIsThread = 0 ; + _WaitSetLock = 0; + _Responsible = NULL; + _succ = NULL; + _cxq = NULL; + FreeNext = NULL; + _EntryList = NULL; + _SpinFreq = 0; + _SpinClock = 0; + OwnerIsThread = 0; _previous_owner_tid = 0; } @@ -164,20 +164,20 @@ class ObjectMonitor { } private: - void Recycle () { + void Recycle() { // TODO: add stronger asserts ... // _cxq == 0 _succ == NULL _owner == NULL _waiters == 0 // _count == 0 EntryList == NULL // _recursions == 0 _WaitSet == NULL // TODO: assert (is_busy()|_recursions) == 0 - _succ = NULL ; - _EntryList = NULL ; - _cxq = NULL ; - _WaitSet = NULL ; - _recursions = 0 ; - _SpinFreq = 0 ; - _SpinClock = 0 ; - OwnerIsThread = 0 ; + _succ = NULL; + _EntryList = NULL; + _cxq = NULL; + _WaitSet = NULL; + _recursions = 0; + _SpinFreq = 0; + _SpinClock = 0; + OwnerIsThread = 0; } public: @@ -194,7 +194,7 @@ public: void print(); #endif - bool try_enter (TRAPS) ; + bool try_enter(TRAPS); void enter(TRAPS); void exit(bool not_suspended, TRAPS); void wait(jlong millis, bool interruptable, TRAPS); @@ -206,22 +206,22 @@ public: void reenter(intptr_t recursions, TRAPS); private: - void AddWaiter (ObjectWaiter * waiter) ; + void AddWaiter(ObjectWaiter * waiter); static void DeferredInitialize(); - ObjectWaiter * DequeueWaiter () ; - void DequeueSpecificWaiter (ObjectWaiter * waiter) ; - void EnterI (TRAPS) ; - void ReenterI (Thread * Self, ObjectWaiter * SelfNode) ; - void UnlinkAfterAcquire (Thread * Self, ObjectWaiter * SelfNode) ; - int TryLock (Thread * Self) ; - int NotRunnable (Thread * Self, Thread * Owner) ; - int TrySpin_Fixed (Thread * Self) ; - int TrySpin_VaryFrequency (Thread * Self) ; - int TrySpin_VaryDuration (Thread * Self) ; - void ctAsserts () ; - void ExitEpilog (Thread * Self, ObjectWaiter * Wakee) ; - bool ExitSuspendEquivalent (JavaThread * Self) ; + ObjectWaiter * DequeueWaiter(); + void DequeueSpecificWaiter(ObjectWaiter * waiter); + void EnterI(TRAPS); + void ReenterI(Thread * Self, ObjectWaiter * SelfNode); + void UnlinkAfterAcquire(Thread * Self, ObjectWaiter * SelfNode); + int TryLock(Thread * Self); + int NotRunnable(Thread * Self, Thread * Owner); + int TrySpin_Fixed(Thread * Self); + int TrySpin_VaryFrequency(Thread * Self); + int TrySpin_VaryDuration(Thread * Self); + void ctAsserts(); + void ExitEpilog(Thread * Self, ObjectWaiter * Wakee); + bool ExitSuspendEquivalent(JavaThread * Self); void post_monitor_wait_event(EventJavaMonitorWait * event, jlong notifier_tid, jlong timeout, @@ -240,7 +240,7 @@ public: volatile markOop _header; // displaced object header word - mark void* volatile _object; // backward object pointer - strong root - double SharingPad [1] ; // temp to reduce false sharing + double SharingPad[1]; // temp to reduce false sharing // All the following fields must be machine word aligned // The VM assumes write ordering wrt these fields, which can be @@ -251,22 +251,22 @@ public: volatile jlong _previous_owner_tid; // thread id of the previous owner of the monitor volatile intptr_t _recursions; // recursion count, 0 for first entry private: - int OwnerIsThread ; // _owner is (Thread *) vs SP/BasicLock - ObjectWaiter * volatile _cxq ; // LL of recently-arrived threads blocked on entry. + int OwnerIsThread; // _owner is (Thread *) vs SP/BasicLock + ObjectWaiter * volatile _cxq; // LL of recently-arrived threads blocked on entry. // The list is actually composed of WaitNodes, acting // as proxies for Threads. protected: - ObjectWaiter * volatile _EntryList ; // Threads blocked on entry or reentry. + ObjectWaiter * volatile _EntryList; // Threads blocked on entry or reentry. private: - Thread * volatile _succ ; // Heir presumptive thread - used for futile wakeup throttling - Thread * volatile _Responsible ; - int _PromptDrain ; // rqst to drain cxq into EntryList ASAP + Thread * volatile _succ; // Heir presumptive thread - used for futile wakeup throttling + Thread * volatile _Responsible; + int _PromptDrain; // rqst to drain cxq into EntryList ASAP - volatile int _Spinner ; // for exit->spinner handoff optimization - volatile int _SpinFreq ; // Spin 1-out-of-N attempts: success rate - volatile int _SpinClock ; - volatile int _SpinDuration ; - volatile intptr_t _SpinState ; // MCS/CLH list of spinners + volatile int _Spinner; // for exit->spinner handoff optimization + volatile int _SpinFreq; // Spin 1-out-of-N attempts: success rate + volatile int _SpinClock; + volatile int _SpinDuration; + volatile intptr_t _SpinState; // MCS/CLH list of spinners // TODO-FIXME: _count, _waiters and _recursions should be of // type int, or int32_t but not intptr_t. There's no reason @@ -284,30 +284,30 @@ public: volatile int _WaitSetLock; // protects Wait Queue - simple spinlock public: - int _QMix ; // Mixed prepend queue discipline - ObjectMonitor * FreeNext ; // Free list linkage - intptr_t StatA, StatsB ; + int _QMix; // Mixed prepend queue discipline + ObjectMonitor * FreeNext; // Free list linkage + intptr_t StatA, StatsB; public: - static void Initialize () ; - static PerfCounter * _sync_ContendedLockAttempts ; - static PerfCounter * _sync_FutileWakeups ; - static PerfCounter * _sync_Parks ; - static PerfCounter * _sync_EmptyNotifications ; - static PerfCounter * _sync_Notifications ; - static PerfCounter * _sync_SlowEnter ; - static PerfCounter * _sync_SlowExit ; - static PerfCounter * _sync_SlowNotify ; - static PerfCounter * _sync_SlowNotifyAll ; - static PerfCounter * _sync_FailedSpins ; - static PerfCounter * _sync_SuccessfulSpins ; - static PerfCounter * _sync_PrivateA ; - static PerfCounter * _sync_PrivateB ; - static PerfCounter * _sync_MonInCirculation ; - static PerfCounter * _sync_MonScavenged ; - static PerfCounter * _sync_Inflations ; - static PerfCounter * _sync_Deflations ; - static PerfLongVariable * _sync_MonExtant ; + static void Initialize(); + static PerfCounter * _sync_ContendedLockAttempts; + static PerfCounter * _sync_FutileWakeups; + static PerfCounter * _sync_Parks; + static PerfCounter * _sync_EmptyNotifications; + static PerfCounter * _sync_Notifications; + static PerfCounter * _sync_SlowEnter; + static PerfCounter * _sync_SlowExit; + static PerfCounter * _sync_SlowNotify; + static PerfCounter * _sync_SlowNotifyAll; + static PerfCounter * _sync_FailedSpins; + static PerfCounter * _sync_SuccessfulSpins; + static PerfCounter * _sync_PrivateA; + static PerfCounter * _sync_PrivateB; + static PerfCounter * _sync_MonInCirculation; + static PerfCounter * _sync_MonScavenged; + static PerfCounter * _sync_Inflations; + static PerfCounter * _sync_Deflations; + static PerfLongVariable * _sync_MonExtant; public: static int Knob_Verbose; @@ -329,7 +329,7 @@ public: #undef TEVENT #define TEVENT(nom) {if (SyncVerbose) FEVENT(nom); } -#define FEVENT(nom) { static volatile int ctr = 0 ; int v = ++ctr ; if ((v & (v-1)) == 0) { ::printf (#nom " : %d \n", v); ::fflush(stdout); }} +#define FEVENT(nom) { static volatile int ctr = 0; int v = ++ctr; if ((v & (v-1)) == 0) { ::printf (#nom " : %d \n", v); ::fflush(stdout); }} #undef TEVENT #define TEVENT(nom) {;} diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index fad31fd02f1..efd8be473b3 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -198,13 +198,13 @@ void SharedRuntime::trace_ic_miss(address at) { void SharedRuntime::print_ic_miss_histogram() { if (ICMissHistogram) { - tty->print_cr ("IC Miss Histogram:"); + tty->print_cr("IC Miss Histogram:"); int tot_misses = 0; for (int i = 0; i < _ICmiss_index; i++) { tty->print_cr(" at: " INTPTR_FORMAT " nof: %d", _ICmiss_at[i], _ICmiss_count[i]); tot_misses += _ICmiss_count[i]; } - tty->print_cr ("Total IC misses: %7d", tot_misses); + tty->print_cr("Total IC misses: %7d", tot_misses); } } #endif // PRODUCT @@ -266,7 +266,7 @@ JRT_LEAF(jfloat, SharedRuntime::frem(jfloat x, jfloat y)) xbits.f = x; ybits.f = y; // x Mod Infinity == x unless x is infinity - if ( ((xbits.i & float_sign_mask) != float_infinity) && + if (((xbits.i & float_sign_mask) != float_infinity) && ((ybits.i & float_sign_mask) == float_infinity) ) { return x; } @@ -281,7 +281,7 @@ JRT_LEAF(jdouble, SharedRuntime::drem(jdouble x, jdouble y)) xbits.d = x; ybits.d = y; // x Mod Infinity == x unless x is infinity - if ( ((xbits.l & double_sign_mask) != double_infinity) && + if (((xbits.l & double_sign_mask) != double_infinity) && ((ybits.l & double_sign_mask) == double_infinity) ) { return x; } @@ -537,13 +537,13 @@ address SharedRuntime::get_poll_stub(address pc) { CodeBlob *cb = CodeCache::find_blob(pc); // Should be an nmethod - assert( cb && cb->is_nmethod(), "safepoint polling: pc must refer to an nmethod" ); + assert(cb && cb->is_nmethod(), "safepoint polling: pc must refer to an nmethod"); // Look up the relocation information - assert( ((nmethod*)cb)->is_at_poll_or_poll_return(pc), - "safepoint polling: type must be poll" ); + assert(((nmethod*)cb)->is_at_poll_or_poll_return(pc), + "safepoint polling: type must be poll"); - assert( ((NativeInstruction*)pc)->is_safepoint_poll(), + assert(((NativeInstruction*)pc)->is_safepoint_poll(), "Only polling locations are used for safepoint"); bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc); @@ -562,7 +562,7 @@ address SharedRuntime::get_poll_stub(address pc) { stub = SharedRuntime::polling_page_safepoint_handler_blob()->entry_point(); } #ifndef PRODUCT - if( TraceSafepoint ) { + if (TraceSafepoint) { char buf[256]; jio_snprintf(buf, sizeof(buf), "... found polling page %s exception at pc = " @@ -1474,7 +1474,7 @@ methodHandle SharedRuntime::handle_ic_miss_helper(JavaThread *thread, TRAPS) { should_be_mono = true; } else if (inline_cache->is_icholder_call()) { CompiledICHolder* ic_oop = inline_cache->cached_icholder(); - if ( ic_oop != NULL) { + if (ic_oop != NULL) { if (receiver()->klass() == ic_oop->holder_klass()) { // This isn't a real miss. We must have seen that compiled code @@ -1728,7 +1728,7 @@ IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address cal iter.next(); assert(iter.has_current(), "must have a reloc at java call site"); relocInfo::relocType typ = iter.reloc()->type(); - if ( typ != relocInfo::static_call_type && + if (typ != relocInfo::static_call_type && typ != relocInfo::opt_virtual_call_type && typ != relocInfo::static_stub_type) { return; @@ -1784,7 +1784,7 @@ JRT_ENTRY(void, SharedRuntime::slow_arraycopy_C(oopDesc* src, jint src_pos, // The copy_array mechanism is awkward and could be removed, but // the compilers don't call this function except as a last resort, // so it probably doesn't matter. - src->klass()->copy_array((arrayOopDesc*)src, src_pos, + src->klass()->copy_array((arrayOopDesc*)src, src_pos, (arrayOopDesc*)dest, dest_pos, length, thread); } @@ -1891,8 +1891,8 @@ void SharedRuntime::print_statistics() { ttyLocker ttyl; if (xtty != NULL) xtty->head("statistics type='SharedRuntime'"); - if (_monitor_enter_ctr ) tty->print_cr("%5d monitor enter slow", _monitor_enter_ctr); - if (_monitor_exit_ctr ) tty->print_cr("%5d monitor exit slow", _monitor_exit_ctr); + if (_monitor_enter_ctr) tty->print_cr("%5d monitor enter slow", _monitor_enter_ctr); + if (_monitor_exit_ctr) tty->print_cr("%5d monitor exit slow", _monitor_exit_ctr); if (_throw_null_ctr) tty->print_cr("%5d implicit null throw", _throw_null_ctr); SharedRuntime::print_ic_miss_histogram(); @@ -1905,36 +1905,36 @@ void SharedRuntime::print_statistics() { } // Dump the JRT_ENTRY counters - if( _new_instance_ctr ) tty->print_cr("%5d new instance requires GC", _new_instance_ctr); - if( _new_array_ctr ) tty->print_cr("%5d new array requires GC", _new_array_ctr); - if( _multi1_ctr ) tty->print_cr("%5d multianewarray 1 dim", _multi1_ctr); - if( _multi2_ctr ) tty->print_cr("%5d multianewarray 2 dim", _multi2_ctr); - if( _multi3_ctr ) tty->print_cr("%5d multianewarray 3 dim", _multi3_ctr); - if( _multi4_ctr ) tty->print_cr("%5d multianewarray 4 dim", _multi4_ctr); - if( _multi5_ctr ) tty->print_cr("%5d multianewarray 5 dim", _multi5_ctr); + if (_new_instance_ctr) tty->print_cr("%5d new instance requires GC", _new_instance_ctr); + if (_new_array_ctr) tty->print_cr("%5d new array requires GC", _new_array_ctr); + if (_multi1_ctr) tty->print_cr("%5d multianewarray 1 dim", _multi1_ctr); + if (_multi2_ctr) tty->print_cr("%5d multianewarray 2 dim", _multi2_ctr); + if (_multi3_ctr) tty->print_cr("%5d multianewarray 3 dim", _multi3_ctr); + if (_multi4_ctr) tty->print_cr("%5d multianewarray 4 dim", _multi4_ctr); + if (_multi5_ctr) tty->print_cr("%5d multianewarray 5 dim", _multi5_ctr); - tty->print_cr("%5d inline cache miss in compiled", _ic_miss_ctr ); - tty->print_cr("%5d wrong method", _wrong_method_ctr ); - tty->print_cr("%5d unresolved static call site", _resolve_static_ctr ); - tty->print_cr("%5d unresolved virtual call site", _resolve_virtual_ctr ); - tty->print_cr("%5d unresolved opt virtual call site", _resolve_opt_virtual_ctr ); + tty->print_cr("%5d inline cache miss in compiled", _ic_miss_ctr); + tty->print_cr("%5d wrong method", _wrong_method_ctr); + tty->print_cr("%5d unresolved static call site", _resolve_static_ctr); + tty->print_cr("%5d unresolved virtual call site", _resolve_virtual_ctr); + tty->print_cr("%5d unresolved opt virtual call site", _resolve_opt_virtual_ctr); - if( _mon_enter_stub_ctr ) tty->print_cr("%5d monitor enter stub", _mon_enter_stub_ctr ); - if( _mon_exit_stub_ctr ) tty->print_cr("%5d monitor exit stub", _mon_exit_stub_ctr ); - if( _mon_enter_ctr ) tty->print_cr("%5d monitor enter slow", _mon_enter_ctr ); - if( _mon_exit_ctr ) tty->print_cr("%5d monitor exit slow", _mon_exit_ctr ); - if( _partial_subtype_ctr) tty->print_cr("%5d slow partial subtype", _partial_subtype_ctr ); - if( _jbyte_array_copy_ctr ) tty->print_cr("%5d byte array copies", _jbyte_array_copy_ctr ); - if( _jshort_array_copy_ctr ) tty->print_cr("%5d short array copies", _jshort_array_copy_ctr ); - if( _jint_array_copy_ctr ) tty->print_cr("%5d int array copies", _jint_array_copy_ctr ); - if( _jlong_array_copy_ctr ) tty->print_cr("%5d long array copies", _jlong_array_copy_ctr ); - if( _oop_array_copy_ctr ) tty->print_cr("%5d oop array copies", _oop_array_copy_ctr ); - if( _checkcast_array_copy_ctr ) tty->print_cr("%5d checkcast array copies", _checkcast_array_copy_ctr ); - if( _unsafe_array_copy_ctr ) tty->print_cr("%5d unsafe array copies", _unsafe_array_copy_ctr ); - if( _generic_array_copy_ctr ) tty->print_cr("%5d generic array copies", _generic_array_copy_ctr ); - if( _slow_array_copy_ctr ) tty->print_cr("%5d slow array copies", _slow_array_copy_ctr ); - if( _find_handler_ctr ) tty->print_cr("%5d find exception handler", _find_handler_ctr ); - if( _rethrow_ctr ) tty->print_cr("%5d rethrow handler", _rethrow_ctr ); + if (_mon_enter_stub_ctr) tty->print_cr("%5d monitor enter stub", _mon_enter_stub_ctr); + if (_mon_exit_stub_ctr) tty->print_cr("%5d monitor exit stub", _mon_exit_stub_ctr); + if (_mon_enter_ctr) tty->print_cr("%5d monitor enter slow", _mon_enter_ctr); + if (_mon_exit_ctr) tty->print_cr("%5d monitor exit slow", _mon_exit_ctr); + if (_partial_subtype_ctr) tty->print_cr("%5d slow partial subtype", _partial_subtype_ctr); + if (_jbyte_array_copy_ctr) tty->print_cr("%5d byte array copies", _jbyte_array_copy_ctr); + if (_jshort_array_copy_ctr) tty->print_cr("%5d short array copies", _jshort_array_copy_ctr); + if (_jint_array_copy_ctr) tty->print_cr("%5d int array copies", _jint_array_copy_ctr); + if (_jlong_array_copy_ctr) tty->print_cr("%5d long array copies", _jlong_array_copy_ctr); + if (_oop_array_copy_ctr) tty->print_cr("%5d oop array copies", _oop_array_copy_ctr); + if (_checkcast_array_copy_ctr) tty->print_cr("%5d checkcast array copies", _checkcast_array_copy_ctr); + if (_unsafe_array_copy_ctr) tty->print_cr("%5d unsafe array copies", _unsafe_array_copy_ctr); + if (_generic_array_copy_ctr) tty->print_cr("%5d generic array copies", _generic_array_copy_ctr); + if (_slow_array_copy_ctr) tty->print_cr("%5d slow array copies", _slow_array_copy_ctr); + if (_find_handler_ctr) tty->print_cr("%5d find exception handler", _find_handler_ctr); + if (_rethrow_ctr) tty->print_cr("%5d rethrow handler", _rethrow_ctr); AdapterHandlerLibrary::print_statistics(); @@ -1997,7 +1997,7 @@ class MethodArityHistogram { MethodArityHistogram() { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); _max_arity = _max_size = 0; - for (int i = 0; i < MAX_ARITY; i++) _arity_histogram[i] = _size_histogram [i] = 0; + for (int i = 0; i < MAX_ARITY; i++) _arity_histogram[i] = _size_histogram[i] = 0; CodeCache::nmethods_do(add_method_to_histogram); print_histogram(); } @@ -2062,7 +2062,7 @@ class AdapterFingerPrint : public CHeapObj { // These are correct for the current system but someday it might be // necessary to make this mapping platform dependent. static int adapter_encoding(BasicType in) { - switch(in) { + switch (in) { case T_BOOLEAN: case T_BYTE: case T_SHORT: @@ -2479,7 +2479,7 @@ AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(methodHandle method) { tty->print_cr("i2c argument handler #%d for: %s %s (%d bytes generated)", _adapters->number_of_entries(), (method->is_static() ? "static" : "receiver"), method->signature()->as_C_string(), insts_size); - tty->print_cr("c2i argument handler starts at %p",entry->get_c2i_entry()); + tty->print_cr("c2i argument handler starts at %p", entry->get_c2i_entry()); if (Verbose || PrintStubCode) { address first_pc = entry->base_address(); if (first_pc != NULL) { @@ -2504,7 +2504,7 @@ AdapterHandlerEntry* AdapterHandlerLibrary::get_adapter(methodHandle method) { new_adapter->name(), fingerprint->as_string(), new_adapter->content_begin()); - Forte::register_stub(blob_id, new_adapter->content_begin(),new_adapter->content_end()); + Forte::register_stub(blob_id, new_adapter->content_begin(), new_adapter->content_end()); if (JvmtiExport::should_post_dynamic_code_generated()) { JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end()); @@ -2605,12 +2605,12 @@ void AdapterHandlerLibrary::create_native_wrapper(methodHandle method) { BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed); VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed); int i=0; - if( !method->is_static() ) // Pass in receiver first + if (!method->is_static()) // Pass in receiver first sig_bt[i++] = T_OBJECT; SignatureStream ss(method->signature()); - for( ; !ss.at_return_type(); ss.next()) { + for (; !ss.at_return_type(); ss.next()) { sig_bt[i++] = ss.type(); // Collect remaining bits of signature - if( ss.type() == T_LONG || ss.type() == T_DOUBLE ) + if (ss.type() == T_LONG || ss.type() == T_DOUBLE) sig_bt[i++] = T_VOID; // Longs & doubles take 2 Java slots } assert(i == total_args_passed, ""); @@ -2762,10 +2762,10 @@ void SharedRuntime::convert_ints_to_longints(int i2l_argcnt, int& in_args_count, case T_SHORT: case T_INT: // Convert (bt) to (T_LONG,bt). - new_in_sig_bt[argcnt ] = T_LONG; + new_in_sig_bt[argcnt] = T_LONG; new_in_sig_bt[argcnt+1] = bt; assert(reg.first()->is_valid() && !reg.second()->is_valid(), ""); - new_in_regs[argcnt ].set2(reg.first()); + new_in_regs[argcnt].set2(reg.first()); new_in_regs[argcnt+1].set_bad(); argcnt++; break; @@ -2808,17 +2808,17 @@ VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, int len = (int)strlen(s); s++; len--; // Skip opening paren char *t = s+len; - while( *(--t) != ')' ) ; // Find close paren + while (*(--t) != ')'); // Find close paren - BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, 256 ); - VMRegPair *regs = NEW_RESOURCE_ARRAY( VMRegPair, 256 ); + BasicType *sig_bt = NEW_RESOURCE_ARRAY(BasicType, 256); + VMRegPair *regs = NEW_RESOURCE_ARRAY(VMRegPair, 256); int cnt = 0; if (has_receiver) { sig_bt[cnt++] = T_OBJECT; // Receiver is argument 0; not in signature } - while( s < t ) { - switch( *s++ ) { // Switch on signature character + while (s < t) { + switch (*s++) { // Switch on signature character case 'B': sig_bt[cnt++] = T_BYTE; break; case 'C': sig_bt[cnt++] = T_CHAR; break; case 'D': sig_bt[cnt++] = T_DOUBLE; sig_bt[cnt++] = T_VOID; break; @@ -2829,16 +2829,16 @@ VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, case 'Z': sig_bt[cnt++] = T_BOOLEAN; break; case 'V': sig_bt[cnt++] = T_VOID; break; case 'L': // Oop - while( *s++ != ';' ) ; // Skip signature + while (*s++ != ';'); // Skip signature sig_bt[cnt++] = T_OBJECT; break; case '[': { // Array do { // Skip optional size - while( *s >= '0' && *s <= '9' ) s++; - } while( *s++ == '[' ); // Nested arrays? + while (*s >= '0' && *s <= '9') s++; + } while (*s++ == '['); // Nested arrays? // Skip element type - if( s[-1] == 'L' ) - while( *s++ != ';' ) ; // Skip signature + if (s[-1] == 'L') + while (*s++ != ';'); // Skip signature sig_bt[cnt++] = T_ARRAY; break; } @@ -2850,7 +2850,7 @@ VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, sig_bt[cnt++] = T_OBJECT; } - assert( cnt < 256, "grow table size" ); + assert(cnt < 256, "grow table size"); int comp_args_on_stack; comp_args_on_stack = java_calling_convention(sig_bt, regs, cnt, true); @@ -2861,12 +2861,12 @@ VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, if (comp_args_on_stack) { for (int i = 0; i < cnt; i++) { VMReg reg1 = regs[i].first(); - if( reg1->is_stack()) { + if (reg1->is_stack()) { // Yuck reg1 = reg1->bias(out_preserve_stack_slots()); } VMReg reg2 = regs[i].second(); - if( reg2->is_stack()) { + if (reg2->is_stack()) { // Yuck reg2 = reg2->bias(out_preserve_stack_slots()); } @@ -2904,15 +2904,15 @@ JRT_LEAF(intptr_t*, SharedRuntime::OSR_migration_begin( JavaThread *thread) ) // frame accessor methods and be platform independent. frame fr = thread->last_frame(); - assert( fr.is_interpreted_frame(), "" ); - assert( fr.interpreter_frame_expression_stack_size()==0, "only handle empty stacks" ); + assert(fr.is_interpreted_frame(), ""); + assert(fr.interpreter_frame_expression_stack_size()==0, "only handle empty stacks"); // Figure out how many monitors are active. int active_monitor_count = 0; - for( BasicObjectLock *kptr = fr.interpreter_frame_monitor_end(); + for (BasicObjectLock *kptr = fr.interpreter_frame_monitor_end(); kptr < fr.interpreter_frame_monitor_begin(); kptr = fr.next_monitor_in_interpreter_frame(kptr) ) { - if( kptr->obj() != NULL ) active_monitor_count++; + if (kptr->obj() != NULL) active_monitor_count++; } // QQQ we could place number of active monitors in the array so that compiled code @@ -2926,17 +2926,17 @@ JRT_LEAF(intptr_t*, SharedRuntime::OSR_migration_begin( JavaThread *thread) ) // Copy the locals. Order is preserved so that loading of longs works. // Since there's no GC I can copy the oops blindly. - assert( sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); + assert(sizeof(HeapWord)==sizeof(intptr_t), "fix this code"); Copy::disjoint_words((HeapWord*)fr.interpreter_frame_local_at(max_locals-1), (HeapWord*)&buf[0], max_locals); // Inflate locks. Copy the displaced headers. Be careful, there can be holes. int i = max_locals; - for( BasicObjectLock *kptr2 = fr.interpreter_frame_monitor_end(); + for (BasicObjectLock *kptr2 = fr.interpreter_frame_monitor_end(); kptr2 < fr.interpreter_frame_monitor_begin(); kptr2 = fr.next_monitor_in_interpreter_frame(kptr2) ) { - if( kptr2->obj() != NULL) { // Avoid 'holes' in the monitor array + if (kptr2->obj() != NULL) { // Avoid 'holes' in the monitor array BasicLock *lock = kptr2->lock(); // Inflate so the displaced header becomes position-independent if (lock->displaced_header()->is_unlocked()) @@ -2946,20 +2946,20 @@ JRT_LEAF(intptr_t*, SharedRuntime::OSR_migration_begin( JavaThread *thread) ) buf[i++] = cast_from_oop(kptr2->obj()); } } - assert( i - max_locals == active_monitor_count*2, "found the expected number of monitors" ); + assert(i - max_locals == active_monitor_count*2, "found the expected number of monitors"); return buf; JRT_END JRT_LEAF(void, SharedRuntime::OSR_migration_end( intptr_t* buf) ) - FREE_C_HEAP_ARRAY(intptr_t,buf, mtCode); + FREE_C_HEAP_ARRAY(intptr_t, buf, mtCode); JRT_END bool AdapterHandlerLibrary::contains(CodeBlob* b) { AdapterHandlerTableIterator iter(_adapters); while (iter.has_next()) { AdapterHandlerEntry* a = iter.next(); - if ( b == CodeCache::find_blob(a->get_i2c_entry()) ) return true; + if (b == CodeCache::find_blob(a->get_i2c_entry())) return true; } return false; } diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp index 62bd1ab9139..7af5fe72b62 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.cpp +++ b/hotspot/src/share/vm/runtime/synchronizer.cpp @@ -120,15 +120,15 @@ int dtrace_waited_probe(ObjectMonitor* monitor, Handle obj, Thread* thr) { } #define NINFLATIONLOCKS 256 -static volatile intptr_t InflationLocks [NINFLATIONLOCKS] ; +static volatile intptr_t InflationLocks[NINFLATIONLOCKS]; -ObjectMonitor * ObjectSynchronizer::gBlockList = NULL ; -ObjectMonitor * volatile ObjectSynchronizer::gFreeList = NULL ; -ObjectMonitor * volatile ObjectSynchronizer::gOmInUseList = NULL ; +ObjectMonitor * ObjectSynchronizer::gBlockList = NULL; +ObjectMonitor * volatile ObjectSynchronizer::gFreeList = NULL; +ObjectMonitor * volatile ObjectSynchronizer::gOmInUseList = NULL; int ObjectSynchronizer::gOmInUseCount = 0; -static volatile intptr_t ListLock = 0 ; // protects global monitor free-list cache -static volatile int MonitorFreeCount = 0 ; // # on gFreeList -static volatile int MonitorPopulation = 0 ; // # Extant -- in circulation +static volatile intptr_t ListLock = 0; // protects global monitor free-list cache +static volatile int MonitorFreeCount = 0; // # on gFreeList +static volatile int MonitorPopulation = 0; // # Extant -- in circulation #define CHAINMARKER (cast_to_oop(-1)) // ----------------------------------------------------------------------------- @@ -152,43 +152,43 @@ void ObjectSynchronizer::fast_enter(Handle obj, BasicLock* lock, bool attempt_re assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); } - slow_enter (obj, lock, THREAD) ; + slow_enter(obj, lock, THREAD); } void ObjectSynchronizer::fast_exit(oop object, BasicLock* lock, TRAPS) { assert(!object->mark()->has_bias_pattern(), "should not see bias pattern here"); // if displaced header is null, the previous enter is recursive enter, no-op markOop dhw = lock->displaced_header(); - markOop mark ; + markOop mark; if (dhw == NULL) { // Recursive stack-lock. // Diagnostics -- Could be: stack-locked, inflating, inflated. - mark = object->mark() ; - assert (!mark->is_neutral(), "invariant") ; + mark = object->mark(); + assert(!mark->is_neutral(), "invariant"); if (mark->has_locker() && mark != markOopDesc::INFLATING()) { - assert(THREAD->is_lock_owned((address)mark->locker()), "invariant") ; + assert(THREAD->is_lock_owned((address)mark->locker()), "invariant"); } if (mark->has_monitor()) { - ObjectMonitor * m = mark->monitor() ; - assert(((oop)(m->object()))->mark() == mark, "invariant") ; - assert(m->is_entered(THREAD), "invariant") ; + ObjectMonitor * m = mark->monitor(); + assert(((oop)(m->object()))->mark() == mark, "invariant"); + assert(m->is_entered(THREAD), "invariant"); } - return ; + return; } - mark = object->mark() ; + mark = object->mark(); // If the object is stack-locked by the current thread, try to // swing the displaced header from the box back to the mark. if (mark == (markOop) lock) { - assert (dhw->is_neutral(), "invariant") ; + assert(dhw->is_neutral(), "invariant"); if ((markOop) Atomic::cmpxchg_ptr (dhw, object->mark_addr(), mark) == mark) { - TEVENT (fast_exit: release stacklock) ; + TEVENT(fast_exit: release stacklock); return; } } - ObjectSynchronizer::inflate(THREAD, object)->exit (true, THREAD) ; + ObjectSynchronizer::inflate(THREAD, object)->exit(true, THREAD); } // ----------------------------------------------------------------------------- @@ -205,8 +205,8 @@ void ObjectSynchronizer::slow_enter(Handle obj, BasicLock* lock, TRAPS) { // be visible <= the ST performed by the CAS. lock->set_displaced_header(mark); if (mark == (markOop) Atomic::cmpxchg_ptr(lock, obj()->mark_addr(), mark)) { - TEVENT (slow_enter: release stacklock) ; - return ; + TEVENT(slow_enter: release stacklock); + return; } // Fall through to inflate() ... } else @@ -220,8 +220,8 @@ void ObjectSynchronizer::slow_enter(Handle obj, BasicLock* lock, TRAPS) { #if 0 // The following optimization isn't particularly useful. if (mark->has_monitor() && mark->monitor()->is_entered(THREAD)) { - lock->set_displaced_header (NULL) ; - return ; + lock->set_displaced_header(NULL); + return; } #endif @@ -238,7 +238,7 @@ void ObjectSynchronizer::slow_enter(Handle obj, BasicLock* lock, TRAPS) { // failed in the interpreter/compiler code. Simply use the heavy // weight monitor should be ok, unless someone find otherwise. void ObjectSynchronizer::slow_exit(oop object, BasicLock* lock, TRAPS) { - fast_exit (object, lock, THREAD) ; + fast_exit(object, lock, THREAD); } // ----------------------------------------------------------------------------- @@ -254,7 +254,7 @@ void ObjectSynchronizer::slow_exit(oop object, BasicLock* lock, TRAPS) { // 5) lock lock2 // NOTE: must use heavy weight monitor to handle complete_exit/reenter() intptr_t ObjectSynchronizer::complete_exit(Handle obj, TRAPS) { - TEVENT (complete_exit) ; + TEVENT(complete_exit); if (UseBiasedLocking) { BiasedLocking::revoke_and_rebias(obj, false, THREAD); assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); @@ -267,7 +267,7 @@ intptr_t ObjectSynchronizer::complete_exit(Handle obj, TRAPS) { // NOTE: must use heavy weight monitor to handle complete_exit/reenter() void ObjectSynchronizer::reenter(Handle obj, intptr_t recursion, TRAPS) { - TEVENT (reenter) ; + TEVENT(reenter); if (UseBiasedLocking) { BiasedLocking::revoke_and_rebias(obj, false, THREAD); assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); @@ -282,7 +282,7 @@ void ObjectSynchronizer::reenter(Handle obj, intptr_t recursion, TRAPS) { // NOTE: must use heavy weight monitor to handle jni monitor enter void ObjectSynchronizer::jni_enter(Handle obj, TRAPS) { // possible entry from jni enter // the current locking is from JNI instead of Java code - TEVENT (jni_enter) ; + TEVENT(jni_enter); if (UseBiasedLocking) { BiasedLocking::revoke_and_rebias(obj, false, THREAD); assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); @@ -306,7 +306,7 @@ bool ObjectSynchronizer::jni_try_enter(Handle obj, Thread* THREAD) { // NOTE: must use heavy weight monitor to handle jni monitor exit void ObjectSynchronizer::jni_exit(oop obj, Thread* THREAD) { - TEVENT (jni_exit) ; + TEVENT(jni_exit); if (UseBiasedLocking) { Handle h_obj(THREAD, obj); BiasedLocking::revoke_and_rebias(h_obj, false, THREAD); @@ -332,7 +332,7 @@ ObjectLocker::ObjectLocker(Handle obj, Thread* thread, bool doLock) { _obj = obj; if (_dolock) { - TEVENT (ObjectLocker) ; + TEVENT(ObjectLocker); ObjectSynchronizer::fast_enter(_obj, &_lock, false, _thread); } @@ -354,7 +354,7 @@ int ObjectSynchronizer::wait(Handle obj, jlong millis, TRAPS) { assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); } if (millis < 0) { - TEVENT (wait - throw IAX) ; + TEVENT(wait - throw IAX); THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative"); } ObjectMonitor* monitor = ObjectSynchronizer::inflate(THREAD, obj()); @@ -374,10 +374,10 @@ void ObjectSynchronizer::waitUninterruptibly (Handle obj, jlong millis, TRAPS) { assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); } if (millis < 0) { - TEVENT (wait - throw IAX) ; + TEVENT(wait - throw IAX); THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "timeout value is negative"); } - ObjectSynchronizer::inflate(THREAD, obj()) -> wait(millis, false, THREAD) ; + ObjectSynchronizer::inflate(THREAD, obj()) -> wait(millis, false, THREAD); } void ObjectSynchronizer::notify(Handle obj, TRAPS) { @@ -428,31 +428,31 @@ void ObjectSynchronizer::notifyall(Handle obj, TRAPS) { struct SharedGlobals { // These are highly shared mostly-read variables. // To avoid false-sharing they need to be the sole occupants of a $ line. - double padPrefix [8]; - volatile int stwRandom ; - volatile int stwCycle ; + double padPrefix[8]; + volatile int stwRandom; + volatile int stwCycle; // Hot RW variables -- Sequester to avoid false-sharing - double padSuffix [16]; - volatile int hcSequence ; - double padFinal [8] ; -} ; + double padSuffix[16]; + volatile int hcSequence; + double padFinal[8]; +}; -static SharedGlobals GVars ; -static int MonitorScavengeThreshold = 1000000 ; -static volatile int ForceMonitorScavenge = 0 ; // Scavenge required and pending +static SharedGlobals GVars; +static int MonitorScavengeThreshold = 1000000; +static volatile int ForceMonitorScavenge = 0; // Scavenge required and pending static markOop ReadStableMark (oop obj) { - markOop mark = obj->mark() ; + markOop mark = obj->mark(); if (!mark->is_being_inflated()) { - return mark ; // normal fast-path return + return mark; // normal fast-path return } - int its = 0 ; + int its = 0; for (;;) { - markOop mark = obj->mark() ; + markOop mark = obj->mark(); if (!mark->is_being_inflated()) { - return mark ; // normal fast-path return + return mark; // normal fast-path return } // The object is being inflated by some other thread. @@ -465,11 +465,11 @@ static markOop ReadStableMark (oop obj) { // TODO: add inflation contention performance counters. // TODO: restrict the aggregate number of spinners. - ++its ; + ++its; if (its > 10000 || !os::is_MP()) { if (its & 1) { - os::NakedYield() ; - TEVENT (Inflate: INFLATING - yield) ; + os::NakedYield(); + TEVENT(Inflate: INFLATING - yield); } else { // Note that the following code attenuates the livelock problem but is not // a complete remedy. A more complete solution would require that the inflating @@ -486,26 +486,26 @@ static markOop ReadStableMark (oop obj) { // then for each thread on the list, set the flag and unpark() the thread. // This is conceptually similar to muxAcquire-muxRelease, except that muxRelease // wakes at most one thread whereas we need to wake the entire list. - int ix = (cast_from_oop(obj) >> 5) & (NINFLATIONLOCKS-1) ; - int YieldThenBlock = 0 ; - assert (ix >= 0 && ix < NINFLATIONLOCKS, "invariant") ; - assert ((NINFLATIONLOCKS & (NINFLATIONLOCKS-1)) == 0, "invariant") ; - Thread::muxAcquire (InflationLocks + ix, "InflationLock") ; + int ix = (cast_from_oop(obj) >> 5) & (NINFLATIONLOCKS-1); + int YieldThenBlock = 0; + assert(ix >= 0 && ix < NINFLATIONLOCKS, "invariant"); + assert((NINFLATIONLOCKS & (NINFLATIONLOCKS-1)) == 0, "invariant"); + Thread::muxAcquire(InflationLocks + ix, "InflationLock"); while (obj->mark() == markOopDesc::INFLATING()) { // Beware: NakedYield() is advisory and has almost no effect on some platforms // so we periodically call Self->_ParkEvent->park(1). // We use a mixed spin/yield/block mechanism. if ((YieldThenBlock++) >= 16) { - Thread::current()->_ParkEvent->park(1) ; + Thread::current()->_ParkEvent->park(1); } else { - os::NakedYield() ; + os::NakedYield(); } } - Thread::muxRelease (InflationLocks + ix ) ; - TEVENT (Inflate: INFLATING - yield/park) ; + Thread::muxRelease(InflationLocks + ix); + TEVENT(Inflate: INFLATING - yield/park); } } else { - SpinPause() ; // SMP-polite spinning + SpinPause(); // SMP-polite spinning } } } @@ -529,48 +529,48 @@ static markOop ReadStableMark (oop obj) { // static inline intptr_t get_next_hash(Thread * Self, oop obj) { - intptr_t value = 0 ; + intptr_t value = 0; if (hashCode == 0) { // This form uses an unguarded global Park-Miller RNG, // so it's possible for two threads to race and generate the same RNG. // On MP system we'll have lots of RW access to a global, so the // mechanism induces lots of coherency traffic. - value = os::random() ; + value = os::random(); } else if (hashCode == 1) { // This variation has the property of being stable (idempotent) // between STW operations. This can be useful in some of the 1-0 // synchronization schemes. - intptr_t addrBits = cast_from_oop(obj) >> 3 ; - value = addrBits ^ (addrBits >> 5) ^ GVars.stwRandom ; + intptr_t addrBits = cast_from_oop(obj) >> 3; + value = addrBits ^ (addrBits >> 5) ^ GVars.stwRandom; } else if (hashCode == 2) { - value = 1 ; // for sensitivity testing + value = 1; // for sensitivity testing } else if (hashCode == 3) { - value = ++GVars.hcSequence ; + value = ++GVars.hcSequence; } else if (hashCode == 4) { - value = cast_from_oop(obj) ; + value = cast_from_oop(obj); } else { // Marsaglia's xor-shift scheme with thread-specific state // This is probably the best overall implementation -- we'll // likely make this the default in future releases. - unsigned t = Self->_hashStateX ; - t ^= (t << 11) ; - Self->_hashStateX = Self->_hashStateY ; - Self->_hashStateY = Self->_hashStateZ ; - Self->_hashStateZ = Self->_hashStateW ; - unsigned v = Self->_hashStateW ; - v = (v ^ (v >> 19)) ^ (t ^ (t >> 8)) ; - Self->_hashStateW = v ; - value = v ; + unsigned t = Self->_hashStateX; + t ^= (t << 11); + Self->_hashStateX = Self->_hashStateY; + Self->_hashStateY = Self->_hashStateZ; + Self->_hashStateZ = Self->_hashStateW; + unsigned v = Self->_hashStateW; + v = (v ^ (v >> 19)) ^ (t ^ (t >> 8)); + Self->_hashStateW = v; + value = v; } value &= markOopDesc::hash_mask; - if (value == 0) value = 0xBAD ; - assert (value != markOopDesc::no_hash, "invariant") ; - TEVENT (hashCode: GENERATE) ; + if (value == 0) value = 0xBAD; + assert(value != markOopDesc::no_hash, "invariant"); + TEVENT(hashCode: GENERATE); return value; } // @@ -585,25 +585,25 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { // thread-local storage. if (obj->mark()->has_bias_pattern()) { // Box and unbox the raw reference just in case we cause a STW safepoint. - Handle hobj (Self, obj) ; + Handle hobj(Self, obj); // Relaxing assertion for bug 6320749. - assert (Universe::verify_in_progress() || + assert(Universe::verify_in_progress() || !SafepointSynchronize::is_at_safepoint(), "biases should not be seen by VM thread here"); BiasedLocking::revoke_and_rebias(hobj, false, JavaThread::current()); - obj = hobj() ; + obj = hobj(); assert(!obj->mark()->has_bias_pattern(), "biases should be revoked by now"); } } // hashCode() is a heap mutator ... // Relaxing assertion for bug 6320749. - assert (Universe::verify_in_progress() || - !SafepointSynchronize::is_at_safepoint(), "invariant") ; - assert (Universe::verify_in_progress() || - Self->is_Java_thread() , "invariant") ; - assert (Universe::verify_in_progress() || - ((JavaThread *)Self)->thread_state() != _thread_blocked, "invariant") ; + assert(Universe::verify_in_progress() || + !SafepointSynchronize::is_at_safepoint(), "invariant"); + assert(Universe::verify_in_progress() || + Self->is_Java_thread() , "invariant"); + assert(Universe::verify_in_progress() || + ((JavaThread *)Self)->thread_state() != _thread_blocked, "invariant"); ObjectMonitor* monitor = NULL; markOop temp, test; @@ -611,7 +611,7 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { markOop mark = ReadStableMark (obj); // object should remain ineligible for biased locking - assert (!mark->has_bias_pattern(), "invariant") ; + assert(!mark->has_bias_pattern(), "invariant"); if (mark->is_neutral()) { hash = mark->hash(); // this is a normal header @@ -631,7 +631,7 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { } else if (mark->has_monitor()) { monitor = mark->monitor(); temp = monitor->header(); - assert (temp->is_neutral(), "invariant") ; + assert(temp->is_neutral(), "invariant"); hash = temp->hash(); if (hash) { return hash; @@ -639,7 +639,7 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { // Skip to the following code to reduce code size } else if (Self->is_lock_owned((address)mark->locker())) { temp = mark->displaced_mark_helper(); // this is a lightweight monitor owned - assert (temp->is_neutral(), "invariant") ; + assert(temp->is_neutral(), "invariant"); hash = temp->hash(); // by current thread, check if the displaced if (hash) { // header contains hash code return hash; @@ -659,20 +659,20 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { monitor = ObjectSynchronizer::inflate(Self, obj); // Load displaced header and check it has hash code mark = monitor->header(); - assert (mark->is_neutral(), "invariant") ; + assert(mark->is_neutral(), "invariant"); hash = mark->hash(); if (hash == 0) { hash = get_next_hash(Self, obj); temp = mark->copy_set_hash(hash); // merge hash code into header - assert (temp->is_neutral(), "invariant") ; + assert(temp->is_neutral(), "invariant"); test = (markOop) Atomic::cmpxchg_ptr(temp, monitor, mark); if (test != mark) { // The only update to the header in the monitor (outside GC) // is install the hash code. If someone add new usage of // displaced header, please update this code hash = test->hash(); - assert (test->is_neutral(), "invariant") ; - assert (hash != 0, "Trivial unexpected object/monitor header usage."); + assert(test->is_neutral(), "invariant"); + assert(hash != 0, "Trivial unexpected object/monitor header usage."); } } // We finally get the hash @@ -682,7 +682,7 @@ intptr_t ObjectSynchronizer::FastHashCode (Thread * Self, oop obj) { // Deprecated -- use FastHashCode() instead. intptr_t ObjectSynchronizer::identity_hash_value_for(Handle obj) { - return FastHashCode (Thread::current(), obj()) ; + return FastHashCode(Thread::current(), obj()); } @@ -696,7 +696,7 @@ bool ObjectSynchronizer::current_thread_holds_lock(JavaThread* thread, assert(thread == JavaThread::current(), "Can only be called on current thread"); oop obj = h_obj(); - markOop mark = ReadStableMark (obj) ; + markOop mark = ReadStableMark(obj); // Uncontended case, header points to stack if (mark->has_locker()) { @@ -705,7 +705,7 @@ bool ObjectSynchronizer::current_thread_holds_lock(JavaThread* thread, // Contended case, header points to ObjectMonitor (tagged pointer) if (mark->has_monitor()) { ObjectMonitor* monitor = mark->monitor(); - return monitor->is_entered(thread) != 0 ; + return monitor->is_entered(thread) != 0; } // Unlocked case, header in place assert(mark->is_neutral(), "sanity check"); @@ -721,8 +721,8 @@ ObjectSynchronizer::LockOwnership ObjectSynchronizer::query_lock_ownership (JavaThread *self, Handle h_obj) { // The caller must beware this method can revoke bias, and // revocation can result in a safepoint. - assert (!SafepointSynchronize::is_at_safepoint(), "invariant") ; - assert (self->thread_state() != _thread_blocked , "invariant") ; + assert(!SafepointSynchronize::is_at_safepoint(), "invariant"); + assert(self->thread_state() != _thread_blocked , "invariant"); // Possible mark states: neutral, biased, stack-locked, inflated @@ -735,7 +735,7 @@ ObjectSynchronizer::LockOwnership ObjectSynchronizer::query_lock_ownership assert(self == JavaThread::current(), "Can only be called on current thread"); oop obj = h_obj(); - markOop mark = ReadStableMark (obj) ; + markOop mark = ReadStableMark(obj); // CASE: stack-locked. Mark points to a BasicLock on the owner's stack. if (mark->has_locker()) { @@ -747,15 +747,15 @@ ObjectSynchronizer::LockOwnership ObjectSynchronizer::query_lock_ownership // The Object:ObjectMonitor relationship is stable as long as we're // not at a safepoint. if (mark->has_monitor()) { - void * owner = mark->monitor()->_owner ; - if (owner == NULL) return owner_none ; + void * owner = mark->monitor()->_owner; + if (owner == NULL) return owner_none; return (owner == self || self->is_lock_owned((address)owner)) ? owner_self : owner_other; } // CASE: neutral assert(mark->is_neutral(), "sanity check"); - return owner_none ; // it's unlocked + return owner_none; // it's unlocked } // FIXME: jvmti should call this @@ -772,7 +772,7 @@ JavaThread* ObjectSynchronizer::get_lock_owner(Handle h_obj, bool doLock) { oop obj = h_obj(); address owner = NULL; - markOop mark = ReadStableMark (obj) ; + markOop mark = ReadStableMark(obj); // Uncontended case, header points to stack if (mark->has_locker()) { @@ -819,7 +819,7 @@ void ObjectSynchronizer::monitors_iterate(MonitorClosure* closure) { // Get the next block in the block list. static inline ObjectMonitor* next(ObjectMonitor* block) { assert(block->object() == CHAINMARKER, "must be a block header"); - block = block->FreeNext ; + block = block->FreeNext; assert(block == NULL || block->object() == CHAINMARKER, "must be a block header"); return block; } @@ -887,17 +887,17 @@ static void InduceScavenge (Thread * Self, const char * Whence) { if (ForceMonitorScavenge == 0 && Atomic::xchg (1, &ForceMonitorScavenge) == 0) { if (ObjectMonitor::Knob_Verbose) { ::printf ("Monitor scavenge - Induced STW @%s (%d)\n", Whence, ForceMonitorScavenge) ; - ::fflush(stdout) ; + ::fflush(stdout); } // Induce a 'null' safepoint to scavenge monitors // Must VM_Operation instance be heap allocated as the op will be enqueue and posted // to the VMthread and have a lifespan longer than that of this activation record. // The VMThread will delete the op when completed. - VMThread::execute (new VM_ForceAsyncSafepoint()) ; + VMThread::execute(new VM_ForceAsyncSafepoint()); if (ObjectMonitor::Knob_Verbose) { ::printf ("Monitor scavenge - STW posted @%s (%d)\n", Whence, ForceMonitorScavenge) ; - ::fflush(stdout) ; + ::fflush(stdout); } } } @@ -923,9 +923,9 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // number of objectMonitors in circulation as well as the STW // scavenge costs. As usual, we lean toward time in space-time // tradeoffs. - const int MAXPRIVATE = 1024 ; + const int MAXPRIVATE = 1024; for (;;) { - ObjectMonitor * m ; + ObjectMonitor * m; // 1: try to allocate from the thread's local omFreeList. // Threads will attempt to allocate first from their local list, then @@ -933,21 +933,21 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // attempt to instantiate new monitors. Thread-local free lists take // heat off the ListLock and improve allocation latency, as well as reducing // coherency traffic on the shared global list. - m = Self->omFreeList ; + m = Self->omFreeList; if (m != NULL) { - Self->omFreeList = m->FreeNext ; - Self->omFreeCount -- ; + Self->omFreeList = m->FreeNext; + Self->omFreeCount--; // CONSIDER: set m->FreeNext = BAD -- diagnostic hygiene - guarantee (m->object() == NULL, "invariant") ; + guarantee(m->object() == NULL, "invariant"); if (MonitorInUseLists) { m->FreeNext = Self->omInUseList; Self->omInUseList = m; - Self->omInUseCount ++; + Self->omInUseCount++; // verifyInUse(Self); } else { m->FreeNext = NULL; } - return m ; + return m; } // 2: try to allocate from the global gFreeList @@ -959,27 +959,27 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // Reprovision the thread's omFreeList. // Use bulk transfers to reduce the allocation rate and heat // on various locks. - Thread::muxAcquire (&ListLock, "omAlloc") ; - for (int i = Self->omFreeProvision; --i >= 0 && gFreeList != NULL; ) { - MonitorFreeCount --; - ObjectMonitor * take = gFreeList ; - gFreeList = take->FreeNext ; - guarantee (take->object() == NULL, "invariant") ; - guarantee (!take->is_busy(), "invariant") ; - take->Recycle() ; - omRelease (Self, take, false) ; + Thread::muxAcquire(&ListLock, "omAlloc"); + for (int i = Self->omFreeProvision; --i >= 0 && gFreeList != NULL;) { + MonitorFreeCount--; + ObjectMonitor * take = gFreeList; + gFreeList = take->FreeNext; + guarantee(take->object() == NULL, "invariant"); + guarantee(!take->is_busy(), "invariant"); + take->Recycle(); + omRelease(Self, take, false); } - Thread::muxRelease (&ListLock) ; - Self->omFreeProvision += 1 + (Self->omFreeProvision/2) ; - if (Self->omFreeProvision > MAXPRIVATE ) Self->omFreeProvision = MAXPRIVATE ; - TEVENT (omFirst - reprovision) ; + Thread::muxRelease(&ListLock); + Self->omFreeProvision += 1 + (Self->omFreeProvision/2); + if (Self->omFreeProvision > MAXPRIVATE) Self->omFreeProvision = MAXPRIVATE; + TEVENT(omFirst - reprovision); - const int mx = MonitorBound ; + const int mx = MonitorBound; if (mx > 0 && (MonitorPopulation-MonitorFreeCount) > mx) { // We can't safely induce a STW safepoint from omAlloc() as our thread // state may not be appropriate for such activities and callers may hold // naked oops, so instead we defer the action. - InduceScavenge (Self, "omAlloc") ; + InduceScavenge(Self, "omAlloc"); } continue; } @@ -987,14 +987,14 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // 3: allocate a block of new ObjectMonitors // Both the local and global free lists are empty -- resort to malloc(). // In the current implementation objectMonitors are TSM - immortal. - assert (_BLOCKSIZE > 1, "invariant") ; + assert(_BLOCKSIZE > 1, "invariant"); ObjectMonitor * temp = new ObjectMonitor[_BLOCKSIZE]; // NOTE: (almost) no way to recover if allocation failed. // We might be able to induce a STW safepoint and scavenge enough // objectMonitors to permit progress. if (temp == NULL) { - vm_exit_out_of_memory (sizeof (ObjectMonitor[_BLOCKSIZE]), OOM_MALLOC_ERROR, + vm_exit_out_of_memory(sizeof (ObjectMonitor[_BLOCKSIZE]), OOM_MALLOC_ERROR, "Allocate ObjectMonitors"); } @@ -1006,12 +1006,12 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // linkage should be reconsidered. A better implementation would // look like: class Block { Block * next; int N; ObjectMonitor Body [N] ; } - for (int i = 1; i < _BLOCKSIZE ; i++) { + for (int i = 1; i < _BLOCKSIZE; i++) { temp[i].FreeNext = &temp[i+1]; } // terminate the last monitor as the end of list - temp[_BLOCKSIZE - 1].FreeNext = NULL ; + temp[_BLOCKSIZE - 1].FreeNext = NULL; // Element [0] is reserved for global list linkage temp[0].set_object(CHAINMARKER); @@ -1022,7 +1022,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // Acquire the ListLock to manipulate BlockList and FreeList. // An Oyama-Taura-Yonezawa scheme might be more efficient. - Thread::muxAcquire (&ListLock, "omAlloc [2]") ; + Thread::muxAcquire(&ListLock, "omAlloc [2]"); MonitorPopulation += _BLOCKSIZE-1; MonitorFreeCount += _BLOCKSIZE-1; @@ -1033,10 +1033,10 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { gBlockList = temp; // Add the new string of objectMonitors to the global free list - temp[_BLOCKSIZE - 1].FreeNext = gFreeList ; + temp[_BLOCKSIZE - 1].FreeNext = gFreeList; gFreeList = temp + 1; - Thread::muxRelease (&ListLock) ; - TEVENT (Allocate block of monitors) ; + Thread::muxRelease(&ListLock); + TEVENT(Allocate block of monitors); } } @@ -1049,12 +1049,12 @@ ObjectMonitor * ATTR ObjectSynchronizer::omAlloc (Thread * Self) { // void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromPerThreadAlloc) { - guarantee (m->object() == NULL, "invariant") ; + guarantee(m->object() == NULL, "invariant"); // Remove from omInUseList if (MonitorInUseLists && fromPerThreadAlloc) { ObjectMonitor* curmidinuse = NULL; - for (ObjectMonitor* mid = Self->omInUseList; mid != NULL; ) { + for (ObjectMonitor* mid = Self->omInUseList; mid != NULL;) { if (m == mid) { // extract from per-thread in-use-list if (mid == Self->omInUseList) { @@ -1062,7 +1062,7 @@ void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromP } else if (curmidinuse != NULL) { curmidinuse->FreeNext = mid->FreeNext; // maintain the current thread inuselist } - Self->omInUseCount --; + Self->omInUseCount--; // verifyInUse(Self); break; } else { @@ -1073,9 +1073,9 @@ void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromP } // FreeNext is used for both onInUseList and omFreeList, so clear old before setting new - m->FreeNext = Self->omFreeList ; - Self->omFreeList = m ; - Self->omFreeCount ++ ; + m->FreeNext = Self->omFreeList; + Self->omFreeList = m; + Self->omFreeCount++; } // Return the monitors of a moribund thread's local free list to @@ -1099,25 +1099,25 @@ void ObjectSynchronizer::omRelease (Thread * Self, ObjectMonitor * m, bool fromP // operator. void ObjectSynchronizer::omFlush (Thread * Self) { - ObjectMonitor * List = Self->omFreeList ; // Null-terminated SLL - Self->omFreeList = NULL ; - ObjectMonitor * Tail = NULL ; + ObjectMonitor * List = Self->omFreeList; // Null-terminated SLL + Self->omFreeList = NULL; + ObjectMonitor * Tail = NULL; int Tally = 0; if (List != NULL) { - ObjectMonitor * s ; - for (s = List ; s != NULL ; s = s->FreeNext) { - Tally ++ ; - Tail = s ; - guarantee (s->object() == NULL, "invariant") ; - guarantee (!s->is_busy(), "invariant") ; - s->set_owner (NULL) ; // redundant but good hygiene - TEVENT (omFlush - Move one) ; + ObjectMonitor * s; + for (s = List; s != NULL; s = s->FreeNext) { + Tally++; + Tail = s; + guarantee(s->object() == NULL, "invariant"); + guarantee(!s->is_busy(), "invariant"); + s->set_owner(NULL); // redundant but good hygiene + TEVENT(omFlush - Move one); } - guarantee (Tail != NULL && List != NULL, "invariant") ; + guarantee(Tail != NULL && List != NULL, "invariant"); } ObjectMonitor * InUseList = Self->omInUseList; - ObjectMonitor * InUseTail = NULL ; + ObjectMonitor * InUseTail = NULL; int InUseTally = 0; if (InUseList != NULL) { Self->omInUseList = NULL; @@ -1129,13 +1129,13 @@ void ObjectSynchronizer::omFlush (Thread * Self) { // TODO debug assert(Self->omInUseCount == InUseTally, "inuse count off"); Self->omInUseCount = 0; - guarantee (InUseTail != NULL && InUseList != NULL, "invariant"); + guarantee(InUseTail != NULL && InUseList != NULL, "invariant"); } - Thread::muxAcquire (&ListLock, "omFlush") ; + Thread::muxAcquire(&ListLock, "omFlush"); if (Tail != NULL) { - Tail->FreeNext = gFreeList ; - gFreeList = List ; + Tail->FreeNext = gFreeList; + gFreeList = List; MonitorFreeCount += Tally; } @@ -1145,8 +1145,8 @@ void ObjectSynchronizer::omFlush (Thread * Self) { gOmInUseCount += InUseTally; } - Thread::muxRelease (&ListLock) ; - TEVENT (omFlush) ; + Thread::muxRelease(&ListLock); + TEVENT(omFlush); } // Fast path code shared by multiple functions @@ -1168,12 +1168,12 @@ ObjectMonitor* ObjectSynchronizer::inflate_helper(oop obj) { ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // Inflate mutates the heap ... // Relaxing assertion for bug 6320749. - assert (Universe::verify_in_progress() || - !SafepointSynchronize::is_at_safepoint(), "invariant") ; + assert(Universe::verify_in_progress() || + !SafepointSynchronize::is_at_safepoint(), "invariant"); for (;;) { - const markOop mark = object->mark() ; - assert (!mark->has_bias_pattern(), "invariant") ; + const markOop mark = object->mark(); + assert(!mark->has_bias_pattern(), "invariant"); // The mark can be in one of the following states: // * Inflated - just return @@ -1184,11 +1184,11 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // CASE: inflated if (mark->has_monitor()) { - ObjectMonitor * inf = mark->monitor() ; - assert (inf->header()->is_neutral(), "invariant"); - assert (inf->object() == object, "invariant") ; - assert (ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid"); - return inf ; + ObjectMonitor * inf = mark->monitor(); + assert(inf->header()->is_neutral(), "invariant"); + assert(inf->object() == object, "invariant"); + assert(ObjectSynchronizer::verify_objmon_isinpool(inf), "monitor is invalid"); + return inf; } // CASE: inflation in progress - inflating over a stack-lock. @@ -1198,9 +1198,9 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // Currently, we spin/yield/park and poll the markword, waiting for inflation to finish. // We could always eliminate polling by parking the thread on some auxiliary list. if (mark == markOopDesc::INFLATING()) { - TEVENT (Inflate: spin while INFLATING) ; - ReadStableMark(object) ; - continue ; + TEVENT(Inflate: spin while INFLATING); + ReadStableMark(object); + continue; } // CASE: stack-locked @@ -1223,20 +1223,20 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // See the comments in omAlloc(). if (mark->has_locker()) { - ObjectMonitor * m = omAlloc (Self) ; + ObjectMonitor * m = omAlloc(Self); // Optimistically prepare the objectmonitor - anticipate successful CAS // We do this before the CAS in order to minimize the length of time // in which INFLATING appears in the mark. m->Recycle(); - m->_Responsible = NULL ; - m->OwnerIsThread = 0 ; - m->_recursions = 0 ; - m->_SpinDuration = ObjectMonitor::Knob_SpinLimit ; // Consider: maintain by type/class + m->_Responsible = NULL; + m->OwnerIsThread = 0; + m->_recursions = 0; + m->_SpinDuration = ObjectMonitor::Knob_SpinLimit; // Consider: maintain by type/class - markOop cmp = (markOop) Atomic::cmpxchg_ptr (markOopDesc::INFLATING(), object->mark_addr(), mark) ; + markOop cmp = (markOop) Atomic::cmpxchg_ptr(markOopDesc::INFLATING(), object->mark_addr(), mark); if (cmp != mark) { - omRelease (Self, m, true) ; - continue ; // Interference -- just retry + omRelease(Self, m, true); + continue; // Interference -- just retry } // We've successfully installed INFLATING (0) into the mark-word. @@ -1269,11 +1269,11 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // The owner can't die or unwind past the lock while our INFLATING // object is in the mark. Furthermore the owner can't complete // an unlock on the object, either. - markOop dmw = mark->displaced_mark_helper() ; - assert (dmw->is_neutral(), "invariant") ; + markOop dmw = mark->displaced_mark_helper(); + assert(dmw->is_neutral(), "invariant"); // Setup monitor fields to proper values -- prepare the monitor - m->set_header(dmw) ; + m->set_header(dmw); // Optimization: if the mark->locker stack address is associated // with this thread we could simply set m->_owner = Self and @@ -1286,13 +1286,13 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // Must preserve store ordering. The monitor state must // be stable at the time of publishing the monitor address. - guarantee (object->mark() == markOopDesc::INFLATING(), "invariant") ; + guarantee(object->mark() == markOopDesc::INFLATING(), "invariant"); object->release_set_mark(markOopDesc::encode(m)); // Hopefully the performance counters are allocated on distinct cache lines // to avoid false sharing on MP systems ... - if (ObjectMonitor::_sync_Inflations != NULL) ObjectMonitor::_sync_Inflations->inc() ; - TEVENT(Inflate: overwrite stacklock) ; + if (ObjectMonitor::_sync_Inflations != NULL) ObjectMonitor::_sync_Inflations->inc(); + TEVENT(Inflate: overwrite stacklock); if (TraceMonitorInflation) { if (object->is_instance()) { ResourceMark rm; @@ -1301,7 +1301,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { object->klass()->external_name()); } } - return m ; + return m; } // CASE: neutral @@ -1314,26 +1314,26 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // An inflateTry() method that we could call from fast_enter() and slow_enter() // would be useful. - assert (mark->is_neutral(), "invariant"); - ObjectMonitor * m = omAlloc (Self) ; + assert(mark->is_neutral(), "invariant"); + ObjectMonitor * m = omAlloc(Self); // prepare m for installation - set monitor to initial state m->Recycle(); m->set_header(mark); m->set_owner(NULL); m->set_object(object); - m->OwnerIsThread = 1 ; - m->_recursions = 0 ; - m->_Responsible = NULL ; - m->_SpinDuration = ObjectMonitor::Knob_SpinLimit ; // consider: keep metastats by type/class + m->OwnerIsThread = 1; + m->_recursions = 0; + m->_Responsible = NULL; + m->_SpinDuration = ObjectMonitor::Knob_SpinLimit; // consider: keep metastats by type/class if (Atomic::cmpxchg_ptr (markOopDesc::encode(m), object->mark_addr(), mark) != mark) { - m->set_object (NULL) ; - m->set_owner (NULL) ; - m->OwnerIsThread = 0 ; - m->Recycle() ; - omRelease (Self, m, true) ; - m = NULL ; - continue ; + m->set_object(NULL); + m->set_owner(NULL); + m->OwnerIsThread = 0; + m->Recycle(); + omRelease(Self, m, true); + m = NULL; + continue; // interference - the markword changed - just retry. // The state-transitions are one-way, so there's no chance of // live-lock -- "Inflated" is an absorbing state. @@ -1341,8 +1341,8 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { // Hopefully the performance counters are allocated on distinct // cache lines to avoid false sharing on MP systems ... - if (ObjectMonitor::_sync_Inflations != NULL) ObjectMonitor::_sync_Inflations->inc() ; - TEVENT(Inflate: overwrite neutral) ; + if (ObjectMonitor::_sync_Inflations != NULL) ObjectMonitor::_sync_Inflations->inc(); + TEVENT(Inflate: overwrite neutral); if (TraceMonitorInflation) { if (object->is_instance()) { ResourceMark rm; @@ -1351,7 +1351,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { object->klass()->external_name()); } } - return m ; + return m; } } @@ -1391,7 +1391,7 @@ ObjectMonitor * ATTR ObjectSynchronizer::inflate (Thread * Self, oop object) { enum ManifestConstants { ClearResponsibleAtSTW = 0, MaximumRecheckInterval = 1000 -} ; +}; // Deflate a single monitor if not in use // Return true if deflated, false if in use @@ -1399,18 +1399,18 @@ bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj, ObjectMonitor** FreeHeadp, ObjectMonitor** FreeTailp) { bool deflated; // Normal case ... The monitor is associated with obj. - guarantee (obj->mark() == markOopDesc::encode(mid), "invariant") ; - guarantee (mid == obj->mark()->monitor(), "invariant"); - guarantee (mid->header()->is_neutral(), "invariant"); + guarantee(obj->mark() == markOopDesc::encode(mid), "invariant"); + guarantee(mid == obj->mark()->monitor(), "invariant"); + guarantee(mid->header()->is_neutral(), "invariant"); if (mid->is_busy()) { - if (ClearResponsibleAtSTW) mid->_Responsible = NULL ; + if (ClearResponsibleAtSTW) mid->_Responsible = NULL; deflated = false; } else { // Deflate the monitor if it is no longer being used // It's idle - scavenge and return to the global free list // plain old deflation ... - TEVENT (deflate_idle_monitors - scavenge1) ; + TEVENT(deflate_idle_monitors - scavenge1); if (TraceMonitorInflation) { if (obj->is_instance()) { ResourceMark rm; @@ -1423,7 +1423,7 @@ bool ObjectSynchronizer::deflate_monitor(ObjectMonitor* mid, oop obj, obj->release_set_mark(mid->header()); mid->clear(); - assert (mid->object() == NULL, "invariant") ; + assert(mid->object() == NULL, "invariant"); // Move the object to the working free list defined by FreeHead,FreeTail. if (*FreeHeadp == NULL) *FreeHeadp = mid; @@ -1446,7 +1446,7 @@ int ObjectSynchronizer::walk_monitor_list(ObjectMonitor** listheadp, ObjectMonitor* curmidinuse = NULL; int deflatedcount = 0; - for (mid = *listheadp; mid != NULL; ) { + for (mid = *listheadp; mid != NULL;) { oop obj = (oop) mid->object(); bool deflated = false; if (obj != NULL) { @@ -1473,19 +1473,19 @@ int ObjectSynchronizer::walk_monitor_list(ObjectMonitor** listheadp, void ObjectSynchronizer::deflate_idle_monitors() { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); - int nInuse = 0 ; // currently associated with objects - int nInCirculation = 0 ; // extant - int nScavenged = 0 ; // reclaimed + int nInuse = 0; // currently associated with objects + int nInCirculation = 0; // extant + int nScavenged = 0; // reclaimed bool deflated = false; - ObjectMonitor * FreeHead = NULL ; // Local SLL of scavenged monitors - ObjectMonitor * FreeTail = NULL ; + ObjectMonitor * FreeHead = NULL; // Local SLL of scavenged monitors + ObjectMonitor * FreeTail = NULL; - TEVENT (deflate_idle_monitors) ; + TEVENT(deflate_idle_monitors); // Prevent omFlush from changing mids in Thread dtor's during deflation // And in case the vm thread is acquiring a lock during a safepoint // See e.g. 6320749 - Thread::muxAcquire (&ListLock, "scavenge - return") ; + Thread::muxAcquire(&ListLock, "scavenge - return"); if (MonitorInUseLists) { int inUse = 0; @@ -1510,8 +1510,8 @@ void ObjectSynchronizer::deflate_idle_monitors() { } else for (ObjectMonitor* block = gBlockList; block != NULL; block = next(block)) { // Iterate over all extant monitors - Scavenge all idle monitors. assert(block->object() == CHAINMARKER, "must be a block header"); - nInCirculation += _BLOCKSIZE ; - for (int i = 1 ; i < _BLOCKSIZE; i++) { + nInCirculation += _BLOCKSIZE; + for (int i = 1; i < _BLOCKSIZE; i++) { ObjectMonitor* mid = &block[i]; oop obj = (oop) mid->object(); @@ -1520,16 +1520,16 @@ void ObjectSynchronizer::deflate_idle_monitors() { // The monitor should either be a thread-specific private // free list or the global free list. // obj == NULL IMPLIES mid->is_busy() == 0 - guarantee (!mid->is_busy(), "invariant") ; - continue ; + guarantee(!mid->is_busy(), "invariant"); + continue; } deflated = deflate_monitor(mid, obj, &FreeHead, &FreeTail); if (deflated) { - mid->FreeNext = NULL ; - nScavenged ++ ; + mid->FreeNext = NULL; + nScavenged++; } else { - nInuse ++; + nInuse++; } } } @@ -1539,31 +1539,31 @@ void ObjectSynchronizer::deflate_idle_monitors() { // Consider: audit gFreeList to ensure that MonitorFreeCount and list agree. if (ObjectMonitor::Knob_Verbose) { - ::printf ("Deflate: InCirc=%d InUse=%d Scavenged=%d ForceMonitorScavenge=%d : pop=%d free=%d\n", + ::printf("Deflate: InCirc=%d InUse=%d Scavenged=%d ForceMonitorScavenge=%d : pop=%d free=%d\n", nInCirculation, nInuse, nScavenged, ForceMonitorScavenge, - MonitorPopulation, MonitorFreeCount) ; - ::fflush(stdout) ; + MonitorPopulation, MonitorFreeCount); + ::fflush(stdout); } ForceMonitorScavenge = 0; // Reset // Move the scavenged monitors back to the global free list. if (FreeHead != NULL) { - guarantee (FreeTail != NULL && nScavenged > 0, "invariant") ; - assert (FreeTail->FreeNext == NULL, "invariant") ; + guarantee(FreeTail != NULL && nScavenged > 0, "invariant"); + assert(FreeTail->FreeNext == NULL, "invariant"); // constant-time list splice - prepend scavenged segment to gFreeList - FreeTail->FreeNext = gFreeList ; - gFreeList = FreeHead ; + FreeTail->FreeNext = gFreeList; + gFreeList = FreeHead; } - Thread::muxRelease (&ListLock) ; + Thread::muxRelease(&ListLock); - if (ObjectMonitor::_sync_Deflations != NULL) ObjectMonitor::_sync_Deflations->inc(nScavenged) ; + if (ObjectMonitor::_sync_Deflations != NULL) ObjectMonitor::_sync_Deflations->inc(nScavenged); if (ObjectMonitor::_sync_MonExtant != NULL) ObjectMonitor::_sync_MonExtant ->set_value(nInCirculation); // TODO: Add objectMonitor leak detection. // Audit/inventory the objectMonitors -- make sure they're all accounted for. - GVars.stwRandom = os::random() ; - GVars.stwCycle ++ ; + GVars.stwRandom = os::random(); + GVars.stwCycle++; } // Monitor cleanup on JavaThread::exit @@ -1601,7 +1601,7 @@ public: void ObjectSynchronizer::release_monitors_owned_by_thread(TRAPS) { assert(THREAD == JavaThread::current(), "must be current Java thread"); - No_Safepoint_Verifier nsv ; + No_Safepoint_Verifier nsv; ReleaseJavaMonitorsClosure rjmc(THREAD); Thread::muxAcquire(&ListLock, "release_monitors_owned_by_thread"); ObjectSynchronizer::monitors_iterate(&rjmc); diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index e3ab1725a1d..baca4a1bea7 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -225,11 +225,11 @@ Thread::Thread() { _current_pending_monitor_is_from_java = true; _current_waiting_monitor = NULL; _num_nested_signal = 0; - omFreeList = NULL ; - omFreeCount = 0 ; - omFreeProvision = 32 ; - omInUseList = NULL ; - omInUseCount = 0 ; + omFreeList = NULL; + omFreeCount = 0; + omFreeProvision = 32; + omInUseList = NULL; + omInUseCount = 0; #ifdef ASSERT _visited_for_critical_count = false; @@ -239,15 +239,15 @@ Thread::Thread() { _suspend_flags = 0; // thread-specific hashCode stream generator state - Marsaglia shift-xor form - _hashStateX = os::random() ; - _hashStateY = 842502087 ; - _hashStateZ = 0x8767 ; // (int)(3579807591LL & 0xffff) ; - _hashStateW = 273326509 ; + _hashStateX = os::random(); + _hashStateY = 842502087; + _hashStateZ = 0x8767; // (int)(3579807591LL & 0xffff) ; + _hashStateW = 273326509; - _OnTrap = 0 ; - _schedctl = NULL ; - _Stalled = 0 ; - _TypeTag = 0x2BAD ; + _OnTrap = 0; + _schedctl = NULL; + _Stalled = 0; + _TypeTag = 0x2BAD; // Many of the following fields are effectively final - immutable // Note that nascent threads can't use the Native Monitor-Mutex @@ -256,10 +256,10 @@ Thread::Thread() { // we might instead use a stack of ParkEvents that we could provision on-demand. // The stack would act as a cache to avoid calls to ParkEvent::Allocate() // and ::Release() - _ParkEvent = ParkEvent::Allocate (this) ; - _SleepEvent = ParkEvent::Allocate (this) ; - _MutexEvent = ParkEvent::Allocate (this) ; - _MuxEvent = ParkEvent::Allocate (this) ; + _ParkEvent = ParkEvent::Allocate(this); + _SleepEvent = ParkEvent::Allocate(this); + _MutexEvent = ParkEvent::Allocate(this); + _MuxEvent = ParkEvent::Allocate(this); #ifdef CHECK_UNHANDLED_OOPS if (CheckUnhandledOops) { @@ -314,7 +314,7 @@ void Thread::record_stack_base_and_size() { Thread::~Thread() { // Reclaim the objectmonitors from the omFreeList of the moribund thread. - ObjectSynchronizer::omFlush (this) ; + ObjectSynchronizer::omFlush(this); EVENT_THREAD_DESTRUCT(this); @@ -342,10 +342,10 @@ Thread::~Thread() { // It's possible we can encounter a null _ParkEvent, etc., in stillborn threads. // We NULL out the fields for good hygiene. - ParkEvent::Release (_ParkEvent) ; _ParkEvent = NULL ; - ParkEvent::Release (_SleepEvent) ; _SleepEvent = NULL ; - ParkEvent::Release (_MutexEvent) ; _MutexEvent = NULL ; - ParkEvent::Release (_MuxEvent) ; _MuxEvent = NULL ; + ParkEvent::Release(_ParkEvent); _ParkEvent = NULL; + ParkEvent::Release(_SleepEvent); _SleepEvent = NULL; + ParkEvent::Release(_MutexEvent); _MutexEvent = NULL; + ParkEvent::Release(_MuxEvent); _MuxEvent = NULL; delete handle_area(); delete metadata_handles(); @@ -844,7 +844,7 @@ void Thread::print_on(outputStream* st) const { // Thread::print_on_error() is called by fatal error handler. Don't use // any lock or allocate memory. void Thread::print_on_error(outputStream* st, char* buf, int buflen) const { - if (is_VM_thread()) st->print("VMThread"); + if (is_VM_thread()) st->print("VMThread"); else if (is_Compiler_thread()) st->print("CompilerThread"); else if (is_Java_thread()) st->print("JavaThread"); else if (is_GC_task_thread()) st->print("GCTaskThread"); @@ -867,7 +867,7 @@ void Thread::print_owned_locks_on(outputStream* st) const { st->print(" (no locks) "); } else { st->print_cr(" Locks owned:"); - while(cur) { + while (cur) { cur->print_on(st); cur = cur->next(); } @@ -877,7 +877,7 @@ void Thread::print_owned_locks_on(outputStream* st) const { static int ref_use_count = 0; bool Thread::owns_locks_but_compiled_lock() const { - for(Monitor *cur = _owned_locks; cur; cur = cur->next()) { + for (Monitor *cur = _owned_locks; cur; cur = cur->next()) { if (cur != Compile_lock) return true; } return false; @@ -904,12 +904,12 @@ void Thread::check_for_valid_safepoint_state(bool potential_vm_operation) { && !Universe::is_bootstrapping()) { // Make sure we do not hold any locks that the VM thread also uses. // This could potentially lead to deadlocks - for(Monitor *cur = _owned_locks; cur; cur = cur->next()) { + for (Monitor *cur = _owned_locks; cur; cur = cur->next()) { // Threads_lock is special, since the safepoint synchronization will not start before this is // acquired. Hence, a JavaThread cannot be holding it at a safepoint. So is VMOperationRequest_lock, // since it is used to transfer control between JavaThreads and the VMThread // Do not *exclude* any locks unless you are absolutely sure it is correct. Ask someone else first! - if ( (cur->allow_vm_block() && + if ((cur->allow_vm_block() && cur != Threads_lock && cur != Compile_lock && // Temporary: should not be necessary when we get separate compilation cur != VMOperationRequest_lock && @@ -1291,9 +1291,9 @@ void WatcherThread::run() { this->record_stack_base_and_size(); this->initialize_thread_local_storage(); this->set_active_handles(JNIHandleBlock::allocate_block()); - while(!_should_terminate) { - assert(watcher_thread() == Thread::current(), "thread consistency check"); - assert(watcher_thread() == this, "thread consistency check"); + while (!_should_terminate) { + assert(watcher_thread() == Thread::current(), "thread consistency check"); + assert(watcher_thread() == this, "thread consistency check"); // Calculate how long it'll be until the next PeriodicTask work // should be done, and sleep that amount of time. @@ -1370,7 +1370,7 @@ void WatcherThread::stop() { // it is ok to take late safepoints here, if needed MutexLocker mu(Terminator_lock); - while(watcher_thread() != NULL) { + while (watcher_thread() != NULL) { // This wait should make safepoint checks, wait without a timeout, // and wait as a suspend-equivalent condition. // @@ -1451,11 +1451,11 @@ void JavaThread::initialize() { _pending_jni_exception_check_fn = NULL; _do_not_unlock_if_synchronized = false; _cached_monitor_info = NULL; - _parker = Parker::Allocate(this) ; + _parker = Parker::Allocate(this); #ifndef PRODUCT _jmp_ring_index = 0; - for (int ji = 0 ; ji < jump_ring_buffer_size ; ji++ ) { + for (int ji = 0; ji < jump_ring_buffer_size; ji++) { record_jump(NULL, NULL, NULL, 0); } #endif /* PRODUCT */ @@ -1592,7 +1592,7 @@ JavaThread::~JavaThread() { // JSR166 -- return the parker to the free list Parker::Release(_parker); - _parker = NULL ; + _parker = NULL; // Free any remaining previous UnrollBlock vframeArray* old_array = vframe_array_last(); @@ -1718,7 +1718,7 @@ static void ensure_join(JavaThread* thread) { // For any new cleanup additions, please check to see if they need to be applied to // cleanup_failed_attach_current_thread as well. void JavaThread::exit(bool destroy_vm, ExitType exit_type) { - assert(this == JavaThread::current(), "thread consistency check"); + assert(this == JavaThread::current(), "thread consistency check"); HandleMark hm(this); Handle uncaught_exception(this, this->pending_exception()); @@ -2058,7 +2058,7 @@ void JavaThread::check_and_handle_async_exceptions(bool check_unsafe_error) { if (TraceExceptions) { ResourceMark rm; tty->print("Async. exception installed at runtime exit (" INTPTR_FORMAT ")", this); - if (has_last_Java_frame() ) { + if (has_last_Java_frame()) { frame f = last_frame(); tty->print(" (pc: " INTPTR_FORMAT " sp: " INTPTR_FORMAT " )", f.pc(), f.sp()); } @@ -2302,11 +2302,11 @@ int JavaThread::java_suspend_self() { void JavaThread::verify_not_published() { if (!Threads_lock->owned_by_self()) { MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag); - assert( !Threads::includes(this), + assert(!Threads::includes(this), "java thread shouldn't have been published yet!"); } else { - assert( !Threads::includes(this), + assert(!Threads::includes(this), "java thread shouldn't have been published yet!"); } } @@ -2375,7 +2375,7 @@ void JavaThread::check_safepoint_and_suspend_for_native_trans(JavaThread *thread thread->clear_deopt_suspend(); RegisterMap map(thread, false); frame f = thread->last_frame(); - while ( f.id() != thread->must_deopt_id() && ! f.is_first_frame()) { + while (f.id() != thread->must_deopt_id() && ! f.is_first_frame()) { f = f.sender(&map); } if (f.id() == thread->must_deopt_id()) { @@ -2499,8 +2499,8 @@ void JavaThread::enable_stack_yellow_zone() { // We need to adjust it to work correctly with guard_memory() address base = stack_yellow_zone_base() - stack_yellow_zone_size(); - guarantee(base < stack_base(),"Error calculating stack yellow zone"); - guarantee(base < os::current_stack_pointer(),"Error calculating stack yellow zone"); + guarantee(base < stack_base(), "Error calculating stack yellow zone"); + guarantee(base < os::current_stack_pointer(), "Error calculating stack yellow zone"); if (os::guard_memory((char *) base, stack_yellow_zone_size())) { _stack_guard_state = stack_guard_enabled; @@ -2535,10 +2535,10 @@ void JavaThread::enable_stack_red_zone() { assert(_stack_guard_state != stack_guard_unused, "must be using guard pages."); address base = stack_red_zone_base() - stack_red_zone_size(); - guarantee(base < stack_base(),"Error calculating stack red zone"); - guarantee(base < os::current_stack_pointer(),"Error calculating stack red zone"); + guarantee(base < stack_base(), "Error calculating stack red zone"); + guarantee(base < os::current_stack_pointer(), "Error calculating stack red zone"); - if(!os::guard_memory((char *) base, stack_red_zone_size())) { + if (!os::guard_memory((char *) base, stack_red_zone_size())) { warning("Attempt to guard stack red zone failed."); } } @@ -2557,7 +2557,7 @@ void JavaThread::frames_do(void f(frame*, const RegisterMap* map)) { // ignore is there is no stack if (!has_last_Java_frame()) return; // traverse the stack frames. Starts from top frame. - for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { frame* fr = fst.current(); f(fr, fst.register_map()); } @@ -2573,8 +2573,8 @@ void JavaThread::deoptimize() { bool deopt = false; // Dump stack only if a deopt actually happens. bool only_at = strlen(DeoptimizeOnlyAt) > 0; // Iterate over all frames in the thread and deoptimize - for(; !fst.is_done(); fst.next()) { - if(fst.current()->can_be_deoptimized()) { + for (; !fst.is_done(); fst.next()) { + if (fst.current()->can_be_deoptimized()) { if (only_at) { // Deoptimize only at particular bcis. DeoptimizeOnlyAt @@ -2619,7 +2619,7 @@ void JavaThread::deoptimize() { // Make zombies void JavaThread::make_zombies() { - for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { if (fst.current()->can_be_deoptimized()) { // it is a Java nmethod nmethod* nm = CodeCache::find_nmethod(fst.current()->pc()); @@ -2634,7 +2634,7 @@ void JavaThread::deoptimized_wrt_marked_nmethods() { if (!has_last_Java_frame()) return; // BiasedLocking needs an updated RegisterMap for the revoke monitors pass StackFrameStream fst(this, UseBiasedLocking); - for(; !fst.is_done(); fst.next()) { + for (; !fst.is_done(); fst.next()) { if (fst.current()->should_be_deoptimized()) { if (LogCompilation && xtty != NULL) { nmethod* nm = fst.current()->cb()->as_nmethod_or_null(); @@ -2694,7 +2694,7 @@ void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) // Traverse the GCHandles Thread::oops_do(f, cld_f, cf); - assert( (!has_last_Java_frame() && java_call_counter() == 0) || + assert((!has_last_Java_frame() && java_call_counter() == 0) || (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); if (has_last_Java_frame()) { @@ -2719,7 +2719,7 @@ void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) } // Traverse the execution stack - for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { fst.current()->oops_do(f, cld_f, cf, fst.register_map()); } } @@ -2754,12 +2754,12 @@ void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) void JavaThread::nmethods_do(CodeBlobClosure* cf) { Thread::nmethods_do(cf); // (super method is a no-op) - assert( (!has_last_Java_frame() && java_call_counter() == 0) || + assert((!has_last_Java_frame() && java_call_counter() == 0) || (has_last_Java_frame() && java_call_counter() > 0), "wrong java_sp info!"); if (has_last_Java_frame()) { // Traverse the execution stack - for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { fst.current()->nmethods_do(cf); } } @@ -2769,7 +2769,7 @@ void JavaThread::metadata_do(void f(Metadata*)) { Thread::metadata_do(f); if (has_last_Java_frame()) { // Traverse the execution stack to call f() on the methods in the stack - for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { fst.current()->metadata_do(f); } } else if (is_Compiler_thread()) { @@ -2832,7 +2832,7 @@ void JavaThread::print_on(outputStream *st) const { // Called by fatal error handler. The difference between this and // JavaThread::print() is that we can't grab lock or allocate memory. void JavaThread::print_on_error(outputStream* st, char *buf, int buflen) const { - st->print("JavaThread \"%s\"", get_thread_name_string(buf, buflen)); + st->print("JavaThread \"%s\"", get_thread_name_string(buf, buflen)); oop thread_obj = threadObj(); if (thread_obj != NULL) { if (java_lang_Thread::is_daemon(thread_obj)) st->print(" daemon"); @@ -3015,7 +3015,7 @@ void JavaThread::print_stack_on(outputStream* st) { RegisterMap reg_map(this); vframe* start_vf = last_java_vframe(®_map); int count = 0; - for (vframe* f = start_vf; f; f = f->sender() ) { + for (vframe* f = start_vf; f; f = f->sender()) { if (f->is_java_frame()) { javaVFrame* jvf = javaVFrame::cast(f); java_lang_Throwable::print_stack_element(st, jvf->method(), jvf->bci()); @@ -3071,9 +3071,9 @@ void JavaThread::popframe_free_preserved_args() { void JavaThread::trace_frames() { tty->print_cr("[Describe stack]"); int frame_no = 1; - for(StackFrameStream fst(this); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { tty->print(" %d. ", frame_no++); - fst.current()->print_value_on(tty,this); + fst.current()->print_value_on(tty, this); tty->cr(); } } @@ -3124,7 +3124,7 @@ void JavaThread::print_frame_layout(int depth, bool validate_only) { PRESERVE_EXCEPTION_MARK; FrameValues values; int frame_no = 0; - for(StackFrameStream fst(this, false); !fst.is_done(); fst.next()) { + for (StackFrameStream fst(this, false); !fst.is_done(); fst.next()) { fst.current()->describe(values, ++frame_no); if (depth == frame_no) break; } @@ -3140,7 +3140,7 @@ void JavaThread::print_frame_layout(int depth, bool validate_only) { void JavaThread::trace_stack_from(vframe* start_vf) { ResourceMark rm; int vframe_no = 1; - for (vframe* f = start_vf; f; f = f->sender() ) { + for (vframe* f = start_vf; f; f = f->sender()) { if (f->is_java_frame()) { javaVFrame::cast(f)->print_activation(vframe_no++); } else { @@ -3169,7 +3169,7 @@ void JavaThread::trace_stack() { javaVFrame* JavaThread::last_java_vframe(RegisterMap *reg_map) { assert(reg_map != NULL, "a map must be given"); frame f = last_frame(); - for (vframe* vf = vframe::new_vframe(&f, reg_map, this); vf; vf = vf->sender() ) { + for (vframe* vf = vframe::new_vframe(&f, reg_map, this); vf; vf = vf->sender()) { if (vf->is_java_frame()) return javaVFrame::cast(vf); } return NULL; @@ -3291,7 +3291,7 @@ void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { // The VM preresolves methods to these classes. Make sure that they get initialized initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK); - initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK); + initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK); call_initializeSystemClass(CHECK); // get the Java runtime name after java.lang.System is initialized @@ -3425,7 +3425,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { main_thread->create_stack_guard_pages(); // Initialize Java-Level synchronization subsystem - ObjectMonitor::Initialize() ; + ObjectMonitor::Initialize(); // Second phase of bootstrapping, VM is about entering multi-thread mode MemTracker::bootstrap_multi_thread(); @@ -3473,7 +3473,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { } } - assert (Universe::is_fully_initialized(), "not initialized"); + assert(Universe::is_fully_initialized(), "not initialized"); if (VerifyDuringStartup) { // Make sure we're starting with a clean slate. VM_Verify verify_op; @@ -3899,7 +3899,7 @@ bool Threads::destroy_vm() { #endif // Wait until we are the last non-daemon thread to execute { MutexLocker nu(Threads_lock); - while (Threads::number_of_non_daemon_threads() > 1 ) + while (Threads::number_of_non_daemon_threads() > 1) // This wait should make safepoint checks, wait without a timeout, // and wait as a suspend-equivalent condition. // @@ -4078,7 +4078,7 @@ void Threads::remove(JavaThread* p) { bool Threads::includes(JavaThread* p) { assert(Threads_lock->is_locked(), "sanity check"); ALL_JAVA_THREADS(q) { - if (q == p ) { + if (q == p) { return true; } } @@ -4363,43 +4363,43 @@ void Threads::print_on_error(outputStream* st, Thread* current, char* buf, int b // cache-coherency traffic. -typedef volatile int SpinLockT ; +typedef volatile int SpinLockT; void Thread::SpinAcquire (volatile int * adr, const char * LockName) { if (Atomic::cmpxchg (1, adr, 0) == 0) { - return ; // normal fast-path return + return; // normal fast-path return } // Slow-path : We've encountered contention -- Spin/Yield/Block strategy. - TEVENT (SpinAcquire - ctx) ; - int ctr = 0 ; - int Yields = 0 ; + TEVENT(SpinAcquire - ctx); + int ctr = 0; + int Yields = 0; for (;;) { while (*adr != 0) { - ++ctr ; + ++ctr; if ((ctr & 0xFFF) == 0 || !os::is_MP()) { if (Yields > 5) { os::naked_short_sleep(1); } else { - os::NakedYield() ; - ++Yields ; + os::NakedYield(); + ++Yields; } } else { - SpinPause() ; + SpinPause(); } } - if (Atomic::cmpxchg (1, adr, 0) == 0) return ; + if (Atomic::cmpxchg(1, adr, 0) == 0) return; } } void Thread::SpinRelease (volatile int * adr) { - assert (*adr != 0, "invariant") ; - OrderAccess::fence() ; // guarantee at least release consistency. + assert(*adr != 0, "invariant"); + OrderAccess::fence(); // guarantee at least release consistency. // Roach-motel semantics. // It's safe if subsequent LDs and STs float "up" into the critical section, // but prior LDs and STs within the critical section can't be allowed // to reorder or float past the ST that releases the lock. - *adr = 0 ; + *adr = 0; } // muxAcquire and muxRelease: @@ -4452,111 +4452,111 @@ void Thread::SpinRelease (volatile int * adr) { // -typedef volatile intptr_t MutexT ; // Mux Lock-word -enum MuxBits { LOCKBIT = 1 } ; +typedef volatile intptr_t MutexT; // Mux Lock-word +enum MuxBits { LOCKBIT = 1 }; void Thread::muxAcquire (volatile intptr_t * Lock, const char * LockName) { - intptr_t w = Atomic::cmpxchg_ptr (LOCKBIT, Lock, 0) ; - if (w == 0) return ; + intptr_t w = Atomic::cmpxchg_ptr(LOCKBIT, Lock, 0); + if (w == 0) return; if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) { - return ; + return; } - TEVENT (muxAcquire - Contention) ; - ParkEvent * const Self = Thread::current()->_MuxEvent ; - assert ((intptr_t(Self) & LOCKBIT) == 0, "invariant") ; + TEVENT(muxAcquire - Contention); + ParkEvent * const Self = Thread::current()->_MuxEvent; + assert((intptr_t(Self) & LOCKBIT) == 0, "invariant"); for (;;) { - int its = (os::is_MP() ? 100 : 0) + 1 ; + int its = (os::is_MP() ? 100 : 0) + 1; // Optional spin phase: spin-then-park strategy while (--its >= 0) { - w = *Lock ; + w = *Lock; if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) { - return ; + return; } } - Self->reset() ; - Self->OnList = intptr_t(Lock) ; + Self->reset(); + Self->OnList = intptr_t(Lock); // The following fence() isn't _strictly necessary as the subsequent // CAS() both serializes execution and ratifies the fetched *Lock value. OrderAccess::fence(); for (;;) { - w = *Lock ; + w = *Lock; if ((w & LOCKBIT) == 0) { if (Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) { - Self->OnList = 0 ; // hygiene - allows stronger asserts - return ; + Self->OnList = 0; // hygiene - allows stronger asserts + return; } - continue ; // Interference -- *Lock changed -- Just retry + continue; // Interference -- *Lock changed -- Just retry } - assert (w & LOCKBIT, "invariant") ; - Self->ListNext = (ParkEvent *) (w & ~LOCKBIT ); - if (Atomic::cmpxchg_ptr (intptr_t(Self)|LOCKBIT, Lock, w) == w) break ; + assert(w & LOCKBIT, "invariant"); + Self->ListNext = (ParkEvent *) (w & ~LOCKBIT); + if (Atomic::cmpxchg_ptr(intptr_t(Self)|LOCKBIT, Lock, w) == w) break; } while (Self->OnList != 0) { - Self->park() ; + Self->park(); } } } void Thread::muxAcquireW (volatile intptr_t * Lock, ParkEvent * ev) { - intptr_t w = Atomic::cmpxchg_ptr (LOCKBIT, Lock, 0) ; - if (w == 0) return ; + intptr_t w = Atomic::cmpxchg_ptr(LOCKBIT, Lock, 0); + if (w == 0) return; if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) { - return ; + return; } - TEVENT (muxAcquire - Contention) ; - ParkEvent * ReleaseAfter = NULL ; + TEVENT(muxAcquire - Contention); + ParkEvent * ReleaseAfter = NULL; if (ev == NULL) { - ev = ReleaseAfter = ParkEvent::Allocate (NULL) ; + ev = ReleaseAfter = ParkEvent::Allocate(NULL); } - assert ((intptr_t(ev) & LOCKBIT) == 0, "invariant") ; + assert((intptr_t(ev) & LOCKBIT) == 0, "invariant"); for (;;) { - guarantee (ev->OnList == 0, "invariant") ; - int its = (os::is_MP() ? 100 : 0) + 1 ; + guarantee(ev->OnList == 0, "invariant"); + int its = (os::is_MP() ? 100 : 0) + 1; // Optional spin phase: spin-then-park strategy while (--its >= 0) { - w = *Lock ; + w = *Lock; if ((w & LOCKBIT) == 0 && Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) { if (ReleaseAfter != NULL) { - ParkEvent::Release (ReleaseAfter) ; + ParkEvent::Release(ReleaseAfter); } - return ; + return; } } - ev->reset() ; - ev->OnList = intptr_t(Lock) ; + ev->reset(); + ev->OnList = intptr_t(Lock); // The following fence() isn't _strictly necessary as the subsequent // CAS() both serializes execution and ratifies the fetched *Lock value. OrderAccess::fence(); for (;;) { - w = *Lock ; + w = *Lock; if ((w & LOCKBIT) == 0) { if (Atomic::cmpxchg_ptr (w|LOCKBIT, Lock, w) == w) { - ev->OnList = 0 ; + ev->OnList = 0; // We call ::Release while holding the outer lock, thus // artificially lengthening the critical section. // Consider deferring the ::Release() until the subsequent unlock(), // after we've dropped the outer lock. if (ReleaseAfter != NULL) { - ParkEvent::Release (ReleaseAfter) ; + ParkEvent::Release(ReleaseAfter); } - return ; + return; } - continue ; // Interference -- *Lock changed -- Just retry + continue; // Interference -- *Lock changed -- Just retry } - assert (w & LOCKBIT, "invariant") ; - ev->ListNext = (ParkEvent *) (w & ~LOCKBIT ); - if (Atomic::cmpxchg_ptr (intptr_t(ev)|LOCKBIT, Lock, w) == w) break ; + assert(w & LOCKBIT, "invariant"); + ev->ListNext = (ParkEvent *) (w & ~LOCKBIT); + if (Atomic::cmpxchg_ptr(intptr_t(ev)|LOCKBIT, Lock, w) == w) break; } while (ev->OnList != 0) { - ev->park() ; + ev->park(); } } } @@ -4583,22 +4583,22 @@ void Thread::muxAcquireW (volatile intptr_t * Lock, ParkEvent * ev) { void Thread::muxRelease (volatile intptr_t * Lock) { for (;;) { - const intptr_t w = Atomic::cmpxchg_ptr (0, Lock, LOCKBIT) ; - assert (w & LOCKBIT, "invariant") ; - if (w == LOCKBIT) return ; - ParkEvent * List = (ParkEvent *) (w & ~LOCKBIT) ; - assert (List != NULL, "invariant") ; - assert (List->OnList == intptr_t(Lock), "invariant") ; - ParkEvent * nxt = List->ListNext ; + const intptr_t w = Atomic::cmpxchg_ptr(0, Lock, LOCKBIT); + assert(w & LOCKBIT, "invariant"); + if (w == LOCKBIT) return; + ParkEvent * List = (ParkEvent *)(w & ~LOCKBIT); + assert(List != NULL, "invariant"); + assert(List->OnList == intptr_t(Lock), "invariant"); + ParkEvent * nxt = List->ListNext; // The following CAS() releases the lock and pops the head element. if (Atomic::cmpxchg_ptr (intptr_t(nxt), Lock, w) != w) { - continue ; + continue; } - List->OnList = 0 ; - OrderAccess::fence() ; - List->unpark () ; - return ; + List->OnList = 0; + OrderAccess::fence(); + List->unpark(); + return; } } diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 64bed4610b0..68c9248dea4 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -244,7 +244,7 @@ class Thread: public ThreadShadow { // The two classes No_Safepoint_Verifier and No_Allocation_Verifier are used to set these counters. // NOT_PRODUCT(int _allow_safepoint_count;) // If 0, thread allow a safepoint to happen - debug_only (int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops. + debug_only(int _allow_allocation_count;) // If 0, the thread is allowed to allocate oops. // Used by SkipGCALot class. NOT_PRODUCT(bool _skip_gcalot;) // Should we elide gc-a-lot? @@ -593,12 +593,12 @@ public: bool is_inside_jvmti_env_iteration() { return _jvmti_env_iteration_count > 0; } // Code generation - static ByteSize exception_file_offset() { return byte_offset_of(Thread, _exception_file ); } - static ByteSize exception_line_offset() { return byte_offset_of(Thread, _exception_line ); } - static ByteSize active_handles_offset() { return byte_offset_of(Thread, _active_handles ); } + static ByteSize exception_file_offset() { return byte_offset_of(Thread, _exception_file); } + static ByteSize exception_line_offset() { return byte_offset_of(Thread, _exception_line); } + static ByteSize active_handles_offset() { return byte_offset_of(Thread, _active_handles); } - static ByteSize stack_base_offset() { return byte_offset_of(Thread, _stack_base ); } - static ByteSize stack_size_offset() { return byte_offset_of(Thread, _stack_size ); } + static ByteSize stack_base_offset() { return byte_offset_of(Thread, _stack_base); } + static ByteSize stack_size_offset() { return byte_offset_of(Thread, _stack_size); } #define TLAB_FIELD_OFFSET(name) \ static ByteSize tlab_##name##_offset() { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); } @@ -615,35 +615,35 @@ public: #undef TLAB_FIELD_OFFSET - static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes ); } + static ByteSize allocated_bytes_offset() { return byte_offset_of(Thread, _allocated_bytes); } public: - volatile intptr_t _Stalled ; - volatile int _TypeTag ; - ParkEvent * _ParkEvent ; // for synchronized() - ParkEvent * _SleepEvent ; // for Thread.sleep - ParkEvent * _MutexEvent ; // for native internal Mutex/Monitor - ParkEvent * _MuxEvent ; // for low-level muxAcquire-muxRelease - int NativeSyncRecursion ; // diagnostic + volatile intptr_t _Stalled; + volatile int _TypeTag; + ParkEvent * _ParkEvent; // for synchronized() + ParkEvent * _SleepEvent; // for Thread.sleep + ParkEvent * _MutexEvent; // for native internal Mutex/Monitor + ParkEvent * _MuxEvent; // for low-level muxAcquire-muxRelease + int NativeSyncRecursion; // diagnostic - volatile int _OnTrap ; // Resume-at IP delta - jint _hashStateW ; // Marsaglia Shift-XOR thread-local RNG - jint _hashStateX ; // thread-specific hashCode generator state - jint _hashStateY ; - jint _hashStateZ ; - void * _schedctl ; + volatile int _OnTrap; // Resume-at IP delta + jint _hashStateW; // Marsaglia Shift-XOR thread-local RNG + jint _hashStateX; // thread-specific hashCode generator state + jint _hashStateY; + jint _hashStateZ; + void * _schedctl; - volatile jint rng [4] ; // RNG for spin loop + volatile jint rng[4]; // RNG for spin loop // Low-level leaf-lock primitives used to implement synchronization // and native monitor-mutex infrastructure. // Not for general synchronization use. - static void SpinAcquire (volatile int * Lock, const char * Name) ; - static void SpinRelease (volatile int * Lock) ; - static void muxAcquire (volatile intptr_t * Lock, const char * Name) ; - static void muxAcquireW (volatile intptr_t * Lock, ParkEvent * ev) ; - static void muxRelease (volatile intptr_t * Lock) ; + static void SpinAcquire(volatile int * Lock, const char * Name); + static void SpinRelease(volatile int * Lock); + static void muxAcquire(volatile intptr_t * Lock, const char * Name); + static void muxAcquireW(volatile intptr_t * Lock, ParkEvent * ev); + static void muxRelease(volatile intptr_t * Lock); }; // Inline implementation of Thread::current() @@ -933,7 +933,7 @@ class JavaThread: public Thread { intptr_t _instruction; const char* _file; int _line; - } _jmp_ring[ jump_ring_buffer_size ]; + } _jmp_ring[jump_ring_buffer_size]; #endif /* PRODUCT */ #if INCLUDE_ALL_GCS @@ -1336,34 +1336,34 @@ class JavaThread: public Thread { #endif /* PRODUCT */ // For assembly stub generation - static ByteSize threadObj_offset() { return byte_offset_of(JavaThread, _threadObj ); } + static ByteSize threadObj_offset() { return byte_offset_of(JavaThread, _threadObj); } #ifndef PRODUCT - static ByteSize jmp_ring_index_offset() { return byte_offset_of(JavaThread, _jmp_ring_index ); } - static ByteSize jmp_ring_offset() { return byte_offset_of(JavaThread, _jmp_ring ); } + static ByteSize jmp_ring_index_offset() { return byte_offset_of(JavaThread, _jmp_ring_index); } + static ByteSize jmp_ring_offset() { return byte_offset_of(JavaThread, _jmp_ring); } #endif /* PRODUCT */ - static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment ); } - static ByteSize last_Java_sp_offset() { + static ByteSize jni_environment_offset() { return byte_offset_of(JavaThread, _jni_environment); } + static ByteSize last_Java_sp_offset() { return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_sp_offset(); } - static ByteSize last_Java_pc_offset() { + static ByteSize last_Java_pc_offset() { return byte_offset_of(JavaThread, _anchor) + JavaFrameAnchor::last_Java_pc_offset(); } - static ByteSize frame_anchor_offset() { + static ByteSize frame_anchor_offset() { return byte_offset_of(JavaThread, _anchor); } - static ByteSize callee_target_offset() { return byte_offset_of(JavaThread, _callee_target ); } - static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result ); } - static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2 ); } - static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state ); } - static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); } - static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); } - static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); } - static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc ); } + static ByteSize callee_target_offset() { return byte_offset_of(JavaThread, _callee_target); } + static ByteSize vm_result_offset() { return byte_offset_of(JavaThread, _vm_result); } + static ByteSize vm_result_2_offset() { return byte_offset_of(JavaThread, _vm_result_2); } + static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state); } + static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc); } + static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread); } + static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop); } + static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc); } static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); } static ByteSize stack_overflow_limit_offset() { return byte_offset_of(JavaThread, _stack_overflow_limit); } static ByteSize is_method_handle_return_offset() { return byte_offset_of(JavaThread, _is_method_handle_return); } - static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state ); } - static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags ); } + static ByteSize stack_guard_state_offset() { return byte_offset_of(JavaThread, _stack_guard_state); } + static ByteSize suspend_flags_offset() { return byte_offset_of(JavaThread, _suspend_flags); } static ByteSize do_not_unlock_if_synchronized_offset() { return byte_offset_of(JavaThread, _do_not_unlock_if_synchronized); } static ByteSize should_post_on_exceptions_flag_offset() { @@ -1422,7 +1422,7 @@ class JavaThread: public Thread { void remove_monitor_chunk(MonitorChunk* chunk); bool in_deopt_handler() const { return _in_deopt_handler > 0; } void inc_in_deopt_handler() { _in_deopt_handler++; } - void dec_in_deopt_handler() { + void dec_in_deopt_handler() { assert(_in_deopt_handler > 0, "mismatched deopt nesting"); if (_in_deopt_handler > 0) { // robustness _in_deopt_handler--; @@ -1776,7 +1776,7 @@ private: uint _claimed_par_id; public: uint get_claimed_par_id() { return _claimed_par_id; } - void set_claimed_par_id(uint id) { _claimed_par_id = id;} + void set_claimed_par_id(uint id) { _claimed_par_id = id; } }; // Inline implementation of JavaThread::current @@ -1811,7 +1811,7 @@ inline bool JavaThread::stack_yellow_zone_enabled() { inline size_t JavaThread::stack_available(address cur_sp) { // This code assumes java stacks grow down address low_addr; // Limit on the address for deepest stack depth - if ( _stack_guard_state == stack_guard_unused) { + if (_stack_guard_state == stack_guard_unused) { low_addr = stack_base() - stack_size(); } else { low_addr = stack_yellow_zone_base(); From 02f3dbb898c271693cad1107dfe55948a2b02022 Mon Sep 17 00:00:00 2001 From: David Dehaven Date: Tue, 17 Jun 2014 11:18:10 -0700 Subject: [PATCH 074/236] 8043340: [macosx] Fix hard-wired paths to JavaVM.framework Build system tweaks to allow building with Xcode 5 and on OS X 10.9 and later Reviewed-by: erikj, henryjen, dholmes --- .../agent/src/os/bsd/MacosxDebuggerLocal.m | 4 +-- hotspot/agent/src/os/bsd/Makefile | 6 ++--- hotspot/make/bsd/makefiles/saproc.make | 27 ++++++++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m b/hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m index 0f0ff4e5da4..044340aa511 100644 --- a/hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m +++ b/hotspot/agent/src/os/bsd/MacosxDebuggerLocal.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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,7 +26,7 @@ #import #import -#include +#include #import #import diff --git a/hotspot/agent/src/os/bsd/Makefile b/hotspot/agent/src/os/bsd/Makefile index ce3e2c4c32c..eabe1f7730d 100644 --- a/hotspot/agent/src/os/bsd/Makefile +++ b/hotspot/agent/src/os/bsd/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2002, 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 @@ -50,9 +50,9 @@ SOURCES = symtab.c \ ps_core.c OBJS = $(SOURCES:.c=.o) OBJSPLUS = MacosxDebuggerLocal.o sadis.o $(OBJS) -EXTINCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers -I. +EXTINCLUDE = -I. EXTCFLAGS = -m64 -D__APPLE__ -framework JavaNativeFoundation -FOUNDATIONFLAGS = -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation +FOUNDATIONFLAGS = -framework Foundation -framework JavaNativeFoundation -framework Security -framework CoreFoundation LIBSA = $(ARCH)/libsaproc.dylib endif # Darwin diff --git a/hotspot/make/bsd/makefiles/saproc.make b/hotspot/make/bsd/makefiles/saproc.make index a147325979f..1b0d5d603e8 100644 --- a/hotspot/make/bsd/makefiles/saproc.make +++ b/hotspot/make/bsd/makefiles/saproc.make @@ -64,9 +64,23 @@ ifeq ($(OS_VENDOR), FreeBSD) else ifeq ($(OS_VENDOR), Darwin) SASRCFILES = $(DARWIN_NON_STUB_SASRCFILES) - SALIBS = -g -framework Foundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks -framework JavaNativeFoundation -framework Security -framework CoreFoundation + SALIBS = -g \ + -framework Foundation \ + -framework JavaNativeFoundation \ + -framework Security \ + -framework CoreFoundation #objc compiler blows up on -march=i586, perhaps it should not be included in the macosx intel 32-bit C++ compiles? SAARCH = $(subst -march=i586,,$(ARCHFLAG)) + + # This is needed to locate JavaNativeFoundation.framework + ifeq ($(SYSROOT_CFLAGS),) + # this will happen when building without spec.gmk, set SDKROOT to a valid SDK + # path if your system does not have headers installed in the system frameworks + SA_SYSROOT_FLAGS = -F"$(SDKROOT)/System/Library/Frameworks/JavaVM.framework/Frameworks" + else + # Just use SYSROOT_CFLAGS + SA_SYSROOT_FLAGS=$(SYSROOT_CFLAGS) + endif else SASRCFILES = $(SASRCDIR)/StubDebuggerLocal.c SALIBS = @@ -100,14 +114,8 @@ SA_LFLAGS = $(MAPFLAG:FILENAME=$(SAMAPFILE)) endif SA_LFLAGS += $(LDFLAGS_HASH_STYLE) -ifeq ($(OS_VENDOR), Darwin) - BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \ - -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") \ - -I/System/Library/Frameworks/JavaVM.framework/Headers -else - BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \ - -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") -endif +BOOT_JAVA_INCLUDES = -I$(BOOT_JAVA_HOME)/include \ + -I$(BOOT_JAVA_HOME)/include/$(shell uname -s | tr "[:upper:]" "[:lower:]") $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE) $(QUIETLY) if [ "$(BOOT_JAVA_HOME)" = "" ]; then \ @@ -116,6 +124,7 @@ $(LIBSAPROC): $(SASRCFILES) $(SAMAPFILE) fi @echo Making SA debugger back-end... $(QUIETLY) $(CC) -D$(BUILDARCH) -D_GNU_SOURCE \ + $(SA_SYSROOT_FLAGS) \ $(SYMFLAG) $(SAARCH) $(SHARED_FLAG) $(PICFLAG) \ -I$(SASRCDIR) \ -I$(GENERATED) \ From 88577971d09c29b9b15cc7a61c8c0c4416d9e078 Mon Sep 17 00:00:00 2001 From: Dan Horak Date: Wed, 18 Jun 2014 13:25:40 +0200 Subject: [PATCH 075/236] 8043722: Swapped usage of idx_t and bm_word_t types in parMarkBitMap.cpp Clean up usage of idx_t and uintptr_t when using it in conjunction with BitMap::set_map(), casting to the appropriate type. Fixes compilation on S390. Reviewed-by: tschatzl --- hotspot/src/share/vm/compiler/methodLiveness.cpp | 4 ++-- hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp | 2 +- .../vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/compiler/methodLiveness.cpp b/hotspot/src/share/vm/compiler/methodLiveness.cpp index 0c1d9b09232..eda1ab156b3 100644 --- a/hotspot/src/share/vm/compiler/methodLiveness.cpp +++ b/hotspot/src/share/vm/compiler/methodLiveness.cpp @@ -475,7 +475,7 @@ MethodLivenessResult MethodLiveness::get_liveness_at(int entry_bci) { bci = 0; } - MethodLivenessResult answer((uintptr_t*)NULL,0); + MethodLivenessResult answer((BitMap::bm_word_t*)NULL,0); if (_block_count > 0) { if (TimeLivenessAnalysis) _time_total.start(); @@ -1000,7 +1000,7 @@ bool MethodLiveness::BasicBlock::merge_exception(BitMap other) { } MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* method, int bci) { - MethodLivenessResult answer(NEW_RESOURCE_ARRAY(uintptr_t, _analyzer->bit_map_size_words()), + MethodLivenessResult answer(NEW_RESOURCE_ARRAY(BitMap::bm_word_t, _analyzer->bit_map_size_words()), _analyzer->bit_map_size_bits()); answer.set_is_valid(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 24c62d775bd..9d80a5c7212 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -127,7 +127,7 @@ bool CMBitMap::allocate(ReservedSpace heap_rs) { } assert(_virtual_space.committed_size() == brs.size(), "didn't reserve backing store for all of concurrent marking bit map?"); - _bm.set_map((uintptr_t*)_virtual_space.low()); + _bm.set_map((BitMap::bm_word_t*)_virtual_space.low()); assert(_virtual_space.committed_size() << (_shifter + LogBitsPerByte) >= _bmWordSize, "inconsistency in bit map sizing"); _bm.set_size(_bmWordSize >> _shifter); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp index 76a368b692c..19a055cc040 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp @@ -71,7 +71,7 @@ ParMarkBitMap::initialize(MemRegion covered_region) if (_virtual_space != NULL && _virtual_space->expand_by(_reserved_byte_size)) { _region_start = covered_region.start(); _region_size = covered_region.word_size(); - idx_t* map = (idx_t*)_virtual_space->reserved_low_addr(); + BitMap::bm_word_t* map = (BitMap::bm_word_t*)_virtual_space->reserved_low_addr(); _beg_bits.set_map(map); _beg_bits.set_size(bits / 2); _end_bits.set_map(map + words / 2); From 7ae9df8697cae73952af9a023aeb519c520af1c8 Mon Sep 17 00:00:00 2001 From: Igor Veresov Date: Wed, 18 Jun 2014 10:54:32 -0700 Subject: [PATCH 076/236] 8046684: sharedRuntime.cpp...assert(((nmethod*)cb)->is_at_poll_or_poll_return(pc)) failed: safepoint polling: type must be poll Emit a poll relocation for the testl in is_polling_page_far() on x86 Reviewed-by: vlivanov, roland --- hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index b9702a35e41..62bb56fe97f 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -625,6 +625,7 @@ int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) { __ lea(rscratch1, polling_page); offset = __ offset(); add_debug_info_for_branch(info); + __ relocate(relocInfo::poll_type); __ testl(rax, Address(rscratch1, 0)); } else { add_debug_info_for_branch(info); From cef2b3be11ec6e8c9adfcafea46f6ae347685737 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 18 Jun 2014 13:58:13 -0400 Subject: [PATCH 077/236] 8039150: host_klass invariant fails when verifying newly loaded JSR-292 anonymous classes Initialize host_klass while parsing the class with the other initializations. Reviewed-by: sspitsyn, stefank --- hotspot/src/share/vm/classfile/classFileParser.cpp | 5 +++++ hotspot/src/share/vm/classfile/systemDictionary.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index d72a50cbb52..3ea6d0c9aee 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -4070,6 +4070,11 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, this_klass->set_major_version(major_version); this_klass->set_has_default_methods(has_default_methods); + if (!host_klass.is_null()) { + assert (this_klass->is_anonymous(), "should be the same"); + this_klass->set_host_klass(host_klass()); + } + // Set up Method*::intrinsic_id as soon as we know the names of methods. // (We used to do this lazily, but now we query it in Rewriter, // which is eagerly done for every method, so we might as well do it now, diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 9a6fa98908b..4a6e1c3e377 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -997,7 +997,6 @@ Klass* SystemDictionary::parse_stream(Symbol* class_name, if (host_klass.not_null() && k.not_null()) { - k->set_host_klass(host_klass()); // If it's anonymous, initialize it now, since nobody else will. { From 243d697d71e3cec694f0baa99bb261e6c8d101fa Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 19 Jun 2014 11:16:10 -0400 Subject: [PATCH 078/236] 8026977: NPG: Remove ConstantPool::lock Write klass and resolved_references constant pool fields lock free. Reviewed-by: jrose, twisti --- hotspot/src/share/vm/ci/ciEnv.cpp | 19 +- hotspot/src/share/vm/ci/ciReplay.cpp | 4 +- .../share/vm/classfile/classFileParser.cpp | 6 +- .../share/vm/classfile/classLoaderData.hpp | 4 +- hotspot/src/share/vm/oops/constantPool.cpp | 224 +++++++----------- hotspot/src/share/vm/oops/constantPool.hpp | 16 +- hotspot/src/share/vm/oops/cpCache.cpp | 4 +- hotspot/src/share/vm/oops/objArrayOop.cpp | 18 +- hotspot/src/share/vm/oops/objArrayOop.hpp | 5 +- hotspot/src/share/vm/prims/jvmtiEnv.cpp | 7 +- 10 files changed, 127 insertions(+), 180 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index fbe7bbbd83c..18cf9add331 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -512,24 +512,9 @@ ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool, } else { // Check if it's resolved if it's not a symbol constant pool entry. klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); - - if (klass.is_null()) { - // The klass has not been inserted into the constant pool. // Try to look it up by name. - { - // We have to lock the cpool to keep the oop from being resolved - // while we are accessing it. - MonitorLockerEx ml(cpool->lock()); - constantTag tag = cpool->tag_at(index); - if (tag.is_klass()) { - // The klass has been inserted into the constant pool - // very recently. - klass = KlassHandle(THREAD, cpool->resolved_klass_at(index)); - } else { - assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag"); - klass_name = cpool->unresolved_klass_at(index); - } - } + if (klass.is_null()) { + klass_name = cpool->klass_name_at(index); } } diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp index 51897b26300..99b742d61dd 100644 --- a/hotspot/src/share/vm/ci/ciReplay.cpp +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2013, 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 @@ -686,7 +686,7 @@ class CompileReplay : public StackObj { switch (cp->tag_at(i).value()) { case JVM_CONSTANT_UnresolvedClass: { if (tag == JVM_CONSTANT_Class) { - tty->print_cr("Resolving klass %s at %d", cp->unresolved_klass_at(i)->as_utf8(), i); + tty->print_cr("Resolving klass %s at %d", cp->klass_name_at(i)->as_utf8(), i); Klass* k = cp->klass_at(i, CHECK); } break; diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 3ea6d0c9aee..73925a12683 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -510,7 +510,7 @@ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) { jbyte tag = cp->tag_at(index).value(); switch (tag) { case JVM_CONSTANT_UnresolvedClass: { - Symbol* class_name = cp->unresolved_klass_at(index); + Symbol* class_name = cp->klass_name_at(index); // check the name, even if _cp_patches will overwrite it verify_legal_class_name(class_name, CHECK_(nullHandle)); break; @@ -3161,7 +3161,7 @@ instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index, if (_need_verify) is_array = super_klass->oop_is_array(); } else if (_need_verify) { - is_array = (_cp->unresolved_klass_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY); + is_array = (_cp->klass_name_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY); } if (_need_verify) { guarantee_property(!is_array, @@ -3855,7 +3855,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, "Invalid this class index %u in constant pool in class file %s", this_class_index, CHECK_(nullHandle)); - Symbol* class_name = cp->unresolved_klass_at(this_class_index); + Symbol* class_name = cp->klass_name_at(this_class_index); assert(class_name != NULL, "class_name can't be null"); // It's important to set parsed_name *before* resolving the super class. diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 964e4289ffe..82ae72c1164 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -187,8 +187,6 @@ class ClassLoaderData : public CHeapObj { JNIHandleBlock* handles() const; void set_handles(JNIHandleBlock* handles); - Mutex* metaspace_lock() const { return _metaspace_lock; } - // GC interface. void clear_claimed() { _claimed = 0; } bool claimed() const { return _claimed == 1; } @@ -216,6 +214,8 @@ class ClassLoaderData : public CHeapObj { return _the_null_class_loader_data; } + Mutex* metaspace_lock() const { return _metaspace_lock; } + bool is_anonymous() const { return _is_anonymous; } static void init_null_class_loader_data() { diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index b45fe508a64..111d55b3af7 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -71,7 +71,6 @@ ConstantPool::ConstantPool(Array* tags) { // only set to non-zero if constant pool is merged by RedefineClasses set_version(0); - set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock")); // initialize tag array int length = tags->length(); @@ -100,9 +99,6 @@ void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) { void ConstantPool::release_C_heap_structures() { // walk constant pool and decrement symbol reference counts unreference_symbols(); - - delete _lock; - set_lock(NULL); } objArrayOop ConstantPool::resolved_references() const { @@ -146,8 +142,7 @@ void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data, // CDS support. Create a new resolved_references array. void ConstantPool::restore_unshareable_info(TRAPS) { - // Only create the new resolved references array and lock if it hasn't been - // attempted before + // Only create the new resolved references array if it hasn't been attempted before if (resolved_references() != NULL) return; // restore the C++ vtable from the shared archive @@ -163,9 +158,6 @@ void ConstantPool::restore_unshareable_info(TRAPS) { ClassLoaderData* loader_data = pool_holder()->class_loader_data(); set_resolved_references(loader_data->add_handle(refs_handle)); } - - // Also need to recreate the mutex. Make sure this matches the constructor - set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock")); } } @@ -176,7 +168,6 @@ void ConstantPool::remove_unshareable_info() { set_resolved_reference_length( resolved_references() != NULL ? resolved_references()->length() : 0); set_resolved_references(NULL); - set_lock(NULL); } int ConstantPool::cp_to_object_index(int cp_index) { @@ -186,11 +177,41 @@ int ConstantPool::cp_to_object_index(int cp_index) { return (i < 0) ? _no_index_sentinel : i; } -Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) { - // A resolved constantPool entry will contain a Klass*, otherwise a Symbol*. - // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and - // tag is not updated atomicly. +void ConstantPool::trace_class_resolution(constantPoolHandle this_cp, KlassHandle k) { + ResourceMark rm; + int line_number = -1; + const char * source_file = NULL; + if (JavaThread::current()->has_last_Java_frame()) { + // try to identify the method which called this function. + vframeStream vfst(JavaThread::current()); + if (!vfst.at_end()) { + line_number = vfst.method()->line_number_from_bci(vfst.bci()); + Symbol* s = vfst.method()->method_holder()->source_file_name(); + if (s != NULL) { + source_file = s->as_C_string(); + } + } + } + if (k() != this_cp->pool_holder()) { + // only print something if the classes are different + if (source_file != NULL) { + tty->print("RESOLVE %s %s %s:%d\n", + this_cp->pool_holder()->external_name(), + InstanceKlass::cast(k())->external_name(), source_file, line_number); + } else { + tty->print("RESOLVE %s %s\n", + this_cp->pool_holder()->external_name(), + InstanceKlass::cast(k())->external_name()); + } + } +} +Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) { + assert(THREAD->is_Java_thread(), "must be a Java thread"); + + // A resolved constantPool entry will contain a Klass*, otherwise a Symbol*. + // It is not safe to rely on the tag bit's here, since we don't have a lock, and + // the entry and tag is not updated atomicly. CPSlot entry = this_cp->slot_at(which); if (entry.is_resolved()) { assert(entry.get_klass()->is_klass(), "must be"); @@ -198,115 +219,51 @@ Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) return entry.get_klass(); } - // Acquire lock on constant oop while doing update. After we get the lock, we check if another object - // already has updated the object - assert(THREAD->is_Java_thread(), "must be a Java thread"); - bool do_resolve = false; - bool in_error = false; - - // Create a handle for the mirror. This will preserve the resolved class - // until the loader_data is registered. - Handle mirror_handle; - - Symbol* name = NULL; - Handle loader; - { MonitorLockerEx ml(this_cp->lock()); - - if (this_cp->tag_at(which).is_unresolved_klass()) { - if (this_cp->tag_at(which).is_unresolved_klass_in_error()) { - in_error = true; - } else { - do_resolve = true; - name = this_cp->unresolved_klass_at(which); - loader = Handle(THREAD, this_cp->pool_holder()->class_loader()); - } - } - } // unlocking constantPool - - - // The original attempt to resolve this constant pool entry failed so find the - // class of the original error and throw another error of the same class (JVMS 5.4.3). - // If there is a detail message, pass that detail message to the error constructor. - // The JVMS does not strictly require us to duplicate the same detail message, - // or any internal exception fields such as cause or stacktrace. But since the - // detail message is often a class name or other literal string, we will repeat it if - // we can find it in the symbol table. - if (in_error) { + // This tag doesn't change back to unresolved class unless at a safepoint. + if (this_cp->tag_at(which).is_unresolved_klass_in_error()) { + // The original attempt to resolve this constant pool entry failed so find the + // class of the original error and throw another error of the same class + // (JVMS 5.4.3). + // If there is a detail message, pass that detail message to the error. + // The JVMS does not strictly require us to duplicate the same detail message, + // or any internal exception fields such as cause or stacktrace. But since the + // detail message is often a class name or other literal string, we will repeat it + // if we can find it in the symbol table. throw_resolution_error(this_cp, which, CHECK_0); + ShouldNotReachHere(); } - if (do_resolve) { - // this_cp must be unlocked during resolve_or_fail - oop protection_domain = this_cp->pool_holder()->protection_domain(); - Handle h_prot (THREAD, protection_domain); - Klass* kk = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD); - KlassHandle k; - if (!HAS_PENDING_EXCEPTION) { - k = KlassHandle(THREAD, kk); - // preserve the resolved klass. - mirror_handle = Handle(THREAD, kk->java_mirror()); - // Do access check for klasses - verify_constant_pool_resolve(this_cp, k, THREAD); - } + Handle mirror_handle; + Symbol* name = entry.get_symbol(); + Handle loader (THREAD, this_cp->pool_holder()->class_loader()); + Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain()); + Klass* kk = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD); + KlassHandle k (THREAD, kk); + if (!HAS_PENDING_EXCEPTION) { + // preserve the resolved klass from unloading + mirror_handle = Handle(THREAD, kk->java_mirror()); + // Do access check for klasses + verify_constant_pool_resolve(this_cp, k, THREAD); + } - // Failed to resolve class. We must record the errors so that subsequent attempts - // to resolve this constant pool entry fail with the same error (JVMS 5.4.3). - if (HAS_PENDING_EXCEPTION) { - MonitorLockerEx ml(this_cp->lock()); + // Failed to resolve class. We must record the errors so that subsequent attempts + // to resolve this constant pool entry fail with the same error (JVMS 5.4.3). + if (HAS_PENDING_EXCEPTION) { + save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_0); + } - // some other thread has beaten us and has resolved the class. - if (this_cp->tag_at(which).is_klass()) { - CLEAR_PENDING_EXCEPTION; - entry = this_cp->resolved_klass_at(which); - return entry.get_klass(); - } + // Make this class loader depend upon the class loader owning the class reference + ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data(); + this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM - // The tag could have changed to in-error before the lock but we have to - // handle that here for the class case. - save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_0); - } - - if (TraceClassResolution && !k()->oop_is_array()) { - // skip resolving the constant pool so that this code get's - // called the next time some bytecodes refer to this class. - ResourceMark rm; - int line_number = -1; - const char * source_file = NULL; - if (JavaThread::current()->has_last_Java_frame()) { - // try to identify the method which called this function. - vframeStream vfst(JavaThread::current()); - if (!vfst.at_end()) { - line_number = vfst.method()->line_number_from_bci(vfst.bci()); - Symbol* s = vfst.method()->method_holder()->source_file_name(); - if (s != NULL) { - source_file = s->as_C_string(); - } - } - } - if (k() != this_cp->pool_holder()) { - // only print something if the classes are different - if (source_file != NULL) { - tty->print("RESOLVE %s %s %s:%d\n", - this_cp->pool_holder()->external_name(), - InstanceKlass::cast(k())->external_name(), source_file, line_number); - } else { - tty->print("RESOLVE %s %s\n", - this_cp->pool_holder()->external_name(), - InstanceKlass::cast(k())->external_name()); - } - } + if (TraceClassResolution && !k->oop_is_array()) { + // skip resolving the constant pool so that this code gets + // called the next time some bytecodes refer to this class. + trace_class_resolution(this_cp, k); return k(); } else { - MonitorLockerEx ml(this_cp->lock()); - // Only updated constant pool - if it is resolved. - do_resolve = this_cp->tag_at(which).is_unresolved_klass(); - if (do_resolve) { - ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data(); - this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM this_cp->klass_at_put(which, k()); } - } - } entry = this_cp->resolved_klass_at(which); assert(entry.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point"); @@ -576,7 +533,7 @@ Symbol* ConstantPool::exception_message(constantPoolHandle this_cp, int which, c switch (tag.value()) { case JVM_CONSTANT_UnresolvedClass: // return the class name in the error message - message = this_cp->unresolved_klass_at(which); + message = this_cp->klass_name_at(which); break; case JVM_CONSTANT_MethodHandle: // return the method handle name in the error message @@ -606,7 +563,6 @@ void ConstantPool::throw_resolution_error(constantPoolHandle this_cp, int which, // in the resolution error table, so that the same exception is thrown again. void ConstantPool::save_and_throw_exception(constantPoolHandle this_cp, int which, constantTag tag, TRAPS) { - assert(this_cp->lock()->is_locked(), "constant pool lock should be held"); Symbol* error = PENDING_EXCEPTION->klass()->name(); int error_tag = tag.error_value(); @@ -620,7 +576,14 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_cp, int whic } else if (this_cp->tag_at(which).value() != error_tag) { Symbol* message = exception_message(this_cp, which, tag, PENDING_EXCEPTION); SystemDictionary::add_resolution_error(this_cp, which, error, message); - this_cp->tag_at_put(which, error_tag); + // CAS in the tag. If a thread beat us to registering this error that's fine. + // If another thread resolved the reference, this is an error. The resolution + // must deterministically get an error. So why do we save this? + // We save this because jvmti can add classes to the bootclass path after this + // error, so it needs to get the same error if the error is first. + jbyte old_tag = Atomic::cmpxchg((jbyte)error_tag, + (jbyte*)this_cp->tag_addr_at(which), (jbyte)tag.value()); + assert(old_tag == error_tag || old_tag == tag.value(), "should not be resolved otherwise"); } else { // some other thread put this in error state throw_resolution_error(this_cp, which, CHECK); @@ -710,7 +673,6 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index THREAD); result_oop = value(); if (HAS_PENDING_EXCEPTION) { - MonitorLockerEx ml(this_cp->lock()); // lock cpool to change tag. save_and_throw_exception(this_cp, index, tag, CHECK_NULL); } break; @@ -727,7 +689,6 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD); result_oop = value(); if (HAS_PENDING_EXCEPTION) { - MonitorLockerEx ml(this_cp->lock()); // lock cpool to change tag. save_and_throw_exception(this_cp, index, tag, CHECK_NULL); } break; @@ -765,22 +726,17 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index } if (cache_index >= 0) { - // Cache the oop here also. - Handle result_handle(THREAD, result_oop); - MonitorLockerEx ml(this_cp->lock()); // don't know if we really need this - oop result = this_cp->resolved_references()->obj_at(cache_index); - // Benign race condition: resolved_references may already be filled in while we were trying to lock. + // Benign race condition: resolved_references may already be filled in. // The important thing here is that all threads pick up the same result. // It doesn't matter which racing thread wins, as long as only one // result is used by all threads, and all future queries. - // That result may be either a resolved constant or a failure exception. - if (result == NULL) { - this_cp->resolved_references()->obj_at_put(cache_index, result_handle()); - return result_handle(); + oop old_result = this_cp->resolved_references()->atomic_compare_exchange_oop(cache_index, result_oop, NULL); + if (old_result == NULL) { + return result_oop; // was installed } else { // Return the winning thread's result. This can be different than - // result_handle() for MethodHandles. - return result; + // the result here for MethodHandles. + return old_result; } } else { return result_oop; @@ -853,9 +809,8 @@ bool ConstantPool::klass_name_at_matches(instanceKlassHandle k, } -// Iterate over symbols and decrement ones which are Symbol*s. -// This is done during GC so do not need to lock constantPool unless we -// have per-thread safepoints. +// Iterate over symbols and decrement ones which are Symbol*s +// This is done during GC. // Only decrement the UTF8 symbols. Unresolved classes and strings point to // these symbols but didn't increment the reference count. void ConstantPool::unreference_symbols() { @@ -987,8 +942,8 @@ bool ConstantPool::compare_entry_to(int index1, constantPoolHandle cp2, case JVM_CONSTANT_UnresolvedClass: { - Symbol* k1 = unresolved_klass_at(index1); - Symbol* k2 = cp2->unresolved_klass_at(index2); + Symbol* k1 = klass_name_at(index1); + Symbol* k2 = cp2->klass_name_at(index2); if (k1 == k2) { return true; } @@ -1970,7 +1925,6 @@ void ConstantPool::print_entry_on(const int index, outputStream* st) { break; case JVM_CONSTANT_UnresolvedClass : // fall-through case JVM_CONSTANT_UnresolvedClassInError: { - // unresolved_klass_at requires lock or safe world. CPSlot entry = slot_at(index); if (entry.is_resolved()) { entry.get_klass()->print_value_on(st); diff --git a/hotspot/src/share/vm/oops/constantPool.hpp b/hotspot/src/share/vm/oops/constantPool.hpp index 99c766ab7c5..5c5ea1c76e2 100644 --- a/hotspot/src/share/vm/oops/constantPool.hpp +++ b/hotspot/src/share/vm/oops/constantPool.hpp @@ -112,12 +112,12 @@ class ConstantPool : public Metadata { int _version; } _saved; - Monitor* _lock; - void set_tags(Array* tags) { _tags = tags; } void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); } void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); } + u1* tag_addr_at(int which) const { return tags()->adr_at(which); } + void set_operands(Array* operands) { _operands = operands; } int flags() const { return _flags; } @@ -362,14 +362,6 @@ class ConstantPool : public Metadata { return CPSlot((Klass*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_klass(); } - // This method should only be used with a cpool lock or during parsing or gc - Symbol* unresolved_klass_at(int which) { // Temporary until actual use - Symbol* s = CPSlot((Symbol*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol(); - // check that the klass is still unresolved. - assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool"); - return s; - } - // RedefineClasses() API support: Symbol* klass_at_noresolve(int which) { return klass_name_at(which); } @@ -818,6 +810,8 @@ class ConstantPool : public Metadata { static Klass* klass_at_impl(constantPoolHandle this_cp, int which, TRAPS); static oop string_at_impl(constantPoolHandle this_cp, int which, int obj_index, TRAPS); + static void trace_class_resolution(constantPoolHandle this_cp, KlassHandle k); + // Resolve string constants (to prevent allocation during compilation) static void resolve_string_constants_impl(constantPoolHandle this_cp, TRAPS); @@ -848,8 +842,6 @@ class ConstantPool : public Metadata { void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; } int resolved_reference_length() const { return _saved._resolved_reference_length; } - void set_lock(Monitor* lock) { _lock = lock; } - Monitor* lock() { return _lock; } // Decrease ref counts of symbols that are in the constant pool // when the holder class is unloaded diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index d601367ba99..cf2ba4806d1 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -286,7 +286,9 @@ void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool, // the lock, so that when the losing writer returns, he can use the linked // cache entry. - MonitorLockerEx ml(cpool->lock()); + // Use the lock from the metaspace for this, which cannot stop for safepoint. + Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock(); + MutexLockerEx ml(metaspace_lock, Mutex::_no_safepoint_check_flag); if (!is_f1_null()) { return; } diff --git a/hotspot/src/share/vm/oops/objArrayOop.cpp b/hotspot/src/share/vm/oops/objArrayOop.cpp index 00c4abe5ec3..2d91b46a680 100644 --- a/hotspot/src/share/vm/oops/objArrayOop.cpp +++ b/hotspot/src/share/vm/oops/objArrayOop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -27,6 +27,22 @@ #include "oops/objArrayOop.hpp" #include "oops/oop.inline.hpp" +oop objArrayOopDesc::atomic_compare_exchange_oop(int index, oop exchange_value, + oop compare_value) { + volatile HeapWord* dest; + if (UseCompressedOops) { + dest = (HeapWord*)obj_at_addr(index); + } else { + dest = (HeapWord*)obj_at_addr(index); + } + oop res = oopDesc::atomic_compare_exchange_oop(exchange_value, dest, compare_value, true); + // update card mark if success + if (res == compare_value) { + update_barrier_set((void*)dest, exchange_value); + } + return res; +} + #define ObjArrayOop_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ \ int objArrayOopDesc::oop_iterate_range(OopClosureType* blk, int start, int end) { \ diff --git a/hotspot/src/share/vm/oops/objArrayOop.hpp b/hotspot/src/share/vm/oops/objArrayOop.hpp index 0cf5d0395e0..897452a6624 100644 --- a/hotspot/src/share/vm/oops/objArrayOop.hpp +++ b/hotspot/src/share/vm/oops/objArrayOop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, 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 @@ -95,6 +95,9 @@ private: oop_store(obj_at_addr(index), value); } } + + oop atomic_compare_exchange_oop(int index, oop exchange_value, oop compare_value); + // Sizing static int header_size() { return arrayOopDesc::header_size(T_OBJECT); } int object_size() { return object_size(length()); } diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index 765cbcd6290..7d6b121e5fa 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -258,9 +258,6 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { // VM representation. We don't attach the reconstituted class // bytes to the InstanceKlass here because they have not been // validated and we're not at a safepoint. - constantPoolHandle constants(current_thread, ikh->constants()); - MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it - JvmtiClassFileReconstituter reconstituter(ikh); if (reconstituter.get_error() != JVMTI_ERROR_NONE) { return reconstituter.get_error(); @@ -2445,9 +2442,6 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con } instanceKlassHandle ikh(thread, k_oop); - constantPoolHandle constants(thread, ikh->constants()); - MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it - JvmtiConstantPoolReconstituter reconstituter(ikh); if (reconstituter.get_error() != JVMTI_ERROR_NONE) { return reconstituter.get_error(); @@ -2467,6 +2461,7 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con return reconstituter.get_error(); } + constantPoolHandle constants(thread, ikh->constants()); *constant_pool_count_ptr = constants->length(); *constant_pool_byte_count_ptr = cpool_size; *constant_pool_bytes_ptr = cpool_bytes; From d8ce93cea53b4f151fbbc3e5b494a4ac0928f58a Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 19 Jun 2014 14:49:33 -0400 Subject: [PATCH 079/236] 6642881: Improve performance of Class.getClassLoader() Add classLoader to java/lang/Class instance for fast access Reviewed-by: alanb, lfoltan, rriggs, vlivanov, twisti, jfranck --- .../share/vm/classfile/classFileParser.cpp | 4 +-- .../src/share/vm/classfile/javaClasses.cpp | 27 +++++++++++++++++-- .../src/share/vm/classfile/javaClasses.hpp | 8 +++++- hotspot/src/share/vm/classfile/vmSymbols.hpp | 1 + hotspot/src/share/vm/oops/arrayKlass.cpp | 2 +- hotspot/src/share/vm/oops/klass.cpp | 2 +- hotspot/src/share/vm/prims/unsafe.cpp | 10 ++++++- 7 files changed, 46 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 73925a12683..e58b280b07b 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -4139,8 +4139,8 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name, } // Allocate mirror and initialize static fields - java_lang_Class::create_mirror(this_klass, protection_domain, CHECK_(nullHandle)); - + java_lang_Class::create_mirror(this_klass, class_loader, protection_domain, + CHECK_(nullHandle)); // Generate any default methods - default methods are interface methods // that have a default implementation. This is new with Lambda project. diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 0e61ff9f391..d4fa4642661 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -558,7 +558,7 @@ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) { } } } - create_mirror(k, Handle(NULL), CHECK); + create_mirror(k, Handle(NULL), Handle(NULL), CHECK); } void java_lang_Class::initialize_mirror_fields(KlassHandle k, @@ -578,7 +578,8 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k, InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); } -void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) { +void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, + Handle protection_domain, TRAPS) { assert(k->java_mirror() == NULL, "should only assign mirror once"); // Use this moment of initialization to cache modifier_flags also, // to support Class.getModifiers(). Instance classes recalculate @@ -633,6 +634,9 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRA } } + // set the classLoader field in the java_lang_Class instance + set_class_loader(mirror(), class_loader()); + // Setup indirection from klass->mirror last // after any exceptions can happen during allocations. if (!k.is_null()) { @@ -694,6 +698,18 @@ void java_lang_Class::set_signers(oop java_class, objArrayOop signers) { } +void java_lang_Class::set_class_loader(oop java_class, oop loader) { + // jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet. + if (_class_loader_offset != 0) { + java_class->obj_field_put(_class_loader_offset, loader); + } +} + +oop java_lang_Class::class_loader(oop java_class) { + assert(_class_loader_offset != 0, "must be set"); + return java_class->obj_field(_class_loader_offset); +} + oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { // This should be improved by adding a field at the Java level or by // introducing a new VM klass (see comment in ClassFileParser) @@ -853,6 +869,12 @@ void java_lang_Class::compute_offsets() { compute_optional_offset(classRedefinedCount_offset, klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); + // Needs to be optional because the old build runs Queens during bootstrapping + // and jdk8-9 doesn't have coordinated pushes yet. + compute_optional_offset(_class_loader_offset, + klass_oop, vmSymbols::classLoader_name(), + vmSymbols::classloader_signature()); + CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); } @@ -3073,6 +3095,7 @@ int java_lang_Class::_klass_offset; int java_lang_Class::_array_klass_offset; int java_lang_Class::_oop_size_offset; int java_lang_Class::_static_oop_field_count_offset; +int java_lang_Class::_class_loader_offset; int java_lang_Class::_protection_domain_offset; int java_lang_Class::_init_lock_offset; int java_lang_Class::_signers_offset; diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp index 60c65fe968a..2c25b6e6c51 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.hpp +++ b/hotspot/src/share/vm/classfile/javaClasses.hpp @@ -240,19 +240,23 @@ class java_lang_Class : AllStatic { static int _protection_domain_offset; static int _init_lock_offset; static int _signers_offset; + static int _class_loader_offset; static bool offsets_computed; static int classRedefinedCount_offset; + static GrowableArray* _fixup_mirror_list; static void set_init_lock(oop java_class, oop init_lock); static void set_protection_domain(oop java_class, oop protection_domain); + static void set_class_loader(oop java_class, oop class_loader); static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS); public: static void compute_offsets(); // Instance creation - static void create_mirror(KlassHandle k, Handle protection_domain, TRAPS); + static void create_mirror(KlassHandle k, Handle class_loader, + Handle protection_domain, TRAPS); static void fixup_mirror(KlassHandle k, TRAPS); static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); // Conversion @@ -290,6 +294,8 @@ class java_lang_Class : AllStatic { static objArrayOop signers(oop java_class); static void set_signers(oop java_class, objArrayOop signers); + static oop class_loader(oop java_class); + static int oop_size(oop java_class); static void set_oop_size(oop java_class, int size); static int static_oop_field_count(oop java_class); diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 2a15564bdbf..d583ea5876e 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -572,6 +572,7 @@ template(serializePropertiesToByteArray_signature, "()[B") \ template(serializeAgentPropertiesToByteArray_name, "serializeAgentPropertiesToByteArray") \ template(classRedefinedCount_name, "classRedefinedCount") \ + template(classLoader_name, "classLoader") \ \ /* trace signatures */ \ TRACE_TEMPLATES(template) \ diff --git a/hotspot/src/share/vm/oops/arrayKlass.cpp b/hotspot/src/share/vm/oops/arrayKlass.cpp index c55992f0749..e8a367a3766 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.cpp +++ b/hotspot/src/share/vm/oops/arrayKlass.cpp @@ -93,7 +93,7 @@ void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_kl ResourceMark rm(THREAD); k->initialize_supers(super_klass(), CHECK); k->vtable()->initialize_vtable(false, CHECK); - java_lang_Class::create_mirror(k, Handle(NULL), CHECK); + java_lang_Class::create_mirror(k, Handle(NULL), Handle(NULL), CHECK); } GrowableArray* ArrayKlass::compute_secondary_supers(int num_extra_slots) { diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index d81dceb8f37..77e2561258f 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -508,7 +508,7 @@ void Klass::restore_unshareable_info(TRAPS) { // Only recreate it if not present. A previous attempt to restore may have // gotten an OOM later but keep the mirror if it was created. if (java_mirror() == NULL) { - java_lang_Class::create_mirror(this, Handle(NULL), CHECK); + java_lang_Class::create_mirror(this, Handle(NULL), Handle(NULL), CHECK); } } diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 332f8fb74ab..e5955c0ac69 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -891,6 +891,14 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring nam } UNSAFE_END +static jobject get_class_loader(JNIEnv* env, jclass cls) { + if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) { + return NULL; + } + Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); + oop loader = k->class_loader(); + return JNIHandles::make_local(env, loader); +} UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length)) UnsafeWrapper("Unsafe_DefineClass"); @@ -899,7 +907,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na int depthFromDefineClass0 = 1; jclass caller = JVM_GetCallerClass(env, depthFromDefineClass0); - jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller); + jobject loader = (caller == NULL) ? NULL : get_class_loader(env, caller); jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller); return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd); From 32cd848b56fda6d9b8c5fb52fbd275e15bebf479 Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Fri, 20 Jun 2014 10:12:02 -0700 Subject: [PATCH 080/236] 8038074: [TESTBUG] Add test for anewarray instruction with more than 255 dimensions Reviewed-by: lfoltan, coleenp --- .../test/runtime/verifier/TestANewArray.java | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 hotspot/test/runtime/verifier/TestANewArray.java diff --git a/hotspot/test/runtime/verifier/TestANewArray.java b/hotspot/test/runtime/verifier/TestANewArray.java new file mode 100644 index 00000000000..e8f58da2a41 --- /dev/null +++ b/hotspot/test/runtime/verifier/TestANewArray.java @@ -0,0 +1,148 @@ +/* + * 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. + */ + +import java.io.File; +import java.io.FileOutputStream; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import static jdk.internal.org.objectweb.asm.Opcodes.*; + +import com.oracle.java.testlibrary.*; + +/* + * @test + * @summary Test that anewarray bytecode is valid only if it specifies 255 or fewer dimensions. + * @library /testlibrary + * @compile -XDignore.symbol.file TestANewArray.java + * @run main/othervm TestANewArray 49 + * @run main/othervm TestANewArray 50 + * @run main/othervm TestANewArray 51 + * @run main/othervm TestANewArray 52 + */ + +/* + * Testing anewarray instruction with 254, 255 & 264 dimensions to verify JVMS 8, + * Section 4.9.1, Static Constraints that states the following: + * + * "No anewarray instruction may be used to create an array of more than 255 dimensions." + * + */ + +public class TestANewArray { + + static String classCName = null; // the generated class name + + static final int test_Dimension_254 = 254; // should always pass + static final int test_Dimension_255 = 255; // should always pass, except for cfv 49 + static final int test_Dimension_264 = 264; // should always fail + + static final String array_Dimension_254 = genArrayDim(test_Dimension_254); + static final String array_Dimension_255 = genArrayDim(test_Dimension_255); + static final String array_Dimension_264 = genArrayDim(test_Dimension_264); + + public static void main(String... args) throws Exception { + int cfv = Integer.parseInt(args[0]); + + // 254 array dimensions + byte[] classFile_254 = dumpClassFile(cfv, test_Dimension_254, array_Dimension_254); + writeClassFileFromByteArray(classFile_254); + System.err.println("Running with cfv: " + cfv + ", test_Dimension_254"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("java.lang.VerifyError"); + output.shouldHaveExitValue(0); + + // 255 array dimensions + byte[] classFile_255 = dumpClassFile(cfv, test_Dimension_255, array_Dimension_255); + writeClassFileFromByteArray(classFile_255); + System.err.println("Running with cfv: " + cfv + ", test_Dimension_255"); + pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); + output = new OutputAnalyzer(pb.start()); + if (cfv == 49) { + // The type-inferencing verifier used for <=49.0 ClassFiles detects an anewarray instruction + // with exactly 255 dimensions and incorrectly issues the "Array with too many dimensions" VerifyError. + output.shouldContain("Array with too many dimensions"); + output.shouldHaveExitValue(1); + } else { + // 255 dimensions should always pass, except for cfv 49 + output.shouldNotContain("java.lang.VerifyError"); + output.shouldNotContain("java.lang.ClassFormatError"); + output.shouldHaveExitValue(0); + } + + // 264 array dimensions + byte[] classFile_264 = dumpClassFile(cfv, test_Dimension_264, array_Dimension_264); + writeClassFileFromByteArray(classFile_264); + System.err.println("Running with cfv: " + cfv + ", test_Dimension_264"); + pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("java.lang.ClassFormatError"); + output.shouldHaveExitValue(1); + } + + public static byte[] dumpClassFile(int cfv, int testDimension264, String arrayDim) throws Exception { + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + MethodVisitor mv; + + classCName = "classCName_" + cfv + "_" + testDimension264; + + cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, classCName, null, "java/lang/Object", null); + { + mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); + mv.visitInsn(RETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + { // classCName main method + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null); + mv.visitCode(); + mv.visitIntInsn(BIPUSH, 1); + mv.visitTypeInsn(ANEWARRAY, arrayDim); // Test ANEWARRAY bytecode with various dimensions + mv.visitInsn(RETURN); + mv.visitMaxs(2, 2); + mv.visitEnd(); + } + cw.visitEnd(); + return cw.toByteArray(); + } + + public static FileOutputStream writeClassFileFromByteArray(byte[] classFileByteArray) throws Exception { + FileOutputStream fos = new FileOutputStream(new File(classCName + ".class")); + fos.write(classFileByteArray); + fos.close(); + return fos; + } + + private static String genArrayDim(int testDim) { + StringBuilder array_Dimension = new StringBuilder(); + for (int i = 0; i < testDim; i++) + { + array_Dimension.append("["); + } + return array_Dimension.append("Ljava/lang/Object;").toString(); + } +} From bc8c6370eae21d2d6315937416779b2bf2e136ce Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Fri, 20 Jun 2014 11:19:22 -0700 Subject: [PATCH 081/236] 8046611: Build errors with gcc on sparc/fastdebug Reviewed-by: dholmes, ctornqvi --- hotspot/src/cpu/sparc/vm/frame_sparc.cpp | 26 -------- hotspot/src/share/vm/runtime/safepoint.cpp | 69 ---------------------- 2 files changed, 95 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp index 2feb5eb0925..17b4d9e05ac 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp @@ -436,32 +436,6 @@ void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) { } #endif // CC_INTERP - -#ifdef ASSERT -// Debugging aid -static frame nth_sender(int n) { - frame f = JavaThread::current()->last_frame(); - - for(int i = 0; i < n; ++i) - f = f.sender((RegisterMap*)NULL); - - printf("first frame %d\n", f.is_first_frame() ? 1 : 0); - printf("interpreted frame %d\n", f.is_interpreted_frame() ? 1 : 0); - printf("java frame %d\n", f.is_java_frame() ? 1 : 0); - printf("entry frame %d\n", f.is_entry_frame() ? 1 : 0); - printf("native frame %d\n", f.is_native_frame() ? 1 : 0); - if (f.is_compiled_frame()) { - if (f.is_deoptimized_frame()) - printf("deoptimized frame 1\n"); - else - printf("compiled frame 1\n"); - } - - return f; -} -#endif - - frame frame::sender_for_entry_frame(RegisterMap *map) const { assert(map != NULL, "map must be set"); // Java frame called from C; skip all C frames and return top C diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index e71185d431d..ff919d607db 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -744,80 +744,12 @@ void SafepointSynchronize::block(JavaThread *thread) { // ------------------------------------------------------------------------------------------------------ // Exception handlers -#ifndef PRODUCT - -#ifdef SPARC - -#ifdef _LP64 -#define PTR_PAD "" -#else -#define PTR_PAD " " -#endif - -static void print_ptrs(intptr_t oldptr, intptr_t newptr, bool wasoop) { - bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false; - tty->print_cr(PTR_FORMAT PTR_PAD " %s %c " PTR_FORMAT PTR_PAD " %s %s", - oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!', - newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" ")); -} - -static void print_longs(jlong oldptr, jlong newptr, bool wasoop) { - bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false; - tty->print_cr(PTR64_FORMAT " %s %c " PTR64_FORMAT " %s %s", - oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!', - newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" ")); -} - -static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) { -#ifdef _LP64 - tty->print_cr("--------+------address-----+------before-----------+-------after----------+"); - const int incr = 1; // Increment to skip a long, in units of intptr_t -#else - tty->print_cr("--------+--address-+------before-----------+-------after----------+"); - const int incr = 2; // Increment to skip a long, in units of intptr_t -#endif - tty->print_cr("---SP---|"); - for( int i=0; i<16; i++ ) { - tty->print("blob %c%d |"PTR_FORMAT" ","LO"[i>>3],i&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); } - tty->print_cr("--------|"); - for( int i1=0; i1print("argv pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); } - tty->print(" pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); - tty->print_cr("--------|"); - tty->print(" G1 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; - tty->print(" G3 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; - tty->print(" G4 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; - tty->print(" G5 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr; - tty->print_cr(" FSR |"PTR_FORMAT" "PTR64_FORMAT" "PTR64_FORMAT,new_sp,*(jlong*)old_sp,*(jlong*)new_sp); - old_sp += incr; new_sp += incr; was_oops += incr; - // Skip the floats - tty->print_cr("--Float-|"PTR_FORMAT,new_sp); - tty->print_cr("---FP---|"); - old_sp += incr*32; new_sp += incr*32; was_oops += incr*32; - for( int i2=0; i2<16; i2++ ) { - tty->print("call %c%d |"PTR_FORMAT" ","LI"[i2>>3],i2&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); } - tty->cr(); -} -#endif // SPARC -#endif // PRODUCT - void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) { assert(thread->is_Java_thread(), "polling reference encountered by VM thread"); assert(thread->thread_state() == _thread_in_Java, "should come from Java code"); assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization"); - // Uncomment this to get some serious before/after printing of the - // Sparc safepoint-blob frame structure. - /* - intptr_t* sp = thread->last_Java_sp(); - intptr_t stack_copy[150]; - for( int i=0; i<150; i++ ) stack_copy[i] = sp[i]; - bool was_oops[150]; - for( int i=0; i<150; i++ ) - was_oops[i] = stack_copy[i] ? ((oop)stack_copy[i])->is_oop() : false; - */ - if (ShowSafepointMsgs) { tty->print("handle_polling_page_exception: "); } @@ -829,7 +761,6 @@ void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) { ThreadSafepointState* state = thread->safepoint_state(); state->handle_polling_page_exception(); - // print_me(sp,stack_copy,was_oops); } From abce44ab84c5fe54fa0fc869e01bc56ab9cb1970 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Wed, 18 Jun 2014 12:35:32 -0700 Subject: [PATCH 082/236] 8046471: Use OPENJDK_TARGET_CPU_ARCH instead of legacy value for hotspot ARCH Reviewed-by: erikj, dholmes --- hotspot/make/linux/makefiles/defs.make | 42 +++++++++----------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/hotspot/make/linux/makefiles/defs.make b/hotspot/make/linux/makefiles/defs.make index 8922fdd8728..dc0bb08728d 100644 --- a/hotspot/make/linux/makefiles/defs.make +++ b/hotspot/make/linux/makefiles/defs.make @@ -69,7 +69,7 @@ ifeq ($(ARCH), ia64) endif # sparc -ifeq ($(ARCH), sparc64) +ifneq (,$(findstring $(ARCH), sparc)) ifeq ($(ARCH_DATA_MODEL), 64) ARCH_DATA_MODEL = 64 MAKE_ARGS += LP64=1 @@ -83,30 +83,20 @@ ifeq ($(ARCH), sparc64) HS_ARCH = sparc endif -# amd64/x86_64 -ifneq (,$(findstring $(ARCH), amd64 x86_64)) +# i686/i586 and amd64/x86_64 +ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586)) ifeq ($(ARCH_DATA_MODEL), 64) ARCH_DATA_MODEL = 64 MAKE_ARGS += LP64=1 PLATFORM = linux-amd64 VM_PLATFORM = linux_amd64 - HS_ARCH = x86 else ARCH_DATA_MODEL = 32 PLATFORM = linux-i586 VM_PLATFORM = linux_i486 - HS_ARCH = x86 - # We have to reset ARCH to i686 since SRCARCH relies on it - ARCH = i686 endif -endif -# i686/i586 ie 32-bit x86 -ifneq (,$(findstring $(ARCH), i686 i586)) - ARCH_DATA_MODEL = 32 - PLATFORM = linux-i586 - VM_PLATFORM = linux_i486 - HS_ARCH = x86 + HS_ARCH = x86 endif # ARM @@ -118,20 +108,18 @@ ifeq ($(ARCH), arm) endif # PPC -ifeq ($(ARCH), ppc) - ARCH_DATA_MODEL = 32 - PLATFORM = linux-ppc - VM_PLATFORM = linux_ppc - HS_ARCH = ppc -endif +ifneq (,$(findstring $(ARCH), ppc)) + ifeq ($(ARCH_DATA_MODEL), 64) + MAKE_ARGS += LP64=1 + PLATFORM = linux-ppc64 + VM_PLATFORM = linux_ppc64 + else + ARCH_DATA_MODEL = 32 + PLATFORM = linux-ppc + VM_PLATFORM = linux_ppc + endif -# PPC64 -ifeq ($(ARCH), ppc64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = linux-ppc64 - VM_PLATFORM = linux_ppc64 - HS_ARCH = ppc + HS_ARCH = ppc endif # On 32 bit linux we build server and client, on 64 bit just server. From bad3b17c29687a308c1111f54fc3945bc169da10 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Wed, 18 Jun 2014 12:35:37 -0700 Subject: [PATCH 083/236] 8046471: Use OPENJDK_TARGET_CPU_ARCH instead of legacy value for hotspot ARCH Reviewed-by: erikj, dholmes --- common/autoconf/hotspot-spec.gmk.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in index f7abdd40e0a..057d882c28e 100644 --- a/common/autoconf/hotspot-spec.gmk.in +++ b/common/autoconf/hotspot-spec.gmk.in @@ -69,8 +69,8 @@ ISA_DIR=$(OPENJDK_TARGET_CPU_ISADIR) # Yet another name for arch used for an extra subdir below the jvm lib. # Uses i386 and amd64, instead of x86 and x86_64. LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB) -# Old name for OPENJDK_TARGET_CPU, uses i586 and amd64, instead of x86 and x86_64. -ARCH=$(OPENJDK_TARGET_CPU_LEGACY) +# Set the cpu architecture +ARCH=$(OPENJDK_TARGET_CPU_ARCH) # Legacy setting for building for a 64 bit machine. # If yes then this expands to _LP64:=1 @LP64@ From 9110c16bd91c36e2afe4fb29008aea46842a3508 Mon Sep 17 00:00:00 2001 From: David Dehaven Date: Wed, 18 Jun 2014 12:52:13 -0700 Subject: [PATCH 084/236] 8043340: [macosx] Fix hard-wired paths to JavaVM.framework Build system tweaks to allow building with Xcode 5 and on OS X 10.9 and later Reviewed-by: erikj, henryjen, dholmes --- common/autoconf/basics.m4 | 71 +++++++- common/autoconf/flags.m4 | 39 +++-- common/autoconf/generated-configure.sh | 227 ++++++++++++++++++------- common/autoconf/libraries.m4 | 16 -- common/autoconf/spec.gmk.in | 5 +- common/autoconf/toolchain.m4 | 33 ++-- 6 files changed, 281 insertions(+), 110 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 649f8ddfc29..00ee498ed82 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -512,7 +512,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], ) AC_ARG_WITH(sysroot, [AS_HELP_STRING([--with-sysroot], - [use this directory as sysroot)])], + [use this directory as sysroot])], [SYSROOT=$with_sysroot] ) @@ -531,6 +531,75 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], [BASIC_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)] ) + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + # detect if Xcode is installed by running xcodebuild -version + # if no Xcode installed, xcodebuild exits with 1 + # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 + if /usr/bin/xcodebuild -version >/dev/null 2>&1; then + # We need to use xcodebuild in the toolchain dir provided by the user, this will + # fall back on the stub binary in /usr/bin/xcodebuild + AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH]) + else + # this should result in SYSROOT being empty, unless --with-sysroot is provided + # when only the command line tools are installed there are no SDKs, so headers + # are copied into the system frameworks + XCODEBUILD= + AC_SUBST(XCODEBUILD) + fi + + AC_MSG_CHECKING([for sdk name]) + AC_ARG_WITH([sdk-name], [AS_HELP_STRING([--with-sdk-name], + [use the platform SDK of the given name. @<:@macosx@:>@])], + [SDKNAME=$with_sdk_name] + ) + AC_MSG_RESULT([$SDKNAME]) + + # if toolchain path is specified then don't rely on system headers, they may not compile + HAVE_SYSTEM_FRAMEWORK_HEADERS=0 + test -z "$TOOLCHAIN_PATH" && \ + HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?` + + if test -z "$SYSROOT"; then + if test -n "$XCODEBUILD"; then + # if we don't have system headers, use default SDK name (last resort) + if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + SDKNAME=${SDKNAME:-macosx} + fi + + if test -n "$SDKNAME"; then + # Call xcodebuild to determine SYSROOT + SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'` + fi + else + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + AC_MSG_ERROR([No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK]) + fi + fi + else + # warn user if --with-sdk-name was also set + if test -n "$with_sdk_name"; then + AC_MSG_WARN([Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used]) + fi + fi + + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then + # If no system framework headers, then SYSROOT must be set, or we won't build + AC_MSG_ERROR([Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments.]) + fi + + # Perform a basic sanity test + if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then + if test -z "$SYSROOT"; then + AC_MSG_ERROR([Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly]) + else + AC_MSG_ERROR([Invalid SDK or SYSROOT path, dependent framework headers not found]) + fi + fi + + # set SDKROOT too, Xcode tools will pick it up + AC_SUBST(SDKROOT,$SYSROOT) + fi + # Prepend the extra path to the global path BASIC_PREPEND_TO_PATH([PATH],$EXTRA_PATH) diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index 95fa6521575..40f60a9c85d 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -131,6 +131,10 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS], -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" fi + elif test "x$OPENJDK_TARGET_OS" = xmacosx; then + # Apple only wants -isysroot , but we also need -iframework/System/Library/Frameworks + SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\"" + SYSROOT_LDFLAGS=$SYSROOT_CFLAGS elif test "x$TOOLCHAIN_TYPE" = xgcc; then SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\"" SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\"" @@ -143,6 +147,14 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS], LEGACY_EXTRA_CXXFLAGS="$LEGACY_EXTRA_CXXFLAGS $SYSROOT_CFLAGS" LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS" fi + + # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework + # set this here so it doesn't have to be peppered throughout the forest + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + fi + AC_SUBST(SYSROOT_CFLAGS) AC_SUBST(SYSROOT_LDFLAGS) ]) @@ -644,23 +656,18 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Additional macosx handling if test "x$OPENJDK_TARGET_OS" = xmacosx; then - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # FIXME: This needs to be exported in spec.gmk due to closed legacy code. - # FIXME: clean this up, and/or move it elsewhere. + # Setting these parameters makes it an error to link to macosx APIs that are + # newer than the given OS version and makes the linked binaries compatible + # even if built on a newer version of the OS. + # The expected format is X.Y.Z + MACOSX_VERSION_MIN=10.7.0 + AC_SUBST(MACOSX_VERSION_MIN) - # Setting these parameters makes it an error to link to macosx APIs that are - # newer than the given OS version and makes the linked binaries compatible - # even if built on a newer version of the OS. - # The expected format is X.Y.Z - MACOSX_VERSION_MIN=10.7.0 - AC_SUBST(MACOSX_VERSION_MIN) - - # The macro takes the version with no dots, ex: 1070 - # Let the flags variables get resolved in make for easier override on make - # command line. - COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - fi + # The macro takes the version with no dots, ex: 1070 + # Let the flags variables get resolved in make for easier override on make + # command line. + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" fi # Setup some hard coded includes diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 4d95f64e34d..4299e53d566 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -874,6 +874,8 @@ PKGHANDLER OUTPUT_ROOT CONF_NAME SPEC +SDKROOT +XCODEBUILD BUILD_VARIANT_RELEASE DEBUG_CLASSFILES FASTDEBUG @@ -1040,6 +1042,7 @@ with_sysroot with_tools_dir with_toolchain_path with_extra_path +with_sdk_name with_conf_name with_builddeps_conf with_builddeps_server @@ -1074,7 +1077,6 @@ with_extra_cxxflags with_extra_ldflags enable_debug_symbols enable_zip_debug_info -enable_macosx_runtime_support with_x with_cups with_cups_include @@ -1841,9 +1843,6 @@ Optional Features: --disable-debug-symbols disable generation of debug symbols [enabled] --disable-zip-debug-info disable zipping of debug-info files [enabled] - --enable-macosx-runtime-support - Deprecated. Option is kept for backwards - compatibility and is ignored --disable-freetype-bundling disable bundling of the freetype library with the build result [enabled on Windows or when using @@ -1872,12 +1871,13 @@ Optional Packages: optimized (HotSpot build only)) [release] --with-devkit use this devkit for compilers, tools and resources --with-sys-root alias for --with-sysroot for backwards compatability - --with-sysroot use this directory as sysroot) + --with-sysroot use this directory as sysroot --with-tools-dir alias for --with-toolchain-path for backwards compatibility --with-toolchain-path prepend these directories when searching for toolchain binaries (compilers etc) --with-extra-path prepend these directories to the default path + --with-sdk-name use the platform SDK of the given name. [macosx] --with-conf-name use this as the name of the configuration [generated from important configuration options] --with-builddeps-conf use this configuration file for the builddeps @@ -4308,7 +4308,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1402614845 +DATE_WHEN_GENERATED=1403110135 ############################################################################### # @@ -14968,6 +14968,122 @@ if test "${with_extra_path+set}" = set; then : fi + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + # detect if Xcode is installed by running xcodebuild -version + # if no Xcode installed, xcodebuild exits with 1 + # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 + if /usr/bin/xcodebuild -version >/dev/null 2>&1; then + # We need to use xcodebuild in the toolchain dir provided by the user, this will + # fall back on the stub binary in /usr/bin/xcodebuild + # Extract the first word of "xcodebuild", so it can be a program name with args. +set dummy xcodebuild; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_XCODEBUILD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $XCODEBUILD in + [\\/]* | ?:[\\/]*) + ac_cv_path_XCODEBUILD="$XCODEBUILD" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $TOOLCHAIN_PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_XCODEBUILD="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_XCODEBUILD" && ac_cv_path_XCODEBUILD="/usr/bin/xcodebuild" + ;; +esac +fi +XCODEBUILD=$ac_cv_path_XCODEBUILD +if test -n "$XCODEBUILD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XCODEBUILD" >&5 +$as_echo "$XCODEBUILD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + # this should result in SYSROOT being empty, unless --with-sysroot is provided + # when only the command line tools are installed there are no SDKs, so headers + # are copied into the system frameworks + XCODEBUILD= + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sdk name" >&5 +$as_echo_n "checking for sdk name... " >&6; } + +# Check whether --with-sdk-name was given. +if test "${with_sdk_name+set}" = set; then : + withval=$with_sdk_name; SDKNAME=$with_sdk_name + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SDKNAME" >&5 +$as_echo "$SDKNAME" >&6; } + + # if toolchain path is specified then don't rely on system headers, they may not compile + HAVE_SYSTEM_FRAMEWORK_HEADERS=0 + test -z "$TOOLCHAIN_PATH" && \ + HAVE_SYSTEM_FRAMEWORK_HEADERS=`test ! -f /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h; echo $?` + + if test -z "$SYSROOT"; then + if test -n "$XCODEBUILD"; then + # if we don't have system headers, use default SDK name (last resort) + if test -z "$SDKNAME" -a $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + SDKNAME=${SDKNAME:-macosx} + fi + + if test -n "$SDKNAME"; then + # Call xcodebuild to determine SYSROOT + SYSROOT=`"$XCODEBUILD" -sdk $SDKNAME -version | grep '^Path: ' | sed 's/Path: //'` + fi + else + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0; then + as_fn_error $? "No xcodebuild tool and no system framework headers found, use --with-sysroot or --with-sdk-name to provide a path to a valid SDK" "$LINENO" 5 + fi + fi + else + # warn user if --with-sdk-name was also set + if test -n "$with_sdk_name"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used" >&5 +$as_echo "$as_me: WARNING: Both SYSROOT and --with-sdk-name are set, only SYSROOT will be used" >&2;} + fi + fi + + if test $HAVE_SYSTEM_FRAMEWORK_HEADERS -eq 0 -a -z "$SYSROOT"; then + # If no system framework headers, then SYSROOT must be set, or we won't build + as_fn_error $? "Unable to determine SYSROOT and no headers found in /System/Library/Frameworks. Check Xcode configuration, --with-sysroot or --with-sdk-name arguments." "$LINENO" 5 + fi + + # Perform a basic sanity test + if test ! -f "$SYSROOT/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h"; then + if test -z "$SYSROOT"; then + as_fn_error $? "Unable to find required framework headers, provide a path to an SDK via --with-sysroot or --with-sdk-name and be sure Xcode is installed properly" "$LINENO" 5 + else + as_fn_error $? "Invalid SDK or SYSROOT path, dependent framework headers not found" "$LINENO" 5 + fi + fi + + # set SDKROOT too, Xcode tools will pick it up + SDKROOT=$SYSROOT + + fi + # Prepend the extra path to the global path if test "x$EXTRA_PATH" != x; then @@ -26596,21 +26712,28 @@ fi VALID_TOOLCHAINS=${!toolchain_var_name} if test "x$OPENJDK_TARGET_OS" = xmacosx; then - # On Mac OS X, default toolchain to clang after Xcode 5 - XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1` - $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null - if test $? -ne 0; then - as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5 - fi - XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ - $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \ - $CUT -f 1 -d .` - { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5 + if test -n "$XCODEBUILD"; then + # On Mac OS X, default toolchain to clang after Xcode 5 + XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1` + $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null + if test $? -ne 0; then + as_fn_error $? "Failed to determine Xcode version." "$LINENO" 5 + fi + XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ + $SED -e 's/^Xcode \([1-9][0-9.]*\)/\1/' | \ + $CUT -f 1 -d .` + { $as_echo "$as_me:${as_lineno-$LINENO}: Xcode major version: $XCODE_MAJOR_VERSION" >&5 $as_echo "$as_me: Xcode major version: $XCODE_MAJOR_VERSION" >&6;} - if test $XCODE_MAJOR_VERSION -ge 5; then - DEFAULT_TOOLCHAIN="clang" + if test $XCODE_MAJOR_VERSION -ge 5; then + DEFAULT_TOOLCHAIN="clang" + else + DEFAULT_TOOLCHAIN="gcc" + fi else - DEFAULT_TOOLCHAIN="gcc" + # If Xcode is not installed, but the command line tools are + # then we can't run xcodebuild. On these systems we should + # default to clang + DEFAULT_TOOLCHAIN="clang" fi else # First toolchain type in the list is the default @@ -41076,6 +41199,10 @@ $as_echo "$tool_specified" >&6; } -L$SYSROOT/lib$OPENJDK_TARGET_CPU_ISADIR \ -L$SYSROOT/usr/ccs/lib$OPENJDK_TARGET_CPU_ISADIR" fi + elif test "x$OPENJDK_TARGET_OS" = xmacosx; then + # Apple only wants -isysroot , but we also need -iframework/System/Library/Frameworks + SYSROOT_CFLAGS="-isysroot \"$SYSROOT\" -iframework\"$SYSROOT/System/Library/Frameworks\"" + SYSROOT_LDFLAGS=$SYSROOT_CFLAGS elif test "x$TOOLCHAIN_TYPE" = xgcc; then SYSROOT_CFLAGS="--sysroot=\"$SYSROOT\"" SYSROOT_LDFLAGS="--sysroot=\"$SYSROOT\"" @@ -41089,6 +41216,14 @@ $as_echo "$tool_specified" >&6; } LEGACY_EXTRA_LDFLAGS="$LEGACY_EXTRA_LDFLAGS $SYSROOT_LDFLAGS" fi + # These always need to be set, or we can't find the frameworks embedded in JavaVM.framework + # set this here so it doesn't have to be peppered throughout the forest + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + SYSROOT_CFLAGS="$SYSROOT_CFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -F\"$SYSROOT/System/Library/Frameworks/JavaVM.framework/Frameworks\"" + fi + + @@ -42135,23 +42270,18 @@ fi # Additional macosx handling if test "x$OPENJDK_TARGET_OS" = xmacosx; then - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # FIXME: This needs to be exported in spec.gmk due to closed legacy code. - # FIXME: clean this up, and/or move it elsewhere. - - # Setting these parameters makes it an error to link to macosx APIs that are - # newer than the given OS version and makes the linked binaries compatible - # even if built on a newer version of the OS. - # The expected format is X.Y.Z - MACOSX_VERSION_MIN=10.7.0 + # Setting these parameters makes it an error to link to macosx APIs that are + # newer than the given OS version and makes the linked binaries compatible + # even if built on a newer version of the OS. + # The expected format is X.Y.Z + MACOSX_VERSION_MIN=10.7.0 - # The macro takes the version with no dots, ex: 1070 - # Let the flags variables get resolved in make for easier override on make - # command line. - COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" - fi + # The macro takes the version with no dots, ex: 1070 + # Let the flags variables get resolved in make for easier override on make + # command line. + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" fi # Setup some hard coded includes @@ -42654,8 +42784,6 @@ $as_echo_n "checking what is not needed on MacOSX?... " >&6; } ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes X11_NOT_NEEDED=yes - # If the java runtime framework is disabled, then we need X11. - # This will be adjusted below. { $as_echo "$as_me:${as_lineno-$LINENO}: result: alsa pulse x11" >&5 $as_echo "alsa pulse x11" >&6; } fi @@ -42676,33 +42804,6 @@ $as_echo "alsa" >&6; } X11_NOT_NEEDED=yes fi - ############################################################################### - # - # Check for MacOSX support for OpenJDK. - # - - - # Check whether --enable-macosx-runtime-support was given. -if test "${enable_macosx_runtime_support+set}" = set; then : - enableval=$enable_macosx_runtime_support; -fi - - if test "x$enable_macosx_runtime_support" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Option --enable-macosx-runtime-support is deprecated and will be ignored." >&5 -$as_echo "$as_me: WARNING: Option --enable-macosx-runtime-support is deprecated and will be ignored." >&2;} - fi - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mac OS X Java Framework" >&5 -$as_echo_n "checking for Mac OS X Java Framework... " >&6; } - if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /System/Library/Frameworks/JavaVM.framework" >&5 -$as_echo "/System/Library/Frameworks/JavaVM.framework" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - ############################################################################### diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index 6ee3221ad96..833efa63e74 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -65,8 +65,6 @@ AC_DEFUN_ONCE([LIB_SETUP_INIT], ALSA_NOT_NEEDED=yes PULSE_NOT_NEEDED=yes X11_NOT_NEEDED=yes - # If the java runtime framework is disabled, then we need X11. - # This will be adjusted below. AC_MSG_RESULT([alsa pulse x11]) fi @@ -83,20 +81,6 @@ AC_DEFUN_ONCE([LIB_SETUP_INIT], if test "x$SUPPORT_HEADFUL" = xno; then X11_NOT_NEEDED=yes fi - - ############################################################################### - # - # Check for MacOSX support for OpenJDK. - # - - BASIC_DEPRECATED_ARG_ENABLE(macosx-runtime-support, macosx_runtime_support) - - AC_MSG_CHECKING([for Mac OS X Java Framework]) - if test -f /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/Headers/JavaRuntimeSupport.h; then - AC_MSG_RESULT([/System/Library/Frameworks/JavaVM.framework]) - else - AC_MSG_RESULT([no]) - fi ]) AC_DEFUN_ONCE([LIB_SETUP_X11], diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 2f6d7bd3746..bc916f636c3 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -347,6 +347,9 @@ CPP:=@FIXPATH@ @CPP@ # The linker can be gcc or ld on posix systems, or link.exe on windows systems. LD:=@FIXPATH@ @LD@ +# Xcode SDK path +SDKROOT:=@SDKROOT@ + # The linker on older SuSE distros (e.g. on SLES 10) complains with: # "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable." # if feeded with a version script which contains named tags. @@ -544,7 +547,7 @@ SETFILE:=@SETFILE@ XATTR:=@XATTR@ JT_HOME:=@JT_HOME@ JTREGEXE:=@JTREGEXE@ - +XCODEBUILD=@XCODEBUILD@ FIXPATH:=@FIXPATH@ # Where the build output is stored for your convenience. diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 4686517151b..f380bf446ad 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -98,20 +98,27 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], VALID_TOOLCHAINS=${!toolchain_var_name} if test "x$OPENJDK_TARGET_OS" = xmacosx; then - # On Mac OS X, default toolchain to clang after Xcode 5 - XCODE_VERSION_OUTPUT=`xcodebuild -version 2>&1 | $HEAD -n 1` - $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null - if test $? -ne 0; then - AC_MSG_ERROR([Failed to determine Xcode version.]) - fi - XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ - $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \ - $CUT -f 1 -d .` - AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION]) - if test $XCODE_MAJOR_VERSION -ge 5; then - DEFAULT_TOOLCHAIN="clang" + if test -n "$XCODEBUILD"; then + # On Mac OS X, default toolchain to clang after Xcode 5 + XCODE_VERSION_OUTPUT=`"$XCODEBUILD" -version 2>&1 | $HEAD -n 1` + $ECHO "$XCODE_VERSION_OUTPUT" | $GREP "Xcode " > /dev/null + if test $? -ne 0; then + AC_MSG_ERROR([Failed to determine Xcode version.]) + fi + XCODE_MAJOR_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | \ + $SED -e 's/^Xcode \(@<:@1-9@:>@@<:@0-9.@:>@*\)/\1/' | \ + $CUT -f 1 -d .` + AC_MSG_NOTICE([Xcode major version: $XCODE_MAJOR_VERSION]) + if test $XCODE_MAJOR_VERSION -ge 5; then + DEFAULT_TOOLCHAIN="clang" + else + DEFAULT_TOOLCHAIN="gcc" + fi else - DEFAULT_TOOLCHAIN="gcc" + # If Xcode is not installed, but the command line tools are + # then we can't run xcodebuild. On these systems we should + # default to clang + DEFAULT_TOOLCHAIN="clang" fi else # First toolchain type in the list is the default From c1c9f333d59f21ceba69e083dcc5c83cb677d992 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Wed, 18 Jun 2014 14:21:28 -0700 Subject: [PATCH 085/236] 8047156: cleanup more non-indent white space issues prior to Contended Locking cleanup bucket Checkpoint some missed do_space_filter.ksh cleanups for Contended Locking. Reviewed-by: sspitsyn, lfoltan, coleenp --- hotspot/src/os/bsd/vm/os_bsd.hpp | 40 +- hotspot/src/os/linux/vm/os_linux.hpp | 42 +- hotspot/src/os/solaris/vm/os_solaris.hpp | 42 +- hotspot/src/share/vm/runtime/atomic.hpp | 2 +- hotspot/src/share/vm/runtime/mutex.cpp | 490 +++++++++--------- .../src/share/vm/runtime/sharedRuntime.hpp | 10 +- hotspot/src/share/vm/runtime/synchronizer.hpp | 14 +- 7 files changed, 320 insertions(+), 320 deletions(-) diff --git a/hotspot/src/os/bsd/vm/os_bsd.hpp b/hotspot/src/os/bsd/vm/os_bsd.hpp index 25a16562dee..36fb913f38a 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.hpp +++ b/hotspot/src/os/bsd/vm/os_bsd.hpp @@ -191,16 +191,16 @@ public: class PlatformEvent : public CHeapObj { private: - double CachePad [4] ; // increase odds that _mutex is sole occupant of cache line - volatile int _Event ; - volatile int _nParked ; - pthread_mutex_t _mutex [1] ; - pthread_cond_t _cond [1] ; - double PostPad [2] ; - Thread * _Assoc ; + double CachePad[4]; // increase odds that _mutex is sole occupant of cache line + volatile int _Event; + volatile int _nParked; + pthread_mutex_t _mutex[1]; + pthread_cond_t _cond[1]; + double PostPad[2]; + Thread * _Assoc; public: // TODO-FIXME: make dtor private - ~PlatformEvent() { guarantee (0, "invariant") ; } + ~PlatformEvent() { guarantee(0, "invariant"); } public: PlatformEvent() { @@ -209,28 +209,28 @@ class PlatformEvent : public CHeapObj { assert_status(status == 0, status, "cond_init"); status = pthread_mutex_init (_mutex, NULL); assert_status(status == 0, status, "mutex_init"); - _Event = 0 ; - _nParked = 0 ; - _Assoc = NULL ; + _Event = 0; + _nParked = 0; + _Assoc = NULL; } // Use caution with reset() and fired() -- they may require MEMBARs - void reset() { _Event = 0 ; } + void reset() { _Event = 0; } int fired() { return _Event; } - void park () ; - void unpark () ; - int TryPark () ; - int park (jlong millis) ; - void SetAssociation (Thread * a) { _Assoc = a ; } + void park(); + void unpark(); + int TryPark(); + int park(jlong millis); + void SetAssociation(Thread * a) { _Assoc = a; } }; class PlatformParker : public CHeapObj { protected: - pthread_mutex_t _mutex [1] ; - pthread_cond_t _cond [1] ; + pthread_mutex_t _mutex[1]; + pthread_cond_t _cond[1]; public: // TODO-FIXME: make dtor private - ~PlatformParker() { guarantee (0, "invariant") ; } + ~PlatformParker() { guarantee(0, "invariant"); } public: PlatformParker() { diff --git a/hotspot/src/os/linux/vm/os_linux.hpp b/hotspot/src/os/linux/vm/os_linux.hpp index 2dfda6be0cf..3e287387b05 100644 --- a/hotspot/src/os/linux/vm/os_linux.hpp +++ b/hotspot/src/os/linux/vm/os_linux.hpp @@ -287,16 +287,16 @@ public: class PlatformEvent : public CHeapObj { private: - double CachePad [4] ; // increase odds that _mutex is sole occupant of cache line - volatile int _Event ; - volatile int _nParked ; - pthread_mutex_t _mutex [1] ; - pthread_cond_t _cond [1] ; - double PostPad [2] ; - Thread * _Assoc ; + double CachePad[4]; // increase odds that _mutex is sole occupant of cache line + volatile int _Event; + volatile int _nParked; + pthread_mutex_t _mutex[1]; + pthread_cond_t _cond[1]; + double PostPad[2]; + Thread * _Assoc; public: // TODO-FIXME: make dtor private - ~PlatformEvent() { guarantee (0, "invariant") ; } + ~PlatformEvent() { guarantee(0, "invariant"); } public: PlatformEvent() { @@ -305,20 +305,20 @@ class PlatformEvent : public CHeapObj { assert_status(status == 0, status, "cond_init"); status = pthread_mutex_init (_mutex, NULL); assert_status(status == 0, status, "mutex_init"); - _Event = 0 ; - _nParked = 0 ; - _Assoc = NULL ; + _Event = 0; + _nParked = 0; + _Assoc = NULL; } // Use caution with reset() and fired() -- they may require MEMBARs - void reset() { _Event = 0 ; } + void reset() { _Event = 0; } int fired() { return _Event; } - void park () ; - void unpark () ; - int TryPark () ; - int park (jlong millis) ; // relative timed-wait only - void SetAssociation (Thread * a) { _Assoc = a ; } -} ; + void park(); + void unpark(); + int TryPark(); + int park(jlong millis); // relative timed-wait only + void SetAssociation(Thread * a) { _Assoc = a; } +}; class PlatformParker : public CHeapObj { protected: @@ -327,11 +327,11 @@ class PlatformParker : public CHeapObj { ABS_INDEX = 1 }; int _cur_index; // which cond is in use: -1, 0, 1 - pthread_mutex_t _mutex [1] ; - pthread_cond_t _cond [2] ; // one for relative times and one for abs. + pthread_mutex_t _mutex[1]; + pthread_cond_t _cond[2]; // one for relative times and one for abs. public: // TODO-FIXME: make dtor private - ~PlatformParker() { guarantee (0, "invariant") ; } + ~PlatformParker() { guarantee(0, "invariant"); } public: PlatformParker() { diff --git a/hotspot/src/os/solaris/vm/os_solaris.hpp b/hotspot/src/os/solaris/vm/os_solaris.hpp index 7c5bedb4d41..28d1700ca62 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.hpp +++ b/hotspot/src/os/solaris/vm/os_solaris.hpp @@ -301,48 +301,48 @@ class Solaris { class PlatformEvent : public CHeapObj { private: - double CachePad [4] ; // increase odds that _mutex is sole occupant of cache line - volatile int _Event ; - int _nParked ; - int _pipev [2] ; - mutex_t _mutex [1] ; - cond_t _cond [1] ; - double PostPad [2] ; + double CachePad[4]; // increase odds that _mutex is sole occupant of cache line + volatile int _Event; + int _nParked; + int _pipev[2]; + mutex_t _mutex[1]; + cond_t _cond[1]; + double PostPad[2]; protected: // Defining a protected ctor effectively gives us an abstract base class. // That is, a PlatformEvent can never be instantiated "naked" but only // as a part of a ParkEvent (recall that ParkEvent extends PlatformEvent). // TODO-FIXME: make dtor private - ~PlatformEvent() { guarantee (0, "invariant") ; } + ~PlatformEvent() { guarantee(0, "invariant"); } PlatformEvent() { int status; status = os::Solaris::cond_init(_cond); assert_status(status == 0, status, "cond_init"); status = os::Solaris::mutex_init(_mutex); assert_status(status == 0, status, "mutex_init"); - _Event = 0 ; - _nParked = 0 ; - _pipev[0] = _pipev[1] = -1 ; + _Event = 0; + _nParked = 0; + _pipev[0] = _pipev[1] = -1; } public: // Exercise caution using reset() and fired() -- they may require MEMBARs - void reset() { _Event = 0 ; } + void reset() { _Event = 0; } int fired() { return _Event; } - void park () ; - int park (jlong millis) ; - int TryPark () ; - void unpark () ; -} ; + void park(); + int park(jlong millis); + int TryPark(); + void unpark(); +}; class PlatformParker : public CHeapObj { protected: - mutex_t _mutex [1] ; - cond_t _cond [1] ; + mutex_t _mutex[1]; + cond_t _cond[1]; public: // TODO-FIXME: make dtor private - ~PlatformParker() { guarantee (0, "invariant") ; } + ~PlatformParker() { guarantee(0, "invariant"); } public: PlatformParker() { @@ -352,6 +352,6 @@ class PlatformParker : public CHeapObj { status = os::Solaris::mutex_init(_mutex); assert_status(status == 0, status, "mutex_init"); } -} ; +}; #endif // OS_SOLARIS_VM_OS_SOLARIS_HPP diff --git a/hotspot/src/share/vm/runtime/atomic.hpp b/hotspot/src/share/vm/runtime/atomic.hpp index 5b46b530b51..b2b56171362 100644 --- a/hotspot/src/share/vm/runtime/atomic.hpp +++ b/hotspot/src/share/vm/runtime/atomic.hpp @@ -116,7 +116,7 @@ class Atomic : AllStatic { atomic_decl #else #define ATOMIC_SHORT_PAIR(atomic_decl, non_atomic_decl) \ - atomic_decl ; \ + atomic_decl; \ non_atomic_decl #endif diff --git a/hotspot/src/share/vm/runtime/mutex.cpp b/hotspot/src/share/vm/runtime/mutex.cpp index 34c9366f0d1..f5ac0f8ea15 100644 --- a/hotspot/src/share/vm/runtime/mutex.cpp +++ b/hotspot/src/share/vm/runtime/mutex.cpp @@ -269,62 +269,62 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC #define CASPTR(a,c,s) intptr_t(Atomic::cmpxchg_ptr ((void *)(s),(void *)(a),(void *)(c))) #define UNS(x) (uintptr_t(x)) -#define TRACE(m) { static volatile int ctr = 0 ; int x = ++ctr ; if ((x & (x-1))==0) { ::printf ("%d:%s\n", x, #m); ::fflush(stdout); }} +#define TRACE(m) { static volatile int ctr = 0; int x = ++ctr; if ((x & (x-1))==0) { ::printf ("%d:%s\n", x, #m); ::fflush(stdout); }} // Simplistic low-quality Marsaglia SHIFT-XOR RNG. // Bijective except for the trailing mask operation. // Useful for spin loops as the compiler can't optimize it away. static inline jint MarsagliaXORV (jint x) { - if (x == 0) x = 1|os::random() ; + if (x == 0) x = 1|os::random(); x ^= x << 6; x ^= ((unsigned)x) >> 21; - x ^= x << 7 ; - return x & 0x7FFFFFFF ; + x ^= x << 7; + return x & 0x7FFFFFFF; } static int Stall (int its) { - static volatile jint rv = 1 ; - volatile int OnFrame = 0 ; - jint v = rv ^ UNS(OnFrame) ; + static volatile jint rv = 1; + volatile int OnFrame = 0; + jint v = rv ^ UNS(OnFrame); while (--its >= 0) { - v = MarsagliaXORV (v) ; + v = MarsagliaXORV(v); } // Make this impossible for the compiler to optimize away, // but (mostly) avoid W coherency sharing on MP systems. - if (v == 0x12345) rv = v ; - return v ; + if (v == 0x12345) rv = v; + return v; } -int Monitor::TryLock () { - intptr_t v = _LockWord.FullWord ; +int Monitor::TryLock() { + intptr_t v = _LockWord.FullWord; for (;;) { - if ((v & _LBIT) != 0) return 0 ; - const intptr_t u = CASPTR (&_LockWord, v, v|_LBIT) ; - if (v == u) return 1 ; - v = u ; + if ((v & _LBIT) != 0) return 0; + const intptr_t u = CASPTR(&_LockWord, v, v|_LBIT); + if (v == u) return 1; + v = u; } } -int Monitor::TryFast () { +int Monitor::TryFast() { // Optimistic fast-path form ... // Fast-path attempt for the common uncontended case. // Avoid RTS->RTO $ coherence upgrade on typical SMP systems. - intptr_t v = CASPTR (&_LockWord, 0, _LBIT) ; // agro ... - if (v == 0) return 1 ; + intptr_t v = CASPTR(&_LockWord, 0, _LBIT); // agro ... + if (v == 0) return 1; for (;;) { - if ((v & _LBIT) != 0) return 0 ; - const intptr_t u = CASPTR (&_LockWord, v, v|_LBIT) ; - if (v == u) return 1 ; - v = u ; + if ((v & _LBIT) != 0) return 0; + const intptr_t u = CASPTR(&_LockWord, v, v|_LBIT); + if (v == u) return 1; + v = u; } } -int Monitor::ILocked () { - const intptr_t w = _LockWord.FullWord & 0xFF ; - assert (w == 0 || w == _LBIT, "invariant") ; - return w == _LBIT ; +int Monitor::ILocked() { + const intptr_t w = _LockWord.FullWord & 0xFF; + assert(w == 0 || w == _LBIT, "invariant"); + return w == _LBIT; } // Polite TATAS spinlock with exponential backoff - bounded spin. @@ -342,38 +342,38 @@ int Monitor::ILocked () { // See synchronizer.cpp for details and rationale. int Monitor::TrySpin (Thread * const Self) { - if (TryLock()) return 1 ; - if (!os::is_MP()) return 0 ; + if (TryLock()) return 1; + if (!os::is_MP()) return 0; - int Probes = 0 ; - int Delay = 0 ; - int Steps = 0 ; - int SpinMax = NativeMonitorSpinLimit ; - int flgs = NativeMonitorFlags ; + int Probes = 0; + int Delay = 0; + int Steps = 0; + int SpinMax = NativeMonitorSpinLimit; + int flgs = NativeMonitorFlags; for (;;) { intptr_t v = _LockWord.FullWord; if ((v & _LBIT) == 0) { if (CASPTR (&_LockWord, v, v|_LBIT) == v) { - return 1 ; + return 1; } - continue ; + continue; } if ((flgs & 8) == 0) { - SpinPause () ; + SpinPause(); } // Periodically increase Delay -- variable Delay form // conceptually: delay *= 1 + 1/Exponent - ++ Probes; - if (Probes > SpinMax) return 0 ; + ++Probes; + if (Probes > SpinMax) return 0; if ((Probes & 0x7) == 0) { - Delay = ((Delay << 1)|1) & 0x7FF ; + Delay = ((Delay << 1)|1) & 0x7FF; // CONSIDER: Delay += 1 + (Delay/4); Delay &= 0x7FF ; } - if (flgs & 2) continue ; + if (flgs & 2) continue; // Consider checking _owner's schedctl state, if OFFPROC abort spin. // If the owner is OFFPROC then it's unlike that the lock will be dropped @@ -389,48 +389,48 @@ int Monitor::TrySpin (Thread * const Self) { // spin loop. N1 and brethren write-around the L1$ over the xbar into the L2$. // Furthermore, they don't have a W$ like traditional SPARC processors. // We currently use a Marsaglia Shift-Xor RNG loop. - Steps += Delay ; + Steps += Delay; if (Self != NULL) { - jint rv = Self->rng[0] ; - for (int k = Delay ; --k >= 0; ) { - rv = MarsagliaXORV (rv) ; - if ((flgs & 4) == 0 && SafepointSynchronize::do_call_back()) return 0 ; + jint rv = Self->rng[0]; + for (int k = Delay; --k >= 0;) { + rv = MarsagliaXORV(rv); + if ((flgs & 4) == 0 && SafepointSynchronize::do_call_back()) return 0; } - Self->rng[0] = rv ; + Self->rng[0] = rv; } else { - Stall (Delay) ; + Stall(Delay); } } } static int ParkCommon (ParkEvent * ev, jlong timo) { // Diagnostic support - periodically unwedge blocked threads - intx nmt = NativeMonitorTimeout ; + intx nmt = NativeMonitorTimeout; if (nmt > 0 && (nmt < timo || timo <= 0)) { - timo = nmt ; + timo = nmt; } - int err = OS_OK ; + int err = OS_OK; if (0 == timo) { - ev->park() ; + ev->park(); } else { - err = ev->park(timo) ; + err = ev->park(timo); } - return err ; + return err; } inline int Monitor::AcquireOrPush (ParkEvent * ESelf) { - intptr_t v = _LockWord.FullWord ; + intptr_t v = _LockWord.FullWord; for (;;) { if ((v & _LBIT) == 0) { - const intptr_t u = CASPTR (&_LockWord, v, v|_LBIT) ; - if (u == v) return 1 ; // indicate acquired - v = u ; + const intptr_t u = CASPTR(&_LockWord, v, v|_LBIT); + if (u == v) return 1; // indicate acquired + v = u; } else { // Anticipate success ... - ESelf->ListNext = (ParkEvent *) (v & ~_LBIT) ; - const intptr_t u = CASPTR (&_LockWord, v, intptr_t(ESelf)|_LBIT) ; - if (u == v) return 0 ; // indicate pushed onto cxq - v = u ; + ESelf->ListNext = (ParkEvent *)(v & ~_LBIT); + const intptr_t u = CASPTR(&_LockWord, v, intptr_t(ESelf)|_LBIT); + if (u == v) return 0; // indicate pushed onto cxq + v = u; } // Interference - LockWord change - just retry } @@ -444,33 +444,33 @@ inline int Monitor::AcquireOrPush (ParkEvent * ESelf) { // _owner is a higher-level logical concept. void Monitor::ILock (Thread * Self) { - assert (_OnDeck != Self->_MutexEvent, "invariant") ; + assert(_OnDeck != Self->_MutexEvent, "invariant"); if (TryFast()) { Exeunt: - assert (ILocked(), "invariant") ; - return ; + assert(ILocked(), "invariant"); + return; } - ParkEvent * const ESelf = Self->_MutexEvent ; - assert (_OnDeck != ESelf, "invariant") ; + ParkEvent * const ESelf = Self->_MutexEvent; + assert(_OnDeck != ESelf, "invariant"); // As an optimization, spinners could conditionally try to set ONDECK to _LBIT // Synchronizer.cpp uses a similar optimization. - if (TrySpin (Self)) goto Exeunt ; + if (TrySpin(Self)) goto Exeunt; // Slow-path - the lock is contended. // Either Enqueue Self on cxq or acquire the outer lock. // LockWord encoding = (cxq,LOCKBYTE) - ESelf->reset() ; - OrderAccess::fence() ; + ESelf->reset(); + OrderAccess::fence(); // Optional optimization ... try barging on the inner lock if ((NativeMonitorFlags & 32) && CASPTR (&_OnDeck, NULL, UNS(Self)) == 0) { - goto OnDeck_LOOP ; + goto OnDeck_LOOP; } - if (AcquireOrPush (ESelf)) goto Exeunt ; + if (AcquireOrPush(ESelf)) goto Exeunt; // At any given time there is at most one ondeck thread. // ondeck implies not resident on cxq and not resident on EntryList @@ -478,26 +478,26 @@ void Monitor::ILock (Thread * Self) { // CONSIDER: use Self->OnDeck instead of m->OnDeck. // Deschedule Self so that others may run. while (_OnDeck != ESelf) { - ParkCommon (ESelf, 0) ; + ParkCommon(ESelf, 0); } // Self is now in the ONDECK position and will remain so until it // manages to acquire the lock. OnDeck_LOOP: for (;;) { - assert (_OnDeck == ESelf, "invariant") ; - if (TrySpin (Self)) break ; + assert(_OnDeck == ESelf, "invariant"); + if (TrySpin(Self)) break; // CONSIDER: if ESelf->TryPark() && TryLock() break ... // It's probably wise to spin only if we *actually* blocked // CONSIDER: check the lockbyte, if it remains set then // preemptively drain the cxq into the EntryList. // The best place and time to perform queue operations -- lock metadata -- // is _before having acquired the outer lock, while waiting for the lock to drop. - ParkCommon (ESelf, 0) ; + ParkCommon(ESelf, 0); } - assert (_OnDeck == ESelf, "invariant") ; - _OnDeck = NULL ; + assert(_OnDeck == ESelf, "invariant"); + _OnDeck = NULL; // Note that we current drop the inner lock (clear OnDeck) in the slow-path // epilogue immediately after having acquired the outer lock. @@ -512,11 +512,11 @@ void Monitor::ILock (Thread * Self) { // effective length of the critical section. // Note that (A) and (B) are tantamount to succession by direct handoff for // the inner lock. - goto Exeunt ; + goto Exeunt; } void Monitor::IUnlock (bool RelaxAssert) { - assert (ILocked(), "invariant") ; + assert(ILocked(), "invariant"); // Conceptually we need a MEMBAR #storestore|#loadstore barrier or fence immediately // before the store that releases the lock. Crucially, all the stores and loads in the // critical section must be globally visible before the store of 0 into the lock-word @@ -532,9 +532,9 @@ void Monitor::IUnlock (bool RelaxAssert) { // safety or lock release consistency. OrderAccess::release_store(&_LockWord.Bytes[_LSBINDEX], 0); // drop outer lock - OrderAccess::storeload (); - ParkEvent * const w = _OnDeck ; - assert (RelaxAssert || w != Thread::current()->_MutexEvent, "invariant") ; + OrderAccess::storeload(); + ParkEvent * const w = _OnDeck; + assert(RelaxAssert || w != Thread::current()->_MutexEvent, "invariant"); if (w != NULL) { // Either we have a valid ondeck thread or ondeck is transiently "locked" // by some exiting thread as it arranges for succession. The LSBit of @@ -549,19 +549,19 @@ void Monitor::IUnlock (bool RelaxAssert) { // then progress is known to have occurred as that means the thread associated // with "w" acquired the lock. In that case this thread need take no further // action to guarantee progress. - if ((UNS(w) & _LBIT) == 0) w->unpark() ; - return ; + if ((UNS(w) & _LBIT) == 0) w->unpark(); + return; } - intptr_t cxq = _LockWord.FullWord ; + intptr_t cxq = _LockWord.FullWord; if (((cxq & ~_LBIT)|UNS(_EntryList)) == 0) { - return ; // normal fast-path exit - cxq and EntryList both empty + return; // normal fast-path exit - cxq and EntryList both empty } if (cxq & _LBIT) { // Optional optimization ... // Some other thread acquired the lock in the window since this // thread released it. Succession is now that thread's responsibility. - return ; + return; } Succession: @@ -575,22 +575,22 @@ void Monitor::IUnlock (bool RelaxAssert) { // picks a successor and marks that thread as OnDeck. That successor // thread will then clear OnDeck once it eventually acquires the outer lock. if (CASPTR (&_OnDeck, NULL, _LBIT) != UNS(NULL)) { - return ; + return; } - ParkEvent * List = _EntryList ; + ParkEvent * List = _EntryList; if (List != NULL) { // Transfer the head of the EntryList to the OnDeck position. // Once OnDeck, a thread stays OnDeck until it acquires the lock. // For a given lock there is at most OnDeck thread at any one instant. WakeOne: - assert (List == _EntryList, "invariant") ; - ParkEvent * const w = List ; - assert (RelaxAssert || w != Thread::current()->_MutexEvent, "invariant") ; - _EntryList = w->ListNext ; + assert(List == _EntryList, "invariant"); + ParkEvent * const w = List; + assert(RelaxAssert || w != Thread::current()->_MutexEvent, "invariant"); + _EntryList = w->ListNext; // as a diagnostic measure consider setting w->_ListNext = BAD - assert (UNS(_OnDeck) == _LBIT, "invariant") ; - _OnDeck = w ; // pass OnDeck to w. + assert(UNS(_OnDeck) == _LBIT, "invariant"); + _OnDeck = w; // pass OnDeck to w. // w will clear OnDeck once it acquires the outer lock // Another optional optimization ... @@ -599,25 +599,25 @@ void Monitor::IUnlock (bool RelaxAssert) { // Try to defer the unpark() operation - Delegate the responsibility // for unpark()ing the OnDeck thread to the current or subsequent owners // That is, the new owner is responsible for unparking the OnDeck thread. - OrderAccess::storeload() ; - cxq = _LockWord.FullWord ; - if (cxq & _LBIT) return ; + OrderAccess::storeload(); + cxq = _LockWord.FullWord; + if (cxq & _LBIT) return; - w->unpark() ; - return ; + w->unpark(); + return; } - cxq = _LockWord.FullWord ; + cxq = _LockWord.FullWord; if ((cxq & ~_LBIT) != 0) { // The EntryList is empty but the cxq is populated. // drain RATs from cxq into EntryList // Detach RATs segment with CAS and then merge into EntryList for (;;) { // optional optimization - if locked, the owner is responsible for succession - if (cxq & _LBIT) goto Punt ; - const intptr_t vfy = CASPTR (&_LockWord, cxq, cxq & _LBIT) ; - if (vfy == cxq) break ; - cxq = vfy ; + if (cxq & _LBIT) goto Punt; + const intptr_t vfy = CASPTR(&_LockWord, cxq, cxq & _LBIT); + if (vfy == cxq) break; + cxq = vfy; // Interference - LockWord changed - Just retry // We can see concurrent interference from contending threads // pushing themselves onto the cxq or from lock-unlock operations. @@ -639,10 +639,10 @@ void Monitor::IUnlock (bool RelaxAssert) { // the EntryList, but it might make sense to reverse the order // or perhaps sort by thread priority. See the comments in // synchronizer.cpp objectMonitor::exit(). - assert (_EntryList == NULL, "invariant") ; - _EntryList = List = (ParkEvent *)(cxq & ~_LBIT) ; - assert (List != NULL, "invariant") ; - goto WakeOne ; + assert(_EntryList == NULL, "invariant"); + _EntryList = List = (ParkEvent *)(cxq & ~_LBIT); + assert(List != NULL, "invariant"); + goto WakeOne; } // cxq|EntryList is empty. @@ -651,8 +651,8 @@ void Monitor::IUnlock (bool RelaxAssert) { // A thread could have added itself to cxq since this thread previously checked. // Detect and recover by refetching cxq. Punt: - assert (UNS(_OnDeck) == _LBIT, "invariant") ; - _OnDeck = NULL ; // Release inner lock. + assert(UNS(_OnDeck) == _LBIT, "invariant"); + _OnDeck = NULL; // Release inner lock. OrderAccess::storeload(); // Dekker duality - pivot point // Resample LockWord/cxq to recover from possible race. @@ -665,32 +665,32 @@ void Monitor::IUnlock (bool RelaxAssert) { // Note that we don't need to recheck EntryList, just cxq. // If threads moved onto EntryList since we dropped OnDeck // that implies some other thread forced succession. - cxq = _LockWord.FullWord ; + cxq = _LockWord.FullWord; if ((cxq & ~_LBIT) != 0 && (cxq & _LBIT) == 0) { - goto Succession ; // potential race -- re-run succession + goto Succession; // potential race -- re-run succession } - return ; + return; } bool Monitor::notify() { - assert (_owner == Thread::current(), "invariant") ; - assert (ILocked(), "invariant") ; - if (_WaitSet == NULL) return true ; - NotifyCount ++ ; + assert(_owner == Thread::current(), "invariant"); + assert(ILocked(), "invariant"); + if (_WaitSet == NULL) return true; + NotifyCount++; // Transfer one thread from the WaitSet to the EntryList or cxq. // Currently we just unlink the head of the WaitSet and prepend to the cxq. // And of course we could just unlink it and unpark it, too, but // in that case it'd likely impale itself on the reentry. - Thread::muxAcquire (_WaitLock, "notify:WaitLock") ; - ParkEvent * nfy = _WaitSet ; + Thread::muxAcquire(_WaitLock, "notify:WaitLock"); + ParkEvent * nfy = _WaitSet; if (nfy != NULL) { // DCL idiom - _WaitSet = nfy->ListNext ; - assert (nfy->Notified == 0, "invariant") ; + _WaitSet = nfy->ListNext; + assert(nfy->Notified == 0, "invariant"); // push nfy onto the cxq for (;;) { - const intptr_t v = _LockWord.FullWord ; - assert ((v & 0xFF) == _LBIT, "invariant") ; + const intptr_t v = _LockWord.FullWord; + assert((v & 0xFF) == _LBIT, "invariant"); nfy->ListNext = (ParkEvent *)(v & ~_LBIT); if (CASPTR (&_LockWord, v, UNS(nfy)|_LBIT) == v) break; // interference - _LockWord changed -- just retry @@ -698,17 +698,17 @@ bool Monitor::notify() { // Note that setting Notified before pushing nfy onto the cxq is // also legal and safe, but the safety properties are much more // subtle, so for the sake of code stewardship ... - OrderAccess::fence() ; + OrderAccess::fence(); nfy->Notified = 1; } - Thread::muxRelease (_WaitLock) ; + Thread::muxRelease(_WaitLock); if (nfy != NULL && (NativeMonitorFlags & 16)) { // Experimental code ... light up the wakee in the hope that this thread (the owner) // will drop the lock just about the time the wakee comes ONPROC. - nfy->unpark() ; + nfy->unpark(); } - assert (ILocked(), "invariant") ; - return true ; + assert(ILocked(), "invariant"); + return true; } // Currently notifyAll() transfers the waiters one-at-a-time from the waitset @@ -719,14 +719,14 @@ bool Monitor::notify() { // will be empty and the cxq will be "DCBAXYZ". This is benign, of course. bool Monitor::notify_all() { - assert (_owner == Thread::current(), "invariant") ; - assert (ILocked(), "invariant") ; - while (_WaitSet != NULL) notify() ; - return true ; + assert(_owner == Thread::current(), "invariant"); + assert(ILocked(), "invariant"); + while (_WaitSet != NULL) notify(); + return true; } int Monitor::IWait (Thread * Self, jlong timo) { - assert (ILocked(), "invariant") ; + assert(ILocked(), "invariant"); // Phases: // 1. Enqueue Self on WaitSet - currently prepend @@ -734,10 +734,10 @@ int Monitor::IWait (Thread * Self, jlong timo) { // 3. wait for either notification or timeout // 4. lock - reentry - reacquire the outer lock - ParkEvent * const ESelf = Self->_MutexEvent ; - ESelf->Notified = 0 ; - ESelf->reset() ; - OrderAccess::fence() ; + ParkEvent * const ESelf = Self->_MutexEvent; + ESelf->Notified = 0; + ESelf->reset(); + OrderAccess::fence(); // Add Self to WaitSet // Ideally only the holder of the outer lock would manipulate the WaitSet - @@ -766,10 +766,10 @@ int Monitor::IWait (Thread * Self, jlong timo) { // In that case we could have one ListElement on the WaitSet and another // on the EntryList, with both referring to the same pure Event. - Thread::muxAcquire (_WaitLock, "wait:WaitLock:Add") ; - ESelf->ListNext = _WaitSet ; - _WaitSet = ESelf ; - Thread::muxRelease (_WaitLock) ; + Thread::muxAcquire(_WaitLock, "wait:WaitLock:Add"); + ESelf->ListNext = _WaitSet; + _WaitSet = ESelf; + Thread::muxRelease(_WaitLock); // Release the outer lock // We call IUnlock (RelaxAssert=true) as a thread T1 might @@ -781,16 +781,16 @@ int Monitor::IWait (Thread * Self, jlong timo) { // IUnlock() call a thread should _never find itself on the EntryList // or cxq, but in the case of wait() it's possible. // See synchronizer.cpp objectMonitor::wait(). - IUnlock (true) ; + IUnlock(true); // Wait for either notification or timeout // Beware that in some circumstances we might propagate // spurious wakeups back to the caller. for (;;) { - if (ESelf->Notified) break ; - int err = ParkCommon (ESelf, timo) ; - if (err == OS_TIMEOUT || (NativeMonitorFlags & 1)) break ; + if (ESelf->Notified) break; + int err = ParkCommon(ESelf, timo); + if (err == OS_TIMEOUT || (NativeMonitorFlags & 1)) break; } // Prepare for reentry - if necessary, remove ESelf from WaitSet @@ -799,55 +799,55 @@ int Monitor::IWait (Thread * Self, jlong timo) { // 2. On the cxq or EntryList // 3. Not resident on cxq, EntryList or WaitSet, but in the OnDeck position. - OrderAccess::fence() ; - int WasOnWaitSet = 0 ; + OrderAccess::fence(); + int WasOnWaitSet = 0; if (ESelf->Notified == 0) { - Thread::muxAcquire (_WaitLock, "wait:WaitLock:remove") ; + Thread::muxAcquire(_WaitLock, "wait:WaitLock:remove"); if (ESelf->Notified == 0) { // DCL idiom - assert (_OnDeck != ESelf, "invariant") ; // can't be both OnDeck and on WaitSet + assert(_OnDeck != ESelf, "invariant"); // can't be both OnDeck and on WaitSet // ESelf is resident on the WaitSet -- unlink it. // A doubly-linked list would be better here so we can unlink in constant-time. // We have to unlink before we potentially recontend as ESelf might otherwise // end up on the cxq|EntryList -- it can't be on two lists at once. - ParkEvent * p = _WaitSet ; - ParkEvent * q = NULL ; // classic q chases p + ParkEvent * p = _WaitSet; + ParkEvent * q = NULL; // classic q chases p while (p != NULL && p != ESelf) { - q = p ; - p = p->ListNext ; + q = p; + p = p->ListNext; } - assert (p == ESelf, "invariant") ; + assert(p == ESelf, "invariant"); if (p == _WaitSet) { // found at head - assert (q == NULL, "invariant") ; - _WaitSet = p->ListNext ; + assert(q == NULL, "invariant"); + _WaitSet = p->ListNext; } else { // found in interior - assert (q->ListNext == p, "invariant") ; - q->ListNext = p->ListNext ; + assert(q->ListNext == p, "invariant"); + q->ListNext = p->ListNext; } - WasOnWaitSet = 1 ; // We were *not* notified but instead encountered timeout + WasOnWaitSet = 1; // We were *not* notified but instead encountered timeout } - Thread::muxRelease (_WaitLock) ; + Thread::muxRelease(_WaitLock); } // Reentry phase - reacquire the lock if (WasOnWaitSet) { // ESelf was previously on the WaitSet but we just unlinked it above // because of a timeout. ESelf is not resident on any list and is not OnDeck - assert (_OnDeck != ESelf, "invariant") ; - ILock (Self) ; + assert(_OnDeck != ESelf, "invariant"); + ILock(Self); } else { // A prior notify() operation moved ESelf from the WaitSet to the cxq. // ESelf is now on the cxq, EntryList or at the OnDeck position. // The following fragment is extracted from Monitor::ILock() for (;;) { - if (_OnDeck == ESelf && TrySpin(Self)) break ; - ParkCommon (ESelf, 0) ; + if (_OnDeck == ESelf && TrySpin(Self)) break; + ParkCommon(ESelf, 0); } - assert (_OnDeck == ESelf, "invariant") ; - _OnDeck = NULL ; + assert(_OnDeck == ESelf, "invariant"); + _OnDeck = NULL; } - assert (ILocked(), "invariant") ; - return WasOnWaitSet != 0 ; // return true IFF timeout + assert(ILocked(), "invariant"); + return WasOnWaitSet != 0; // return true IFF timeout } @@ -896,15 +896,15 @@ void Monitor::lock (Thread * Self) { #endif // CHECK_UNHANDLED_OOPS debug_only(check_prelock_state(Self)); - assert (_owner != Self , "invariant") ; - assert (_OnDeck != Self->_MutexEvent, "invariant") ; + assert(_owner != Self , "invariant"); + assert(_OnDeck != Self->_MutexEvent, "invariant"); if (TryFast()) { Exeunt: - assert (ILocked(), "invariant") ; - assert (owner() == NULL, "invariant"); - set_owner (Self); - return ; + assert(ILocked(), "invariant"); + assert(owner() == NULL, "invariant"); + set_owner(Self); + return; } // The lock is contended ... @@ -916,23 +916,23 @@ void Monitor::lock (Thread * Self) { // and go on. we note this with _snuck so we can also // pretend to unlock when the time comes. _snuck = true; - goto Exeunt ; + goto Exeunt; } // Try a brief spin to avoid passing thru thread state transition ... - if (TrySpin (Self)) goto Exeunt ; + if (TrySpin(Self)) goto Exeunt; check_block_state(Self); if (Self->is_Java_thread()) { // Horrible dictu - we suffer through a state transition assert(rank() > Mutex::special, "Potential deadlock with special or lesser rank mutex"); - ThreadBlockInVM tbivm ((JavaThread *) Self) ; - ILock (Self) ; + ThreadBlockInVM tbivm((JavaThread *) Self); + ILock(Self); } else { // Mirabile dictu - ILock (Self) ; + ILock(Self); } - goto Exeunt ; + goto Exeunt; } void Monitor::lock() { @@ -945,14 +945,14 @@ void Monitor::lock() { // thread state set to be in VM, the safepoint synchronization code will deadlock! void Monitor::lock_without_safepoint_check (Thread * Self) { - assert (_owner != Self, "invariant") ; - ILock (Self) ; - assert (_owner == NULL, "invariant"); - set_owner (Self); + assert(_owner != Self, "invariant"); + ILock(Self); + assert(_owner == NULL, "invariant"); + set_owner(Self); } -void Monitor::lock_without_safepoint_check () { - lock_without_safepoint_check (Thread::current()) ; +void Monitor::lock_without_safepoint_check() { + lock_without_safepoint_check(Thread::current()); } @@ -976,23 +976,23 @@ bool Monitor::try_lock() { if (TryLock()) { // We got the lock - assert (_owner == NULL, "invariant"); - set_owner (Self); + assert(_owner == NULL, "invariant"); + set_owner(Self); return true; } return false; } void Monitor::unlock() { - assert (_owner == Thread::current(), "invariant") ; - assert (_OnDeck != Thread::current()->_MutexEvent , "invariant") ; - set_owner (NULL) ; + assert(_owner == Thread::current(), "invariant"); + assert(_OnDeck != Thread::current()->_MutexEvent , "invariant"); + set_owner(NULL); if (_snuck) { assert(SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread(), "sneak"); _snuck = false; - return ; + return; } - IUnlock (false) ; + IUnlock(false); } // Yet another degenerate version of Monitor::lock() or lock_without_safepoint_check() @@ -1020,29 +1020,29 @@ void Monitor::jvm_raw_lock() { if (TryLock()) { Exeunt: - assert (ILocked(), "invariant") ; - assert (_owner == NULL, "invariant"); + assert(ILocked(), "invariant"); + assert(_owner == NULL, "invariant"); // This can potentially be called by non-java Threads. Thus, the ThreadLocalStorage // might return NULL. Don't call set_owner since it will break on an NULL owner // Consider installing a non-null "ANON" distinguished value instead of just NULL. _owner = ThreadLocalStorage::thread(); - return ; + return; } - if (TrySpin(NULL)) goto Exeunt ; + if (TrySpin(NULL)) goto Exeunt; // slow-path - apparent contention // Allocate a ParkEvent for transient use. // The ParkEvent remains associated with this thread until // the time the thread manages to acquire the lock. - ParkEvent * const ESelf = ParkEvent::Allocate(NULL) ; - ESelf->reset() ; - OrderAccess::storeload() ; + ParkEvent * const ESelf = ParkEvent::Allocate(NULL); + ESelf->reset(); + OrderAccess::storeload(); // Either Enqueue Self on cxq or acquire the outer lock. if (AcquireOrPush (ESelf)) { - ParkEvent::Release (ESelf) ; // surrender the ParkEvent - goto Exeunt ; + ParkEvent::Release(ESelf); // surrender the ParkEvent + goto Exeunt; } // At any given time there is at most one ondeck thread. @@ -1050,37 +1050,37 @@ void Monitor::jvm_raw_lock() { // Only the OnDeck thread can try to acquire -- contended for -- the lock. // CONSIDER: use Self->OnDeck instead of m->OnDeck. for (;;) { - if (_OnDeck == ESelf && TrySpin(NULL)) break ; - ParkCommon (ESelf, 0) ; + if (_OnDeck == ESelf && TrySpin(NULL)) break; + ParkCommon(ESelf, 0); } - assert (_OnDeck == ESelf, "invariant") ; - _OnDeck = NULL ; - ParkEvent::Release (ESelf) ; // surrender the ParkEvent - goto Exeunt ; + assert(_OnDeck == ESelf, "invariant"); + _OnDeck = NULL; + ParkEvent::Release(ESelf); // surrender the ParkEvent + goto Exeunt; } void Monitor::jvm_raw_unlock() { // Nearly the same as Monitor::unlock() ... // directly set _owner instead of using set_owner(null) - _owner = NULL ; + _owner = NULL; if (_snuck) { // ??? assert(SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread(), "sneak"); _snuck = false; - return ; + return; } - IUnlock(false) ; + IUnlock(false); } bool Monitor::wait(bool no_safepoint_check, long timeout, bool as_suspend_equivalent) { - Thread * const Self = Thread::current() ; - assert (_owner == Self, "invariant") ; - assert (ILocked(), "invariant") ; + Thread * const Self = Thread::current(); + assert(_owner == Self, "invariant"); + assert(ILocked(), "invariant"); // as_suspend_equivalent logically implies !no_safepoint_check - guarantee (!as_suspend_equivalent || !no_safepoint_check, "invariant") ; + guarantee(!as_suspend_equivalent || !no_safepoint_check, "invariant"); // !no_safepoint_check logically implies java_thread - guarantee (no_safepoint_check || Self->is_Java_thread(), "invariant") ; + guarantee(no_safepoint_check || Self->is_Java_thread(), "invariant"); #ifdef ASSERT Monitor * least = get_least_ranked_lock_besides_this(Self->owned_locks()); @@ -1093,14 +1093,14 @@ bool Monitor::wait(bool no_safepoint_check, long timeout, bool as_suspend_equiva } #endif // ASSERT - int wait_status ; + int wait_status; // conceptually set the owner to NULL in anticipation of // abdicating the lock in wait set_owner(NULL); if (no_safepoint_check) { - wait_status = IWait (Self, timeout) ; + wait_status = IWait(Self, timeout); } else { - assert (Self->is_Java_thread(), "invariant") ; + assert(Self->is_Java_thread(), "invariant"); JavaThread *jt = (JavaThread *)Self; // Enter safepoint region - ornate and Rococo ... @@ -1113,7 +1113,7 @@ bool Monitor::wait(bool no_safepoint_check, long timeout, bool as_suspend_equiva // java_suspend_self() } - wait_status = IWait (Self, timeout) ; + wait_status = IWait(Self, timeout); // were we externally suspended while we were waiting? if (as_suspend_equivalent && jt->handle_special_suspend_equivalent_condition()) { @@ -1121,67 +1121,67 @@ bool Monitor::wait(bool no_safepoint_check, long timeout, bool as_suspend_equiva // while we were waiting another thread suspended us. We don't // want to hold the lock while suspended because that // would surprise the thread that suspended us. - assert (ILocked(), "invariant") ; - IUnlock (true) ; + assert(ILocked(), "invariant"); + IUnlock(true); jt->java_suspend_self(); - ILock (Self) ; - assert (ILocked(), "invariant") ; + ILock(Self); + assert(ILocked(), "invariant"); } } // Conceptually reestablish ownership of the lock. // The "real" lock -- the LockByte -- was reacquired by IWait(). - assert (ILocked(), "invariant") ; - assert (_owner == NULL, "invariant") ; - set_owner (Self) ; - return wait_status != 0 ; // return true IFF timeout + assert(ILocked(), "invariant"); + assert(_owner == NULL, "invariant"); + set_owner(Self); + return wait_status != 0; // return true IFF timeout } Monitor::~Monitor() { - assert ((UNS(_owner)|UNS(_LockWord.FullWord)|UNS(_EntryList)|UNS(_WaitSet)|UNS(_OnDeck)) == 0, "") ; + assert((UNS(_owner)|UNS(_LockWord.FullWord)|UNS(_EntryList)|UNS(_WaitSet)|UNS(_OnDeck)) == 0, ""); } void Monitor::ClearMonitor (Monitor * m, const char *name) { - m->_owner = NULL ; - m->_snuck = false ; + m->_owner = NULL; + m->_snuck = false; if (name == NULL) { - strcpy(m->_name, "UNKNOWN") ; + strcpy(m->_name, "UNKNOWN"); } else { strncpy(m->_name, name, MONITOR_NAME_LEN - 1); m->_name[MONITOR_NAME_LEN - 1] = '\0'; } - m->_LockWord.FullWord = 0 ; - m->_EntryList = NULL ; - m->_OnDeck = NULL ; - m->_WaitSet = NULL ; - m->_WaitLock[0] = 0 ; + m->_LockWord.FullWord = 0; + m->_EntryList = NULL; + m->_OnDeck = NULL; + m->_WaitSet = NULL; + m->_WaitLock[0] = 0; } Monitor::Monitor() { ClearMonitor(this); } Monitor::Monitor (int Rank, const char * name, bool allow_vm_block) { - ClearMonitor (this, name) ; + ClearMonitor(this, name); #ifdef ASSERT _allow_vm_block = allow_vm_block; - _rank = Rank ; + _rank = Rank; #endif } Mutex::~Mutex() { - assert ((UNS(_owner)|UNS(_LockWord.FullWord)|UNS(_EntryList)|UNS(_WaitSet)|UNS(_OnDeck)) == 0, "") ; + assert((UNS(_owner)|UNS(_LockWord.FullWord)|UNS(_EntryList)|UNS(_WaitSet)|UNS(_OnDeck)) == 0, ""); } Mutex::Mutex (int Rank, const char * name, bool allow_vm_block) { - ClearMonitor ((Monitor *) this, name) ; + ClearMonitor((Monitor *) this, name); #ifdef ASSERT _allow_vm_block = allow_vm_block; - _rank = Rank ; + _rank = Rank; #endif } bool Monitor::owned_by_self() const { bool ret = _owner == Thread::current(); - assert (!ret || _LockWord.Bytes[_LSBINDEX] != 0, "invariant") ; + assert(!ret || _LockWord.Bytes[_LSBINDEX] != 0, "invariant"); return ret; } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index c28c469d0e8..a6d4dfd704d 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -217,7 +217,7 @@ class SharedRuntime: AllStatic { static UncommonTrapBlob* uncommon_trap_blob() { return _uncommon_trap_blob; } #endif // COMPILER2 - static address get_resolve_opt_virtual_call_stub(){ + static address get_resolve_opt_virtual_call_stub() { assert(_resolve_opt_virtual_call_blob != NULL, "oops"); return _resolve_opt_virtual_call_blob->entry_point(); } @@ -253,7 +253,7 @@ class SharedRuntime: AllStatic { // bytecode tracing is only used by the TraceBytecodes static intptr_t trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2) PRODUCT_RETURN0; - static oop retrieve_receiver( Symbol* sig, frame caller ); + static oop retrieve_receiver(Symbol* sig, frame caller); static void register_finalizer(JavaThread* thread, oopDesc* obj); @@ -446,8 +446,8 @@ class SharedRuntime: AllStatic { static bool is_wide_vector(int size); // Save and restore a native result - static void save_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots ); - static void restore_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots ); + static void save_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots); + static void restore_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots); // Generate a native wrapper for a given method. The method takes arguments // in the Java compiled code convention, marshals them to the native @@ -463,7 +463,7 @@ class SharedRuntime: AllStatic { int compile_id, BasicType* sig_bt, VMRegPair* regs, - BasicType ret_type ); + BasicType ret_type); // Block before entering a JNI critical method static void block_for_jni_critical(JavaThread* thread); diff --git a/hotspot/src/share/vm/runtime/synchronizer.hpp b/hotspot/src/share/vm/runtime/synchronizer.hpp index 4f95b31350d..bf3959be688 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.hpp +++ b/hotspot/src/share/vm/runtime/synchronizer.hpp @@ -75,7 +75,7 @@ class ObjectSynchronizer : AllStatic { // Special internal-use-only method for use by JVM infrastructure // that needs to wait() on a java-level object but that can't risk // throwing unexpected InterruptedExecutionExceptions. - static void waitUninterruptibly (Handle obj, jlong Millis, Thread * THREAD) ; + static void waitUninterruptibly(Handle obj, jlong Millis, Thread * THREAD); // used by classloading to free classloader object lock, // wait on an internal lock, and reclaim original lock @@ -85,9 +85,9 @@ class ObjectSynchronizer : AllStatic { // thread-specific and global objectMonitor free list accessors // static void verifyInUse (Thread * Self) ; too slow for general assert/debug - static ObjectMonitor * omAlloc (Thread * Self) ; - static void omRelease (Thread * Self, ObjectMonitor * m, bool FromPerThreadAlloc) ; - static void omFlush (Thread * Self) ; + static ObjectMonitor * omAlloc(Thread * Self); + static void omRelease(Thread * Self, ObjectMonitor * m, bool FromPerThreadAlloc); + static void omFlush(Thread * Self); // Inflate light weight monitor to heavy weight monitor static ObjectMonitor* inflate(Thread * Self, oop obj); @@ -97,7 +97,7 @@ class ObjectSynchronizer : AllStatic { // Returns the identity hash value for an oop // NOTE: It may cause monitor inflation static intptr_t identity_hash_value_for(Handle obj); - static intptr_t FastHashCode (Thread * Self, oop obj) ; + static intptr_t FastHashCode(Thread * Self, oop obj); // java.lang.Thread support static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj); @@ -124,7 +124,7 @@ class ObjectSynchronizer : AllStatic { static void verify() PRODUCT_RETURN; static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0; - static void RegisterSpinCallback (int (*)(intptr_t, int), intptr_t) ; + static void RegisterSpinCallback(int(*)(intptr_t, int), intptr_t); private: enum { _BLOCKSIZE = 128 }; @@ -155,7 +155,7 @@ class ObjectLocker : public StackObj { // Monitor behavior void wait (TRAPS) { ObjectSynchronizer::wait (_obj, 0, CHECK); } // wait forever void notify_all(TRAPS) { ObjectSynchronizer::notifyall(_obj, CHECK); } - void waitUninterruptibly (TRAPS) { ObjectSynchronizer::waitUninterruptibly (_obj, 0, CHECK);} + void waitUninterruptibly (TRAPS) { ObjectSynchronizer::waitUninterruptibly (_obj, 0, CHECK); } // complete_exit gives up lock completely, returning recursion count // reenter reclaims lock with original recursion count intptr_t complete_exit(TRAPS) { return ObjectSynchronizer::complete_exit(_obj, CHECK_0); } From 17f9ae57134cd346e54838d7216e1d972b4cbab2 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Wed, 18 Jun 2014 14:58:16 -0700 Subject: [PATCH 086/236] 8046071: update three javadoc tests for empty

tag Reviewed-by: jjg, ksrini --- langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html | 1 - langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html | 1 - langtools/test/com/sun/javadoc/ValidHtml/overview.html | 1 - 3 files changed, 3 deletions(-) diff --git a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html index d4ea8bec977..b31149b5d34 100644 --- a/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html +++ b/langtools/test/com/sun/javadoc/DocRootSlash/p1/package.html @@ -67,7 +67,6 @@ Actual: package Actual: package description {@docRoot}/p1/package-summary.html#package_description
Expect: ../p1/package-summary.html#package description -

diff --git a/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html b/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html index 88c45b3a6e4..732aaabbaf1 100644 --- a/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html +++ b/langtools/test/com/sun/javadoc/JavascriptWinTitle/overview.html @@ -9,7 +9,6 @@ with examples of a wide variety of Java language constructs: packages, subclasses, subinterfaces, nested classes, nested interfaces, inheriting from other packages, constructors, fields, methods, and so forth. -

diff --git a/langtools/test/com/sun/javadoc/ValidHtml/overview.html b/langtools/test/com/sun/javadoc/ValidHtml/overview.html index 88c45b3a6e4..732aaabbaf1 100644 --- a/langtools/test/com/sun/javadoc/ValidHtml/overview.html +++ b/langtools/test/com/sun/javadoc/ValidHtml/overview.html @@ -9,7 +9,6 @@ with examples of a wide variety of Java language constructs: packages, subclasses, subinterfaces, nested classes, nested interfaces, inheriting from other packages, constructors, fields, methods, and so forth. -

From 18ac28e76f627d1ece50a0da257a67ca4d9a41c6 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Thu, 19 Jun 2014 10:46:31 +0200 Subject: [PATCH 087/236] 8047078: Fuzzing bug discovered when ArrayLiteralNodes weren't immutable Reviewed-by: attila, sundar --- .../internal/codegen/CompilationPhase.java | 15 +- .../codegen/LocalVariableTypesCalculator.java | 10 +- .../nashorn/internal/codegen/Splitter.java | 2 +- .../nashorn/internal/codegen/WeighNodes.java | 1 - .../jdk/nashorn/internal/ir/LiteralNode.java | 370 ++++++++++-------- nashorn/test/script/basic/JDK-8047057.js | 12 +- nashorn/test/script/basic/JDK-8047078.js | 38 ++ 7 files changed, 277 insertions(+), 171 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8047078.js diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java index aba9962373d..c415d0cec6d 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java @@ -173,7 +173,18 @@ enum CompilationPhase { @Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); - final FunctionNode newFunctionNode = new Splitter(compiler, fn, outermostCompileUnit).split(fn, true); + + FunctionNode newFunctionNode; + + //ensure elementTypes, postsets and presets exist for splitter and arraynodes + newFunctionNode = (FunctionNode)fn.accept(new NodeVisitor(new LexicalContext()) { + @Override + public LiteralNode leaveLiteralNode(final LiteralNode literalNode) { + return literalNode.initialize(lc); + } + }); + + newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); @@ -374,7 +385,7 @@ enum CompilationPhase { assert newUnit != null; newArrayUnits.add(new ArrayUnit(newUnit, au.getLo(), au.getHi())); } - aln.setUnits(newArrayUnits); + return aln.setUnits(lc, newArrayUnits); } return node; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java index 5a1f09ae1ec..7112a53eb76 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.AccessNode; import jdk.nashorn.internal.ir.BaseNode; @@ -63,7 +64,6 @@ import jdk.nashorn.internal.ir.LabelNode; import jdk.nashorn.internal.ir.LexicalContext; import jdk.nashorn.internal.ir.LexicalContextNode; import jdk.nashorn.internal.ir.LiteralNode; -import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LocalVariableConversion; import jdk.nashorn.internal.ir.LoopNode; import jdk.nashorn.internal.ir.Node; @@ -1207,10 +1207,10 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ @Override public Node leaveLiteralNode(final LiteralNode literalNode) { - if(literalNode instanceof ArrayLiteralNode) { - ((ArrayLiteralNode)literalNode).analyze(); - } - return literalNode; + //for e.g. ArrayLiteralNodes the initial types may have been narrowed due to the + //introduction of optimistic behavior - hence ensure that all literal nodes are + //reinitialized + return literalNode.initialize(lc); } @Override diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java index 088e49e1b66..9405d062faa 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Splitter.java @@ -307,7 +307,7 @@ final class Splitter extends NodeVisitor { units.add(new ArrayUnit(unit, lo, postsets.length)); } - arrayLiteralNode.setUnits(units); + return arrayLiteralNode.setUnits(lc, units); } return literal; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java b/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java index 7f735a2933b..26660a3a859 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/WeighNodes.java @@ -173,7 +173,6 @@ final class WeighNodes extends NodeOperatorVisitor { if (functionNode == topFunction) { // the function being weighted; descend into its statements return true; -// functionNode.visitStatements(this); } // just a reference to inner function from outer function weight += FUNC_EXPR_WEIGHT; diff --git a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java index e83901e4442..b71e450389f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/LiteralNode.java @@ -29,6 +29,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Function; + import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.types.ArrayType; import jdk.nashorn.internal.codegen.types.Type; @@ -86,6 +87,17 @@ public abstract class LiteralNode extends Expression implements PropertyKey { this.value = newValue; } + /** + * Initialization setter, if required for immutable state. This is used for + * things like ArrayLiteralNodes that need to carry state for the splitter. + * Default implementation is just a nop. + * @param lc lexical context + * @return new literal node with initialized state, or same if nothing changed + */ + public LiteralNode initialize(final LexicalContext lc) { + return this; + } + /** * Check if the literal value is null * @return true if literal value is null @@ -573,24 +585,26 @@ public abstract class LiteralNode extends Expression implements PropertyKey { /** * Array literal node class. */ + @Immutable public static final class ArrayLiteralNode extends LiteralNode implements LexicalContextNode { /** Array element type. */ - private Type elementType; + private final Type elementType; /** Preset constant array. */ - private Object presets; + private final Object presets; /** Indices of array elements requiring computed post sets. */ - private int[] postsets; + private final int[] postsets; - private List units; + /** Sub units with indexes ranges, in which to split up code generation, for large literals */ + private final List units; /** * An ArrayUnit is a range in an ArrayLiteral. ArrayLiterals can * be split if they are too large, for bytecode generation reasons */ - public static class ArrayUnit { + public static final class ArrayUnit { /** Compile unit associated with the postsets range. */ private final CompileUnit compileUnit; @@ -634,6 +648,150 @@ public abstract class LiteralNode extends Expression implements PropertyKey { } } + private static final class ArrayLiteralInitializer { + + static ArrayLiteralNode initialize(final ArrayLiteralNode node) { + final Type elementType = computeElementType(node.value, node.elementType); + final int[] postsets = computePostsets(node.value); + final Object presets = computePresets(node.value, elementType, postsets); + return new ArrayLiteralNode(node, node.value, elementType, postsets, presets, node.units); + } + + private static Type computeElementType(final Expression[] value, final Type elementType) { + Type widestElementType = Type.INT; + + for (final Expression elem : value) { + if (elem == null) { + widestElementType = widestElementType.widest(Type.OBJECT); //no way to represent undefined as number + break; + } + + final Type type = elem.getType().isUnknown() ? Type.OBJECT : elem.getType(); + if (type.isBoolean()) { + //TODO fix this with explicit boolean types + widestElementType = widestElementType.widest(Type.OBJECT); + break; + } + + widestElementType = widestElementType.widest(type); + if (widestElementType.isObject()) { + break; + } + } + return widestElementType; + } + + private static int[] computePostsets(final Expression[] value) { + final int[] computed = new int[value.length]; + int nComputed = 0; + + for (int i = 0; i < value.length; i++) { + final Expression element = value[i]; + if (element == null || objectAsConstant(element) == POSTSET_MARKER) { + computed[nComputed++] = i; + } + } + return Arrays.copyOf(computed, nComputed); + } + + private static boolean setArrayElement(final int[] array, final int i, final Object n) { + if (n instanceof Number) { + array[i] = ((Number)n).intValue(); + return true; + } + return false; + } + + private static boolean setArrayElement(final long[] array, final int i, final Object n) { + if (n instanceof Number) { + array[i] = ((Number)n).longValue(); + return true; + } + return false; + } + + private static boolean setArrayElement(final double[] array, final int i, final Object n) { + if (n instanceof Number) { + array[i] = ((Number)n).doubleValue(); + return true; + } + return false; + } + + private static int[] presetIntArray(final Expression[] value, final int[] postsets) { + final int[] array = new int[value.length]; + int nComputed = 0; + for (int i = 0; i < value.length; i++) { + if (!setArrayElement(array, i, objectAsConstant(value[i]))) { + assert postsets[nComputed++] == i; + } + } + assert postsets.length == nComputed; + return array; + } + + private static long[] presetLongArray(final Expression[] value, final int[] postsets) { + final long[] array = new long[value.length]; + int nComputed = 0; + for (int i = 0; i < value.length; i++) { + if (!setArrayElement(array, i, objectAsConstant(value[i]))) { + assert postsets[nComputed++] == i; + } + } + assert postsets.length == nComputed; + return array; + } + + private static double[] presetDoubleArray(final Expression[] value, final int[] postsets) { + final double[] array = new double[value.length]; + int nComputed = 0; + for (int i = 0; i < value.length; i++) { + if (!setArrayElement(array, i, objectAsConstant(value[i]))) { + assert postsets[nComputed++] == i; + } + } + assert postsets.length == nComputed; + return array; + } + + private static Object[] presetObjectArray(final Expression[] value, final int[] postsets) { + final Object[] array = new Object[value.length]; + int nComputed = 0; + + for (int i = 0; i < value.length; i++) { + final Node node = value[i]; + + if (node == null) { + assert postsets[nComputed++] == i; + continue; + } + final Object element = objectAsConstant(node); + + if (element != POSTSET_MARKER) { + array[i] = element; + } else { + assert postsets[nComputed++] == i; + } + } + + assert postsets.length == nComputed; + return array; + } + + static Object computePresets(final Expression[] value, final Type elementType, final int[] postsets) { + assert !elementType.isUnknown(); + if (elementType.isInteger()) { + return presetIntArray(value, postsets); + } else if (elementType.isLong()) { + return presetLongArray(value, postsets); + } else if (elementType.isNumeric()) { + return presetDoubleArray(value, postsets); + } else { + return presetObjectArray(value, postsets); + } + } + } + /** * Constructor * @@ -644,136 +802,21 @@ public abstract class LiteralNode extends Expression implements PropertyKey { protected ArrayLiteralNode(final long token, final int finish, final Expression[] value) { super(Token.recast(token, TokenType.ARRAY), finish, value); this.elementType = Type.UNKNOWN; + this.presets = null; + this.postsets = null; + this.units = null; } /** * Copy constructor * @param node source array literal node */ - private ArrayLiteralNode(final ArrayLiteralNode node, final Expression[] value) { + private ArrayLiteralNode(final ArrayLiteralNode node, final Expression[] value, final Type elementType, final int[] postsets, final Object presets, final List units) { super(node, value); - this.elementType = node.elementType; - this.presets = node.presets; - this.postsets = node.postsets; - this.units = node.units; - } - - /** - * Compute things like widest element type needed. Internal use from compiler only - */ - public void analyze() { - assert elementType.isUnknown(); - elementType = getNarrowestElementType(value); - } - - private int[] presetIntArray() { - final int[] array = new int[value.length]; - int nComputed = 0; - - for (int i = 0; i < value.length; i++) { - final Object element = objectAsConstant(value[i]); - - if (element instanceof Number) { - array[i] = ((Number)element).intValue(); - } else { - assert getPostsets()[nComputed++] == i; - } - } - - assert getPostsets().length == nComputed; - return array; - } - - private long[] presetLongArray() { - final long[] array = new long[value.length]; - int nComputed = 0; - - for (int i = 0; i < value.length; i++) { - final Object element = objectAsConstant(value[i]); - - if (element instanceof Number) { - array[i] = ((Number)element).longValue(); - } else { - assert getPostsets()[nComputed++] == i; - } - } - - assert getPostsets().length == nComputed; - return array; - } - - private double[] presetNumberArray() { - final double[] array = new double[value.length]; - int nComputed = 0; - - for (int i = 0; i < value.length; i++) { - final Object element = objectAsConstant(value[i]); - - if (element instanceof Number) { - array[i] = ((Number)element).doubleValue(); - } else { - assert getPostsets()[nComputed++] == i; - } - } - - assert getPostsets().length == nComputed; - return array; - } - - private Object[] presetObjectArray() { - final Object[] array = new Object[value.length]; - int nComputed = 0; - - for (int i = 0; i < value.length; i++) { - final Node node = value[i]; - - if (node == null) { - assert getPostsets()[nComputed++] == i; - } else { - final Object element = objectAsConstant(node); - - if (element != POSTSET_MARKER) { - array[i] = element; - } else { - assert getPostsets()[nComputed++] == i; - } - } - } - - assert getPostsets().length == nComputed; - return array; - } - - /** - * Returns the narrowest element type that is wide enough to represent all the expressions in the array. - * @param elementExpressions the array of expressions - * @return the narrowest element type that is wide enough to represent all the expressions in the array. - */ - private static Type getNarrowestElementType(final Expression[] elementExpressions) { - Type widestElementType = Type.INT; - for (final Expression element : elementExpressions) { - if (element == null) { - widestElementType = widestElementType.widest(Type.OBJECT); //no way to represent undefined as number - break; - } - - Type elementType = element.getType(); - if (elementType.isUnknown()) { - elementType = Type.OBJECT; - } - - if (elementType.isBoolean()) { - widestElementType = widestElementType.widest(Type.OBJECT); - break; - } - - widestElementType = widestElementType.widest(elementType); - - if (widestElementType.isObject()) { - break; - } - } - return widestElementType; + this.elementType = elementType; + this.postsets = postsets; + this.presets = presets; + this.units = units; } @Override @@ -781,6 +824,19 @@ public abstract class LiteralNode extends Expression implements PropertyKey { return value; } + /** + * Setter that initializes all code generation meta data for an + * ArrayLiteralNode. This acts a setter, so the return value may + * return a new node and must be handled + * + * @param lc lexical context + * @return new array literal node with postsets, presets and element types initialized + */ + @Override + public ArrayLiteralNode initialize(final LexicalContext lc) { + return Node.replaceInLexicalContext(lc, this, ArrayLiteralInitializer.initialize(this)); + } + /** * Get the array element type as Java format, e.g. [I * @return array element type @@ -811,7 +867,7 @@ public abstract class LiteralNode extends Expression implements PropertyKey { * @return element type */ public Type getElementType() { - assert !elementType.isUnknown(); + assert !elementType.isUnknown() : this + " has elementType=unknown"; return elementType; } @@ -821,38 +877,28 @@ public abstract class LiteralNode extends Expression implements PropertyKey { * @return post set indices */ public int[] getPostsets() { - if(postsets == null) { - final int[] computed = new int[value.length]; - int nComputed = 0; - - for (int i = 0; i < value.length; i++) { - final Expression element = value[i]; - if(element == null || objectAsConstant(element) == POSTSET_MARKER) { - computed[nComputed++] = i; - } - } - postsets = Arrays.copyOf(computed, nComputed); - } + assert postsets != null : this + " elementType=" + elementType + " has no postsets"; return postsets; } + private boolean presetsMatchElementType() { + if (elementType == Type.INT) { + return presets instanceof int[]; + } else if (elementType == Type.LONG) { + return presets instanceof long[]; + } else if (elementType == Type.NUMBER) { + return presets instanceof double[]; + } else { + return presets instanceof Object[]; + } + } + /** * Get presets constant array * @return presets array, always returns an array type */ public Object getPresets() { - if(presets == null) { - final Type type = getElementType(); - if (type.isInteger()) { - presets = presetIntArray(); - } else if (type.isLong()) { - presets = presetLongArray(); - } else if (type.isNumeric()) { - presets = presetNumberArray(); - } else { - presets = presetObjectArray(); - } - } + assert presets != null && presetsMatchElementType() : this + " doesn't have presets, or invalid preset type: " + presets; return presets; } @@ -867,11 +913,16 @@ public abstract class LiteralNode extends Expression implements PropertyKey { /** * Set the ArrayUnits that make up this ArrayLiteral + * @param lc lexical context * @see ArrayUnit * @param units list of array units + * @return new or changed arrayliteralnode */ - public void setUnits(final List units) { - this.units = units; + public ArrayLiteralNode setUnits(final LexicalContext lc, final List units) { + if (this.units == units) { + return this; + } + return Node.replaceInLexicalContext(lc, this, new ArrayLiteralNode(this, value, elementType, postsets, presets, units)); } @Override @@ -889,8 +940,15 @@ public abstract class LiteralNode extends Expression implements PropertyKey { return this; } + private ArrayLiteralNode setValue(final LexicalContext lc, final Expression[] value) { + if (this.value == value) { + return this; + } + return Node.replaceInLexicalContext(lc, this, new ArrayLiteralNode(this, value, elementType, postsets, presets, units)); + } + private ArrayLiteralNode setValue(final LexicalContext lc, final List value) { - return (ArrayLiteralNode)lc.replace(this, new ArrayLiteralNode(this, value.toArray(new Expression[value.size()]))); + return setValue(lc, value.toArray(new Expression[value.size()])); } @Override diff --git a/nashorn/test/script/basic/JDK-8047057.js b/nashorn/test/script/basic/JDK-8047057.js index cf1263a1243..3ce588bfe6f 100644 --- a/nashorn/test/script/basic/JDK-8047057.js +++ b/nashorn/test/script/basic/JDK-8047057.js @@ -29,8 +29,7 @@ */ // commented out makeFuncAndCall calls are still result in crash -// Tests commented with //** fail only within test framework. -// Pass fine with standalone "jjs" mode. +// Tests commented with //** fail only when assertions are turned on function makeFuncAndCall(code) { Function(code)(); @@ -52,19 +51,19 @@ makeFuncAndCall("L: { while(0) break L; return; }"); makeFuncExpectError("L: {while(0) break L; return [](); }", TypeError); // makeFuncAndCall("do with({}) break ; while(0);"); makeFuncAndCall("while(0) with({}) continue ;"); -//** makeFuncAndCall("eval([]);"); -//** makeFuncAndCall("try{} finally{[]}"); +makeFuncAndCall("eval([]);"); +makeFuncAndCall("try{} finally{[]}"); makeFuncAndCall("try { } catch(x if 1) { try { } catch(x2) { } }"); makeFuncAndCall("try { } catch(x if 1) { try { return; } catch(x2) { { } } }"); makeFuncAndCall("Error() * (false)[-0]--"); makeFuncAndCall("try { var x = 1, x = null; } finally { }"); makeFuncAndCall("try { var x = {}, x = []; } catch(x3) { }"); -//** makeFuncAndCall("[delete this]"); +makeFuncAndCall("[delete this]"); // makeFuncAndCall("if(eval('', eval('', function() {}))) { }"); // makeFuncAndCall("if(eval('', eval('', function() {}))) { }"); // makeFuncAndCall("eval(\"[,,];\", [11,12,13,14].some)"); // makeFuncAndCall("eval(\"1.2e3\", ({})[ /x/ ])"); -// makeFuncAndCall("eval(\"x4\", x3);"); +makeFuncExpectError("eval(\"x4\", x3);", ReferenceError); makeFuncAndCall("with({5.0000000000000000000000: String()}){(false); }"); makeFuncAndCall("try { var x = undefined, x = 5.0000000000000000000000; } catch(x) { x = undefined; }"); makeFuncAndCall("(function (x){ x %= this}(false))"); @@ -73,3 +72,4 @@ makeFuncAndCall("(false % !this) && 0"); makeFuncAndCall("with({8: 'fafafa'.replace()}){ }"); makeFuncAndCall("(function (x) '' )(true)"); makeFuncExpectError("new eval(function(){})", TypeError); +//** makeFuncAndCall('eval("23", ({})[/x/])'); diff --git a/nashorn/test/script/basic/JDK-8047078.js b/nashorn/test/script/basic/JDK-8047078.js new file mode 100644 index 00000000000..984e4f29abc --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047078.js @@ -0,0 +1,38 @@ +/* + * 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. + */ + +/** + * JDK-8047078: ArrayLiteral mutability caused trouble in optimistic types + * + * @test + * @run + */ + +function makeFuncAndCall(code) { + Function(code)(); +} + +makeFuncAndCall("eval([]);"); +makeFuncAndCall("eval([1]);"); +makeFuncAndCall("eval([1,2,3,,4]);"); +makeFuncAndCall("try{} finally{[]}"); From 5b199f3cb8cd39073af2a4901ffee0fb696576d1 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 19 Jun 2014 15:39:37 +0100 Subject: [PATCH 088/236] 8038182: javac crash with FunctionDescriptorLookupError for invalid functional interface Co-authored-by: Maurizio Cimadamore Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Types.java | 2 +- .../com/sun/tools/javac/comp/Attr.java | 17 +++++++++---- .../CrashFunctionDescriptorExceptionTest.java | 24 +++++++++++++++++++ .../CrashFunctionDescriptorExceptionTest.out | 2 ++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java create mode 100644 langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index ba653114d78..c80bd054d24 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -626,7 +626,7 @@ public class Types { * (ii) perform functional interface bridge calculation. */ public ClassSymbol makeFunctionalInterfaceClass(Env env, Name name, List targets, long cflags) { - if (targets.isEmpty() || !isFunctionalInterface(targets.head)) { + if (targets.isEmpty()) { return null; } Symbol descSym = findDescriptorSymbol(targets.head.tsym); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 97f123f2b45..6c68c5c63f4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -3135,10 +3135,19 @@ public class Attr extends JCTree.Visitor { if (checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && pt != Type.recoveryType) { //check that functional interface class is well-formed - ClassSymbol csym = types.makeFunctionalInterfaceClass(env, - names.empty, List.of(fExpr.targets.head), ABSTRACT); - if (csym != null) { - chk.checkImplementations(env.tree, csym, csym); + try { + /* Types.makeFunctionalInterfaceClass() may throw an exception + * when it's executed post-inference. See the listener code + * above. + */ + ClassSymbol csym = types.makeFunctionalInterfaceClass(env, + names.empty, List.of(fExpr.targets.head), ABSTRACT); + if (csym != null) { + chk.checkImplementations(env.tree, csym, csym); + } + } catch (Types.FunctionDescriptorLookupError ex) { + JCDiagnostic cause = ex.getDiagnostic(); + resultInfo.checkContext.report(env.tree, cause); } } } diff --git a/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java new file mode 100644 index 00000000000..51895dc3307 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.java @@ -0,0 +1,24 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8038182 + * @summary javac crash with FunctionDescriptorLookupError for invalid functional interface + * @compile/fail/ref=CrashFunctionDescriptorExceptionTest.out -XDrawDiagnostics CrashFunctionDescriptorExceptionTest.java + */ + +class CrashFunctionDescriptorExceptionTest { + + @SuppressWarnings("unchecked") + void m () { + bar((B b) -> {}); + } + + > void bar(I i) {} + + class A {} + + class B extends A {} + + interface I> { + void foo(E e); + } +} diff --git a/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out new file mode 100644 index 00000000000..19f5569aff1 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8038182/CrashFunctionDescriptorExceptionTest.out @@ -0,0 +1,2 @@ +CrashFunctionDescriptorExceptionTest.java:12:13: compiler.err.prob.found.req: (compiler.misc.no.suitable.functional.intf.inst: CrashFunctionDescriptorExceptionTest.I) +1 error From 2bdfb1233c343cf8de1accb210dceffbf3115cc5 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 19 Jun 2014 20:36:03 +0530 Subject: [PATCH 089/236] 8047369: Add regression tests for passing test cases of JDK-8024971 Reviewed-by: hannesw, jlaskey --- nashorn/test/script/basic/JDK-8047369.js | 186 +++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 nashorn/test/script/basic/JDK-8047369.js diff --git a/nashorn/test/script/basic/JDK-8047369.js b/nashorn/test/script/basic/JDK-8047369.js new file mode 100644 index 00000000000..dec55152bd5 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047369.js @@ -0,0 +1,186 @@ +/* + * 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. + */ + +/** + * JDK-8047369: Add regression tests for passing test cases of JDK-8024971 + * + * @test + * @run + * @option -scripting + */ + +function makeFuncAndCall(code) { + Function(code)(); +} + +function makeFuncExpectError(code, ErrorType) { + try { + makeFuncAndCall(code); + } catch (e) { + if (! (e instanceof ErrorType)) { + fail(ErrorType.name + " expected, got " + e); + } + } +} + +function evalExpectError(code, ErrorType) { + try { + eval(code)(); + } catch (e) { + if (! (e instanceof ErrorType)) { + fail(ErrorType.name + " expected, got " + e); + } + } +} + +function evalExpectValue(code, value) { + if (eval(code) != value) { + fail("Expected " + value + " with eval of " + code); + } +} + +makeFuncAndCall("for(x.x in 0) {}"); +// bug JDK-8047357 +// makeFuncAndCall("switch((null >> x3)) { default: {var x; break ; }\nthrow x; }"); +makeFuncExpectError("switch(x) { case 8: break; case false: }", ReferenceError); +makeFuncAndCall("try { return true; } finally { return false; } "); +makeFuncAndCall("({ get 1e81(){} })"); +makeFuncAndCall("{var x, x3;try { return 0; } finally { return 3/0; } }"); +makeFuncExpectError("with(x ? 1e81 : (x2.constructor = 0.1)) {}", ReferenceError); +makeFuncAndCall("while(x-=1) {var x=0; }"); +makeFuncAndCall("while((x-=false) && 0) { var x = this; }"); +makeFuncAndCall("/*infloop*/while(x4-=x) var x, x4 = x1;"); +makeFuncAndCall("/*infloop*/L:while(x+=null) { this;var x = /x/g ; }"); +makeFuncAndCall("while((x1|=0.1) && 0) { var x1 = -0, functional; }"); +makeFuncAndCall("with({}) return (eval(\"arguments\"));"); + +evalExpectValue(< Date: Thu, 19 Jun 2014 22:06:29 +0200 Subject: [PATCH 090/236] 8041648: do while loop that misses ending semicolon has wrong end position Ensure the end positions are meaningful even if statement's semicolon is missing. Co-authored-by: Dusan Balek Reviewed-by: jjg --- .../sun/tools/javac/parser/JavacParser.java | 31 ++- .../javac/tree/MissingSemicolonTest.java | 262 ++++++++++++++++++ 2 files changed, 282 insertions(+), 11 deletions(-) create mode 100644 langtools/test/tools/javac/tree/MissingSemicolonTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index 52c18418e55..25bbf6dfdf4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -412,9 +412,16 @@ public class JavacParser implements Parser { case ELSE: case FINALLY: case CATCH: + case THIS: + case SUPER: + case NEW: if (stopAtStatement) return; break; + case ASSERT: + if (stopAtStatement && allowAsserts) + return ; + break; } nextToken(); } @@ -2374,8 +2381,8 @@ public class JavacParser implements Parser { ListBuffer stats = variableDeclarators(mods, t, new ListBuffer()); // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon - storeEnd(stats.last(), token.endPos); accept(SEMI); + storeEnd(stats.last(), S.prevToken().endPos); return stats.toList(); } } @@ -2412,13 +2419,14 @@ public class JavacParser implements Parser { ListBuffer stats = variableDeclarators(mods, t, new ListBuffer()); // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon - storeEnd(stats.last(), token.endPos); accept(SEMI); + storeEnd(stats.last(), S.prevToken().endPos); return stats.toList(); } else { // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon - JCExpressionStatement expr = to(F.at(pos).Exec(checkExprStat(t))); + t = checkExprStat(t); accept(SEMI); + JCExpressionStatement expr = toP(F.at(pos).Exec(t)); return List.of(expr); } } @@ -2497,8 +2505,8 @@ public class JavacParser implements Parser { JCStatement body = parseStatementAsBlock(); accept(WHILE); JCExpression cond = parExpression(); - JCDoWhileLoop t = to(F.at(pos).DoLoop(body, cond)); accept(SEMI); + JCDoWhileLoop t = toP(F.at(pos).DoLoop(body, cond)); return t; } case TRY: { @@ -2546,29 +2554,29 @@ public class JavacParser implements Parser { case RETURN: { nextToken(); JCExpression result = token.kind == SEMI ? null : parseExpression(); - JCReturn t = to(F.at(pos).Return(result)); accept(SEMI); + JCReturn t = toP(F.at(pos).Return(result)); return t; } case THROW: { nextToken(); JCExpression exc = parseExpression(); - JCThrow t = to(F.at(pos).Throw(exc)); accept(SEMI); + JCThrow t = toP(F.at(pos).Throw(exc)); return t; } case BREAK: { nextToken(); Name label = LAX_IDENTIFIER.accepts(token.kind) ? ident() : null; - JCBreak t = to(F.at(pos).Break(label)); accept(SEMI); + JCBreak t = toP(F.at(pos).Break(label)); return t; } case CONTINUE: { nextToken(); Name label = LAX_IDENTIFIER.accepts(token.kind) ? ident() : null; - JCContinue t = to(F.at(pos).Continue(label)); accept(SEMI); + JCContinue t = toP(F.at(pos).Continue(label)); return t; } case SEMI: @@ -2593,8 +2601,8 @@ public class JavacParser implements Parser { nextToken(); message = parseExpression(); } - JCAssert t = to(F.at(pos).Assert(assertion, message)); accept(SEMI); + JCAssert t = toP(F.at(pos).Assert(assertion, message)); return t; } /* else fall through to default case */ @@ -2609,8 +2617,9 @@ public class JavacParser implements Parser { return F.at(pos).Labelled(prevToken.name(), stat); } else { // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon - JCExpressionStatement stat = to(F.at(pos).Exec(checkExprStat(expr))); + expr = checkExprStat(expr); accept(SEMI); + JCExpressionStatement stat = toP(F.at(pos).Exec(expr)); return stat; } } @@ -3513,8 +3522,8 @@ public class JavacParser implements Parser { List defs = variableDeclaratorsRest(pos, mods, type, name, isInterface, dc, new ListBuffer()).toList(); - storeEnd(defs.last(), token.endPos); accept(SEMI); + storeEnd(defs.last(), S.prevToken().endPos); return defs; } else { pos = token.pos; diff --git a/langtools/test/tools/javac/tree/MissingSemicolonTest.java b/langtools/test/tools/javac/tree/MissingSemicolonTest.java new file mode 100644 index 00000000000..c6b257ed8e1 --- /dev/null +++ b/langtools/test/tools/javac/tree/MissingSemicolonTest.java @@ -0,0 +1,262 @@ +/* + * 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 + * 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 8041648 + * @summary Verify that end positions are sane if semicolons are missing. + * @run main MissingSemicolonTest MissingSemicolonTest.java + */ + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.util.*; + +import javax.tools.*; + +import com.sun.source.tree.*; +import com.sun.source.tree.Tree.Kind; +import com.sun.source.util.*; +import com.sun.tools.javac.api.JavacTool; +import com.sun.tools.javac.parser.Scanner; +import com.sun.tools.javac.parser.ScannerFactory; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.util.Context; + +public class MissingSemicolonTest { + public static void main(String... args) { + String testSrc = System.getProperty("test.src"); + File baseDir = new File(testSrc); + boolean ok = new MissingSemicolonTest().run(baseDir, args); + if (!ok) { + throw new Error("failed"); + } + } + + boolean run(File baseDir, String... args) { + if (args.length == 0) { + throw new IllegalStateException("Needs input files."); + } + + for (String arg : args) { + File file = new File(baseDir, arg); + if (file.exists()) + test(file); + else + error("File not found: " + file); + } + + System.err.println(fileCount + " files read"); + if (errors > 0) + System.err.println(errors + " errors"); + + return errors == 0; + } + + void test(File file) { + if (file.isFile() && file.getName().endsWith(".java")) { + try { + fileCount++; + String content = new String(Files.readAllBytes(file.toPath())); + List spans = gatherTreeSpans(file, content); + int nextSemicolon = -1; + + //remove semicolons, one at a time, and verify the positions are still meaningful: + while ((nextSemicolon = content.indexOf(';', nextSemicolon + 1)) != (-1)) { + String updatedContent = + content.substring(0, nextSemicolon) + + " " + + content.substring(nextSemicolon + 1); + verifyTreeSpans(file, spans, updatedContent, nextSemicolon); + } + } catch (IOException e) { + error("Error reading " + file + ": " + e); + } + } + } + + public List gatherTreeSpans(File file, String content) throws IOException { + JCCompilationUnit unit = read(file.toURI(), content); + List spans = new ArrayList<>(); + new TreePathScanner() { + @Override + public Void scan(Tree tree, Void p) { + if (tree != null) { + int start = ((JCTree) tree).getStartPosition(); + int end = ((JCTree) tree).getEndPosition(unit.endPositions); + + spans.add(new int[] {start, end}); + } + return super.scan(tree, p); + } + }.scan(unit, null); + return spans; + } + + public void verifyTreeSpans(File file, List spans, + String updatedContent, int semicolon) throws IOException { + JCCompilationUnit updated = read(file.toURI(), updatedContent); + Iterator nextSpan = spans.iterator(); + new TreePathScanner() { + @Override + public Void scan(Tree tree, Void p) { + if (tree != null) { + int start = ((JCTree) tree).getStartPosition(); + int end = ((JCTree) tree).getEndPosition(updated.endPositions); + + if (tree.getKind() != Kind.ERRONEOUS) { + int[] expected = nextSpan.next(); + int expectedEnd = expected[1]; + + if (expectedEnd == semicolon + 1) { + Scanner scanner = scannerFactory.newScanner(updatedContent, true); + scanner.nextToken(); + while (scanner.token().pos < expectedEnd) + scanner.nextToken(); + expectedEnd = scanner.token().pos; + } + + if (expected[0] != start || expectedEnd != end) { + error(updatedContent + "; semicolon: " + semicolon + "; expected: " + + expected[0] + "-" + expectedEnd + "; found=" + start + "-" + end + + ";" + tree); + } + } + } + return super.scan(tree, p); + } + }.scan(updated, null); + } + + DiagnosticListener devNull = (d) -> {}; + JavacTool tool = JavacTool.create(); + StandardJavaFileManager fm = tool.getStandardFileManager(devNull, null, null); + ScannerFactory scannerFactory = ScannerFactory.instance(new Context()); + + /** + * Read a file. + * @param file the file to be read + * @return the tree for the content of the file + * @throws IOException if any IO errors occur + * @throws MissingSemicolonTest.ParseException if any errors occur while parsing the file + */ + JCCompilationUnit read(URI uri, String content) throws IOException { + JavacTool tool = JavacTool.create(); + JavacTask task = tool.getTask(null, fm, devNull, Collections.emptyList(), null, + Arrays.asList(new JavaSource(uri, content))); + Iterable trees = task.parse(); + Iterator iter = trees.iterator(); + if (!iter.hasNext()) + throw new Error("no trees found"); + JCCompilationUnit t = (JCCompilationUnit) iter.next(); + if (iter.hasNext()) + throw new Error("too many trees found"); + return t; + } + + class JavaSource extends SimpleJavaFileObject { + + private final String content; + public JavaSource(URI uri, String content) { + super(uri, JavaFileObject.Kind.SOURCE); + this.content = content; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return content; + } + } + + /** + * Report an error. When the program is complete, the program will either + * exit or throw an Error if any errors have been reported. + * @param msg the error message + */ + void error(String msg) { + System.err.println(msg); + errors++; + } + + /** Number of files that have been analyzed. */ + int fileCount; + /** Number of errors reported. */ + int errors; + +} + +class TestCase { + String str1; + String str2; + public TestCase() { + super(); + super.hashCode(); + } + public TestCase(String str1, String str2) { + super(); + this.str1 = str1; + this.str2 = str2; + assert true; + } + + void newClass() { + new String(); + new String(); + } + + void localVars() { + String str1 = ""; + String str2; + String str3; + final String str4; + } + + void throwsException() { + throw new IllegalStateException(); + } + + int returnWithExpression() { + return 1; + } + + void returnWithoutExpression() { + return ; + } + + void doWhileBreakContinue() { + do { + if (true) + break; + if (false) + continue; + } while(true); + } + + void labelled() { + LABEL: doWhileBreakContinue(); + } + +} From 52f6412c530e1e4e83196eb83b718c145cbbec03 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Thu, 19 Jun 2014 15:35:10 -0700 Subject: [PATCH 091/236] 8047723: @since tag cleanup in jaxp Reviewed-by: joehw --- .../javax/xml/parsers/DocumentBuilder.java | 1 + .../xml/parsers/DocumentBuilderFactory.java | 4 +- .../parsers/FactoryConfigurationError.java | 1 + .../parsers/ParserConfigurationException.java | 1 + jaxp/src/javax/xml/parsers/SAXParser.java | 1 + .../javax/xml/parsers/SAXParserFactory.java | 2 +- .../javax/xml/transform/ErrorListener.java | 2 + jaxp/src/javax/xml/transform/OutputKeys.java | 1 + jaxp/src/javax/xml/transform/Result.java | 1 + jaxp/src/javax/xml/transform/Source.java | 2 + .../javax/xml/transform/SourceLocator.java | 2 + jaxp/src/javax/xml/transform/Templates.java | 2 + jaxp/src/javax/xml/transform/Transformer.java | 1 + .../TransformerConfigurationException.java | 2 + .../xml/transform/TransformerException.java | 2 + .../TransformerFactoryConfigurationError.java | 2 + jaxp/src/javax/xml/transform/URIResolver.java | 2 + .../javax/xml/transform/dom/DOMLocator.java | 2 + .../javax/xml/transform/dom/DOMResult.java | 1 + .../javax/xml/transform/dom/DOMSource.java | 1 + .../javax/xml/transform/sax/SAXResult.java | 1 + .../javax/xml/transform/sax/SAXSource.java | 1 + .../transform/sax/SAXTransformerFactory.java | 2 + .../xml/transform/sax/TemplatesHandler.java | 2 + .../xml/transform/sax/TransformerHandler.java | 2 + .../xml/transform/stream/StreamResult.java | 1 + .../xml/transform/stream/StreamSource.java | 1 + jaxp/src/org/w3c/dom/Attr.java | 6 +-- jaxp/src/org/w3c/dom/DOMConfiguration.java | 2 +- jaxp/src/org/w3c/dom/DOMError.java | 2 +- jaxp/src/org/w3c/dom/DOMErrorHandler.java | 2 +- jaxp/src/org/w3c/dom/DOMException.java | 14 +++--- jaxp/src/org/w3c/dom/DOMImplementation.java | 6 +-- .../org/w3c/dom/DOMImplementationList.java | 2 +- .../org/w3c/dom/DOMImplementationSource.java | 2 +- jaxp/src/org/w3c/dom/DOMLocator.java | 2 +- jaxp/src/org/w3c/dom/DOMStringList.java | 2 +- jaxp/src/org/w3c/dom/Document.java | 40 ++++++++-------- jaxp/src/org/w3c/dom/DocumentType.java | 6 +-- jaxp/src/org/w3c/dom/Element.java | 24 +++++----- jaxp/src/org/w3c/dom/Entity.java | 6 +-- jaxp/src/org/w3c/dom/NameList.java | 2 +- jaxp/src/org/w3c/dom/NamedNodeMap.java | 6 +-- jaxp/src/org/w3c/dom/Node.java | 48 +++++++++---------- jaxp/src/org/w3c/dom/Text.java | 6 +-- jaxp/src/org/w3c/dom/TypeInfo.java | 2 +- jaxp/src/org/w3c/dom/UserDataHandler.java | 2 +- .../bootstrap/DOMImplementationRegistry.java | 2 +- .../src/org/w3c/dom/events/DocumentEvent.java | 2 +- jaxp/src/org/w3c/dom/events/Event.java | 2 +- .../org/w3c/dom/events/EventException.java | 2 +- .../src/org/w3c/dom/events/EventListener.java | 2 +- jaxp/src/org/w3c/dom/events/EventTarget.java | 2 +- jaxp/src/org/w3c/dom/events/MouseEvent.java | 2 +- .../src/org/w3c/dom/events/MutationEvent.java | 2 +- jaxp/src/org/w3c/dom/events/UIEvent.java | 2 +- .../org/w3c/dom/ls/DOMImplementationLS.java | 2 + jaxp/src/org/w3c/dom/ls/LSException.java | 2 + jaxp/src/org/w3c/dom/ls/LSInput.java | 2 + jaxp/src/org/w3c/dom/ls/LSLoadEvent.java | 2 + jaxp/src/org/w3c/dom/ls/LSOutput.java | 2 + jaxp/src/org/w3c/dom/ls/LSParser.java | 2 + jaxp/src/org/w3c/dom/ls/LSParserFilter.java | 2 + jaxp/src/org/w3c/dom/ls/LSProgressEvent.java | 2 + .../org/w3c/dom/ls/LSResourceResolver.java | 2 + jaxp/src/org/w3c/dom/ls/LSSerializer.java | 2 + .../org/w3c/dom/ls/LSSerializerFilter.java | 2 + jaxp/src/org/w3c/dom/package.html | 2 +- jaxp/src/org/w3c/dom/views/AbstractView.java | 2 +- jaxp/src/org/w3c/dom/views/DocumentView.java | 2 +- jaxp/src/org/xml/sax/AttributeList.java | 2 +- jaxp/src/org/xml/sax/Attributes.java | 2 +- jaxp/src/org/xml/sax/ContentHandler.java | 2 +- jaxp/src/org/xml/sax/DTDHandler.java | 2 +- jaxp/src/org/xml/sax/DocumentHandler.java | 2 +- jaxp/src/org/xml/sax/EntityResolver.java | 2 +- jaxp/src/org/xml/sax/ErrorHandler.java | 2 +- jaxp/src/org/xml/sax/HandlerBase.java | 2 +- jaxp/src/org/xml/sax/InputSource.java | 2 +- jaxp/src/org/xml/sax/Locator.java | 2 +- jaxp/src/org/xml/sax/Parser.java | 2 +- jaxp/src/org/xml/sax/SAXException.java | 2 +- .../xml/sax/SAXNotRecognizedException.java | 2 +- .../org/xml/sax/SAXNotSupportedException.java | 2 +- jaxp/src/org/xml/sax/SAXParseException.java | 2 +- jaxp/src/org/xml/sax/XMLFilter.java | 2 +- jaxp/src/org/xml/sax/XMLReader.java | 2 +- jaxp/src/org/xml/sax/ext/Attributes2.java | 2 +- jaxp/src/org/xml/sax/ext/Attributes2Impl.java | 2 +- jaxp/src/org/xml/sax/ext/DeclHandler.java | 2 +- jaxp/src/org/xml/sax/ext/DefaultHandler2.java | 2 +- jaxp/src/org/xml/sax/ext/EntityResolver2.java | 2 +- jaxp/src/org/xml/sax/ext/LexicalHandler.java | 2 +- jaxp/src/org/xml/sax/ext/Locator2.java | 2 +- jaxp/src/org/xml/sax/ext/Locator2Impl.java | 2 +- .../xml/sax/helpers/AttributeListImpl.java | 2 +- .../org/xml/sax/helpers/AttributesImpl.java | 2 +- .../org/xml/sax/helpers/DefaultHandler.java | 2 +- jaxp/src/org/xml/sax/helpers/LocatorImpl.java | 2 +- .../org/xml/sax/helpers/NamespaceSupport.java | 8 ++-- .../org/xml/sax/helpers/ParserAdapter.java | 2 +- .../org/xml/sax/helpers/ParserFactory.java | 2 +- .../org/xml/sax/helpers/XMLFilterImpl.java | 2 +- .../org/xml/sax/helpers/XMLReaderAdapter.java | 2 +- .../org/xml/sax/helpers/XMLReaderFactory.java | 2 +- 105 files changed, 204 insertions(+), 143 deletions(-) diff --git a/jaxp/src/javax/xml/parsers/DocumentBuilder.java b/jaxp/src/javax/xml/parsers/DocumentBuilder.java index 33c325d11af..95530bcdf73 100644 --- a/jaxp/src/javax/xml/parsers/DocumentBuilder.java +++ b/jaxp/src/javax/xml/parsers/DocumentBuilder.java @@ -57,6 +57,7 @@ import org.xml.sax.SAXException; * communicate with the application using these existing APIs. * * @author Jeff Suttor + * @since 1.4 */ public abstract class DocumentBuilder { diff --git a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java index ed77da8a73f..fa4b618b42a 100644 --- a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java +++ b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java @@ -35,7 +35,7 @@ import javax.xml.validation.Schema; * @author Neeraj Bajaj * * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $ - + * @since 1.4 */ public abstract class DocumentBuilderFactory { @@ -440,6 +440,7 @@ public abstract class DocumentBuilderFactory { * @throws ParserConfigurationException if this DocumentBuilderFactory or the DocumentBuilders * it creates cannot support this feature. * @throws NullPointerException If the name parameter is null. + * @since 1.5 */ public abstract void setFeature(String name, boolean value) throws ParserConfigurationException; @@ -461,6 +462,7 @@ public abstract class DocumentBuilderFactory { * * @throws ParserConfigurationException if this DocumentBuilderFactory * or the DocumentBuilders it creates cannot support this feature. + * @since 1.5 */ public abstract boolean getFeature(String name) throws ParserConfigurationException; diff --git a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java index be008262124..fc3cd6eaa2a 100644 --- a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java +++ b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java @@ -33,6 +33,7 @@ package javax.xml.parsers; * * @author Jeff Suttor * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:09 $ + * @since 1.4 */ public class FactoryConfigurationError extends Error { diff --git a/jaxp/src/javax/xml/parsers/ParserConfigurationException.java b/jaxp/src/javax/xml/parsers/ParserConfigurationException.java index ed9ecfc03d2..587d4175784 100644 --- a/jaxp/src/javax/xml/parsers/ParserConfigurationException.java +++ b/jaxp/src/javax/xml/parsers/ParserConfigurationException.java @@ -29,6 +29,7 @@ package javax.xml.parsers; * Indicates a serious configuration error. * * @author Jeff Suttor + * @since 1.4 */ public class ParserConfigurationException extends Exception { diff --git a/jaxp/src/javax/xml/parsers/SAXParser.java b/jaxp/src/javax/xml/parsers/SAXParser.java index 8a58bee232a..9be9381f59e 100644 --- a/jaxp/src/javax/xml/parsers/SAXParser.java +++ b/jaxp/src/javax/xml/parsers/SAXParser.java @@ -75,6 +75,7 @@ import org.xml.sax.helpers.DefaultHandler; * this revised class. * * @author Jeff Suttor + * @since 1.4 */ public abstract class SAXParser { diff --git a/jaxp/src/javax/xml/parsers/SAXParserFactory.java b/jaxp/src/javax/xml/parsers/SAXParserFactory.java index b0a3bb67f8e..c36033f571f 100644 --- a/jaxp/src/javax/xml/parsers/SAXParserFactory.java +++ b/jaxp/src/javax/xml/parsers/SAXParserFactory.java @@ -38,7 +38,7 @@ import org.xml.sax.SAXNotSupportedException; * @author Neeraj Bajaj * * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $ - * + * @since 1.4 */ public abstract class SAXParserFactory { diff --git a/jaxp/src/javax/xml/transform/ErrorListener.java b/jaxp/src/javax/xml/transform/ErrorListener.java index b81e6119605..5d8d82c3662 100644 --- a/jaxp/src/javax/xml/transform/ErrorListener.java +++ b/jaxp/src/javax/xml/transform/ErrorListener.java @@ -49,6 +49,8 @@ package javax.xml.transform; * *

Transformers may use this mechanism to report XML parsing * errors as well as transformation errors.

+ * + * @since 1.4 */ public interface ErrorListener { diff --git a/jaxp/src/javax/xml/transform/OutputKeys.java b/jaxp/src/javax/xml/transform/OutputKeys.java index 3c0fc35e049..ac1a0213239 100644 --- a/jaxp/src/javax/xml/transform/OutputKeys.java +++ b/jaxp/src/javax/xml/transform/OutputKeys.java @@ -33,6 +33,7 @@ package javax.xml.transform; * * @see * section 16 of the XSL Transformations (XSLT) W3C Recommendation + * @since 1.4 */ public class OutputKeys { diff --git a/jaxp/src/javax/xml/transform/Result.java b/jaxp/src/javax/xml/transform/Result.java index 47472852707..fb5a42ee923 100644 --- a/jaxp/src/javax/xml/transform/Result.java +++ b/jaxp/src/javax/xml/transform/Result.java @@ -30,6 +30,7 @@ package javax.xml.transform; * needed to build a transformation result tree.

* * @author Jeff Suttor + * @since 1.4 */ public interface Result { diff --git a/jaxp/src/javax/xml/transform/Source.java b/jaxp/src/javax/xml/transform/Source.java index 3af6969d09f..fe3d7111439 100644 --- a/jaxp/src/javax/xml/transform/Source.java +++ b/jaxp/src/javax/xml/transform/Source.java @@ -28,6 +28,8 @@ package javax.xml.transform; /** * An object that implements this interface contains the information * needed to act as source input (XML source or transformation instructions). + * + * @since 1.4 */ public interface Source { diff --git a/jaxp/src/javax/xml/transform/SourceLocator.java b/jaxp/src/javax/xml/transform/SourceLocator.java index 475e6546392..e5cd840f686 100644 --- a/jaxp/src/javax/xml/transform/SourceLocator.java +++ b/jaxp/src/javax/xml/transform/SourceLocator.java @@ -28,6 +28,8 @@ package javax.xml.transform; /** * This interface is primarily for the purposes of reporting where * an error occurred in the XML source or transformation instructions. + * + * @since 1.4 */ public interface SourceLocator { diff --git a/jaxp/src/javax/xml/transform/Templates.java b/jaxp/src/javax/xml/transform/Templates.java index 9952368e7bc..9e3871800fe 100644 --- a/jaxp/src/javax/xml/transform/Templates.java +++ b/jaxp/src/javax/xml/transform/Templates.java @@ -37,6 +37,8 @@ import java.util.Properties; *

Templates must be threadsafe for a given instance * over multiple threads running concurrently, and may * be used multiple times in a given session.

+ * + * @since 1.4 */ public interface Templates { diff --git a/jaxp/src/javax/xml/transform/Transformer.java b/jaxp/src/javax/xml/transform/Transformer.java index 783e87a73fb..96292803f2e 100644 --- a/jaxp/src/javax/xml/transform/Transformer.java +++ b/jaxp/src/javax/xml/transform/Transformer.java @@ -45,6 +45,7 @@ import java.util.Properties; * output properties are preserved across transformations.

* * @author Jeff Suttor + * @since 1.4 */ public abstract class Transformer { diff --git a/jaxp/src/javax/xml/transform/TransformerConfigurationException.java b/jaxp/src/javax/xml/transform/TransformerConfigurationException.java index 7e24ac808b7..a81fde2989c 100644 --- a/jaxp/src/javax/xml/transform/TransformerConfigurationException.java +++ b/jaxp/src/javax/xml/transform/TransformerConfigurationException.java @@ -27,6 +27,8 @@ package javax.xml.transform; /** * Indicates a serious configuration error. + * + * @since 1.4 */ public class TransformerConfigurationException extends TransformerException { diff --git a/jaxp/src/javax/xml/transform/TransformerException.java b/jaxp/src/javax/xml/transform/TransformerException.java index 0985ebb0594..dfd48246e27 100644 --- a/jaxp/src/javax/xml/transform/TransformerException.java +++ b/jaxp/src/javax/xml/transform/TransformerException.java @@ -31,6 +31,8 @@ import java.lang.reflect.InvocationTargetException; /** * This class specifies an exceptional condition that occured * during the transformation process. + * + * @since 1.4 */ public class TransformerException extends Exception { diff --git a/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java b/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java index b8ac36cd58a..3eda99138af 100644 --- a/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java +++ b/jaxp/src/javax/xml/transform/TransformerFactoryConfigurationError.java @@ -30,6 +30,8 @@ package javax.xml.transform; * exists. This error will typically be thrown when the class of a * transformation factory specified in the system properties cannot be found * or instantiated. + * + * @since 1.4 */ public class TransformerFactoryConfigurationError extends Error { private static final long serialVersionUID = -6527718720676281516L; diff --git a/jaxp/src/javax/xml/transform/URIResolver.java b/jaxp/src/javax/xml/transform/URIResolver.java index a4ea4c052ad..d8a3ac090a2 100644 --- a/jaxp/src/javax/xml/transform/URIResolver.java +++ b/jaxp/src/javax/xml/transform/URIResolver.java @@ -28,6 +28,8 @@ package javax.xml.transform; /** *

An object that implements this interface that can be called by the processor * to turn a URI used in document(), xsl:import, or xsl:include into a Source object. + * + * @since 1.4 */ public interface URIResolver { diff --git a/jaxp/src/javax/xml/transform/dom/DOMLocator.java b/jaxp/src/javax/xml/transform/dom/DOMLocator.java index 13a7446148f..a68c031b72b 100644 --- a/jaxp/src/javax/xml/transform/dom/DOMLocator.java +++ b/jaxp/src/javax/xml/transform/dom/DOMLocator.java @@ -37,6 +37,8 @@ import org.w3c.dom.Node; * object returned by an exception. A {@link javax.xml.transform.Transformer} * may use this object for purposes other than error reporting, for instance, * to indicate the source node that originated a result node. + * + * @since 1.4 */ public interface DOMLocator extends SourceLocator { diff --git a/jaxp/src/javax/xml/transform/dom/DOMResult.java b/jaxp/src/javax/xml/transform/dom/DOMResult.java index c7adfc4ef40..67ec2418740 100644 --- a/jaxp/src/javax/xml/transform/dom/DOMResult.java +++ b/jaxp/src/javax/xml/transform/dom/DOMResult.java @@ -35,6 +35,7 @@ import org.w3c.dom.Node; * which may be retrieved with {@link #getNode()}.

* * @author Jeff Suttor + * @since 1.4 */ public class DOMResult implements Result { diff --git a/jaxp/src/javax/xml/transform/dom/DOMSource.java b/jaxp/src/javax/xml/transform/dom/DOMSource.java index 83e64fd471b..dc4e93e07f1 100644 --- a/jaxp/src/javax/xml/transform/dom/DOMSource.java +++ b/jaxp/src/javax/xml/transform/dom/DOMSource.java @@ -40,6 +40,7 @@ import org.w3c.dom.Node; * * @author Jeff Suttor * @see Document Object Model (DOM) Level 2 Specification + * @since 1.4 */ public class DOMSource implements Source { diff --git a/jaxp/src/javax/xml/transform/sax/SAXResult.java b/jaxp/src/javax/xml/transform/sax/SAXResult.java index b0158b3dcdc..bc88d6bd206 100644 --- a/jaxp/src/javax/xml/transform/sax/SAXResult.java +++ b/jaxp/src/javax/xml/transform/sax/SAXResult.java @@ -34,6 +34,7 @@ import org.xml.sax.ext.LexicalHandler; *

Acts as an holder for a transformation Result.

* * @author Jeff Suttor + * @since 1.4 */ public class SAXResult implements Result { diff --git a/jaxp/src/javax/xml/transform/sax/SAXSource.java b/jaxp/src/javax/xml/transform/sax/SAXSource.java index 52315646cf3..0d573780e56 100644 --- a/jaxp/src/javax/xml/transform/sax/SAXSource.java +++ b/jaxp/src/javax/xml/transform/sax/SAXSource.java @@ -41,6 +41,7 @@ import org.xml.sax.XMLReader; * {@link javax.xml.parsers.SAXParserFactory#setNamespaceAware(boolean awareness)} method.

* * @author Jeff Suttor + * @since 1.4 */ public class SAXSource implements Source { diff --git a/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java b/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java index 777e0bf2420..cb419e20c37 100644 --- a/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java +++ b/jaxp/src/javax/xml/transform/sax/SAXTransformerFactory.java @@ -39,6 +39,8 @@ import org.xml.sax.XMLFilter; * for an XMLReader used during a transformation, it should use a URIResolver * to return the SAXSource which provides (with getXMLReader) a reference to * the XMLReader.

+ * + * @since 1.4 */ public abstract class SAXTransformerFactory extends TransformerFactory { diff --git a/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java b/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java index 34b5ba2bec4..b2efea5d88c 100644 --- a/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java +++ b/jaxp/src/javax/xml/transform/sax/TemplatesHandler.java @@ -34,6 +34,8 @@ import org.xml.sax.ContentHandler; * parse events (parsing transformation instructions) into a Templates object. * *

Note that TemplatesHandler does not need to implement LexicalHandler.

+ * + * @since 1.4 */ public interface TemplatesHandler extends ContentHandler { diff --git a/jaxp/src/javax/xml/transform/sax/TransformerHandler.java b/jaxp/src/javax/xml/transform/sax/TransformerHandler.java index 8bced5e8649..3c15367f892 100644 --- a/jaxp/src/javax/xml/transform/sax/TransformerHandler.java +++ b/jaxp/src/javax/xml/transform/sax/TransformerHandler.java @@ -36,6 +36,8 @@ import org.xml.sax.ext.LexicalHandler; * A TransformerHandler * listens for SAX ContentHandler parse events and transforms * them to a Result. + * + * @since 1.4 */ public interface TransformerHandler extends ContentHandler, LexicalHandler, DTDHandler { diff --git a/jaxp/src/javax/xml/transform/stream/StreamResult.java b/jaxp/src/javax/xml/transform/stream/StreamResult.java index 39df253fa12..57db8665801 100644 --- a/jaxp/src/javax/xml/transform/stream/StreamResult.java +++ b/jaxp/src/javax/xml/transform/stream/StreamResult.java @@ -37,6 +37,7 @@ import java.net.MalformedURLException; * which may be XML, plain Text, HTML, or some other form of markup.

* * @author Jeff Suttor + * @since 1.4 */ public class StreamResult implements Result { diff --git a/jaxp/src/javax/xml/transform/stream/StreamSource.java b/jaxp/src/javax/xml/transform/stream/StreamSource.java index ad41b9d303d..7627d5e3b55 100644 --- a/jaxp/src/javax/xml/transform/stream/StreamSource.java +++ b/jaxp/src/javax/xml/transform/stream/StreamSource.java @@ -39,6 +39,7 @@ import javax.xml.transform.Source; * StreamSource instances may only be used once.

* * @author Jeff Suttor + * @since 1.4 */ public class StreamSource implements Source { diff --git a/jaxp/src/org/w3c/dom/Attr.java b/jaxp/src/org/w3c/dom/Attr.java index 8231a54156a..8db99e9a6a1 100644 --- a/jaxp/src/org/w3c/dom/Attr.java +++ b/jaxp/src/org/w3c/dom/Attr.java @@ -239,7 +239,7 @@ public interface Attr extends Node { /** * The Element node this attribute is attached to or * null if this attribute is not in use. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Element getOwnerElement(); @@ -249,7 +249,7 @@ public interface Attr extends Node { * after loading the document or invoking * Document.normalizeDocument(), schemaTypeInfo * may not be reliable if the node was moved. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public TypeInfo getSchemaTypeInfo(); @@ -297,7 +297,7 @@ public interface Attr extends Node { * reevaluated in accordance to the schema used. As a consequence, if * the Attr.schemaTypeInfo attribute contains an ID type, * isId will always return true. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isId(); diff --git a/jaxp/src/org/w3c/dom/DOMConfiguration.java b/jaxp/src/org/w3c/dom/DOMConfiguration.java index 4a3e66b020c..320ca42b592 100644 --- a/jaxp/src/org/w3c/dom/DOMConfiguration.java +++ b/jaxp/src/org/w3c/dom/DOMConfiguration.java @@ -383,7 +383,7 @@ package org.w3c.dom; * set, Document.normalizeDocument() will invoke the resource * resolver instead of using Document.documentURI. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMConfiguration { /** diff --git a/jaxp/src/org/w3c/dom/DOMError.java b/jaxp/src/org/w3c/dom/DOMError.java index 15821c865d4..c0a00cd5c3c 100644 --- a/jaxp/src/org/w3c/dom/DOMError.java +++ b/jaxp/src/org/w3c/dom/DOMError.java @@ -44,7 +44,7 @@ package org.w3c.dom; /** * DOMError is an interface that describes an error. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMError { // ErrorSeverity diff --git a/jaxp/src/org/w3c/dom/DOMErrorHandler.java b/jaxp/src/org/w3c/dom/DOMErrorHandler.java index 1de0cb9387e..82e9988deff 100644 --- a/jaxp/src/org/w3c/dom/DOMErrorHandler.java +++ b/jaxp/src/org/w3c/dom/DOMErrorHandler.java @@ -53,7 +53,7 @@ package org.w3c.dom; *

The application that is using the DOM implementation is expected to * implement this interface. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMErrorHandler { /** diff --git a/jaxp/src/org/w3c/dom/DOMException.java b/jaxp/src/org/w3c/dom/DOMException.java index b351b7b7362..679c6a7c363 100644 --- a/jaxp/src/org/w3c/dom/DOMException.java +++ b/jaxp/src/org/w3c/dom/DOMException.java @@ -116,29 +116,29 @@ public class DOMException extends RuntimeException { /** * If an attempt is made to use an object that is not, or is no longer, * usable. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short INVALID_STATE_ERR = 11; /** * If an invalid or illegal string is specified. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short SYNTAX_ERR = 12; /** * If an attempt is made to modify the type of the underlying object. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short INVALID_MODIFICATION_ERR = 13; /** * If an attempt is made to create or change an object in a way which is * incorrect with regard to namespaces. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short NAMESPACE_ERR = 14; /** * If a parameter or an operation is not supported by the underlying * object. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public static final short INVALID_ACCESS_ERR = 15; /** @@ -147,13 +147,13 @@ public class DOMException extends RuntimeException { * with respect to "partial validity", this exception would be raised * and the operation would not be done. This code is used in [DOM Level 3 Validation] * . Refer to this specification for further information. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public static final short VALIDATION_ERR = 16; /** * If the type of an object is incompatible with the expected type of the * parameter associated to the object. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public static final short TYPE_MISMATCH_ERR = 17; diff --git a/jaxp/src/org/w3c/dom/DOMImplementation.java b/jaxp/src/org/w3c/dom/DOMImplementation.java index acf79fe9313..2bcd5f7d39c 100644 --- a/jaxp/src/org/w3c/dom/DOMImplementation.java +++ b/jaxp/src/org/w3c/dom/DOMImplementation.java @@ -77,7 +77,7 @@ public interface DOMImplementation { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public DocumentType createDocumentType(String qualifiedName, String publicId, @@ -129,7 +129,7 @@ public interface DOMImplementation { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Document createDocument(String namespaceURI, String qualifiedName, @@ -157,7 +157,7 @@ public interface DOMImplementation { * return results inconsistent with the primary core * DOMImplementation such as hasFeature, * getFeature, etc. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object getFeature(String feature, String version); diff --git a/jaxp/src/org/w3c/dom/DOMImplementationList.java b/jaxp/src/org/w3c/dom/DOMImplementationList.java index d7712f2e3f0..1fb2caa9b7d 100644 --- a/jaxp/src/org/w3c/dom/DOMImplementationList.java +++ b/jaxp/src/org/w3c/dom/DOMImplementationList.java @@ -48,7 +48,7 @@ package org.w3c.dom; * DOMImplementationList are accessible via an integral index, * starting from 0. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMImplementationList { /** diff --git a/jaxp/src/org/w3c/dom/DOMImplementationSource.java b/jaxp/src/org/w3c/dom/DOMImplementationSource.java index 41aa1ab01b0..317c4ba6600 100644 --- a/jaxp/src/org/w3c/dom/DOMImplementationSource.java +++ b/jaxp/src/org/w3c/dom/DOMImplementationSource.java @@ -49,7 +49,7 @@ package org.w3c.dom; * listed in the binding-specific list of available sources so that its * DOMImplementation objects are made available. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMImplementationSource { /** diff --git a/jaxp/src/org/w3c/dom/DOMLocator.java b/jaxp/src/org/w3c/dom/DOMLocator.java index 9104976a56a..ece7db191b0 100644 --- a/jaxp/src/org/w3c/dom/DOMLocator.java +++ b/jaxp/src/org/w3c/dom/DOMLocator.java @@ -45,7 +45,7 @@ package org.w3c.dom; * DOMLocator is an interface that describes a location (e.g. * where an error occurred). *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMLocator { /** diff --git a/jaxp/src/org/w3c/dom/DOMStringList.java b/jaxp/src/org/w3c/dom/DOMStringList.java index 670bdd0e04e..50d045b9d81 100644 --- a/jaxp/src/org/w3c/dom/DOMStringList.java +++ b/jaxp/src/org/w3c/dom/DOMStringList.java @@ -48,7 +48,7 @@ package org.w3c.dom; * DOMStringList are accessible via an integral index, starting * from 0. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface DOMStringList { /** diff --git a/jaxp/src/org/w3c/dom/Document.java b/jaxp/src/org/w3c/dom/Document.java index 5e489ac98c4..ab2d6e4f17e 100644 --- a/jaxp/src/org/w3c/dom/Document.java +++ b/jaxp/src/org/w3c/dom/Document.java @@ -73,7 +73,7 @@ public interface Document extends Node { * changing it afterwards is very unlikely to result in a change of the * features supported. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public DocumentType getDoctype(); @@ -337,7 +337,7 @@ public interface Document extends Node { * Document.xmlVersion attribute. This may happen when * importing an XML 1.1 [XML 1.1] element * into an XML 1.0 document, for instance. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node importNode(Node importedNode, boolean deep) @@ -401,7 +401,7 @@ public interface Document extends Node { *
NOT_SUPPORTED_ERR: Always thrown if the current document does not * support the "XML" feature, since namespaces were * defined by XML. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Element createElementNS(String namespaceURI, String qualifiedName) @@ -470,7 +470,7 @@ public interface Document extends Node { *
NOT_SUPPORTED_ERR: Always thrown if the current document does not * support the "XML" feature, since namespaces were * defined by XML. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Attr createAttributeNS(String namespaceURI, String qualifiedName) @@ -485,7 +485,7 @@ public interface Document extends Node { * special value "*" matches all local names. * @return A new NodeList object containing all the matched * Elements. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public NodeList getElementsByTagNameNS(String namespaceURI, String localName); @@ -501,7 +501,7 @@ public interface Document extends Node { * ID unless so defined. * @param elementId The unique id value for an element. * @return The matching element or null if there is none. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Element getElementById(String elementId); @@ -509,7 +509,7 @@ public interface Document extends Node { * An attribute specifying the encoding used for this document at the time * of the parsing. This is null when it is not known, such * as when the Document was created in memory. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getInputEncoding(); @@ -517,7 +517,7 @@ public interface Document extends Node { * An attribute specifying, as part of the XML declaration, the encoding of this document. This is null when * unspecified or when it is not known, such as when the * Document was created in memory. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlEncoding(); @@ -529,7 +529,7 @@ public interface Document extends Node { * Document.normalizeDocument() with the "validate" * parameter to verify if the value matches the validity * constraint for standalone document declaration as defined in [XML 1.0]. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean getXmlStandalone(); /** @@ -543,7 +543,7 @@ public interface Document extends Node { * @exception DOMException * NOT_SUPPORTED_ERR: Raised if this document does not support the * "XML" feature. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setXmlStandalone(boolean xmlStandalone) throws DOMException; @@ -570,7 +570,7 @@ public interface Document extends Node { * objects supporting a version of the "XMLVersion" feature must not * raise a NOT_SUPPORTED_ERR exception for the same version * number when using Document.xmlVersion. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlVersion(); /** @@ -599,7 +599,7 @@ public interface Document extends Node { * NOT_SUPPORTED_ERR: Raised if the version is set to a value that is * not supported by this Document or if this document * does not support the "XML" feature. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setXmlVersion(String xmlVersion) throws DOMException; @@ -612,7 +612,7 @@ public interface Document extends Node { * errors while using Document.normalizeDocument(). In case * of error, the behavior is undefined. This attribute is * true by default. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean getStrictErrorChecking(); /** @@ -623,7 +623,7 @@ public interface Document extends Node { * errors while using Document.normalizeDocument(). In case * of error, the behavior is undefined. This attribute is * true by default. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setStrictErrorChecking(boolean strictErrorChecking); @@ -638,7 +638,7 @@ public interface Document extends Node { * "HTML" [DOM Level 2 HTML] * , the href attribute of the HTML BASE element takes precedence over * this attribute when computing Node.baseURI. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getDocumentURI(); /** @@ -652,7 +652,7 @@ public interface Document extends Node { * "HTML" [DOM Level 2 HTML] * , the href attribute of the HTML BASE element takes precedence over * this attribute when computing Node.baseURI. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setDocumentURI(String documentURI); @@ -723,7 +723,7 @@ public interface Document extends Node { * DOCUMENT, DOCUMENT_TYPE. *
NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is * readonly. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Node adoptNode(Node source) throws DOMException; @@ -731,7 +731,7 @@ public interface Document extends Node { /** * The configuration used when Document.normalizeDocument() * is invoked. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public DOMConfiguration getDomConfig(); @@ -765,7 +765,7 @@ public interface Document extends Node { * " parameter. Note this method might also report fatal errors ( * DOMError.SEVERITY_FATAL_ERROR) if an implementation * cannot recover from an error. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void normalizeDocument(); @@ -834,7 +834,7 @@ public interface Document extends Node { * . Also raised, when the node being renamed is an attribute, if the * qualifiedName, or its prefix, is "xmlns" and the * namespaceURI is different from "http://www.w3.org/2000/xmlns/". - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Node renameNode(Node n, String namespaceURI, diff --git a/jaxp/src/org/w3c/dom/DocumentType.java b/jaxp/src/org/w3c/dom/DocumentType.java index 3b687e3a1e4..b28bea811b6 100644 --- a/jaxp/src/org/w3c/dom/DocumentType.java +++ b/jaxp/src/org/w3c/dom/DocumentType.java @@ -87,14 +87,14 @@ public interface DocumentType extends Node { /** * The public identifier of the external subset. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getPublicId(); /** * The system identifier of the external subset. This may be an absolute * URI or not. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getSystemId(); @@ -105,7 +105,7 @@ public interface DocumentType extends Node { * information is available to the implementation. This may vary * depending on various parameters, including the XML processor used to * build the document. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getInternalSubset(); diff --git a/jaxp/src/org/w3c/dom/Element.java b/jaxp/src/org/w3c/dom/Element.java index 195c71f7a95..ab5087d2c52 100644 --- a/jaxp/src/org/w3c/dom/Element.java +++ b/jaxp/src/org/w3c/dom/Element.java @@ -203,7 +203,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getAttributeNS(String namespaceURI, String localName) @@ -249,7 +249,7 @@ public interface Element extends Node { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public void setAttributeNS(String namespaceURI, String qualifiedName, @@ -278,7 +278,7 @@ public interface Element extends Node { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public void removeAttributeNS(String namespaceURI, String localName) @@ -299,7 +299,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Attr getAttributeNodeNS(String namespaceURI, String localName) @@ -329,7 +329,7 @@ public interface Element extends Node { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Attr setAttributeNodeNS(Attr newAttr) throws DOMException; @@ -348,7 +348,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public NodeList getElementsByTagNameNS(String namespaceURI, String localName) @@ -362,7 +362,7 @@ public interface Element extends Node { * @return true if an attribute with the given name is * specified on this element or has a default value, false * otherwise. - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean hasAttribute(String name); @@ -383,7 +383,7 @@ public interface Element extends Node { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed * through the Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean hasAttributeNS(String namespaceURI, String localName) @@ -391,7 +391,7 @@ public interface Element extends Node { /** * The type information associated with this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public TypeInfo getSchemaTypeInfo(); @@ -413,7 +413,7 @@ public interface Element extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if the specified node is not an attribute * of this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setIdAttribute(String name, boolean isId) @@ -436,7 +436,7 @@ public interface Element extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if the specified node is not an attribute * of this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setIdAttributeNS(String namespaceURI, String localName, @@ -459,7 +459,7 @@ public interface Element extends Node { * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. *
NOT_FOUND_ERR: Raised if the specified node is not an attribute * of this element. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setIdAttributeNode(Attr idAttr, boolean isId) diff --git a/jaxp/src/org/w3c/dom/Entity.java b/jaxp/src/org/w3c/dom/Entity.java index 2242fe1449e..c4e3b8930c7 100644 --- a/jaxp/src/org/w3c/dom/Entity.java +++ b/jaxp/src/org/w3c/dom/Entity.java @@ -96,7 +96,7 @@ public interface Entity extends Node { * of parsing, when it is an external parsed entity. This is * null if it an entity from the internal subset or if it * is not known. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getInputEncoding(); @@ -104,7 +104,7 @@ public interface Entity extends Node { * An attribute specifying, as part of the text declaration, the encoding * of this entity, when it is an external parsed entity. This is * null otherwise. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlEncoding(); @@ -112,7 +112,7 @@ public interface Entity extends Node { * An attribute specifying, as part of the text declaration, the version * number of this entity, when it is an external parsed entity. This is * null otherwise. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getXmlVersion(); diff --git a/jaxp/src/org/w3c/dom/NameList.java b/jaxp/src/org/w3c/dom/NameList.java index 01cfe10c9c0..92ee1814087 100644 --- a/jaxp/src/org/w3c/dom/NameList.java +++ b/jaxp/src/org/w3c/dom/NameList.java @@ -48,7 +48,7 @@ package org.w3c.dom; * implemented. The items in the NameList are accessible via an * integral index, starting from 0. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface NameList { /** diff --git a/jaxp/src/org/w3c/dom/NamedNodeMap.java b/jaxp/src/org/w3c/dom/NamedNodeMap.java index 00466c16bda..c9d3084f151 100644 --- a/jaxp/src/org/w3c/dom/NamedNodeMap.java +++ b/jaxp/src/org/w3c/dom/NamedNodeMap.java @@ -141,7 +141,7 @@ public interface NamedNodeMap { * NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node getNamedItemNS(String namespaceURI, String localName) @@ -177,7 +177,7 @@ public interface NamedNodeMap { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node setNamedItemNS(Node arg) throws DOMException; @@ -203,7 +203,7 @@ public interface NamedNodeMap { *
NOT_SUPPORTED_ERR: May be raised if the implementation does not * support the feature "XML" and the language exposed through the * Document does not support XML Namespaces (such as [HTML 4.01]). - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Node removeNamedItemNS(String namespaceURI, String localName) diff --git a/jaxp/src/org/w3c/dom/Node.java b/jaxp/src/org/w3c/dom/Node.java index 68404b95ebb..a62ad94d91e 100644 --- a/jaxp/src/org/w3c/dom/Node.java +++ b/jaxp/src/org/w3c/dom/Node.java @@ -299,7 +299,7 @@ public interface Node { * which is not used with any Document yet, this is * null. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public Document getOwnerDocument(); @@ -335,7 +335,7 @@ public interface Node { * support the insertion of a DocumentType or * Element node. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node insertBefore(Node newChild, Node refChild) @@ -373,7 +373,7 @@ public interface Node { * support the replacement of the DocumentType child or * Element child. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node replaceChild(Node newChild, Node oldChild) @@ -393,7 +393,7 @@ public interface Node { * support the removal of the DocumentType child or the * Element child. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node removeChild(Node oldChild) throws DOMException; @@ -422,7 +422,7 @@ public interface Node { * if the DOM implementation doesn't support the removal of the * DocumentType child or Element child. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public Node appendChild(Node newChild) throws DOMException; @@ -491,7 +491,7 @@ public interface Node { * sufficient, since XPointers do not differentiate between * Text nodes and CDATASection nodes. * - * @since DOM Level 3 + * @since 1.4, DOM Level 3 */ public void normalize(); @@ -503,7 +503,7 @@ public interface Node { * @return Returns true if the specified feature is * supported on this node, false otherwise. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean isSupported(String feature, String version); @@ -523,7 +523,7 @@ public interface Node { * attached to. If an attribute is not explicitly given a namespace, it * simply has no namespace. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getNamespaceURI(); @@ -547,7 +547,7 @@ public interface Node { * method, such as createElement from the * Document interface, this is always null. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getPrefix(); /** @@ -584,7 +584,7 @@ public interface Node { * this node is "xmlns" [XML Namespaces] * . * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public void setPrefix(String prefix) throws DOMException; @@ -596,7 +596,7 @@ public interface Node { * method, such as Document.createElement(), this is always * null. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public String getLocalName(); @@ -605,7 +605,7 @@ public interface Node { * @return Returns true if this node has any attributes, * false otherwise. * - * @since DOM Level 2 + * @since 1.4, DOM Level 2 */ public boolean hasAttributes(); @@ -619,7 +619,7 @@ public interface Node { * documentURI attribute from the Document * interface otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getBaseURI(); @@ -666,7 +666,7 @@ public interface Node { * implementations that do not coordinate to return consistent * implementation-specific results. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public short compareDocumentPosition(Node other) throws DOMException; @@ -717,7 +717,7 @@ public interface Node { * fit in a DOMString variable on the implementation * platform. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getTextContent() throws DOMException; @@ -765,7 +765,7 @@ public interface Node { * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public void setTextContent(String textContent) throws DOMException; @@ -783,7 +783,7 @@ public interface Node { * @return Returns true if the nodes are the same, * false otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isSameNode(Node other); @@ -798,7 +798,7 @@ public interface Node { * associated to the namespace prefix, the returned namespace prefix * is implementation dependent. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String lookupPrefix(String namespaceURI); @@ -810,7 +810,7 @@ public interface Node { * namespaceURI is the default namespace, * false otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isDefaultNamespace(String namespaceURI); @@ -824,7 +824,7 @@ public interface Node { * @return Returns the associated namespace URI or null if * none is found. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String lookupNamespaceURI(String prefix); @@ -890,7 +890,7 @@ public interface Node { * @return Returns true if the nodes are equal, * false otherwise. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isEqualNode(Node arg); @@ -915,7 +915,7 @@ public interface Node { * with the primary core Node such as attributes, * childNodes, etc. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object getFeature(String feature, String version); @@ -932,7 +932,7 @@ public interface Node { * @return Returns the DOMUserData previously associated to * the given key on this node, or null if there was none. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object setUserData(String key, Object data, @@ -946,7 +946,7 @@ public interface Node { * @return Returns the DOMUserData associated to the given * key on this node, or null if there was none. * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Object getUserData(String key); diff --git a/jaxp/src/org/w3c/dom/Text.java b/jaxp/src/org/w3c/dom/Text.java index f54d0ee8681..c603dac3ead 100644 --- a/jaxp/src/org/w3c/dom/Text.java +++ b/jaxp/src/org/w3c/dom/Text.java @@ -93,7 +93,7 @@ public interface Text extends CharacterData { * determined to contain whitespace in element content during the load * of the document or if validation occurs while using * Document.normalizeDocument(). - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public boolean isElementContentWhitespace(); @@ -121,7 +121,7 @@ public interface Text extends CharacterData { * * Figure: barTextNode.wholeText value is "barfoo" * - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public String getWholeText(); @@ -179,7 +179,7 @@ public interface Text extends CharacterData { * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text * nodes being replaced is readonly. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public Text replaceWholeText(String content) throws DOMException; diff --git a/jaxp/src/org/w3c/dom/TypeInfo.java b/jaxp/src/org/w3c/dom/TypeInfo.java index 044ede0bccb..a67f1c3e8dc 100644 --- a/jaxp/src/org/w3c/dom/TypeInfo.java +++ b/jaxp/src/org/w3c/dom/TypeInfo.java @@ -118,7 +118,7 @@ package org.w3c.dom; * and therefore should define how to represent their type systems using * TypeInfo. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface TypeInfo { /** diff --git a/jaxp/src/org/w3c/dom/UserDataHandler.java b/jaxp/src/org/w3c/dom/UserDataHandler.java index a4ec6e89832..e6595abfc1f 100644 --- a/jaxp/src/org/w3c/dom/UserDataHandler.java +++ b/jaxp/src/org/w3c/dom/UserDataHandler.java @@ -49,7 +49,7 @@ package org.w3c.dom; * implement various behaviors regarding the data it associates to the DOM * nodes. This interface defines that handler. *

See also the Document Object Model (DOM) Level 3 Core Specification. - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public interface UserDataHandler { // OperationType diff --git a/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java b/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java index cfeeeea4907..48fda761e1e 100644 --- a/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java +++ b/jaxp/src/org/w3c/dom/bootstrap/DOMImplementationRegistry.java @@ -79,7 +79,7 @@ import java.security.PrivilegedAction; * * @see DOMImplementation * @see DOMImplementationSource - * @since DOM Level 3 + * @since 1.5, DOM Level 3 */ public final class DOMImplementationRegistry { /** diff --git a/jaxp/src/org/w3c/dom/events/DocumentEvent.java b/jaxp/src/org/w3c/dom/events/DocumentEvent.java index cdbbb367f43..2a5f62f10fd 100644 --- a/jaxp/src/org/w3c/dom/events/DocumentEvent.java +++ b/jaxp/src/org/w3c/dom/events/DocumentEvent.java @@ -50,7 +50,7 @@ import org.w3c.dom.DOMException; * implemented on the same object which implements the Document * interface in an implementation which supports the Event model. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface DocumentEvent { /** diff --git a/jaxp/src/org/w3c/dom/events/Event.java b/jaxp/src/org/w3c/dom/events/Event.java index b1351e9b8dd..efa68650104 100644 --- a/jaxp/src/org/w3c/dom/events/Event.java +++ b/jaxp/src/org/w3c/dom/events/Event.java @@ -51,7 +51,7 @@ package org.w3c.dom.events; * type of event they accompany. These derived interfaces are also * implemented by the object passed to the event listener. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface Event { // PhaseType diff --git a/jaxp/src/org/w3c/dom/events/EventException.java b/jaxp/src/org/w3c/dom/events/EventException.java index 6273f64063a..1d646b4f63c 100644 --- a/jaxp/src/org/w3c/dom/events/EventException.java +++ b/jaxp/src/org/w3c/dom/events/EventException.java @@ -45,7 +45,7 @@ package org.w3c.dom.events; * Event operations may throw an EventException as specified in * their method descriptions. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public class EventException extends RuntimeException { public EventException(short code, String message) { diff --git a/jaxp/src/org/w3c/dom/events/EventListener.java b/jaxp/src/org/w3c/dom/events/EventListener.java index 2adfe58f647..a11dec1ef86 100644 --- a/jaxp/src/org/w3c/dom/events/EventListener.java +++ b/jaxp/src/org/w3c/dom/events/EventListener.java @@ -54,7 +54,7 @@ package org.w3c.dom.events; * the user wishes the same EventListeners to be added to the * newly created copy the user must add them manually. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface EventListener { /** diff --git a/jaxp/src/org/w3c/dom/events/EventTarget.java b/jaxp/src/org/w3c/dom/events/EventTarget.java index 46ac1f62266..3fd5aefa458 100644 --- a/jaxp/src/org/w3c/dom/events/EventTarget.java +++ b/jaxp/src/org/w3c/dom/events/EventTarget.java @@ -50,7 +50,7 @@ package org.w3c.dom.events; * EventListeners on an EventTarget and dispatch * of events to that EventTarget. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface EventTarget { /** diff --git a/jaxp/src/org/w3c/dom/events/MouseEvent.java b/jaxp/src/org/w3c/dom/events/MouseEvent.java index dee4cda5b5c..7a21af99b05 100644 --- a/jaxp/src/org/w3c/dom/events/MouseEvent.java +++ b/jaxp/src/org/w3c/dom/events/MouseEvent.java @@ -58,7 +58,7 @@ import org.w3c.dom.views.AbstractView; * bubbling to obtain notification of mouse events which occur within its * descendent elements. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface MouseEvent extends UIEvent { /** diff --git a/jaxp/src/org/w3c/dom/events/MutationEvent.java b/jaxp/src/org/w3c/dom/events/MutationEvent.java index a520b6f0a5c..1dc5c815991 100644 --- a/jaxp/src/org/w3c/dom/events/MutationEvent.java +++ b/jaxp/src/org/w3c/dom/events/MutationEvent.java @@ -47,7 +47,7 @@ import org.w3c.dom.Node; * The MutationEvent interface provides specific contextual * information associated with Mutation events. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface MutationEvent extends Event { // attrChangeType diff --git a/jaxp/src/org/w3c/dom/events/UIEvent.java b/jaxp/src/org/w3c/dom/events/UIEvent.java index 0931c5ff874..01192194ced 100644 --- a/jaxp/src/org/w3c/dom/events/UIEvent.java +++ b/jaxp/src/org/w3c/dom/events/UIEvent.java @@ -47,7 +47,7 @@ import org.w3c.dom.views.AbstractView; * The UIEvent interface provides specific contextual information * associated with User Interface events. *

See also the Document Object Model (DOM) Level 2 Events Specification. - * @since DOM Level 2 + * @since 1.5, DOM Level 2 */ public interface UIEvent extends Event { /** diff --git a/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java b/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java index c876dafcd6b..13b863e7536 100644 --- a/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java +++ b/jaxp/src/org/w3c/dom/ls/DOMImplementationLS.java @@ -57,6 +57,8 @@ import org.w3c.dom.DOMException; * "3.0" (respectively). *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface DOMImplementationLS { // DOMImplementationLSMode diff --git a/jaxp/src/org/w3c/dom/ls/LSException.java b/jaxp/src/org/w3c/dom/ls/LSException.java index f23d38a0a9c..fad53bafc1d 100644 --- a/jaxp/src/org/w3c/dom/ls/LSException.java +++ b/jaxp/src/org/w3c/dom/ls/LSException.java @@ -54,6 +54,8 @@ package org.w3c.dom.ls; * implementation dependent. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public class LSException extends RuntimeException { public LSException(short code, String message) { diff --git a/jaxp/src/org/w3c/dom/ls/LSInput.java b/jaxp/src/org/w3c/dom/ls/LSInput.java index a9b08c17bf1..f6f69b986cb 100644 --- a/jaxp/src/org/w3c/dom/ls/LSInput.java +++ b/jaxp/src/org/w3c/dom/ls/LSInput.java @@ -82,6 +82,8 @@ package org.w3c.dom.ls; * modify the copies, if necessary). *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSInput { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java b/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java index 5c9b7671e75..a4f938d0c89 100644 --- a/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java +++ b/jaxp/src/org/w3c/dom/ls/LSLoadEvent.java @@ -49,6 +49,8 @@ import org.w3c.dom.events.Event; * of a document load. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSLoadEvent extends Event { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSOutput.java b/jaxp/src/org/w3c/dom/ls/LSOutput.java index c6ace48cf3e..b69f8d8f367 100644 --- a/jaxp/src/org/w3c/dom/ls/LSOutput.java +++ b/jaxp/src/org/w3c/dom/ls/LSOutput.java @@ -74,6 +74,8 @@ package org.w3c.dom.ls; * modify the copies, if necessary). *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSOutput { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSParser.java b/jaxp/src/org/w3c/dom/ls/LSParser.java index 72d7db2f89c..0ddbd49ddfb 100644 --- a/jaxp/src/org/w3c/dom/ls/LSParser.java +++ b/jaxp/src/org/w3c/dom/ls/LSParser.java @@ -166,6 +166,8 @@ import org.w3c.dom.DOMException; * permission denied,...), XML well-formedness errors, and so on. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSParser { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSParserFilter.java b/jaxp/src/org/w3c/dom/ls/LSParserFilter.java index 0638c382dd4..96797bbb3cf 100644 --- a/jaxp/src/org/w3c/dom/ls/LSParserFilter.java +++ b/jaxp/src/org/w3c/dom/ls/LSParserFilter.java @@ -73,6 +73,8 @@ import org.w3c.dom.Element; * throwing exceptions from a filter is DOM implementation dependent. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSParserFilter { // Constants returned by startElement and acceptNode diff --git a/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java b/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java index 25a76a6a469..6e1b5653ef7 100644 --- a/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java +++ b/jaxp/src/org/w3c/dom/ls/LSProgressEvent.java @@ -53,6 +53,8 @@ import org.w3c.dom.events.Event; * input dependent. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSProgressEvent extends Event { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java b/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java index bcb57be01e1..2361c2dd5eb 100644 --- a/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java +++ b/jaxp/src/org/w3c/dom/ls/LSResourceResolver.java @@ -63,6 +63,8 @@ package org.w3c.dom.ls; * interface. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSResourceResolver { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSSerializer.java b/jaxp/src/org/w3c/dom/ls/LSSerializer.java index 6553f2112eb..05b003a15a7 100644 --- a/jaxp/src/org/w3c/dom/ls/LSSerializer.java +++ b/jaxp/src/org/w3c/dom/ls/LSSerializer.java @@ -204,6 +204,8 @@ import org.w3c.dom.DOMException; * permission denied,...) and so on. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSSerializer { /** diff --git a/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java b/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java index bc8e7241799..1263473c753 100644 --- a/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java +++ b/jaxp/src/org/w3c/dom/ls/LSSerializerFilter.java @@ -70,6 +70,8 @@ import org.w3c.dom.traversal.NodeFilter; * document. *

See also the Document Object Model (DOM) Level 3 Load and Save Specification. + * + * @since 1.5 */ public interface LSSerializerFilter extends NodeFilter { /** diff --git a/jaxp/src/org/w3c/dom/package.html b/jaxp/src/org/w3c/dom/package.html index def37a39016..b53925625a2 100644 --- a/jaxp/src/org/w3c/dom/package.html +++ b/jaxp/src/org/w3c/dom/package.html @@ -10,6 +10,6 @@ to dynamically access and update the content and structure of documents. See the specification for more information. -@since JDK1.4 +@since 1.4 diff --git a/jaxp/src/org/w3c/dom/views/AbstractView.java b/jaxp/src/org/w3c/dom/views/AbstractView.java index 52195717f70..4f23df62974 100644 --- a/jaxp/src/org/w3c/dom/views/AbstractView.java +++ b/jaxp/src/org/w3c/dom/views/AbstractView.java @@ -44,7 +44,7 @@ package org.w3c.dom.views; /** * A base interface that all views shall derive from. *

See also the Document Object Model (DOM) Level 2 Views Specification. - * @since DOM Level 2 + * @since 1.8, DOM Level 2 */ public interface AbstractView { /** diff --git a/jaxp/src/org/w3c/dom/views/DocumentView.java b/jaxp/src/org/w3c/dom/views/DocumentView.java index 38793a49634..8716d797079 100644 --- a/jaxp/src/org/w3c/dom/views/DocumentView.java +++ b/jaxp/src/org/w3c/dom/views/DocumentView.java @@ -47,7 +47,7 @@ package org.w3c.dom.views; * Views. It provides an attribute to retrieve the default view of a * document. *

See also the Document Object Model (DOM) Level 2 Views Specification. - * @since DOM Level 2 + * @since 1.8, DOM Level 2 */ public interface DocumentView { /** diff --git a/jaxp/src/org/xml/sax/AttributeList.java b/jaxp/src/org/xml/sax/AttributeList.java index 07ee3dd42ae..877155409c5 100644 --- a/jaxp/src/org/xml/sax/AttributeList.java +++ b/jaxp/src/org/xml/sax/AttributeList.java @@ -88,7 +88,7 @@ package org.xml.sax; * @deprecated This interface has been replaced by the SAX2 * {@link org.xml.sax.Attributes Attributes} * interface, which includes Namespace support. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.DocumentHandler#startElement startElement * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl diff --git a/jaxp/src/org/xml/sax/Attributes.java b/jaxp/src/org/xml/sax/Attributes.java index 0202aa457ff..15ad0aa5fe7 100644 --- a/jaxp/src/org/xml/sax/Attributes.java +++ b/jaxp/src/org/xml/sax/Attributes.java @@ -85,7 +85,7 @@ package org.xml.sax; *

The order of attributes in the list is unspecified, and will * vary from implementation to implementation.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.helpers.AttributesImpl * @see org.xml.sax.ext.DeclHandler#attributeDecl diff --git a/jaxp/src/org/xml/sax/ContentHandler.java b/jaxp/src/org/xml/sax/ContentHandler.java index 99d8f5a3f3d..7189ee7c847 100644 --- a/jaxp/src/org/xml/sax/ContentHandler.java +++ b/jaxp/src/org/xml/sax/ContentHandler.java @@ -73,7 +73,7 @@ package org.xml.sax; * anyway, so the user should consider this a feature rather than a * bug.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.XMLReader * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/DTDHandler.java b/jaxp/src/org/xml/sax/DTDHandler.java index 6d43ecdb9d9..29978308963 100644 --- a/jaxp/src/org/xml/sax/DTDHandler.java +++ b/jaxp/src/org/xml/sax/DTDHandler.java @@ -67,7 +67,7 @@ package org.xml.sax; * obtained through this interface to find the entity and/or * notation corresponding with the attribute value.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#setDTDHandler */ diff --git a/jaxp/src/org/xml/sax/DocumentHandler.java b/jaxp/src/org/xml/sax/DocumentHandler.java index ffe4d2a3571..0c8b93b85b2 100644 --- a/jaxp/src/org/xml/sax/DocumentHandler.java +++ b/jaxp/src/org/xml/sax/DocumentHandler.java @@ -62,7 +62,7 @@ package org.xml.sax; * @deprecated This interface has been replaced by the SAX2 * {@link org.xml.sax.ContentHandler ContentHandler} * interface, which includes Namespace support. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.Parser#setDocumentHandler * @see org.xml.sax.Locator diff --git a/jaxp/src/org/xml/sax/EntityResolver.java b/jaxp/src/org/xml/sax/EntityResolver.java index 6f8c5013bf9..ecd3368de12 100644 --- a/jaxp/src/org/xml/sax/EntityResolver.java +++ b/jaxp/src/org/xml/sax/EntityResolver.java @@ -85,7 +85,7 @@ import java.io.IOException; * identifiers to local URIs or to look up replacements in a catalog * (possibly by using the public identifier).

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#setEntityResolver * @see org.xml.sax.InputSource diff --git a/jaxp/src/org/xml/sax/ErrorHandler.java b/jaxp/src/org/xml/sax/ErrorHandler.java index 11833823106..40a2394de45 100644 --- a/jaxp/src/org/xml/sax/ErrorHandler.java +++ b/jaxp/src/org/xml/sax/ErrorHandler.java @@ -65,7 +65,7 @@ package org.xml.sax; * For example, {@link XMLReader#parse XMLReader.parse()} would throw * an IOException for errors accessing entities or the document.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#setErrorHandler * @see org.xml.sax.SAXParseException diff --git a/jaxp/src/org/xml/sax/HandlerBase.java b/jaxp/src/org/xml/sax/HandlerBase.java index db2e646f6a0..cbbcf029aa0 100644 --- a/jaxp/src/org/xml/sax/HandlerBase.java +++ b/jaxp/src/org/xml/sax/HandlerBase.java @@ -59,7 +59,7 @@ package org.xml.sax; * interface. It has been replaced by the SAX2 * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler} * class. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.EntityResolver * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/InputSource.java b/jaxp/src/org/xml/sax/InputSource.java index 4f47f9ea6eb..9498da395c7 100644 --- a/jaxp/src/org/xml/sax/InputSource.java +++ b/jaxp/src/org/xml/sax/InputSource.java @@ -74,7 +74,7 @@ import java.io.InputStream; * so applications should not attempt to re-use such streams after they * have been handed to a parser.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource) * @see org.xml.sax.EntityResolver#resolveEntity diff --git a/jaxp/src/org/xml/sax/Locator.java b/jaxp/src/org/xml/sax/Locator.java index 868168dbfe8..fc3a9487871 100644 --- a/jaxp/src/org/xml/sax/Locator.java +++ b/jaxp/src/org/xml/sax/Locator.java @@ -62,7 +62,7 @@ package org.xml.sax; * event, the application should assume that a locator is not * available.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.ContentHandler#setDocumentLocator */ diff --git a/jaxp/src/org/xml/sax/Parser.java b/jaxp/src/org/xml/sax/Parser.java index 61bfbc74fa5..099df32951b 100644 --- a/jaxp/src/org/xml/sax/Parser.java +++ b/jaxp/src/org/xml/sax/Parser.java @@ -64,7 +64,7 @@ import java.util.Locale; * @deprecated This interface has been replaced by the SAX2 * {@link org.xml.sax.XMLReader XMLReader} * interface, which includes Namespace support. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.EntityResolver * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/SAXException.java b/jaxp/src/org/xml/sax/SAXException.java index 65b25cc381a..0352ebbe858 100644 --- a/jaxp/src/org/xml/sax/SAXException.java +++ b/jaxp/src/org/xml/sax/SAXException.java @@ -54,7 +54,7 @@ package org.xml.sax; * specific location in an XML document, it should use the * {@link org.xml.sax.SAXParseException SAXParseException} subclass.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @version 2.0.1 (sax2r2) * @see org.xml.sax.SAXParseException diff --git a/jaxp/src/org/xml/sax/SAXNotRecognizedException.java b/jaxp/src/org/xml/sax/SAXNotRecognizedException.java index f963e01bed2..66bffe07487 100644 --- a/jaxp/src/org/xml/sax/SAXNotRecognizedException.java +++ b/jaxp/src/org/xml/sax/SAXNotRecognizedException.java @@ -46,7 +46,7 @@ package org.xml.sax; * unrecognized feature or property identifier; SAX applications and * extensions may use this class for other, similar purposes.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.SAXNotSupportedException */ diff --git a/jaxp/src/org/xml/sax/SAXNotSupportedException.java b/jaxp/src/org/xml/sax/SAXNotSupportedException.java index d31f49e7ae6..e1c728ff7ea 100644 --- a/jaxp/src/org/xml/sax/SAXNotSupportedException.java +++ b/jaxp/src/org/xml/sax/SAXNotSupportedException.java @@ -46,7 +46,7 @@ package org.xml.sax; * operation (setting a state or value). Other SAX2 applications and * extensions may use this class for similar purposes.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.SAXNotRecognizedException */ diff --git a/jaxp/src/org/xml/sax/SAXParseException.java b/jaxp/src/org/xml/sax/SAXParseException.java index 38f37ff47c6..8036dd914da 100644 --- a/jaxp/src/org/xml/sax/SAXParseException.java +++ b/jaxp/src/org/xml/sax/SAXParseException.java @@ -52,7 +52,7 @@ package org.xml.sax; *

Since this exception is a subclass of {@link org.xml.sax.SAXException * SAXException}, it inherits the ability to wrap another exception.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @version 2.0.1 (sax2r2) * @see org.xml.sax.SAXException diff --git a/jaxp/src/org/xml/sax/XMLFilter.java b/jaxp/src/org/xml/sax/XMLFilter.java index f88cff1965c..eda292e0f6b 100644 --- a/jaxp/src/org/xml/sax/XMLFilter.java +++ b/jaxp/src/org/xml/sax/XMLFilter.java @@ -53,7 +53,7 @@ package org.xml.sax; * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler * ErrorHandler} events automatically.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.helpers.XMLFilterImpl */ diff --git a/jaxp/src/org/xml/sax/XMLReader.java b/jaxp/src/org/xml/sax/XMLReader.java index 93b73420a4c..0f2b9cbae8a 100644 --- a/jaxp/src/org/xml/sax/XMLReader.java +++ b/jaxp/src/org/xml/sax/XMLReader.java @@ -75,7 +75,7 @@ import java.io.IOException; *

There are adapters available to convert a SAX1 Parser to * a SAX2 XMLReader and vice-versa.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.XMLFilter * @see org.xml.sax.helpers.ParserAdapter diff --git a/jaxp/src/org/xml/sax/ext/Attributes2.java b/jaxp/src/org/xml/sax/ext/Attributes2.java index 4c7023df48e..d8715595aea 100644 --- a/jaxp/src/org/xml/sax/ext/Attributes2.java +++ b/jaxp/src/org/xml/sax/ext/Attributes2.java @@ -57,7 +57,7 @@ import org.xml.sax.Attributes; * must have been declared. *

* - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public interface Attributes2 extends Attributes diff --git a/jaxp/src/org/xml/sax/ext/Attributes2Impl.java b/jaxp/src/org/xml/sax/ext/Attributes2Impl.java index aabb0b9fd25..42b85cae2ab 100644 --- a/jaxp/src/org/xml/sax/ext/Attributes2Impl.java +++ b/jaxp/src/org/xml/sax/ext/Attributes2Impl.java @@ -56,7 +56,7 @@ import org.xml.sax.helpers.AttributesImpl; * its declared flag to match. *

* - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public class Attributes2Impl extends AttributesImpl implements Attributes2 diff --git a/jaxp/src/org/xml/sax/ext/DeclHandler.java b/jaxp/src/org/xml/sax/ext/DeclHandler.java index b2c72c5621e..f2f46c197d2 100644 --- a/jaxp/src/org/xml/sax/ext/DeclHandler.java +++ b/jaxp/src/org/xml/sax/ext/DeclHandler.java @@ -66,7 +66,7 @@ import org.xml.sax.SAXException; * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} * when you attempt to register the handler.

* - * @since SAX 2.0 (extensions 1.0) + * @since 1.4, SAX 2.0 (extensions 1.0) * @author David Megginson */ public interface DeclHandler diff --git a/jaxp/src/org/xml/sax/ext/DefaultHandler2.java b/jaxp/src/org/xml/sax/ext/DefaultHandler2.java index cb7a91a4ca3..6b5ed26dfd3 100644 --- a/jaxp/src/org/xml/sax/ext/DefaultHandler2.java +++ b/jaxp/src/org/xml/sax/ext/DefaultHandler2.java @@ -55,7 +55,7 @@ import org.xml.sax.helpers.DefaultHandler; * ContentHandler.startElement() call might be passed a * {@link Attributes2} object. * - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public class DefaultHandler2 extends DefaultHandler diff --git a/jaxp/src/org/xml/sax/ext/EntityResolver2.java b/jaxp/src/org/xml/sax/ext/EntityResolver2.java index dbd1242a9d7..178adf08aa7 100644 --- a/jaxp/src/org/xml/sax/ext/EntityResolver2.java +++ b/jaxp/src/org/xml/sax/ext/EntityResolver2.java @@ -80,7 +80,7 @@ import org.xml.sax.SAXException; * * @see org.xml.sax.XMLReader#setEntityResolver * - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public interface EntityResolver2 extends EntityResolver diff --git a/jaxp/src/org/xml/sax/ext/LexicalHandler.java b/jaxp/src/org/xml/sax/ext/LexicalHandler.java index dcceceeef17..094ca73d7ae 100644 --- a/jaxp/src/org/xml/sax/ext/LexicalHandler.java +++ b/jaxp/src/org/xml/sax/ext/LexicalHandler.java @@ -62,7 +62,7 @@ import org.xml.sax.SAXException; * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} * when you attempt to register the handler.

* - * @since SAX 2.0 (extensions 1.0) + * @since 1.4, SAX 2.0 (extensions 1.0) * @author David Megginson */ public interface LexicalHandler diff --git a/jaxp/src/org/xml/sax/ext/Locator2.java b/jaxp/src/org/xml/sax/ext/Locator2.java index c651a6e17cc..684b0c7ce5c 100644 --- a/jaxp/src/org/xml/sax/ext/Locator2.java +++ b/jaxp/src/org/xml/sax/ext/Locator2.java @@ -51,7 +51,7 @@ import org.xml.sax.Locator; *

XMLReader implementations are not required to support this * information, and it is not part of core-only SAX2 distributions.

* - * @since SAX 2.0 (extensions 1.1 alpha) + * @since 1.5, SAX 2.0 (extensions 1.1 alpha) * @author David Brownell */ public interface Locator2 extends Locator diff --git a/jaxp/src/org/xml/sax/ext/Locator2Impl.java b/jaxp/src/org/xml/sax/ext/Locator2Impl.java index d47b27e67b3..abb52cf4427 100644 --- a/jaxp/src/org/xml/sax/ext/Locator2Impl.java +++ b/jaxp/src/org/xml/sax/ext/Locator2Impl.java @@ -45,7 +45,7 @@ import org.xml.sax.helpers.LocatorImpl; * *

This is not part of core-only SAX2 distributions.

* - * @since SAX 2.0.2 + * @since 1.5, SAX 2.0.2 * @author David Brownell */ public class Locator2Impl extends LocatorImpl implements Locator2 diff --git a/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java b/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java index 93c111e95a5..41d9310f6e5 100644 --- a/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java +++ b/jaxp/src/org/xml/sax/helpers/AttributeListImpl.java @@ -82,7 +82,7 @@ import java.util.Vector; * which is implemented in the * {@link org.xml.sax.helpers.AttributesImpl * AttributesImpl} helper class. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.AttributeList * @see org.xml.sax.DocumentHandler#startElement diff --git a/jaxp/src/org/xml/sax/helpers/AttributesImpl.java b/jaxp/src/org/xml/sax/helpers/AttributesImpl.java index fc5e9533146..d6fcc4f90ec 100644 --- a/jaxp/src/org/xml/sax/helpers/AttributesImpl.java +++ b/jaxp/src/org/xml/sax/helpers/AttributesImpl.java @@ -64,7 +64,7 @@ import org.xml.sax.Attributes; * AttributeList} interface, it also includes a much more efficient * implementation using a single array rather than a set of Vectors.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson */ public class AttributesImpl implements Attributes diff --git a/jaxp/src/org/xml/sax/helpers/DefaultHandler.java b/jaxp/src/org/xml/sax/helpers/DefaultHandler.java index 4ae6b1d498a..00632f984b4 100644 --- a/jaxp/src/org/xml/sax/helpers/DefaultHandler.java +++ b/jaxp/src/org/xml/sax/helpers/DefaultHandler.java @@ -73,7 +73,7 @@ import org.xml.sax.SAXParseException; *

This class replaces the deprecated SAX1 * {@link org.xml.sax.HandlerBase HandlerBase} class.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson, * @see org.xml.sax.EntityResolver * @see org.xml.sax.DTDHandler diff --git a/jaxp/src/org/xml/sax/helpers/LocatorImpl.java b/jaxp/src/org/xml/sax/helpers/LocatorImpl.java index f4c538b3aea..4b0a6e282fe 100644 --- a/jaxp/src/org/xml/sax/helpers/LocatorImpl.java +++ b/jaxp/src/org/xml/sax/helpers/LocatorImpl.java @@ -69,7 +69,7 @@ import org.xml.sax.Locator; * is more efficient to provide location information only when * requested, rather than constantly updating a Locator object.

* - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @see org.xml.sax.Locator Locator */ diff --git a/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java b/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java index 13cf74e855f..90e8c2824e7 100644 --- a/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java +++ b/jaxp/src/org/xml/sax/helpers/NamespaceSupport.java @@ -90,7 +90,7 @@ import java.util.Vector; * Applications must track namespace information themselves if they * want to use namespace information. * - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson */ public class NamespaceSupport @@ -126,7 +126,7 @@ public class NamespaceSupport * xmlns and xmlns:* attributes, which are used to * declare namespaces.

* - * @since SAX 2.1alpha + * @since 1.5, SAX 2.1alpha * @see #setNamespaceDeclUris * @see #isNamespaceDeclUris */ @@ -497,7 +497,7 @@ public class NamespaceSupport * by {@link #processName processName()}. This may only be * changed before any contexts have been pushed. * - * @since SAX 2.1alpha + * @since 1.5, SAX 2.1alpha * * @exception IllegalStateException when attempting to set this * after any context has been pushed. @@ -521,7 +521,7 @@ public class NamespaceSupport * Returns true if namespace declaration attributes are placed into * a namespace. This behavior is not the default. * - * @since SAX 2.1alpha + * @since 1.5, SAX 2.1alpha */ public boolean isNamespaceDeclUris () { return namespaceDeclUris; } diff --git a/jaxp/src/org/xml/sax/helpers/ParserAdapter.java b/jaxp/src/org/xml/sax/helpers/ParserAdapter.java index 62e76c720ef..3c69e5c9aae 100644 --- a/jaxp/src/org/xml/sax/helpers/ParserAdapter.java +++ b/jaxp/src/org/xml/sax/helpers/ParserAdapter.java @@ -72,7 +72,7 @@ import org.xml.sax.SAXNotSupportedException; *

This adapter does not test for duplicate Namespace-qualified * attribute names.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @version 2.0.1 (sax2r2) * @see org.xml.sax.helpers.XMLReaderAdapter diff --git a/jaxp/src/org/xml/sax/helpers/ParserFactory.java b/jaxp/src/org/xml/sax/helpers/ParserFactory.java index 03983123897..efbefe01509 100644 --- a/jaxp/src/org/xml/sax/helpers/ParserFactory.java +++ b/jaxp/src/org/xml/sax/helpers/ParserFactory.java @@ -61,7 +61,7 @@ import org.xml.sax.Parser; * @deprecated This class works with the deprecated * {@link org.xml.sax.Parser Parser} * interface. - * @since SAX 1.0 + * @since 1.4, SAX 1.0 * @author David Megginson * @version 2.0.1 (sax2r2) */ diff --git a/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java b/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java index 1e55672eaba..d103190cca5 100644 --- a/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java +++ b/jaxp/src/org/xml/sax/helpers/XMLFilterImpl.java @@ -65,7 +65,7 @@ import org.xml.sax.SAXNotRecognizedException; * specific methods to modify the event stream or the configuration * requests as they pass through.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.XMLFilter * @see org.xml.sax.XMLReader diff --git a/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java b/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java index 394633fb1e3..8256d976761 100644 --- a/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java +++ b/jaxp/src/org/xml/sax/helpers/XMLReaderAdapter.java @@ -68,7 +68,7 @@ import org.xml.sax.SAXNotSupportedException; * supports a false value for the http://xml.org/sax/features/namespaces * property, that will also be used to improve efficiency.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson * @see org.xml.sax.Parser * @see org.xml.sax.XMLReader diff --git a/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java b/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java index 27ce1c1afd5..f8d27363331 100644 --- a/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java +++ b/jaxp/src/org/xml/sax/helpers/XMLReaderFactory.java @@ -67,7 +67,7 @@ import org.xml.sax.SAXException; * nothing bound its class name to org.xml.sax.driver so * those configuration mechanisms would see it.

* - * @since SAX 2.0 + * @since 1.4, SAX 2.0 * @author David Megginson, David Brownell * @version 2.0.1 (sax2r2) */ From d7c001dd04ad699cf17a0e3dd8cc552c08dcac55 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Thu, 19 Jun 2014 23:52:33 +0100 Subject: [PATCH 092/236] 8042759: Lambda returning implicitly-typed lambdas considered pertinent to applicability Reviewed-by: mcimadamore --- .../sun/tools/javac/comp/DeferredAttr.java | 2 +- ...tLambdaConsideredForApplicabilityTest.java | 33 +++++++++++++++++++ ...itLambdaConsideredForApplicabilityTest.out | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java create mode 100644 langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index ef37f097493..9275ea4429b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -953,7 +953,7 @@ public class DeferredAttr extends JCTree.Visitor { LambdaReturnScanner() { super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, - FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); + FORLOOP, IF, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); } } diff --git a/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java new file mode 100644 index 00000000000..07f14efce96 --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.java @@ -0,0 +1,33 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8042759 + * @summary Lambda returning implicitly-typed lambdas considered pertinent to applicability + * @compile/fail/ref=ImplicitLambdaConsideredForApplicabilityTest.out -XDrawDiagnostics ImplicitLambdaConsideredForApplicabilityTest.java + */ + +abstract class ImplicitLambdaConsideredForApplicabilityTest { + interface A { + B m(int a, int b); + } + + interface C { + String m(int a, int b); + } + + interface B { + int m(int c); + } + + abstract void foo(A a); + + abstract void foo(C c); + + void bar() { + foo((int a, int b) -> { + if(a < b) + return c -> 0; + else + return c -> 0; + }); + } +} diff --git a/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out new file mode 100644 index 00000000000..d62ac05b61e --- /dev/null +++ b/langtools/test/tools/javac/lambda/T8042759/ImplicitLambdaConsideredForApplicabilityTest.out @@ -0,0 +1,2 @@ +ImplicitLambdaConsideredForApplicabilityTest.java:26:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.A), ImplicitLambdaConsideredForApplicabilityTest, kindname.method, foo(ImplicitLambdaConsideredForApplicabilityTest.C), ImplicitLambdaConsideredForApplicabilityTest +1 error From 2626aed785f68e6d51cb780ea5d1108aae7fe153 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Fri, 20 Jun 2014 08:14:30 +0200 Subject: [PATCH 093/236] 8008321: compile.cpp verify_graph_edges uses bool as int The dead_nodes counter in verify_graph_edges(..) has the type bool but is used as int. Reviewed-by: roland, anoll --- hotspot/src/share/vm/opto/compile.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 0036e76518e..9c8ae35a04e 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -3411,7 +3411,7 @@ void Compile::verify_graph_edges(bool no_dead_code) { _root->verify_edges(visited); if (no_dead_code) { // Now make sure that no visited node is used by an unvisited node. - bool dead_nodes = 0; + bool dead_nodes = false; Unique_Node_List checked(area); while (visited.size() > 0) { Node* n = visited.pop(); @@ -3422,14 +3422,16 @@ void Compile::verify_graph_edges(bool no_dead_code) { if (visited.member(use)) continue; // already in the graph if (use->is_Con()) continue; // a dead ConNode is OK // At this point, we have found a dead node which is DU-reachable. - if (dead_nodes++ == 0) + if (!dead_nodes) { tty->print_cr("*** Dead nodes reachable via DU edges:"); + dead_nodes = true; + } use->dump(2); tty->print_cr("---"); checked.push(use); // No repeats; pretend it is now checked. } } - assert(dead_nodes == 0, "using nodes must be reachable from root"); + assert(!dead_nodes, "using nodes must be reachable from root"); } } } From 1319cf1a68df68f7ecf14cc9b525182977946fd2 Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Fri, 20 Jun 2014 09:25:13 +0200 Subject: [PATCH 094/236] 8043158: Crash in CodeSweeperSweepNoFlushTest in CompileQueue::free_all() Acquire lock before calling notify() Reviewed-by: twisti, thartmann --- hotspot/src/share/vm/compiler/compileBroker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index ff292fbd747..d062c7085c4 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -639,8 +639,11 @@ void CompileQueue::free_all() { while (next != NULL) { CompileTask* current = next; next = current->next(); - // Wake up thread that blocks on the compile task. - current->lock()->notify(); + { + // Wake up thread that blocks on the compile task. + MutexLocker ct_lock(current->lock()); + current->lock()->notify(); + } // Put the task back on the freelist. CompileTask::free(current); } From f4c68a9cfcd7408767c2c926e7166410f352189e Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Fri, 20 Jun 2014 12:25:00 +0200 Subject: [PATCH 095/236] 8046921: Deoptimization type information peristence Reviewed-by: hannesw, lagergren --- nashorn/make/project.properties | 1 + .../internal/codegen/CodeGenerator.java | 36 +- .../internal/codegen/CompilationPhase.java | 4 +- .../nashorn/internal/codegen/Compiler.java | 32 +- .../codegen/OptimisticTypesPersistence.java | 345 ++++++++++++++++++ .../jdk/nashorn/internal/codegen/TypeMap.java | 15 + .../internal/runtime/CompiledFunction.java | 10 +- .../RecompilableScriptFunctionData.java | 69 +++- .../script/basic/JDK-8030182_2.js.EXPECTED | 2 +- 9 files changed, 484 insertions(+), 30 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index eb708a41320..77f8ed73bf7 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -279,6 +279,7 @@ run.test.jvmargs.common=\ -Dfile.encoding=UTF-8 \ -Duser.language=${run.test.user.language} \ -Duser.country=${run.test.user.country} \ + -Dnashorn.typeInfo.cacheDir=${build.dir}${file.separator}test${file.separator}type_info_cache \ ${jfr.args} \ -XX:+HeapDumpOnOutOfMemoryError diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 21b51b334c3..984440f39bf 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -145,6 +145,7 @@ import jdk.nashorn.internal.runtime.PropertyMap; import jdk.nashorn.internal.runtime.RecompilableScriptFunctionData; import jdk.nashorn.internal.runtime.RewriteException; import jdk.nashorn.internal.runtime.Scope; +import jdk.nashorn.internal.runtime.ScriptEnvironment; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; import jdk.nashorn.internal.runtime.ScriptRuntime; @@ -1821,19 +1822,40 @@ final class CodeGenerator extends NodeOperatorVisitor 0) { + b.append('-'); + for(final Type t: paramTypes) { + b.append(t.getBytecodeStackType()); + } + } + return new LocationDescriptor(new File(cacheDir, b.toString())); + } + + private static final class LocationDescriptor { + private final File file; + + LocationDescriptor(final File file) { + this.file = file; + } + } + + + /** + * Stores the map of optimistic types for a given function. + * @param locationDescriptor the opaque persistence location descriptor, retrieved by calling + * {@link #getLocationDescriptor(Source, int, Type[])}. + * @param optimisticTypes the map of optimistic types. + */ + @SuppressWarnings("resource") + public static void store(final Object locationDescriptor, final Map optimisticTypes) { + if(locationDescriptor == null) { + return; + } + final File file = ((LocationDescriptor)locationDescriptor).file; + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + synchronized(getFileLock(file)) { + try (final FileOutputStream out = new FileOutputStream(file);) { + out.getChannel().lock(); // lock exclusive + final DataOutputStream dout = new DataOutputStream(new BufferedOutputStream(out)); + dout.writeInt(optimisticTypes.size()); + for(Map.Entry e: optimisticTypes.entrySet()) { + dout.writeInt(e.getKey()); + final byte typeChar; + final Type type = e.getValue(); + if(type == Type.OBJECT) { + typeChar = 'L'; + } else if(type == Type.NUMBER) { + typeChar = 'D'; + } else if(type == Type.LONG) { + typeChar = 'J'; + } else { + throw new AssertionError(); + } + dout.write(typeChar); + } + dout.flush(); + } catch(final Exception e) { + final long now = System.currentTimeMillis(); + if(now - lastReportedError > ERROR_REPORT_THRESHOLD) { + getLogger().warning("Failed to write " + file, e); + lastReportedError = now; + } + } + } + return null; + } + }); + } + + /** + * Loads the map of optimistic types for a given function. + * @param locationDescriptor the opaque persistence location descriptor, retrieved by calling + * {@link #getLocationDescriptor(Source, int, Type[])}. + * @return the map of optimistic types, or null if persisted type information could not be retrieved. + */ + @SuppressWarnings("resource") + public static Map load(final Object locationDescriptor) { + if (locationDescriptor == null) { + return null; + } + final File file = ((LocationDescriptor)locationDescriptor).file; + + return AccessController.doPrivileged(new PrivilegedAction>() { + @Override + public Map run() { + try { + if(!file.isFile()) { + return null; + } + synchronized(getFileLock(file)) { + try (final FileInputStream in = new FileInputStream(file);) { + in.getChannel().lock(0, Long.MAX_VALUE, true); // lock shared + final DataInputStream din = new DataInputStream(new BufferedInputStream(in)); + final Map map = new TreeMap<>(); + final int size = din.readInt(); + for(int i = 0; i < size; ++i) { + final int pp = din.readInt(); + final int typeChar = din.read(); + final Type type; + switch(typeChar) { + case 'L': type = Type.OBJECT; break; + case 'D': type = Type.NUMBER; break; + case 'J': type = Type.LONG; break; + default: throw new AssertionError(); + } + map.put(pp, type); + } + return map; + } + } + } catch (final Exception e) { + final long now = System.currentTimeMillis(); + if(now - lastReportedError > ERROR_REPORT_THRESHOLD) { + getLogger().warning("Failed to read " + file, e); + lastReportedError = now; + } + return null; + } + } + }); + } + + private static File createCacheDir() { + if(Options.getBooleanProperty("nashorn.typeInfo.disabled")) { + return null; + } + try { + return createCacheDirPrivileged(); + } catch(final Exception e) { + getLogger().warning("Failed to create cache dir", e); + return null; + } + } + + private static File createCacheDirPrivileged() { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public File run() { + final String explicitDir = System.getProperty("nashorn.typeInfo.cacheDir"); + final File dir; + if(explicitDir != null) { + dir = new File(explicitDir); + } else { + // When no directory is explicitly specified, get an operating system specific cache directory, + // and create "com.oracle.java.NashornTypeInfo" in it. + dir = new File(getCacheDirBase(), "com.oracle.java.NashornTypeInfo"); + } + final String versionDirName; + try { + versionDirName = getVersionDirName(); + } catch(Exception e) { + getLogger().warning("Failed to calculate version dir name", e); + return null; + } + final File versionDir = new File(dir, versionDirName); + versionDir.mkdirs(); + if(versionDir.isDirectory()) { + getLogger().info("Optimistic type persistence directory is " + versionDir); + return versionDir; + } + getLogger().warning("Could not create optimistic type persistence directory " + versionDir); + return null; + } + }); + } + + /** + * Returns an operating system specific root directory for cache files. + * @return an operating system specific root directory for cache files. + */ + private static File getCacheDirBase() { + final String os = System.getProperty("os.name", "generic"); + if("Mac OS X".equals(os)) { + // Mac OS X stores caches in ~/Library/Caches + return new File(new File(System.getProperty("user.home"), "Library"), "Caches"); + } else if(os.startsWith("Windows")) { + // On Windows, temp directory is the best approximation of a cache directory, as its contents persist across + // reboots and various cleanup utilities know about it. java.io.tmpdir normally points to a user-specific + // temp directory, %HOME%\LocalSettings\Temp. + return new File(System.getProperty("java.io.tmpdir")); + } else { + // In all other cases we're presumably dealing with a UNIX flavor (Linux, Solaris, etc.); "~/.cache" + return new File(System.getProperty("user.home"), ".cache"); + } + } + + /** + * In order to ensure that changes in Nashorn code don't cause corruption in the data, we'll create a + * per-code-version directory. Normally, this will create the SHA-1 digest of the nashorn.jar. In case the classpath + * for nashorn is local directory (e.g. during development), this will create the string "dev-" followed by the + * timestamp of the most recent .class file. + * @return + */ + private static String getVersionDirName() throws Exception { + final URL url = OptimisticTypesPersistence.class.getResource(""); + final String protocol = url.getProtocol(); + if(protocol.equals("jar")) { + // Normal deployment: nashorn.jar + final String jarUrlFile = url.getFile(); + final String filePath = jarUrlFile.substring(0, jarUrlFile.indexOf('!')); + final URL file = new URL(filePath); + try (final InputStream in = file.openStream()) { + final byte[] buf = new byte[128*1024]; + final MessageDigest digest = MessageDigest.getInstance("SHA-1"); + for(;;) { + final int l = in.read(buf); + if(l == -1) { + return Base64.getUrlEncoder().encodeToString(digest.digest()); + } + digest.update(buf, 0, l); + } + } + } else if(protocol.equals("file")) { + // Development + final String fileStr = url.getFile(); + final String className = OptimisticTypesPersistence.class.getName(); + final int packageNameLen = className.lastIndexOf('.'); + final String dirStr = fileStr.substring(0, fileStr.length() - packageNameLen - 1); + final File dir = new File(dirStr); + return "dev-" + new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date(getLastModifiedClassFile(dir, 0L))); + } else { + throw new AssertionError(); + } + } + + private static long getLastModifiedClassFile(final File dir, final long max) { + long currentMax = max; + for(File f: dir.listFiles()) { + if(f.getName().endsWith(".class")) { + final long lastModified = f.lastModified(); + if(lastModified > currentMax) { + currentMax = lastModified; + } + } else if(f.isDirectory()) { + final long lastModified = getLastModifiedClassFile(f, currentMax); + if(lastModified > currentMax) { + currentMax = lastModified; + } + } + } + return currentMax; + } + + private static Object[] createLockArray() { + final Object[] lockArray = new Object[Runtime.getRuntime().availableProcessors() * 2]; + for(int i = 0; i < lockArray.length; ++i) { + lockArray[i] = new Object(); + } + return lockArray; + } + + private static Object getFileLock(final File file) { + return locks[(file.hashCode() & Integer.MAX_VALUE) % locks.length]; + } + + private static DebugLogger getLogger() { + try { + return Context.getContext().getLogger(RecompilableScriptFunctionData.class); + } catch (final Exception e) { + e.printStackTrace(); + return DebugLogger.DISABLED_LOGGER; + } + } +} diff --git a/nashorn/src/jdk/nashorn/internal/codegen/TypeMap.java b/nashorn/src/jdk/nashorn/internal/codegen/TypeMap.java index eb337f55245..11efce1a3db 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/TypeMap.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/TypeMap.java @@ -29,6 +29,7 @@ import java.lang.invoke.MethodType; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.NoSuchElementException; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.runtime.ScriptFunction; @@ -61,6 +62,20 @@ public class TypeMap { this.needsCallee = needsCallee; } + /** + * Returns the array of parameter types for a particular function node + * @param functionNodeId the ID of the function node + * @return an array of parameter types + * @throws NoSuchElementException if the type map has no mapping for the requested function + */ + public Type[] getParameterTypes(final int functionNodeId) { + final Type[] paramTypes = paramTypeMap.get(functionNodeId); + if (paramTypes == null) { + throw new NoSuchElementException(Integer.toString(functionNodeId)); + } + return paramTypes.clone(); + } + MethodType getCallSiteType(final FunctionNode functionNode) { final Type[] types = paramTypeMap.get(functionNode.getId()); if (types == null) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java index 6c1ca1ec757..87e32fc6508 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/CompiledFunction.java @@ -89,11 +89,12 @@ final class CompiledFunction { this.log = log; } - CompiledFunction(final MethodHandle invoker, final RecompilableScriptFunctionData functionData, final int flags) { + CompiledFunction(final MethodHandle invoker, final RecompilableScriptFunctionData functionData, + final Map invalidatedProgramPoints, final int flags) { this(invoker, null, functionData.getLogger()); this.flags = flags; if ((flags & FunctionNode.IS_DEOPTIMIZABLE) != 0) { - optimismInfo = new OptimismInfo(functionData); + optimismInfo = new OptimismInfo(functionData, invalidatedProgramPoints); } else { optimismInfo = null; } @@ -691,13 +692,14 @@ final class CompiledFunction { private static class OptimismInfo { // TODO: this is pointing to its owning ScriptFunctionData. Re-evaluate if that's okay. private final RecompilableScriptFunctionData data; - private final Map invalidatedProgramPoints = new TreeMap<>(); + private final Map invalidatedProgramPoints; private SwitchPoint optimisticAssumptions; private final DebugLogger log; - OptimismInfo(final RecompilableScriptFunctionData data) { + OptimismInfo(final RecompilableScriptFunctionData data, final Map invalidatedProgramPoints) { this.data = data; this.log = data.getLogger(); + this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new TreeMap() : invalidatedProgramPoints; newOptimisticAssumptions(); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index 78ee06e58ce..b2c0ed6b57f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -36,12 +36,14 @@ import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import jdk.internal.dynalink.support.NameCodec; import jdk.nashorn.internal.codegen.CompileUnit; import jdk.nashorn.internal.codegen.Compiler; import jdk.nashorn.internal.codegen.Compiler.CompilationPhases; import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.codegen.FunctionSignature; +import jdk.nashorn.internal.codegen.OptimisticTypesPersistence; import jdk.nashorn.internal.codegen.TypeMap; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.FunctionNode; @@ -390,7 +392,11 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp return getCompiler(fn, actualCallSiteType, newLocals(runtimeScope), null, null); } - Compiler getCompiler(final FunctionNode functionNode, final MethodType actualCallSiteType, final ScriptObject runtimeScope, final Map ipp, final int[] cep) { + Compiler getCompiler(final FunctionNode functionNode, final MethodType actualCallSiteType, + final ScriptObject runtimeScope, final Map invalidatedProgramPoints, + final int[] continuationEntryPoints) { + final TypeMap typeMap = typeMap(actualCallSiteType); + final Object typeInformationFile = OptimisticTypesPersistence.getLocationDescriptor(source, functionNodeId, typeMap == null ? null : typeMap.getParameterTypes(functionNodeId)); final Context context = Context.getContextTrusted(); return new Compiler( context, @@ -402,12 +408,31 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp true, // is on demand this, // compiledFunction, i.e. this RecompilableScriptFunctionData typeMap(actualCallSiteType), // type map - ipp, // invalidated program points - cep, // continuation entry points + getEffectiveInvalidatedProgramPoints(invalidatedProgramPoints, typeInformationFile), // invalidated program points + typeInformationFile, + continuationEntryPoints, // continuation entry points runtimeScope); // runtime scope } - private FunctionNode compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope) { + /** + * If the function being compiled already has its own invalidated program points map, use it. Otherwise, attempt to + * load invalidated program points map from the persistent type info cache. + * @param invalidatedProgramPoints the function's current invalidated program points map. Null if the function + * doesn't have it. + * @param typeInformationFile the object describing the location of the persisted type information. + * @return either the existing map, or a loaded map from the persistent type info cache, or a new empty map if + * neither an existing map or a persistent cached type info is available. + */ + private static Map getEffectiveInvalidatedProgramPoints( + final Map invalidatedProgramPoints, final Object typeInformationFile) { + if(invalidatedProgramPoints != null) { + return invalidatedProgramPoints; + } + final Map loadedProgramPoints = OptimisticTypesPersistence.load(typeInformationFile); + return loadedProgramPoints != null ? loadedProgramPoints : new TreeMap(); + } + + private TypeSpecializedFunction compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope) { // We're creating an empty script object for holding local variables. AssignSymbols will populate it with // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and // CompilationEnvironment#declareLocalSymbol()). @@ -417,7 +442,20 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp } final FunctionNode fn = reparse(); - return getCompiler(fn, actualCallSiteType, runtimeScope).compile(fn, CompilationPhases.COMPILE_ALL); + final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope); + + final FunctionNode compiledFn = compiler.compile(fn, CompilationPhases.COMPILE_ALL); + return new TypeSpecializedFunction(compiledFn, compiler.getInvalidatedProgramPoints()); + } + + private static class TypeSpecializedFunction { + private final FunctionNode fn; + private final Map invalidatedProgramPoints; + + TypeSpecializedFunction(final FunctionNode fn, final Map invalidatedProgramPoints) { + this.fn = fn; + this.invalidatedProgramPoints = invalidatedProgramPoints; + } } private MethodType explicitParams(final MethodType callSiteType) { @@ -494,14 +532,14 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp methodLocator = new MethodLocator(functionNode); } - private CompiledFunction addCode(final MethodHandle target, final int fnFlags) { - final CompiledFunction cfn = new CompiledFunction(target, this, fnFlags); + private CompiledFunction addCode(final MethodHandle target, final Map invalidatedProgramPoints, final int fnFlags) { + final CompiledFunction cfn = new CompiledFunction(target, this, invalidatedProgramPoints, fnFlags); code.add(cfn); return cfn; } private CompiledFunction addCode(final FunctionNode fn) { - return addCode(lookup(fn), fn.getFlags()); + return addCode(lookup(fn), null, fn.getFlags()); } /** @@ -510,11 +548,12 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp * up getting one that takes a "double" etc. because of internal function logic causes widening (e.g. assignment of * a wider value to the parameter variable). However, we use the method handle type for matching subsequent lookups * for the same specialization, so we must adapt the handle to the expected type. - * @param fn the function + * @param tfn the function * @param callSiteType the call site type * @return the compiled function object, with its type matching that of the call site type. */ - private CompiledFunction addCode(final FunctionNode fn, final MethodType callSiteType) { + private CompiledFunction addCode(final TypeSpecializedFunction tfn, final MethodType callSiteType) { + final FunctionNode fn = tfn.fn; if (fn.isVarArg()) { return addCode(fn); } @@ -544,7 +583,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp toType = toType.dropParameterTypes(fromCount, toCount); } - return addCode(lookup(fn).asType(toType), fn.getFlags()); + return addCode(lookup(fn).asType(toType), tfn.invalidatedProgramPoints, fn.getFlags()); } @@ -555,7 +594,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp if (existingBest == null) { if(code.isEmpty() && methodLocator != null) { // This is a deserialized object, reconnect from method handle - existingBest = addCode(methodLocator.getMethodHandle(), methodLocator.getFunctionFlags()); + existingBest = addCode(methodLocator.getMethodHandle(), null, methodLocator.getFunctionFlags()); } else { existingBest = addCode(compileTypeSpecialization(callSiteType, runtimeScope), callSiteType); } @@ -576,9 +615,9 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp } if (applyToCall) { - final FunctionNode fn = compileTypeSpecialization(callSiteType, runtimeScope); - if (fn.hasOptimisticApplyToCall()) { //did the specialization work - existingBest = addCode(fn, callSiteType); + final TypeSpecializedFunction tfn = compileTypeSpecialization(callSiteType, runtimeScope); + if (tfn.fn.hasOptimisticApplyToCall()) { //did the specialization work + existingBest = addCode(tfn, callSiteType); } } diff --git a/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED index 772e504d917..090bd1f1ab2 100644 --- a/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED @@ -1,3 +1,3 @@ ReferenceError: "g" is not defined - at (test/script/basic/JDK-8030182_2.js#42:4@0:-1) + at (test/script/basic/JDK-8030182_2.js#42:4@1:-1) at (test/script/basic/JDK-8030182_2.js:42) From 06b8a7ac806f4fb677ae8abe8a1c171bb47bc8f2 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 20 Jun 2014 10:56:31 -0600 Subject: [PATCH 096/236] 8034147: javac crashes with a NullPointerException during bounds checking Types.supertype should return Type.noType rather than null Reviewed-by: vromero, mcimadamore --- .../com/sun/tools/javac/code/Types.java | 4 +-- .../com/sun/tools/javac/comp/Check.java | 2 +- .../javac/generics/wildcards/T8034147.java | 35 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 langtools/test/tools/javac/generics/wildcards/T8034147.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index c80bd054d24..9a52d21ae60 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2315,7 +2315,7 @@ public class Types { public Type visitType(Type t, Void ignored) { // A note on wildcards: there is no good way to // determine a supertype for a super bounded wildcard. - return null; + return Type.noType; } @Override @@ -2482,7 +2482,7 @@ public class Types { return false; return t.isRaw() || - supertype(t) != null && isDerivedRaw(supertype(t)) || + supertype(t) != Type.noType && isDerivedRaw(supertype(t)) || isDerivedRaw(interfaces(t)); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 2857b4d5957..cefcfa4af56 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -2684,7 +2684,7 @@ public class Check { checkClassBounds(pos, seensofar, it); } Type st = types.supertype(type); - if (st != null) checkClassBounds(pos, seensofar, st); + if (st != Type.noType) checkClassBounds(pos, seensofar, st); } /** Enter interface into into set. diff --git a/langtools/test/tools/javac/generics/wildcards/T8034147.java b/langtools/test/tools/javac/generics/wildcards/T8034147.java new file mode 100644 index 00000000000..4baade1ef5c --- /dev/null +++ b/langtools/test/tools/javac/generics/wildcards/T8034147.java @@ -0,0 +1,35 @@ +/* + * 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 8034147 + * @summary javac crashes with a NullPointerException during bounds checking + * @compile T8034147.java + */ + +class T8034147 { + static class One> {} + static class Two> implements Three {} + interface Three {} +} From fe46aeabb06db242925945bee9dd0b40c97d1108 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 20 Jun 2014 11:42:16 -0600 Subject: [PATCH 097/236] 8047407: Add test for JDK-8037385 Reviewed-by: mcimadamore --- .../javac/defaultMethods/static/StaticInvoke.java | 15 +++++++++++++++ .../javac/defaultMethods/static/StaticInvoke6.out | 3 +++ .../javac/defaultMethods/static/StaticInvoke7.out | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java create mode 100644 langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out create mode 100644 langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out diff --git a/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java new file mode 100644 index 00000000000..368e35d6f73 --- /dev/null +++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke.java @@ -0,0 +1,15 @@ +/* @test /nodynamiccopyright/ + * @bug 8037385 + * @summary Must not allow static interface method invocation in legacy code + * @compile -source 8 -Xlint:-options StaticInvoke.java + * @compile/fail/ref=StaticInvoke7.out -source 7 -Xlint:-options -XDrawDiagnostics StaticInvoke.java + * @compile/fail/ref=StaticInvoke6.out -source 6 -Xlint:-options -XDrawDiagnostics StaticInvoke.java + */ +import java.util.stream.Stream; + +class StaticInvoke { + void test() { + Stream.empty(); + java.util.stream.Stream.empty(); + } +} diff --git a/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out new file mode 100644 index 00000000000..947d3ab4470 --- /dev/null +++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke6.out @@ -0,0 +1,3 @@ +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.6 +2 errors diff --git a/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out new file mode 100644 index 00000000000..1a2f58db856 --- /dev/null +++ b/langtools/test/tools/javac/defaultMethods/static/StaticInvoke7.out @@ -0,0 +1,3 @@ +StaticInvoke.java:12:15: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 +StaticInvoke.java:13:32: compiler.err.static.intf.method.invoke.not.supported.in.source: 1.7 +2 errors From 5fad815dec3613d1aa56007ac89ad884e809cfff Mon Sep 17 00:00:00 2001 From: Robert Field Date: Fri, 20 Jun 2014 10:56:47 -0700 Subject: [PATCH 098/236] 8046060: Different results of floating point multiplication for lambda code block Propogate strictfp into lambda body Reviewed-by: vromero, jlahoda --- .../sun/tools/javac/comp/LambdaToMethod.java | 4 + .../javac/lambda/LambdaTestStrictFP.java | 70 +++++++++++++++++ .../javac/lambda/LambdaTestStrictFPFlag.java | 76 +++++++++++++++++++ .../lambda/LambdaTestStrictFPMethod.java | 65 ++++++++++++++++ 4 files changed, 215 insertions(+) create mode 100644 langtools/test/tools/javac/lambda/LambdaTestStrictFP.java create mode 100644 langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java create mode 100644 langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java index d4680eb9ff5..1431b531324 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java @@ -1992,7 +1992,11 @@ public class LambdaToMethod extends TreeTranslator { // If instance access isn't needed, make it static. // Interface instance methods must be default methods. // Lambda methods are private synthetic. + // Inherit ACC_STRICT from the enclosing method, or, for clinit, + // from the class. translatedSym.flags_field = SYNTHETIC | LAMBDA_METHOD | + owner.flags_field & STRICTFP | + owner.owner.flags_field & STRICTFP | PRIVATE | (thisReferenced? (inInterface? DEFAULT : 0) : STATIC); diff --git a/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java b/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java new file mode 100644 index 00000000000..67e247e4224 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFP.java @@ -0,0 +1,70 @@ +/* + * 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 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +strictfp +public class LambdaTestStrictFP { + + static double fld = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + + public static void main(String args[]) { + double result = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + double z = x * y; + check(z, result, "method"); + check(z, fld, "field"); + } + } + + private static void check(double expected, double got, String where) { + if (got != expected) { + throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); + } + } + + private static double eval(Face arg) { + return arg.m(); + } + + private interface Face { + double m(); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java b/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java new file mode 100644 index 00000000000..dc1cccd608c --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFPFlag.java @@ -0,0 +1,76 @@ +/* + * 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 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +import java.io.*; +import java.net.URL; +import com.sun.tools.classfile.*; +import static com.sun.tools.classfile.AccessFlags.ACC_STRICT; + +public class LambdaTestStrictFPFlag { + public static void main(String[] args) throws Exception { + new LambdaTestStrictFPFlag().run(); + } + + void run() throws Exception { + ClassFile cf = getClassFile("LambdaTestStrictFPFlag$Test.class"); + ConstantPool cp = cf.constant_pool; + boolean found = false; + for (Method meth: cf.methods) { + if (meth.getName(cp).startsWith("lambda$")) { + if ((meth.access_flags.flags & ACC_STRICT) == 0) { + throw new Exception("strict flag missing from lambda"); + } + found = true; + } + } + if (!found) { + throw new Exception("did not find lambda method"); + } + } + + ClassFile getClassFile(String name) throws IOException, ConstantPoolException { + URL url = getClass().getResource(name); + InputStream in = url.openStream(); + try { + return ClassFile.read(in); + } finally { + in.close(); + } + } + + class Test { + strictfp void test() { + Face itf = () -> { }; + } + } + + interface Face { + void m(); + } +} diff --git a/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java b/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java new file mode 100644 index 00000000000..e8a03ebcbe4 --- /dev/null +++ b/langtools/test/tools/javac/lambda/LambdaTestStrictFPMethod.java @@ -0,0 +1,65 @@ +/* + * 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 8046060 + * @summary Different results of floating point multiplication for lambda code block + */ + +public class LambdaTestStrictFPMethod { + + public static void main(String args[]) { + new LambdaTestStrictFPMethod().test(); + } + + strictfp void test() { + double result = eval(() -> { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + return x * y; + }); + { + double x = Double.longBitsToDouble(0x1e7ee00000000000L); + double y = Double.longBitsToDouble(0x2180101010101010L); + + double z = x * y; + check(z, result, "method"); + } + } + + strictfp void check(double expected, double got, String where) { + if (got != expected) { + throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); + } + } + + static double eval(Face arg) { + return arg.m(); + } + + interface Face { + double m(); + } +} From 6abe4955a6799c8d2492a4daee450d010338658e Mon Sep 17 00:00:00 2001 From: Igor Veresov Date: Fri, 20 Jun 2014 11:25:08 -0700 Subject: [PATCH 099/236] 8047321: Hotspot debug builds with clang are broken Don't use -Og with clang Reviewed-by: twisti --- hotspot/make/bsd/makefiles/gcc.make | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index c96ff2a78b6..8dd2a8dccbf 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -280,7 +280,10 @@ endif # optimization control flags (Used by fastdebug and release variants) OPT_CFLAGS/NOOPT=-O0 -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" +ifeq ($(USE_CLANG), true) + # Clang does not support -Og + OPT_CFLAGS/DEBUG=-O0 +else ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) OPT_CFLAGS/DEBUG=-Og else @@ -443,7 +446,10 @@ ifeq ($(USE_CLANG), true) CFLAGS += -flimit-debug-info endif -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" +ifeq ($(USE_CLANG), true) + # Clang does not support -Og + DEBUG_CFLAGS=-O0 +else ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) DEBUG_CFLAGS=-Og else From 644042fe4a0eaaff0929c9c8715e3aa9339991d9 Mon Sep 17 00:00:00 2001 From: Lev Priima Date: Fri, 20 Jun 2014 22:39:56 +0400 Subject: [PATCH 100/236] 8041794: remove bytecodes_.{cpp,hpp} files Reviewed-by: dholmes, coleenp, twisti, iignatyev --- hotspot/src/cpu/ppc/vm/bytecodes_ppc.cpp | 31 ---------------- hotspot/src/cpu/ppc/vm/bytecodes_ppc.hpp | 31 ---------------- hotspot/src/cpu/sparc/vm/bytecodes_sparc.cpp | 35 ------------------ hotspot/src/cpu/sparc/vm/bytecodes_sparc.hpp | 37 ------------------- hotspot/src/cpu/x86/vm/bytecodes_x86.cpp | 37 ------------------- hotspot/src/cpu/x86/vm/bytecodes_x86.hpp | 30 --------------- hotspot/src/cpu/zero/vm/bytecodes_zero.cpp | 31 ---------------- hotspot/src/cpu/zero/vm/bytecodes_zero.hpp | 31 ---------------- .../src/share/vm/interpreter/bytecodes.cpp | 3 -- .../src/share/vm/interpreter/bytecodes.hpp | 19 ---------- 10 files changed, 285 deletions(-) delete mode 100644 hotspot/src/cpu/ppc/vm/bytecodes_ppc.cpp delete mode 100644 hotspot/src/cpu/ppc/vm/bytecodes_ppc.hpp delete mode 100644 hotspot/src/cpu/sparc/vm/bytecodes_sparc.cpp delete mode 100644 hotspot/src/cpu/sparc/vm/bytecodes_sparc.hpp delete mode 100644 hotspot/src/cpu/x86/vm/bytecodes_x86.cpp delete mode 100644 hotspot/src/cpu/x86/vm/bytecodes_x86.hpp delete mode 100644 hotspot/src/cpu/zero/vm/bytecodes_zero.cpp delete mode 100644 hotspot/src/cpu/zero/vm/bytecodes_zero.hpp diff --git a/hotspot/src/cpu/ppc/vm/bytecodes_ppc.cpp b/hotspot/src/cpu/ppc/vm/bytecodes_ppc.cpp deleted file mode 100644 index 6418951cee6..00000000000 --- a/hotspot/src/cpu/ppc/vm/bytecodes_ppc.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012, 2013 SAP AG. 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 "interpreter/bytecodes.hpp" - -void Bytecodes::pd_initialize() { - // No ppc specific initialization. -} diff --git a/hotspot/src/cpu/ppc/vm/bytecodes_ppc.hpp b/hotspot/src/cpu/ppc/vm/bytecodes_ppc.hpp deleted file mode 100644 index 35fc51147a7..00000000000 --- a/hotspot/src/cpu/ppc/vm/bytecodes_ppc.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012, 2013 SAP AG. 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 CPU_PPC_VM_BYTECODES_PPC_HPP -#define CPU_PPC_VM_BYTECODES_PPC_HPP - -// No ppc64 specific bytecodes - -#endif // CPU_PPC_VM_BYTECODES_PPC_HPP diff --git a/hotspot/src/cpu/sparc/vm/bytecodes_sparc.cpp b/hotspot/src/cpu/sparc/vm/bytecodes_sparc.cpp deleted file mode 100644 index 8874d8ca8cc..00000000000 --- a/hotspot/src/cpu/sparc/vm/bytecodes_sparc.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "interpreter/bytecodes.hpp" - - -void Bytecodes::pd_initialize() { - // (nothing) -} - -Bytecodes::Code Bytecodes::pd_base_code_for(Code code) { - return code; -} diff --git a/hotspot/src/cpu/sparc/vm/bytecodes_sparc.hpp b/hotspot/src/cpu/sparc/vm/bytecodes_sparc.hpp deleted file mode 100644 index f1d08b336ab..00000000000 --- a/hotspot/src/cpu/sparc/vm/bytecodes_sparc.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef CPU_SPARC_VM_BYTECODES_SPARC_HPP -#define CPU_SPARC_VM_BYTECODES_SPARC_HPP - -#ifdef SPARC -#define NLOCALS_IN_REGS 6 -#endif - - -// Sparc specific bytecodes - -// (none) - -#endif // CPU_SPARC_VM_BYTECODES_SPARC_HPP diff --git a/hotspot/src/cpu/x86/vm/bytecodes_x86.cpp b/hotspot/src/cpu/x86/vm/bytecodes_x86.cpp deleted file mode 100644 index 4e6993548c9..00000000000 --- a/hotspot/src/cpu/x86/vm/bytecodes_x86.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "interpreter/bytecodes.hpp" - - -void Bytecodes::pd_initialize() { - // No i486 specific initialization -} - - -Bytecodes::Code Bytecodes::pd_base_code_for(Code code) { - // No i486 specific bytecodes - return code; -} diff --git a/hotspot/src/cpu/x86/vm/bytecodes_x86.hpp b/hotspot/src/cpu/x86/vm/bytecodes_x86.hpp deleted file mode 100644 index e21c16a09ae..00000000000 --- a/hotspot/src/cpu/x86/vm/bytecodes_x86.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef CPU_X86_VM_BYTECODES_X86_HPP -#define CPU_X86_VM_BYTECODES_X86_HPP - -// No i486 specific bytecodes - -#endif // CPU_X86_VM_BYTECODES_X86_HPP diff --git a/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp b/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp deleted file mode 100644 index e3f801f400a..00000000000 --- a/hotspot/src/cpu/zero/vm/bytecodes_zero.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2007 Red Hat, Inc. - * 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 "interpreter/bytecodes.hpp" - -void Bytecodes::pd_initialize() { - // No zero specific initialization -} diff --git a/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp b/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp deleted file mode 100644 index f214bb74512..00000000000 --- a/hotspot/src/cpu/zero/vm/bytecodes_zero.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2009 Red Hat, Inc. - * 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 CPU_ZERO_VM_BYTECODES_ZERO_HPP -#define CPU_ZERO_VM_BYTECODES_ZERO_HPP - -// This file is intentionally empty - -#endif // CPU_ZERO_VM_BYTECODES_ZERO_HPP diff --git a/hotspot/src/share/vm/interpreter/bytecodes.cpp b/hotspot/src/share/vm/interpreter/bytecodes.cpp index 0f78210fcc9..5c26a4a751f 100644 --- a/hotspot/src/share/vm/interpreter/bytecodes.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodes.cpp @@ -541,9 +541,6 @@ void Bytecodes::initialize() { def(_shouldnotreachhere , "_shouldnotreachhere" , "b" , NULL , T_VOID , 0, false); - // platform specific JVM bytecodes - pd_initialize(); - // compare can_trap information for each bytecode with the // can_trap information for the corresponding base bytecode // (if a rewritten bytecode can trap, so must the base bytecode) diff --git a/hotspot/src/share/vm/interpreter/bytecodes.hpp b/hotspot/src/share/vm/interpreter/bytecodes.hpp index 2cb49c98cb1..04a1f564abc 100644 --- a/hotspot/src/share/vm/interpreter/bytecodes.hpp +++ b/hotspot/src/share/vm/interpreter/bytecodes.hpp @@ -287,23 +287,6 @@ class Bytecodes: AllStatic { _shouldnotreachhere, // For debugging - // Platform specific JVM bytecodes -#ifdef TARGET_ARCH_x86 -# include "bytecodes_x86.hpp" -#endif -#ifdef TARGET_ARCH_sparc -# include "bytecodes_sparc.hpp" -#endif -#ifdef TARGET_ARCH_zero -# include "bytecodes_zero.hpp" -#endif -#ifdef TARGET_ARCH_arm -# include "bytecodes_arm.hpp" -#endif -#ifdef TARGET_ARCH_ppc -# include "bytecodes_ppc.hpp" -#endif - number_of_codes }; @@ -348,8 +331,6 @@ class Bytecodes: AllStatic { static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap); static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap, Code java_code); - static void pd_initialize(); // platform specific initialization - static Code pd_base_code_for(Code code); // platform specific base_code_for implementation // Verify that bcp points into method #ifdef ASSERT From 1ff4245739df46bdc91a965c7a92b47b5706131a Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Fri, 20 Jun 2014 20:36:54 +0100 Subject: [PATCH 101/236] 8044546: Crash on faulty reduce/lambda Co-authored-by: Maurizio Cimadamore Reviewed-by: mcimadamore, dlsmith --- .../com/sun/tools/javac/code/Types.java | 6 +++ .../com/sun/tools/javac/comp/Attr.java | 39 +++++++-------- .../com/sun/tools/javac/comp/Check.java | 4 +- .../com/sun/tools/javac/comp/Infer.java | 5 +- .../com/sun/tools/javac/comp/Resolve.java | 5 +- .../T8044546/CrashImplicitLambdaTest.java | 41 ++++++++++++++++ .../T8044546/NestedInvocationsTest.java | 47 +++++++++++++++++++ 7 files changed, 120 insertions(+), 27 deletions(-) create mode 100644 langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java create mode 100644 langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index 9a52d21ae60..e1831b284db 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2967,6 +2967,12 @@ public class Types { return t; } + @Override + public Type visitUndetVar(UndetVar t, Void ignored) { + //do nothing - we should not replace inside undet variables + return t; + } + @Override public Type visitClassType(ClassType t, Void ignored) { if (!t.isCompound()) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 6c68c5c63f4..fb17574a987 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -249,36 +249,30 @@ public class Attr extends JCTree.Visitor { */ Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) { InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); - Type owntype = found; - if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { - if (allowPoly && inferenceContext.free(found)) { - if ((ownkind & ~resultInfo.pkind) == 0) { - owntype = resultInfo.check(tree, inferenceContext.asUndetVar(owntype)); - } else { - log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); - owntype = types.createErrorType(owntype); - } + Type owntype; + if (!found.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { + if ((ownkind & ~resultInfo.pkind) != 0) { + log.error(tree.pos(), "unexpected.type", + kindNames(resultInfo.pkind), + kindName(ownkind)); + owntype = types.createErrorType(found); + } else if (allowPoly && inferenceContext.free(found)) { + //delay the check if there are inference variables in the found type + //this means we are dealing with a partially inferred poly expression + owntype = resultInfo.pt; inferenceContext.addFreeTypeListener(List.of(found, resultInfo.pt), new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { ResultInfo pendingResult = - resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); + resultInfo.dup(inferenceContext.asInstType(resultInfo.pt)); check(tree, inferenceContext.asInstType(found), ownkind, pendingResult); } }); - return tree.type = resultInfo.pt; } else { - if ((ownkind & ~resultInfo.pkind) == 0) { - owntype = resultInfo.check(tree, owntype); - } else { - log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); - owntype = types.createErrorType(owntype); - } + owntype = resultInfo.check(tree, found); } + } else { + owntype = found; } tree.type = owntype; return owntype; @@ -2472,6 +2466,7 @@ public class Attr extends JCTree.Visitor { currentTarget = infer.instantiateFunctionalInterface(that, currentTarget, explicitParamTypes, resultInfo.checkContext); } + currentTarget = types.removeWildcards(currentTarget); lambdaType = types.findDescriptorType(currentTarget); } else { currentTarget = Type.recoveryType; @@ -2894,7 +2889,7 @@ public class Attr extends JCTree.Visitor { resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.CHECK && isSerializable(currentTarget); if (currentTarget != Type.recoveryType) { - currentTarget = targetChecker.visit(currentTarget, that); + currentTarget = types.removeWildcards(targetChecker.visit(currentTarget, that)); desc = types.findDescriptorType(currentTarget); } else { currentTarget = Type.recoveryType; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index cefcfa4af56..139be89d75e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -534,8 +534,8 @@ public class Check { Type checkType(final DiagnosticPosition pos, final Type found, final Type req, final CheckContext checkContext) { final Infer.InferenceContext inferenceContext = checkContext.inferenceContext(); - if (inferenceContext.free(req)) { - inferenceContext.addFreeTypeListener(List.of(req), new FreeTypeListener() { + if (inferenceContext.free(req) || inferenceContext.free(found)) { + inferenceContext.addFreeTypeListener(List.of(req, found), new FreeTypeListener() { @Override public void typesInferred(InferenceContext inferenceContext) { checkType(pos, inferenceContext.asInstType(found), inferenceContext.asInstType(req), checkContext); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java index d554e0e2cc9..8ad5c17fbd4 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java @@ -354,6 +354,7 @@ public class Infer { Type to, Attr.ResultInfo resultInfo, InferenceContext inferenceContext) { inferenceContext.solve(List.of(from.qtype), new Warner()); + inferenceContext.notifyChange(); Type capturedType = resultInfo.checkContext.inferenceContext() .cachedCapture(tree, from.inst, false); if (types.isConvertible(capturedType, @@ -450,7 +451,7 @@ public class Infer { class ImplicitArgType extends DeferredAttr.DeferredTypeMap { public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) { - rs.deferredAttr.super(AttrMode.SPECULATIVE, msym, phase); + (rs.deferredAttr).super(AttrMode.SPECULATIVE, msym, phase); } public Type apply(Type t) { @@ -518,6 +519,8 @@ public class Infer { //or if it's not a subtype of the original target, issue an error checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); } + //propagate constraints as per JLS 18.2.1 + checkContext.compatible(owntype, funcInterface, types.noWarnings); return owntype; } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index f8ab3109450..40dfa0696dd 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -958,9 +958,10 @@ public class Resolve { } public boolean compatible(Type found, Type req, Warner warn) { + InferenceContext inferenceContext = deferredAttrContext.inferenceContext; return strict ? - types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn) : - types.isConvertible(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn); + types.isSubtypeUnchecked(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn) : + types.isConvertible(inferenceContext.asUndetVar(found), inferenceContext.asUndetVar(req), warn); } public void report(DiagnosticPosition pos, JCDiagnostic details) { diff --git a/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java b/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java new file mode 100644 index 00000000000..a34b356339b --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/T8044546/CrashImplicitLambdaTest.java @@ -0,0 +1,41 @@ +/* + * 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 8044546 + * @summary Crash on faulty reduce/lambda + * @compile CrashImplicitLambdaTest.java + */ + +abstract class CrashImplicitLambdaTest { + boolean foo() { + return bar(true, a -> {}); + } + + abstract T1 bar(T1 t1, S s); + + interface S { + void baz(S1 s1); + } +} diff --git a/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java b/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java new file mode 100644 index 00000000000..40e5c3df34a --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/T8044546/NestedInvocationsTest.java @@ -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 8044546 + * @summary Crash on faulty reduce/lambda + * @compile NestedInvocationsTest.java + */ + +class NestedInvocationsTest { + boolean foo(I i) { + return baz(zas(i)); + } + + J zas(I i) { + return null; + } + + R baz(J j) { + return null; + } + + interface I {} + + interface J {} +} From ae6f87cc246ddec5a2471bd2410db7b2b5db61a2 Mon Sep 17 00:00:00 2001 From: Sonali Goel Date: Fri, 20 Jun 2014 13:26:24 -0700 Subject: [PATCH 102/236] 8047300: update tools/javadoc/6227454 test for missing tags Reviewed-by: jjg, ksrini --- .../test/tools/javadoc/6227454/Test.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/langtools/test/tools/javadoc/6227454/Test.java b/langtools/test/tools/javadoc/6227454/Test.java index e42c301b6d7..89c02a89dda 100644 --- a/langtools/test/tools/javadoc/6227454/Test.java +++ b/langtools/test/tools/javadoc/6227454/Test.java @@ -38,15 +38,17 @@ public class Test extends Doclet { } void run() throws Exception { - test("ABC XYZ"); - test("ABC XYZ"); - test("ABC XYZ"); - test("ABC XYZ"); - test("ABC XYZ"); - test(" ABC XYZ", "Body tag missing from HTML"); - test("ABC XYZ ", "Close body tag missing from HTML"); - test(" ABC XYZ ", "Body tag missing from HTML"); - test("ABC" + bigText(8192, 40) + "XYZ"); + String docType = ""; + test(docType+"ABC XYZ"); + test(docType+"ABC XYZ"); + test(docType+"ABC XYZ"); + test(docType+"ABC XYZ"); + test(docType+"ABC XYZ"); + test(docType+" ABC XYZ", "Body tag missing from HTML"); + test(docType+"ABC XYZ ", "Close body tag missing from HTML"); + test(docType+" ABC XYZ ", "Body tag missing from HTML"); + test(docType+"ABC" + bigText(8192, 40) + "XYZ"); if (errors > 0) throw new Exception(errors + " errors occurred"); From 1211cc5dbc6375f060d3925d8b57957a1f456181 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 20 Jun 2014 13:35:56 -0700 Subject: [PATCH 103/236] 8044063: Remove com.sun.java.browser.* from jdk repo Reviewed-by: darcy, alanb --- make/Javadoc.gmk | 2 +- make/common/NON_CORE_PKGS.gmk | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index aebdb21a8b2..bd683578746 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -527,7 +527,7 @@ DOMAPI_WINDOWTITLE := Common DOM API DOMAPI_HEADER := Common DOM API DOMAPI_BOTTOM := $(call CommonTrademarkBottom,$(DOMAPI_FIRST_COPYRIGHT_YEAR)) DOMAPI_GROUPNAME := Packages -DOMAPI_REGEXP := com.sun.java.browser.dom:org.w3c.dom* +DOMAPI_REGEXP := org.w3c.dom* # DOMAPI_PKGS is located in NON_CORE_PKGS.gmk # The index.html, options, and packages files diff --git a/make/common/NON_CORE_PKGS.gmk b/make/common/NON_CORE_PKGS.gmk index 601f5f81f23..ed93fa9e30e 100644 --- a/make/common/NON_CORE_PKGS.gmk +++ b/make/common/NON_CORE_PKGS.gmk @@ -33,8 +33,7 @@ # team when determining which APIs to extract javadoc # comments from. -DOMAPI_PKGS = com.sun.java.browser.dom \ - org.w3c.dom \ +DOMAPI_PKGS = org.w3c.dom \ org.w3c.dom.bootstrap \ org.w3c.dom.ls \ org.w3c.dom.ranges \ From 399ef93b311e99844384d6e3aacd46b65b038a69 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 20 Jun 2014 13:36:10 -0700 Subject: [PATCH 104/236] 8044063: Remove com.sun.java.browser.* from jdk repo Reviewed-by: darcy, alanb --- .../classes/com/sun/tools/javac/resources/legacy.properties | 2 -- .../share/classes/com/sun/tools/javac/sym/CreateSymbols.java | 1 - 2 files changed, 3 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties index 2504451a37e..ee06c764779 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties @@ -102,8 +102,6 @@ com.sun.imageio.plugins.jpeg = tiger legacy com.sun.imageio.plugins.png = tiger legacy com.sun.imageio.plugins.wbmp = tiger legacy com.sun.imageio.spi = tiger legacy -com.sun.java.browser.dom = tiger legacy -com.sun.java.browser.net = tiger legacy com.sun.java.swing = tiger legacy com.sun.java.swing.plaf.gtk = tiger legacy com.sun.java.swing.plaf.gtk.icons = tiger legacy diff --git a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java index c1a45e76e2d..589032f06ae 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java +++ b/langtools/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java @@ -490,7 +490,6 @@ public class CreateSymbols extends AbstractProcessor { "org.xml.sax", "org.xml.sax.ext", "org.xml.sax.helpers", - "com.sun.java.browser.dom", "org.w3c.dom", "org.w3c.dom.bootstrap", "org.w3c.dom.ls", From d9a2dbc73bd574fb1d14b3d7aecbea85adbce339 Mon Sep 17 00:00:00 2001 From: Pavel Chistyakov Date: Sun, 22 Jun 2014 21:23:32 -0400 Subject: [PATCH 105/236] 8044818: [TESTBUG] runtime/CDSCompressedKPtrs/XShareAuto.java fails with RuntimeException 'sharing' found in stderr Reviewed-by: hseigel, lfoltan, coleenp, dholmes --- .../test/runtime/CDSCompressedKPtrs/XShareAuto.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java index 73f0c804312..458a781de80 100644 --- a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java +++ b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java @@ -44,8 +44,16 @@ public class XShareAuto { "-server", "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./sample.jsa", "-version"); output = new OutputAnalyzer(pb.start()); - output.shouldNotContain("sharing"); - output.shouldHaveExitValue(0); + // We asked for server but it could be aliased to something else + if (output.getOutput().contains("Server VM")) { + // In server case we don't expect to see sharing flag + output.shouldNotContain("sharing"); + output.shouldHaveExitValue(0); + } + else { + System.out.println("Skipping test - no Server VM available"); + return; + } pb = ProcessTools.createJavaProcessBuilder( "-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions", From 43d50245b719dd55821e257759eedaeed8dbb3d0 Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Mon, 23 Jun 2014 08:40:31 +0200 Subject: [PATCH 106/236] 8046286: assert: Do not add task if compilation is turned off forever Remove the unnecessary and missleading assert Reviewed-by: iveresov --- hotspot/src/share/vm/compiler/compileBroker.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index ff292fbd747..23351275165 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -589,11 +589,10 @@ void CompileTask::log_task_done(CompileLog* log) { /** - * Add a CompileTask to a CompileQueue + * Add a CompileTask to a CompileQueue. */ void CompileQueue::add(CompileTask* task) { assert(lock()->owned_by_self(), "must own lock"); - assert(!CompileBroker::is_compilation_disabled_forever(), "Do not add task if compilation is turned off forever"); task->set_next(NULL); task->set_prev(NULL); From 7aa808a993ed1d666d4abe759dc33376fcd95edb Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Mon, 23 Jun 2014 10:59:33 +0200 Subject: [PATCH 107/236] 8046905: apply on apply is broken Reviewed-by: hannesw, lagergren --- .../internal/runtime/ScriptFunction.java | 78 +++++++++++++++- .../internal/runtime/ScriptObject.java | 28 +++--- nashorn/test/script/basic/JDK-8046905.js | 91 +++++++++++++++++++ .../test/script/basic/JDK-8046905.js.EXPECTED | 41 +++++++++ nashorn/test/script/basic/JDK-8047057.js | 2 +- 5 files changed, 224 insertions(+), 16 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8046905.js create mode 100644 nashorn/test/script/basic/JDK-8046905.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java index 0d2fcd00a75..ca98f4047b1 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java @@ -35,6 +35,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.invoke.SwitchPoint; +import java.util.Collections; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; @@ -593,6 +594,12 @@ public abstract class ScriptFunction extends ScriptObject { private GuardedInvocation createApplyOrCallCall(final boolean isApply, final CallSiteDescriptor desc, final LinkRequest request, final Object[] args) { final MethodType descType = desc.getMethodType(); final int paramCount = descType.parameterCount(); + if(descType.parameterType(paramCount - 1).isArray()) { + // This is vararg invocation of apply or call. This can normally only happen when we do a recursive + // invocation of createApplyOrCallCall (because we're doing apply-of-apply). In this case, create delegate + // linkage by unpacking the vararg invocation and use pairArguments to introduce the necessary spreader. + return createVarArgApplyOrCallCall(isApply, desc, request, args); + } final boolean passesThis = paramCount > 2; final boolean passesArgs = paramCount > 3; @@ -647,6 +654,7 @@ public abstract class ScriptFunction extends ScriptObject { System.arraycopy(args, 3, tmp, 0, tmp.length); appliedArgs[2] = NativeFunction.toApplyArgs(tmp); } else { + assert !isApply; System.arraycopy(args, 3, appliedArgs, 2, args.length - 3); } } else if (isFailedApplyToCall) { @@ -705,8 +713,7 @@ public abstract class ScriptFunction extends ScriptObject { } final MethodType guardType = guard.type(); - // Original function guard will expect the invoked function in parameter position 0, but we're passing it in - // position 1. + // We need to account for the dropped (apply|call) function argument. guard = MH.dropArguments(guard, 0, descType.parameterType(0)); // Take the "isApplyFunction" guard, and bind it to this function. MethodHandle applyFnGuard = MH.insertArguments(IS_APPLY_FUNCTION, 2, this); @@ -718,7 +725,72 @@ public abstract class ScriptFunction extends ScriptObject { return appliedInvocation.replaceMethods(inv, guard); } - private static MethodHandle bindImplicitThis(final Object fn, final MethodHandle mh) { + /* + * This method is used for linking nested apply. Specialized apply and call linking will create a variable arity + * call site for an apply call; when createApplyOrCallCall sees a linking request for apply or call with + * Nashorn-style variable arity call site (last argument type is Object[]) it'll delegate to this method. + * This method converts the link request from a vararg to a non-vararg one (unpacks the array), then delegates back + * to createApplyOrCallCall (with which it is thus mutually recursive), and adds appropriate argument spreaders to + * invocation and the guard of whatever createApplyOrCallCall returned to adapt it back into a variable arity + * invocation. It basically reduces the problem of vararg call site linking of apply and call back to the (already + * solved by createApplyOrCallCall) non-vararg call site linking. + */ + private GuardedInvocation createVarArgApplyOrCallCall(final boolean isApply, final CallSiteDescriptor desc, + final LinkRequest request, final Object[] args) { + final MethodType descType = desc.getMethodType(); + final int paramCount = descType.parameterCount(); + final Object[] varArgs = (Object[])args[paramCount - 1]; + // -1 'cause we're not passing the vararg array itself + final int copiedArgCount = args.length - 1; + int varArgCount = varArgs.length; + + // Spread arguments for the delegate createApplyOrCallCall invocation. + final Object[] spreadArgs = new Object[copiedArgCount + varArgCount]; + System.arraycopy(args, 0, spreadArgs, 0, copiedArgCount); + System.arraycopy(varArgs, 0, spreadArgs, copiedArgCount, varArgCount); + + // Spread call site descriptor for the delegate createApplyOrCallCall invocation. We drop vararg array and + // replace it with a list of Object.class. + final MethodType spreadType = descType.dropParameterTypes(paramCount - 1, paramCount).appendParameterTypes( + Collections.>nCopies(varArgCount, Object.class)); + final CallSiteDescriptor spreadDesc = desc.changeMethodType(spreadType); + + // Delegate back to createApplyOrCallCall with the spread (that is, reverted to non-vararg) request/ + final LinkRequest spreadRequest = request.replaceArguments(spreadDesc, spreadArgs); + final GuardedInvocation spreadInvocation = createApplyOrCallCall(isApply, spreadDesc, spreadRequest, spreadArgs); + + // Add spreader combinators to returned invocation and guard. + return spreadInvocation.replaceMethods( + // Use standard ScriptObject.pairArguments on the invocation + pairArguments(spreadInvocation.getInvocation(), descType), + // Use our specialized spreadGuardArguments on the guard (see below). + spreadGuardArguments(spreadInvocation.getGuard(), descType)); + } + + private static MethodHandle spreadGuardArguments(final MethodHandle guard, final MethodType descType) { + final MethodType guardType = guard.type(); + final int guardParamCount = guardType.parameterCount(); + final int descParamCount = descType.parameterCount(); + final int spreadCount = guardParamCount - descParamCount + 1; + if (spreadCount <= 0) { + // Guard doesn't dip into the varargs + return guard; + } + + final MethodHandle arrayConvertingGuard; + // If the last parameter type of the guard is an array, then it is already itself a guard for a vararg apply + // invocation. We must filter the last argument with toApplyArgs otherwise deeper levels of nesting will fail + // with ClassCastException of NativeArray to Object[]. + if(guardType.parameterType(guardParamCount - 1).isArray()) { + arrayConvertingGuard = MH.filterArguments(guard, guardParamCount - 1, NativeFunction.TO_APPLY_ARGS); + } else { + arrayConvertingGuard = guard; + } + + return ScriptObject.adaptHandleToVarArgCallSite(arrayConvertingGuard, descParamCount); + } + + private static MethodHandle bindImplicitThis(final Object fn, final MethodHandle mh) { final MethodHandle bound; if(fn instanceof ScriptFunction && ((ScriptFunction)fn).needsWrappedThis()) { bound = MH.filterArguments(mh, 1, SCRIPTFUNCTION_GLOBALFILTER); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 1e095d45905..90003b38f67 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -2499,18 +2499,7 @@ public abstract class ScriptObject implements PropertyAccess { } if (isCallerVarArg) { - final int spreadArgs = parameterCount - callCount + 1; - return MH.filterArguments( - MH.asSpreader( - methodHandle, - Object[].class, - spreadArgs), - callCount - 1, - MH.insertArguments( - TRUNCATINGFILTER, - 0, - spreadArgs) - ); + return adaptHandleToVarArgCallSite(methodHandle, callCount); } if (callCount < parameterCount) { @@ -2541,6 +2530,21 @@ public abstract class ScriptObject implements PropertyAccess { return methodHandle; } + static MethodHandle adaptHandleToVarArgCallSite(final MethodHandle mh, final int callSiteParamCount) { + final int spreadArgs = mh.type().parameterCount() - callSiteParamCount + 1; + return MH.filterArguments( + MH.asSpreader( + mh, + Object[].class, + spreadArgs), + callSiteParamCount - 1, + MH.insertArguments( + TRUNCATINGFILTER, + 0, + spreadArgs) + ); + } + @SuppressWarnings("unused") private static Object[] truncatingFilter(final int n, final Object[] array) { final int length = array == null ? 0 : array.length; diff --git a/nashorn/test/script/basic/JDK-8046905.js b/nashorn/test/script/basic/JDK-8046905.js new file mode 100644 index 00000000000..231e2a1d803 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8046905.js @@ -0,0 +1,91 @@ +/* + * 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 + * 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. + */ + +/** + * JDK-8046905: apply on apply is broken + * + * @test + * @run + */ + +var apply = Function.prototype.apply; +var call = Function.prototype.call; +var sort = Array.prototype.sort; +var join = Array.prototype.join; + +// Running three times so that we test an already linked call site too: +// i==0: linking initially with assumed optimistic returned type int. +// i==1: linking after deoptimization with returned type Object. +// i==2: re-running code linked in previous iteration. This will +// properly exercise the guards too. +print("1 level of apply") +for(i = 0; i < 3; ++i) { + print(sort.apply([4,3,2,1])) +} +print("2 levels of apply") +for(i = 0; i < 3; ++i) { + print(apply.apply(sort,[[4,3,2,1]])) +} +print("3 levels of apply") +for(i = 0; i < 3; ++i) { + print(apply.apply(apply,[sort,[[4,3,2,1]]])) +} +print("4 levels of apply") +for(i = 0; i < 3; ++i) { + print(apply.apply(apply,[apply,[sort,[[4,3,2,1]]]])) +} +print("5 levels of apply") +for(i = 0; i < 3; ++i) { + print(apply.apply(apply,[apply,[apply,[sort,[[4,3,2,1]]]]])) +} +print("Many levels of apply!") +for(i = 0; i < 3; ++i) { + print(apply.apply(apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[apply,[sort,[[4,3,2,1]]]]]]]]]]]]]]]]]]]]]])) +} + +print("different invocations that'll trigger relinking") +var invocation = [sort,[[4,3,2,1]]]; +for(i = 0; i < 4; ++i) { + print(apply.apply(apply,[apply,invocation])) + // First change after i==1, so it relinks an otherwise stable linkage + if(i == 1) { + invocation = [sort,[[8,7,6,5]]]; + } else if(i == 2) { + invocation = [join,[[8,7,6,5],["-"]]]; + } +} + +print("Many levels of call!") +for(i = 0; i < 3; ++i) { + print(call.call(call,call,call,call,call,call,call,call,call,call,call,call,call,call,call,call,call,call,call,call,sort,[4,3,2,1])) +} + +print("call apply call apply call... a lot"); +for(i = 0; i < 3; ++i) { + print(apply.call(call, apply, [call, apply, [call, apply, [call, apply, [call, apply, [call, apply, [sort, [4,3,2,1]]]]]]])) +} + +print("apply call apply call apply... a lot"); +for(i = 0; i < 3; ++i) { + print(call.apply(apply, [call, apply, [call, apply, [call, apply, [call, apply, [call, apply, [call, apply, [call, sort, [[4,3,2,1]]]]]]]]])) +} diff --git a/nashorn/test/script/basic/JDK-8046905.js.EXPECTED b/nashorn/test/script/basic/JDK-8046905.js.EXPECTED new file mode 100644 index 00000000000..0cee6789f61 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8046905.js.EXPECTED @@ -0,0 +1,41 @@ +1 level of apply +1,2,3,4 +1,2,3,4 +1,2,3,4 +2 levels of apply +1,2,3,4 +1,2,3,4 +1,2,3,4 +3 levels of apply +1,2,3,4 +1,2,3,4 +1,2,3,4 +4 levels of apply +1,2,3,4 +1,2,3,4 +1,2,3,4 +5 levels of apply +1,2,3,4 +1,2,3,4 +1,2,3,4 +Many levels of apply! +1,2,3,4 +1,2,3,4 +1,2,3,4 +different invocations that'll trigger relinking +1,2,3,4 +1,2,3,4 +5,6,7,8 +8-7-6-5 +Many levels of call! +1,2,3,4 +1,2,3,4 +1,2,3,4 +call apply call apply call... a lot +1,2,3,4 +1,2,3,4 +1,2,3,4 +apply call apply call apply... a lot +1,2,3,4 +1,2,3,4 +1,2,3,4 diff --git a/nashorn/test/script/basic/JDK-8047057.js b/nashorn/test/script/basic/JDK-8047057.js index 3ce588bfe6f..84183f19059 100644 --- a/nashorn/test/script/basic/JDK-8047057.js +++ b/nashorn/test/script/basic/JDK-8047057.js @@ -67,7 +67,7 @@ makeFuncExpectError("eval(\"x4\", x3);", ReferenceError); makeFuncAndCall("with({5.0000000000000000000000: String()}){(false); }"); makeFuncAndCall("try { var x = undefined, x = 5.0000000000000000000000; } catch(x) { x = undefined; }"); makeFuncAndCall("(function (x){ x %= this}(false))"); -// makeFuncAndCall("eval.apply.apply(function(){ eval('') })"); +makeFuncAndCall("eval.apply.apply(function(){ eval('') })"); makeFuncAndCall("(false % !this) && 0"); makeFuncAndCall("with({8: 'fafafa'.replace()}){ }"); makeFuncAndCall("(function (x) '' )(true)"); From 5507f2b47621a9c6521f28f5850d9b299c474c95 Mon Sep 17 00:00:00 2001 From: Frederic Parain Date: Mon, 23 Jun 2014 06:58:26 -0700 Subject: [PATCH 108/236] 8043630: Method os::yield_all() should be removed Reviewed-by: dholmes, dsimms --- hotspot/src/os/aix/vm/os_aix.cpp | 11 ++--------- hotspot/src/os/bsd/vm/os_bsd.cpp | 7 ------- hotspot/src/os/linux/vm/os_linux.cpp | 7 ------- hotspot/src/os/solaris/vm/os_solaris.cpp | 5 ----- hotspot/src/os/windows/vm/os_windows.cpp | 5 ----- hotspot/src/share/vm/prims/jni.cpp | 8 +------- hotspot/src/share/vm/runtime/os.hpp | 2 -- hotspot/src/share/vm/runtime/safepoint.cpp | 8 +++----- hotspot/src/share/vm/services/memTracker.hpp | 14 +++----------- 9 files changed, 9 insertions(+), 58 deletions(-) diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index e9d57c580ce..5c841ea87e2 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -2812,13 +2812,6 @@ void os::yield() { os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } -void os::yield_all() { - // Yields to all threads, including threads with lower priorities - // Threads on Linux are all with same priority. The Solaris style - // os::yield_all() with nanosleep(1ms) is not necessary. - sched_yield(); -} - //////////////////////////////////////////////////////////////////////////////// // thread priority support @@ -3075,7 +3068,7 @@ static bool do_suspend(OSThread* osthread) { for (int n = 0; !osthread->sr.is_suspended(); n++) { for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) { - os::yield_all(); + os::yield(); } // timeout, try to cancel the request @@ -3109,7 +3102,7 @@ static void do_resume(OSThread* osthread) { if (sr_notify(osthread) == 0) { for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) { for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) { - os::yield_all(); + os::yield(); } } } else { diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 7facffe684d..4618480b54c 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -2600,13 +2600,6 @@ void os::yield() { os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } -void os::yield_all() { - // Yields to all threads, including threads with lower priorities - // Threads on Bsd are all with same priority. The Solaris style - // os::yield_all() with nanosleep(1ms) is not necessary. - sched_yield(); -} - //////////////////////////////////////////////////////////////////////////////// // thread priority support diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 7057bcd557b..78dc5963a97 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -3795,13 +3795,6 @@ void os::yield() { os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; } -void os::yield_all() { - // Yields to all threads, including threads with lower priorities - // Threads on Linux are all with same priority. The Solaris style - // os::yield_all() with nanosleep(1ms) is not necessary. - sched_yield(); -} - //////////////////////////////////////////////////////////////////////////////// // thread priority support diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 77cc8abb192..4633329025f 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -3186,11 +3186,6 @@ void os::yield() { os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; } -void os::yield_all() { - // Yields to all threads, including threads with lower priorities - os::sleep(Thread::current(), 1, false); -} - // Interface for setting lwp priorities. If we are using T2 libthread, // which forces the use of BoundThreads or we manually set UseBoundThreads, // all of our threads will be assigned to real lwp's. Using the thr_setprio diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index e3ca08a747e..21711023f67 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3526,11 +3526,6 @@ os::YieldResult os::NakedYield() { void os::yield() { os::NakedYield(); } -void os::yield_all() { - // Yields to all threads, including threads with lower priorities - Sleep(1); -} - // Win32 only gives you access to seven real priorities at a time, // so we compress Java's ten down to seven. It would be better // if we dynamically adjusted relative priorities. diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index cdb53afe1b7..151f8b214d5 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -3336,13 +3336,7 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { directBufferSupportInitializeEnded = 1; } else { while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) { - // Set state as yield_all can call os:sleep. On Solaris, yield_all calls - // os::sleep which requires the VM state transition. On other platforms, it - // is not necessary. The following call to change the VM state is purposely - // put inside the loop to avoid potential deadlock when multiple threads - // try to call this method. See 6791815 for more details. - ThreadInVMfromNative tivn(thread); - os::yield_all(); + os::yield(); } } diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index c0c81a1f2ad..ddac934e79e 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -453,8 +453,6 @@ class os: AllStatic { // yield that can be used in lieu of blocking. } ; static YieldResult NakedYield () ; - static void yield_all(); // Yields to all other threads including lower priority - // (for the default scheduling policy) static OSReturn set_priority(Thread* thread, ThreadPriority priority); static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority); diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index ff919d607db..d05fcb5ee7f 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -264,8 +264,8 @@ void SafepointSynchronize::begin() { // // Further complicating matters is that yield() does not work as naively expected // on many platforms -- yield() does not guarantee that any other ready threads - // will run. As such we revert yield_all() after some number of iterations. - // Yield_all() is implemented as a short unconditional sleep on some platforms. + // will run. As such we revert to naked_short_sleep() after some number of iterations. + // nakes_short_sleep() is implemented as a short unconditional sleep. // Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping // can actually increase the time it takes the VM thread to detect that a system-wide // stop-the-world safepoint has been reached. In a pathological scenario such as that @@ -322,9 +322,7 @@ void SafepointSynchronize::begin() { if (steps < DeferThrSuspendLoopCount) { os::NakedYield() ; } else { - os::yield_all() ; - // Alternately, the VM thread could transiently depress its scheduling priority or - // transiently increase the priority of the tardy mutator(s). + os::naked_short_sleep(1); } iterations ++ ; diff --git a/hotspot/src/share/vm/services/memTracker.hpp b/hotspot/src/share/vm/services/memTracker.hpp index 1072e5d6a3d..52715a68764 100644 --- a/hotspot/src/share/vm/services/memTracker.hpp +++ b/hotspot/src/share/vm/services/memTracker.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -481,17 +481,9 @@ class MemTracker : AllStatic { if (_slowdown_calling_thread && thr != _worker_thread) { #ifdef _WINDOWS // On Windows, os::NakedYield() does not work as well - // as os::yield_all() - os::yield_all(); + // as short sleep. + os::naked_short_sleep(1); #else - // On Solaris, os::yield_all() depends on os::sleep() - // which requires JavaTherad in _thread_in_vm state. - // Transits thread to _thread_in_vm state can be dangerous - // if caller holds lock, as it may deadlock with Threads_lock. - // So use NaKedYield instead. - // - // Linux and BSD, NakedYield() and yield_all() implementations - // are the same. os::NakedYield(); #endif } From d0e17d1ff09a8e123258d81bf503f6478ebf9aee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Lid=C3=A9n?= Date: Mon, 23 Jun 2014 16:43:41 +0200 Subject: [PATCH 109/236] 8046231: G1: Code root location ... from nmethod ... not in strong code roots for region Reviewed-by: tschatzl, ehelin --- hotspot/src/share/vm/code/nmethod.cpp | 18 ++++++++++++------ .../gc_implementation/g1/g1CollectedHeap.cpp | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 40ca55a9b96..ac141eac3e1 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -669,8 +669,10 @@ nmethod::nmethod( _hotness_counter = NMethodSweeper::hotness_counter_reset_val(); code_buffer->copy_values_to(this); - if (ScavengeRootsInCode && detect_scavenge_root_oops()) { - CodeCache::add_scavenge_root_nmethod(this); + if (ScavengeRootsInCode) { + if (detect_scavenge_root_oops()) { + CodeCache::add_scavenge_root_nmethod(this); + } Universe::heap()->register_nmethod(this); } debug_only(verify_scavenge_root_oops()); @@ -754,8 +756,10 @@ nmethod::nmethod( _hotness_counter = NMethodSweeper::hotness_counter_reset_val(); code_buffer->copy_values_to(this); - if (ScavengeRootsInCode && detect_scavenge_root_oops()) { - CodeCache::add_scavenge_root_nmethod(this); + if (ScavengeRootsInCode) { + if (detect_scavenge_root_oops()) { + CodeCache::add_scavenge_root_nmethod(this); + } Universe::heap()->register_nmethod(this); } DEBUG_ONLY(verify_scavenge_root_oops();) @@ -870,8 +874,10 @@ nmethod::nmethod( code_buffer->copy_values_to(this); debug_info->copy_to(this); dependencies->copy_to(this); - if (ScavengeRootsInCode && detect_scavenge_root_oops()) { - CodeCache::add_scavenge_root_nmethod(this); + if (ScavengeRootsInCode) { + if (detect_scavenge_root_oops()) { + CodeCache::add_scavenge_root_nmethod(this); + } Universe::heap()->register_nmethod(this); } debug_only(verify_scavenge_root_oops()); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 770060cb808..012d851d97e 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -6995,7 +6995,7 @@ public: return; } - if (ScavengeRootsInCode && nm->detect_scavenge_root_oops()) { + if (ScavengeRootsInCode) { _g1h->register_nmethod(nm); } } From 90b667d86525815976d58be88ea5e0fa74cacac5 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 23 Jun 2014 21:23:53 +0530 Subject: [PATCH 110/236] 8047728: (function(x){var o={x:0}; with(o){delete x} return o.x})() evaluates to 0 instead of undefined Reviewed-by: jlaskey, hannesw, attila --- nashorn/bin/jjsdebug.sh | 25 +++++++++ nashorn/make/nbproject/ide-targets.xml | 2 +- .../internal/codegen/AssignSymbols.java | 2 +- .../codegen/LocalVariableTypesCalculator.java | 6 ++- nashorn/test/script/basic/JDK-8047728.js | 54 +++++++++++++++++++ 5 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 nashorn/bin/jjsdebug.sh create mode 100644 nashorn/test/script/basic/JDK-8047728.js diff --git a/nashorn/bin/jjsdebug.sh b/nashorn/bin/jjsdebug.sh new file mode 100644 index 00000000000..509700c39bf --- /dev/null +++ b/nashorn/bin/jjsdebug.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# 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. +# + +$JAVA_HOME/bin/jjs -J-Djava.ext.dirs=`dirname $0`/../dist -J-agentlib:jdwp=transport=dt_socket,address=localhost:9009,server=y,suspend=y $* diff --git a/nashorn/make/nbproject/ide-targets.xml b/nashorn/make/nbproject/ide-targets.xml index a592cff6a07..d1e8135f101 100644 --- a/nashorn/make/nbproject/ide-targets.xml +++ b/nashorn/make/nbproject/ide-targets.xml @@ -34,7 +34,7 @@ - + diff --git a/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java b/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java index 4a817fae3db..65e65c785a1 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java @@ -702,7 +702,7 @@ final class AssignSymbols extends NodeOperatorVisitor implements // If this is a declared variable or a function parameter, delete always fails (except for globals). final String name = ident.getName(); final Symbol symbol = ident.getSymbol(); - final boolean failDelete = strictMode || symbol.isParam() || (symbol.isVar() && !symbol.isProgramLevel()); + final boolean failDelete = strictMode || (!symbol.isScope() && (symbol.isParam() || (symbol.isVar() && !symbol.isProgramLevel()))); if (failDelete && symbol.isThis()) { return LiteralNode.newInstance(unaryNode, true).accept(this); diff --git a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java index 7112a53eb76..5ffe4b7f66b 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java @@ -583,7 +583,11 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ } } setCompilerConstantAsObject(functionNode, CompilerConstants.THIS); - if(functionNode.needsParentScope()) { + + // NOTE: coarse-grained. If we wanted to solve it completely precisely, + // we'd also need to push/pop its type when handling WithNode (so that + // it can go back to undefined after a 'with' block. + if(functionNode.hasScopeBlock() || functionNode.needsParentScope()) { setCompilerConstantAsObject(functionNode, CompilerConstants.SCOPE); } if(functionNode.needsCallee()) { diff --git a/nashorn/test/script/basic/JDK-8047728.js b/nashorn/test/script/basic/JDK-8047728.js new file mode 100644 index 00000000000..ba36ccd5058 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047728.js @@ -0,0 +1,54 @@ +/* + * 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. + */ + +/** + * JDK-8047728: (function(x){var o={x:0}; with(o){delete x} return o.x})() evaluates to 0 instead of undefined + * + * @test + * @run + */ + +function func(x) { + var o = {x:0}; + with(o){ + delete x; + } + return o.x +} + +if (typeof func() != 'undefined') { + fail("expected undefined from 'func' call"); +} + +function func2() { + var x; + var o = {x:0}; + with(o){ + delete x; + } + return o.x +} + +if (typeof func2() != 'undefined') { + fail("expected undefined from 'func2' call"); +} From 3ad3dd1d894c690a425e04c2499ecb6618e2c625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 23 Jun 2014 18:32:11 +0200 Subject: [PATCH 111/236] 8046201: Avoid repeated flattening of nested ConsStrings Reviewed-by: lagergren, attila --- .../nashorn/internal/runtime/ConsString.java | 43 ++++-- .../internal/runtime/ConsStringTest.java | 135 ++++++++++++++++++ 2 files changed, 166 insertions(+), 12 deletions(-) create mode 100644 nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java b/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java index 8f764f4bdda..41e2c49e938 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java @@ -36,8 +36,12 @@ import java.util.Deque; public final class ConsString implements CharSequence { private CharSequence left, right; - final private int length; - private boolean flat = false; + private final int length; + private volatile int state = STATE_NEW; + + private final static int STATE_NEW = 0; + private final static int STATE_THRESHOLD = 2; + private final static int STATE_FLATTENED = -1; /** * Constructor @@ -57,7 +61,7 @@ public final class ConsString implements CharSequence { @Override public String toString() { - return (String) flattened(); + return (String) flattened(true); } @Override @@ -67,22 +71,31 @@ public final class ConsString implements CharSequence { @Override public char charAt(final int index) { - return flattened().charAt(index); + return flattened(true).charAt(index); } @Override public CharSequence subSequence(final int start, final int end) { - return flattened().subSequence(start, end); + return flattened(true).subSequence(start, end); } - private CharSequence flattened() { - if (!flat) { - flatten(); + /** + * Returns the components of this ConsString as a {@code CharSequence} array with two elements. + * The elements will be either {@code Strings} or other {@code ConsStrings}. + * @return CharSequence array of length 2 + */ + public synchronized CharSequence[] getComponents() { + return new CharSequence[] { left, right }; + } + + private CharSequence flattened(boolean flattenNested) { + if (state != STATE_FLATTENED) { + flatten(flattenNested); } return left; } - private void flatten() { + private synchronized void flatten(boolean flattenNested) { // We use iterative traversal as recursion may exceed the stack size limit. final char[] chars = new char[length]; int pos = length; @@ -97,8 +110,14 @@ public final class ConsString implements CharSequence { do { if (cs instanceof ConsString) { final ConsString cons = (ConsString) cs; - stack.addFirst(cons.left); - cs = cons.right; + // Count the times a cons-string is traversed as part of other cons-strings being flattened. + // If it crosses a threshold we flatten the nested cons-string internally. + if (cons.state == STATE_FLATTENED || (flattenNested && ++cons.state >= STATE_THRESHOLD)) { + cs = cons.flattened(false); + } else { + stack.addFirst(cons.left); + cs = cons.right; + } } else { final String str = (String) cs; pos -= str.length(); @@ -109,7 +128,7 @@ public final class ConsString implements CharSequence { left = new String(chars); right = ""; - flat = true; + state = STATE_FLATTENED; } } diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java new file mode 100644 index 00000000000..9a10ab6d042 --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/ConsStringTest.java @@ -0,0 +1,135 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.runtime; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import jdk.nashorn.internal.runtime.JSType; +import jdk.nashorn.internal.runtime.ScriptRuntime; +import org.testng.annotations.Test; + +/** + * Tests for JSType methods. + * + * @test + * @run testng jdk.nashorn.internal.runtime.ConsStringTest + */ +public class ConsStringTest { + + /** + * Test toString conversion + */ + @Test + public void testConsStringToString() { + final ConsString cs1 = new ConsString("b", "c"); + final ConsString cs2 = new ConsString("d", "e"); + final ConsString cs3 = new ConsString(cs1, cs2); + final ConsString cs4 = new ConsString(cs3, "f"); + final ConsString cs5 = new ConsString("a", cs4); + assertEquals(cs5.toString(), "abcdef"); + assertEquals(cs4.toString(), "bcdef"); + assertEquals(cs3.toString(), "bcde"); + assertEquals(cs2.toString(), "de"); + assertEquals(cs1.toString(), "bc"); + // ConsStrings should be flattened now + assertEquals(cs1.getComponents()[0], "bc"); + assertEquals(cs1.getComponents()[1], ""); + assertEquals(cs2.getComponents()[0], "de"); + assertEquals(cs2.getComponents()[1], ""); + assertEquals(cs3.getComponents()[0], "bcde"); + assertEquals(cs3.getComponents()[1], ""); + assertEquals(cs4.getComponents()[0], "bcdef"); + assertEquals(cs4.getComponents()[1], ""); + assertEquals(cs5.getComponents()[0], "abcdef"); + assertEquals(cs5.getComponents()[1], ""); + } + + /** + * Test charAt + */ + @Test + public void testConsStringCharAt() { + final ConsString cs1 = new ConsString("b", "c"); + final ConsString cs2 = new ConsString("d", "e"); + final ConsString cs3 = new ConsString(cs1, cs2); + final ConsString cs4 = new ConsString(cs3, "f"); + final ConsString cs5 = new ConsString("a", cs4); + assertEquals(cs1.charAt(1), 'c'); + assertEquals(cs2.charAt(0), 'd'); + assertEquals(cs3.charAt(3), 'e'); + assertEquals(cs4.charAt(1), 'c'); + assertEquals(cs5.charAt(2), 'c'); + // ConsStrings should be flattened now + assertEquals(cs1.getComponents()[0], "bc"); + assertEquals(cs1.getComponents()[1], ""); + assertEquals(cs2.getComponents()[0], "de"); + assertEquals(cs2.getComponents()[1], ""); + assertEquals(cs3.getComponents()[0], "bcde"); + assertEquals(cs3.getComponents()[1], ""); + assertEquals(cs4.getComponents()[0], "bcdef"); + assertEquals(cs4.getComponents()[1], ""); + assertEquals(cs5.getComponents()[0], "abcdef"); + assertEquals(cs5.getComponents()[1], ""); + } + + + /** + * Test flattening of top-level and internal ConsStrings + */ + @Test + public void testConsStringFlattening() { + final ConsString cs1 = new ConsString("b", "c"); + final ConsString cs2 = new ConsString("d", "e"); + final ConsString cs3 = new ConsString(cs1, cs2); + final ConsString cs4 = new ConsString(cs3, "f"); + + final ConsString cs5 = new ConsString("a", cs4); + // top-level ConsString should not yet be flattened + assert(cs5.getComponents()[0] == "a"); + assert(cs5.getComponents()[1] == cs4); + assertEquals(cs5.toString(), "abcdef"); + // top-level ConsString should be flattened + assertEquals(cs5.getComponents()[0], "abcdef"); + assertEquals(cs5.getComponents()[1], ""); + // internal ConsString should not yet be flattened after first traversal + assertEquals(cs4.getComponents()[0], cs3); + assertEquals(cs4.getComponents()[1], "f"); + + final ConsString cs6 = new ConsString("a", cs4); + // top-level ConsString should not yet be flattened + assertEquals(cs6.getComponents()[0], "a"); + assertEquals(cs6.getComponents()[1], cs4); + assertEquals(cs6.toString(), "abcdef"); + // top-level ConsString should be flattened + assertEquals(cs6.getComponents()[0], "abcdef"); + assertEquals(cs6.getComponents()[1], ""); + // internal ConsString should have been flattened after second traversal + assertEquals(cs4.getComponents()[0], "bcdef"); + assertEquals(cs4.getComponents()[1], ""); + } +} From 3c72f00dd82c9ef0bc93a4969f46e1fec60d2efa Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 23 Jun 2014 10:36:30 -0700 Subject: [PATCH 112/236] 5077522: Duration.compare incorrect for some values Reviewed-by: lancea, dfuchs --- .../internal/jaxp/datatype/DurationImpl.java | 293 +++++------------- 1 file changed, 74 insertions(+), 219 deletions(-) diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java index da5de3e1ff5..5286934cba4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java @@ -21,6 +21,7 @@ package com.sun.org.apache.xerces.internal.jaxp.datatype; +import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; import java.io.IOException; import java.io.ObjectStreamException; import java.io.Serializable; @@ -30,13 +31,10 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; - import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.Duration; import javax.xml.datatype.XMLGregorianCalendar; -import com.sun.org.apache.xerces.internal.util.DatatypeMessageFormatter; - /** *

Immutable representation of a time span as defined in * the W3C XML Schema 1.0 specification.

@@ -120,28 +118,23 @@ class DurationImpl DatatypeConstants.SECONDS }; - /** - *

Internal array of value Field ids.

- */ - private static final int[] FIELD_IDS = { - DatatypeConstants.YEARS.getId(), - DatatypeConstants.MONTHS.getId(), - DatatypeConstants.DAYS.getId(), - DatatypeConstants.HOURS.getId(), - DatatypeConstants.MINUTES.getId(), - DatatypeConstants.SECONDS.getId() - }; /** * TimeZone for GMT. */ private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); - /** + /** *

BigDecimal value of 0.

*/ private static final BigDecimal ZERO = BigDecimal.valueOf(0); + /** + * BigInteger value of Integer's max value.

+ */ + private static final BigInteger MaxIntAsBigInt = + BigInteger.valueOf((long) Integer.MAX_VALUE); + /** *

Indicates the sign. -1, 0 or 1 if the duration is negative, * zero, or positive.

@@ -195,12 +188,12 @@ class DurationImpl return signum; } - /** - * TODO: Javadoc - * @param isPositive Sign. - * - * @return 1 if positive, else -1. - */ + /** + * Determine the sign of the duration. + * + * @param isPositive Sign. + * @return 1 if positive, -1 negative, or 0 if all fields are zero. + */ protected int calcSignum(boolean isPositive) { if ((years == null || years.signum() == 0) && (months == null || months.signum() == 0) @@ -694,209 +687,71 @@ class DurationImpl XMLGregorianCalendarImpl.parse("1903-07-01T00:00:00Z") }; - /** - *

Partial order relation comparison with this Duration instance.

- * - *

Comparison result must be in accordance with - * W3C XML Schema 1.0 Part 2, Section 3.2.7.6.2, - * Order relation on duration.

- * - *

Return:

- *
    - *
  • {@link DatatypeConstants#LESSER} if this Duration is shorter than duration parameter
  • - *
  • {@link DatatypeConstants#EQUAL} if this Duration is equal to duration parameter
  • - *
  • {@link DatatypeConstants#GREATER} if this Duration is longer than duration parameter
  • - *
  • {@link DatatypeConstants#INDETERMINATE} if a conclusive partial order relation cannot be determined
  • - *
- * - * @param duration to compare - * - * @return the relationship between this Durationand duration parameter as - * {@link DatatypeConstants#LESSER}, {@link DatatypeConstants#EQUAL}, {@link DatatypeConstants#GREATER} - * or {@link DatatypeConstants#INDETERMINATE}. - * - * @throws UnsupportedOperationException If the underlying implementation - * cannot reasonably process the request, e.g. W3C XML Schema allows for - * arbitrarily large/small/precise values, the request may be beyond the - * implementations capability. - * @throws NullPointerException if duration is null. - * - * @see #isShorterThan(Duration) - * @see #isLongerThan(Duration) - */ + /** + *

Partial order relation comparison with this Duration instance.

+ * + *

Comparison result must be in accordance with + * W3C XML Schema 1.0 Part 2, Section 3.2.7.6.2, + * Order relation on duration.

+ * + *

Return:

+ *
    + *
  • {@link DatatypeConstants#LESSER} if this Duration is shorter than duration parameter
  • + *
  • {@link DatatypeConstants#EQUAL} if this Duration is equal to duration parameter
  • + *
  • {@link DatatypeConstants#GREATER} if this Duration is longer than duration parameter
  • + *
  • {@link DatatypeConstants#INDETERMINATE} if a conclusive partial order relation cannot be determined
  • + *
+ * + * @param duration to compare + * + * @return the relationship between this Durationand duration parameter as + * {@link DatatypeConstants#LESSER}, {@link DatatypeConstants#EQUAL}, {@link DatatypeConstants#GREATER} + * or {@link DatatypeConstants#INDETERMINATE}. + * + * @throws UnsupportedOperationException If the underlying implementation + * cannot reasonably process the request, e.g. W3C XML Schema allows for + * arbitrarily large/small/precise values, the request may be beyond the + * implementations capability. + * @throws NullPointerException if duration is null. + * + * @see #isShorterThan(Duration) + * @see #isLongerThan(Duration) + */ public int compare(Duration rhs) { + /** check if any field in the Durations is too large for the operation + * that uses XMLGregorianCalendar for comparison + */ + for (DatatypeConstants.Field field : FIELDS) { + checkMaxValue(getField(field), field); + checkMaxValue(rhs.getField(field), field); + } - BigInteger maxintAsBigInteger = BigInteger.valueOf(Integer.MAX_VALUE); + return compareDates(this, rhs); + } - // check for fields that are too large in this Duration - if (years != null && years.compareTo(maxintAsBigInteger) == 1) { + /** + * Check if a field exceeds the maximum value + * @param field the value of a field + * @param fieldType type of the field, e.g. year, month, day, hour, minute or second. + */ + private void checkMaxValue(Number field, DatatypeConstants.Field fieldType) { + BigInteger fieldValue = null; + if (fieldType != DatatypeConstants.SECONDS) { + fieldValue = (BigInteger) field; + } else { + BigDecimal rhsSecondsAsBigDecimal = (BigDecimal) field; + if ( rhsSecondsAsBigDecimal != null ) { + fieldValue = rhsSecondsAsBigDecimal.toBigInteger(); + } + } + + if (fieldValue != null && fieldValue.compareTo(MaxIntAsBigInt) == 1) { throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.YEARS.toString(), years.toString()}) - //this.getClass().getName() + "#compare(Duration duration)" - //+ " years too large to be supported by this implementation " - //+ years.toString() - ); + DatatypeMessageFormatter.formatMessage(null, "TooLarge", + new Object[]{this.getClass().getName() + "#compare(Duration duration)" + + fieldType, field.toString()}) + ); } - if (months != null && months.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MONTHS.toString(), months.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " months too large to be supported by this implementation " - //+ months.toString() - ); - } - if (days != null && days.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.DAYS.toString(), days.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " days too large to be supported by this implementation " - //+ days.toString() - ); - } - if (hours != null && hours.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.HOURS.toString(), hours.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " hours too large to be supported by this implementation " - //+ hours.toString() - ); - } - if (minutes != null && minutes.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MINUTES.toString(), minutes.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " minutes too large to be supported by this implementation " - //+ minutes.toString() - ); - } - if (seconds != null && seconds.toBigInteger().compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.SECONDS.toString(), toString(seconds)}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " seconds too large to be supported by this implementation " - //+ seconds.toString() - ); - } - - // check for fields that are too large in rhs Duration - BigInteger rhsYears = (BigInteger) rhs.getField(DatatypeConstants.YEARS); - if (rhsYears != null && rhsYears.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.YEARS.toString(), rhsYears.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " years too large to be supported by this implementation " - //+ rhsYears.toString() - ); - } - BigInteger rhsMonths = (BigInteger) rhs.getField(DatatypeConstants.MONTHS); - if (rhsMonths != null && rhsMonths.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MONTHS.toString(), rhsMonths.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " months too large to be supported by this implementation " - //+ rhsMonths.toString() - ); - } - BigInteger rhsDays = (BigInteger) rhs.getField(DatatypeConstants.DAYS); - if (rhsDays != null && rhsDays.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.DAYS.toString(), rhsDays.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " days too large to be supported by this implementation " - //+ rhsDays.toString() - ); - } - BigInteger rhsHours = (BigInteger) rhs.getField(DatatypeConstants.HOURS); - if (rhsHours != null && rhsHours.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.HOURS.toString(), rhsHours.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " hours too large to be supported by this implementation " - //+ rhsHours.toString() - ); - } - BigInteger rhsMinutes = (BigInteger) rhs.getField(DatatypeConstants.MINUTES); - if (rhsMinutes != null && rhsMinutes.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.MINUTES.toString(), rhsMinutes.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " minutes too large to be supported by this implementation " - //+ rhsMinutes.toString() - ); - } - BigDecimal rhsSecondsAsBigDecimal = (BigDecimal) rhs.getField(DatatypeConstants.SECONDS); - BigInteger rhsSeconds = null; - if ( rhsSecondsAsBigDecimal != null ) { - rhsSeconds = rhsSecondsAsBigDecimal.toBigInteger(); - } - if (rhsSeconds != null && rhsSeconds.compareTo(maxintAsBigInteger) == 1) { - throw new UnsupportedOperationException( - DatatypeMessageFormatter.formatMessage(null, "TooLarge", - new Object[]{this.getClass().getName() + "#compare(Duration duration)" + DatatypeConstants.SECONDS.toString(), rhsSeconds.toString()}) - - //this.getClass().getName() + "#compare(Duration duration)" - //+ " seconds too large to be supported by this implementation " - //+ rhsSeconds.toString() - ); - } - - // turn this Duration into a GregorianCalendar - GregorianCalendar lhsCalendar = new GregorianCalendar( - 1970, - 1, - 1, - 0, - 0, - 0); - lhsCalendar.add(GregorianCalendar.YEAR, getYears() * getSign()); - lhsCalendar.add(GregorianCalendar.MONTH, getMonths() * getSign()); - lhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, getDays() * getSign()); - lhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, getHours() * getSign()); - lhsCalendar.add(GregorianCalendar.MINUTE, getMinutes() * getSign()); - lhsCalendar.add(GregorianCalendar.SECOND, getSeconds() * getSign()); - - // turn compare Duration into a GregorianCalendar - GregorianCalendar rhsCalendar = new GregorianCalendar( - 1970, - 1, - 1, - 0, - 0, - 0); - rhsCalendar.add(GregorianCalendar.YEAR, rhs.getYears() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.MONTH, rhs.getMonths() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.DAY_OF_YEAR, rhs.getDays() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.HOUR_OF_DAY, rhs.getHours() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.MINUTE, rhs.getMinutes() * rhs.getSign()); - rhsCalendar.add(GregorianCalendar.SECOND, rhs.getSeconds() * rhs.getSign()); - - - if (lhsCalendar.equals(rhsCalendar)) { - return DatatypeConstants.EQUAL; - } - - return compareDates(this, rhs); } /** From 3761efd83563792605eac2bd8ddfd6dba0f3fc15 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Mon, 23 Jun 2014 14:08:45 -0700 Subject: [PATCH 113/236] 8047763: Recognize sparc64 as a sparc platform Reviewed-by: dholmes --- common/autoconf/generated-configure.sh | 6 +++--- common/autoconf/platform.m4 | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 1a4ad9aef7c..2ec5ac45fb8 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -4311,7 +4311,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1403110135 +DATE_WHEN_GENERATED=1403557683 ############################################################################### # @@ -13610,7 +13610,7 @@ test -n "$target_alias" && VAR_CPU_BITS=32 VAR_CPU_ENDIAN=big ;; - sparcv9) + sparcv9|sparc64) VAR_CPU=sparcv9 VAR_CPU_ARCH=sparc VAR_CPU_BITS=64 @@ -13741,7 +13741,7 @@ $as_echo "$OPENJDK_BUILD_OS-$OPENJDK_BUILD_CPU" >&6; } VAR_CPU_BITS=32 VAR_CPU_ENDIAN=big ;; - sparcv9) + sparcv9|sparc64) VAR_CPU=sparcv9 VAR_CPU_ARCH=sparc VAR_CPU_BITS=64 diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 1f06f0ce7d5..54838a3e72c 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -84,7 +84,7 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU], VAR_CPU_BITS=32 VAR_CPU_ENDIAN=big ;; - sparcv9) + sparcv9|sparc64) VAR_CPU=sparcv9 VAR_CPU_ARCH=sparc VAR_CPU_BITS=64 From 5cfb709349bbc842e2986cd1d0e5c756c11e4d72 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Mon, 23 Jun 2014 14:51:10 -0700 Subject: [PATCH 114/236] 8047878: [TESTBUG] runtime/memory/ReadFromNoaccessArea.java and runtime/memory/ReserveMemory.java time out on Solaris Limited heap size to reduce size of core file generated Reviewed-by: sla, coleenp, dcubed --- hotspot/test/runtime/memory/ReadFromNoaccessArea.java | 1 + hotspot/test/runtime/memory/ReserveMemory.java | 1 + 2 files changed, 2 insertions(+) diff --git a/hotspot/test/runtime/memory/ReadFromNoaccessArea.java b/hotspot/test/runtime/memory/ReadFromNoaccessArea.java index 1078dd2e4ea..484240287ce 100644 --- a/hotspot/test/runtime/memory/ReadFromNoaccessArea.java +++ b/hotspot/test/runtime/memory/ReadFromNoaccessArea.java @@ -47,6 +47,7 @@ public class ReadFromNoaccessArea { "-XX:+WhiteBoxAPI", "-XX:+UseCompressedOops", "-XX:HeapBaseMinAddress=33G", + "-Xmx32m", DummyClassWithMainTryingToReadFromNoaccessArea.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/hotspot/test/runtime/memory/ReserveMemory.java b/hotspot/test/runtime/memory/ReserveMemory.java index 9e37d52ccda..3a65ca605c2 100644 --- a/hotspot/test/runtime/memory/ReserveMemory.java +++ b/hotspot/test/runtime/memory/ReserveMemory.java @@ -57,6 +57,7 @@ public class ReserveMemory { "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", + "-Xmx32m", "ReserveMemory", "test"); From 886066e697fabe1322715911f1047897315db674 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 24 Jun 2014 08:12:30 +0200 Subject: [PATCH 115/236] 8035328: closed/compiler/6595044/Main.java failed with timeout Patch call sites of non-entrant methods to avoid re-resolving if method is still executed. Reviewed-by: twisti, iveresov, roland, kvn --- .../src/share/vm/runtime/sharedRuntime.cpp | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index efd8be473b3..a7883af308c 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1176,10 +1176,7 @@ methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread, (!is_virtual && invoke_code == Bytecodes::_invokedynamic) || ( is_virtual && invoke_code != Bytecodes::_invokestatic ), "inconsistent bytecode"); - // We do not patch the call site if the caller nmethod has been made non-entrant. - if (!caller_nm->is_in_use()) { - return callee_method; - } + assert(caller_nm->is_alive(), "It should be alive"); #ifndef PRODUCT // tracing/debugging/statistics @@ -1249,13 +1246,11 @@ methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread, // Now that we are ready to patch if the Method* was redefined then // don't update call site and let the caller retry. - // Don't update call site if caller nmethod has been made non-entrant - // as it is a waste of time. // Don't update call site if callee nmethod was unloaded or deoptimized. // Don't update call site if callee nmethod was replaced by an other nmethod // which may happen when multiply alive nmethod (tiered compilation) // will be supported. - if (!callee_method->is_old() && caller_nm->is_in_use() && + if (!callee_method->is_old() && (callee_nm == NULL || callee_nm->is_in_use() && (callee_method->code() == callee_nm))) { #ifdef ASSERT // We must not try to patch to jump to an already unloaded method. @@ -1454,14 +1449,12 @@ methodHandle SharedRuntime::handle_ic_miss_helper(JavaThread *thread, TRAPS) { // out of scope. JvmtiDynamicCodeEventCollector event_collector; - // Update inline cache to megamorphic. Skip update if caller has been - // made non-entrant or we are called from interpreted. + // Update inline cache to megamorphic. Skip update if we are called from interpreted. { MutexLocker ml_patch (CompiledIC_lock); RegisterMap reg_map(thread, false); frame caller_frame = thread->last_frame().sender(®_map); CodeBlob* cb = caller_frame.cb(); - if (cb->is_nmethod() && ((nmethod*)cb)->is_in_use()) { - // Not a non-entrant nmethod, so find inline_cache + if (cb->is_nmethod()) { CompiledIC* inline_cache = CompiledIC_before(((nmethod*)cb), caller_frame.pc()); bool should_be_mono = false; if (inline_cache->is_optimized()) { @@ -1604,19 +1597,13 @@ methodHandle SharedRuntime::reresolve_call_site(JavaThread *thread, TRAPS) { // resolve is only done once. MutexLocker ml(CompiledIC_lock); - // - // We do not patch the call site if the nmethod has been made non-entrant - // as it is a waste of time - // - if (caller_nm->is_in_use()) { - if (is_static_call) { - CompiledStaticCall* ssc= compiledStaticCall_at(call_addr); - ssc->set_to_clean(); - } else { - // compiled, dispatched call (which used to call an interpreted method) - CompiledIC* inline_cache = CompiledIC_at(caller_nm, call_addr); - inline_cache->set_to_clean(); - } + if (is_static_call) { + CompiledStaticCall* ssc= compiledStaticCall_at(call_addr); + ssc->set_to_clean(); + } else { + // compiled, dispatched call (which used to call an interpreted method) + CompiledIC* inline_cache = CompiledIC_at(caller_nm, call_addr); + inline_cache->set_to_clean(); } } From 754a598a62e13f797d7b932ce28e6b59f8175809 Mon Sep 17 00:00:00 2001 From: Poonam Bajaj Date: Tue, 24 Jun 2014 02:19:59 -0700 Subject: [PATCH 116/236] 8046282: SA update These changes add some definitions on the SA side and the supporting code on the hotspot side. Reviewed-by: sundar, mgronlun --- .../jvm/hotspot/gc_interface/G1YCType.java | 45 ++++++++++ .../sun/jvm/hotspot/gc_interface/GCCause.java | 69 +++++++++++++++ .../sun/jvm/hotspot/gc_interface/GCName.java | 50 +++++++++++ .../sun/jvm/hotspot/gc_interface/GCWhen.java | 45 ++++++++++ .../hotspot/gc_interface/ReferenceType.java | 45 ++++++++++ .../sun/jvm/hotspot/memory/Universe.java | 18 +++- .../classes/sun/jvm/hotspot/oops/Klass.java | 3 + .../sun/jvm/hotspot/oops/OopUtilities.java | 12 +++ .../jvm/hotspot/opto/CompilerPhaseType.java | 67 +++++++++++++++ .../sun/jvm/hotspot/runtime/Flags.java | 48 +++++++++++ .../sun/jvm/hotspot/runtime/Thread.java | 7 ++ .../sun/jvm/hotspot/runtime/VMOps.java | 86 +++++++++++++++++++ hotspot/make/solaris/makefiles/sa.make | 4 + hotspot/make/windows/makefiles/sa.make | 16 ++++ hotspot/src/share/vm/runtime/vmStructs.cpp | 40 +++++++++ .../src/share/vm/runtime/vmStructs_trace.hpp | 35 ++++++++ 16 files changed, 589 insertions(+), 1 deletion(-) create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/G1YCType.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCCause.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCName.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCWhen.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/ReferenceType.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CompilerPhaseType.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Flags.java create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VMOps.java create mode 100644 hotspot/src/share/vm/runtime/vmStructs_trace.hpp diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/G1YCType.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/G1YCType.java new file mode 100644 index 00000000000..d3d15512b04 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/G1YCType.java @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.gc_interface; + +//These definitions should be kept in sync with the definitions in the HotSpot +//code. + +public enum G1YCType { + Normal ("Normal"), + InitialMark ("Initial Mark"), + DuringMark ("During Mark"), + Mixed ("Mixed"), + G1YCTypeEndSentinel ("Unknown"); + + private final String value; + + G1YCType(String val) { + this.value = val; + } + public String value() { + return value; + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCCause.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCCause.java new file mode 100644 index 00000000000..fc8f251f919 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCCause.java @@ -0,0 +1,69 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.gc_interface; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum GCCause { + _java_lang_system_gc ("System.gc()"), + _full_gc_alot ("FullGCAlot"), + _scavenge_alot ("ScavengeAlot"), + _allocation_profiler ("Allocation Profiler"), + _jvmti_force_gc ("JvmtiEnv ForceGarbageCollection"), + _gc_locker ("GCLocker Initiated GC"), + _heap_inspection ("Heap Inspection Initiated GC"), + _heap_dump ("Heap Dump Initiated GC"), + + _no_gc ("No GC"), + _no_cause_specified ("Unknown GCCause"), + _allocation_failure ("Allocation Failure"), + + _tenured_generation_full ("Tenured Generation Full"), + _metadata_GC_threshold ("Metadata GC Threshold"), + + _cms_generation_full ("CMS Generation Full"), + _cms_initial_mark ("CMS Initial Mark"), + _cms_final_remark ("CMS Final Remark"), + _cms_concurrent_mark ("CMS Concurrent Mark"), + + _old_generation_expanded_on_last_scavenge ("Old Generation Expanded On Last Scavenge"), + _old_generation_too_full_to_scavenge ("Old Generation Too Full To Scavenge"), + _adaptive_size_policy ("Ergonomics"), + + _g1_inc_collection_pause ("G1 Evacuation Pause"), + _g1_humongous_allocation ("G1 Humongous Allocation"), + + _last_ditch_collection ("Last ditch collection"), + _last_gc_cause ("ILLEGAL VALUE - last gc cause - ILLEGAL VALUE"); + + private final String value; + + GCCause(String val) { + this.value = val; + } + public String value() { + return value; + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCName.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCName.java new file mode 100644 index 00000000000..f8985778d35 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCName.java @@ -0,0 +1,50 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.gc_interface; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum GCName { + ParallelOld ("ParallelOld"), + SerialOld ("SerialOld"), + PSMarkSweep ("PSMarkSweep"), + ParallelScavenge ("ParallelScavenge"), + DefNew ("DefNew"), + ParNew ("ParNew"), + G1New ("G1New"), + ConcurrentMarkSweep ("ConcurrentMarkSweep"), + G1Old ("G1Old"), + GCNameEndSentinel ("GCNameEndSentinel"); + + private final String value; + + GCName(String val) { + this.value = val; + } + public String value() { + return value; + } +} + diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCWhen.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCWhen.java new file mode 100644 index 00000000000..74d4a83f744 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/GCWhen.java @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.gc_interface; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum GCWhen { + BeforeGC ("Before GC"), + AfterGC ("After GC"), + GCWhenEndSentinel ("GCWhenEndSentinel"); + + private final String value; + + GCWhen(String val) { + this.value = val; + } + public String value() { + return value; + } +} + + + diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/ReferenceType.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/ReferenceType.java new file mode 100644 index 00000000000..e8bb8bc2119 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_interface/ReferenceType.java @@ -0,0 +1,45 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.gc_interface; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum ReferenceType { + REF_NONE ("None reference"), // Regular class + REF_OTHER ("Other reference"), // Subclass of java/lang/ref/Reference, but not subclass of one of the classes below + REF_SOFT ("Soft reference"), // Subclass of java/lang/ref/SoftReference + REF_WEAK ("Weak reference"), // Subclass of java/lang/ref/WeakReference + REF_FINAL ("Final reference"), // Subclass of java/lang/ref/FinalReference + REF_PHANTOM ("Phantom reference"); // Subclass of java/lang/ref/PhantomReference + + private final String value; + + ReferenceType(String val) { + this.value = val; + } + public String value() { + return value; + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java index c23ce3a4093..a6654340276 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/Universe.java @@ -56,6 +56,12 @@ public class Universe { private static AddressField narrowKlassBaseField; private static CIntegerField narrowKlassShiftField; + public enum NARROW_OOP_MODE { + UnscaledNarrowOop, + ZeroBasedNarrowOop, + HeapBasedNarrowOop + } + static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -94,7 +100,17 @@ public class Universe { public Universe() { } - + public static String narrowOopModeToString(NARROW_OOP_MODE mode) { + switch (mode) { + case UnscaledNarrowOop: + return "32-bits Oops"; + case ZeroBasedNarrowOop: + return "zero based Compressed Oops"; + case HeapBasedNarrowOop: + return "Compressed Oops with base"; + } + return ""; + } public CollectedHeap heap() { try { return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue()); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java index 9e1561bd390..c3f7b8cb88b 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java @@ -55,6 +55,7 @@ public class Klass extends Metadata implements ClassConstants { layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0); name = type.getAddressField("_name"); accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0); + traceIDField = type.getField("_trace_id"); subklass = new MetadataField(type.getAddressField("_subklass"), 0); nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0); @@ -86,6 +87,7 @@ public class Klass extends Metadata implements ClassConstants { private static CIntField accessFlags; private static MetadataField subklass; private static MetadataField nextSibling; + private static sun.jvm.hotspot.types.Field traceIDField; private Address getValue(AddressField field) { return addr.getAddressAt(field.getOffset()); @@ -106,6 +108,7 @@ public class Klass extends Metadata implements ClassConstants { public AccessFlags getAccessFlagsObj(){ return new AccessFlags(getAccessFlags()); } public Klass getSubklassKlass() { return (Klass) subklass.getValue(this); } public Klass getNextSiblingKlass() { return (Klass) nextSibling.getValue(this); } + public long traceID() { return traceIDField.getJLong(addr); } // computed access flags - takes care of inner classes etc. // This is closer to actual source level than getAccessFlags() etc. diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java index a42d8be68b5..fe93d6238a8 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java @@ -54,6 +54,8 @@ public class OopUtilities implements /* imports */ JVMTIThreadState { private static OopField threadNameField; private static OopField threadGroupField; private static LongField threadEETopField; + //tid field is new since 1.5 + private static LongField threadTIDField; // threadStatus field is new since 1.5 private static IntField threadStatusField; // parkBlocker field is new since 1.6 @@ -220,6 +222,7 @@ public class OopUtilities implements /* imports */ JVMTIThreadState { threadNameField = (OopField) k.findField("name", "[C"); threadGroupField = (OopField) k.findField("group", "Ljava/lang/ThreadGroup;"); threadEETopField = (LongField) k.findField("eetop", "J"); + threadTIDField = (LongField) k.findField("tid", "J"); threadStatusField = (IntField) k.findField("threadStatus", "I"); threadParkBlockerField = (OopField) k.findField("parkBlocker", "Ljava/lang/Object;"); @@ -268,6 +271,15 @@ public class OopUtilities implements /* imports */ JVMTIThreadState { return VM.getVM().getThreads().createJavaThreadWrapper(addr); } + public static long threadOopGetTID(Oop threadOop) { + initThreadFields(); + if (threadTIDField != null) { + return threadTIDField.getValue(threadOop); + } else { + return 0; + } + } + /** returns value of java.lang.Thread.threadStatus field */ public static int threadOopGetThreadStatus(Oop threadOop) { initThreadFields(); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CompilerPhaseType.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CompilerPhaseType.java new file mode 100644 index 00000000000..e0eb10942df --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/CompilerPhaseType.java @@ -0,0 +1,67 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.opto; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum CompilerPhaseType { + PHASE_BEFORE_STRINGOPTS ("Before StringOpts"), + PHASE_AFTER_STRINGOPTS ("After StringOpts"), + PHASE_BEFORE_REMOVEUSELESS ("Before RemoveUseless"), + PHASE_AFTER_PARSING ("After Parsing"), + PHASE_ITER_GVN1 ("Iter GVN 1"), + PHASE_PHASEIDEAL_BEFORE_EA ("PhaseIdealLoop before EA"), + PHASE_ITER_GVN_AFTER_EA ("Iter GVN after EA"), + PHASE_ITER_GVN_AFTER_ELIMINATION ("Iter GVN after eliminating allocations and locks"), + PHASE_PHASEIDEALLOOP1 ("PhaseIdealLoop 1"), + PHASE_PHASEIDEALLOOP2 ("PhaseIdealLoop 2"), + PHASE_PHASEIDEALLOOP3 ("PhaseIdealLoop 3"), + PHASE_CPP1 ("PhaseCPP 1"), + PHASE_ITER_GVN2 ("Iter GVN 2"), + PHASE_PHASEIDEALLOOP_ITERATIONS ("PhaseIdealLoop iterations"), + PHASE_OPTIMIZE_FINISHED ("Optimize finished"), + PHASE_GLOBAL_CODE_MOTION ("Global code motion"), + PHASE_FINAL_CODE ("Final Code"), + PHASE_AFTER_EA ("After Escape Analysis"), + PHASE_BEFORE_CLOOPS ("Before CountedLoop"), + PHASE_AFTER_CLOOPS ("After CountedLoop"), + PHASE_BEFORE_BEAUTIFY_LOOPS ("Before beautify loops"), + PHASE_AFTER_BEAUTIFY_LOOPS ("After beautify loops"), + PHASE_BEFORE_MATCHING ("Before Matching"), + PHASE_INCREMENTAL_INLINE ("Incremental Inline"), + PHASE_INCREMENTAL_BOXING_INLINE ("Incremental Boxing Inline"), + PHASE_END ("End"), + PHASE_FAILURE ("Failure"), + PHASE_NUM_TYPES ("Number of Phase Types"); + + private final String value; + + CompilerPhaseType(String val) { + this.value = val; + } + public String value() { + return value; + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Flags.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Flags.java new file mode 100644 index 00000000000..320dda27ee4 --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Flags.java @@ -0,0 +1,48 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.runtime; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum Flags { + // value origin + DEFAULT ("Default"), + COMMAND_LINE ("Command line"), + ENVIRON_VAR ("Environment variable"), + CONFIG_FILE ("Config file"), + MANAGEMENT ("Management"), + ERGONOMIC ("Ergonomic"), + ATTACH_ON_DEMAND ("Attach on demand"), + INTERNAL ("Internal"); + + private final String value; + + Flags(String val) { + this.value = val; + } + public String value() { + return value; + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java index 2948f7b95ca..03c426ba84a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/Thread.java @@ -41,6 +41,8 @@ public class Thread extends VMObject { private static AddressField currentPendingMonitorField; private static AddressField currentWaitingMonitorField; + private static JLongField allocatedBytesField; + static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { @@ -61,6 +63,7 @@ public class Thread extends VMObject { activeHandlesField = type.getAddressField("_active_handles"); currentPendingMonitorField = type.getAddressField("_current_pending_monitor"); currentWaitingMonitorField = type.getAddressField("_current_waiting_monitor"); + allocatedBytesField = type.getJLongField("_allocated_bytes"); } public Thread(Address addr) { @@ -104,6 +107,10 @@ public class Thread extends VMObject { return new JNIHandleBlock(a); } + public long allocatedBytes() { + return allocatedBytesField.getValue(addr); + } + public boolean isVMThread() { return false; } public boolean isJavaThread() { return false; } public boolean isCompilerThread() { return false; } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VMOps.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VMOps.java new file mode 100644 index 00000000000..c2ab69f4b2f --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VMOps.java @@ -0,0 +1,86 @@ +/* + * 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. + * + */ + +package sun.jvm.hotspot.runtime; + +//These definitions should be kept in sync with the definitions in the HotSpot code. + +public enum VMOps { + Dummy, + ThreadStop, + ThreadDump, + PrintThreads, + FindDeadlocks, + ForceSafepoint, + ForceAsyncSafepoint, + Deoptimize, + DeoptimizeFrame, + DeoptimizeAll, + ZombieAll, + UnlinkSymbols, + Verify, + PrintJNI, + HeapDumper, + DeoptimizeTheWorld, + CollectForMetadataAllocation, + GC_HeapInspection, + GenCollectFull, + GenCollectFullConcurrent, + GenCollectForAllocation, + ParallelGCFailedAllocation, + ParallelGCSystemGC, + CGC_Operation, + CMS_Initial_Mark, + CMS_Final_Remark, + G1CollectFull, + G1CollectForAllocation, + G1IncCollectionPause, + EnableBiasedLocking, + RevokeBias, + BulkRevokeBias, + PopulateDumpSharedSpace, + JNIFunctionTableCopier, + RedefineClasses, + GetOwnedMonitorInfo, + GetObjectMonitorUsage, + GetCurrentContendedMonitor, + GetStackTrace, + GetMultipleStackTraces, + GetAllStackTraces, + GetThreadListStackTraces, + GetFrameCount, + GetFrameLocation, + ChangeBreakpoints, + GetOrSetLocal, + GetCurrentLocation, + EnterInterpOnlyMode, + ChangeSingleStep, + HeapWalkOperation, + HeapIterateOperation, + ReportJavaOutOfMemory, + JFRCheckpoint, + Exit, + LinuxDllLoad, + Terminating +} diff --git a/hotspot/make/solaris/makefiles/sa.make b/hotspot/make/solaris/makefiles/sa.make index 2c08b1c5170..546e2630ce4 100644 --- a/hotspot/make/solaris/makefiles/sa.make +++ b/hotspot/make/solaris/makefiles/sa.make @@ -29,8 +29,12 @@ # and generate JNI header file for native methods. include $(GAMMADIR)/make/solaris/makefiles/rules.make +include $(GAMMADIR)/make/defs.make AGENT_DIR = $(GAMMADIR)/agent include $(GAMMADIR)/make/sa.files + +-include $(HS_ALT_MAKE)/solaris/makefiles/sa.make + GENERATED = ../generated # tools.jar is needed by the JDI - SA binding diff --git a/hotspot/make/windows/makefiles/sa.make b/hotspot/make/windows/makefiles/sa.make index 13bb8130ef4..4ac5d89f5fa 100644 --- a/hotspot/make/windows/makefiles/sa.make +++ b/hotspot/make/windows/makefiles/sa.make @@ -38,6 +38,22 @@ checkAndBuildSA:: GENERATED = ../generated +HS_COMMON_SRC_REL = src + +!if "$(OPENJDK)" != "true" +HS_ALT_SRC_REL=src/closed +HS_ALT_SRC = $(WorkSpace)/$(HS_ALT_SRC_REL) +!ifndef HS_ALT_MAKE +HS_ALT_MAKE=$(WorkSpace)/make/closed +!endif +!endif + +HS_COMMON_SRC = $(WorkSpace)/$(HS_COMMON_SRC_REL) + +!ifdef HS_ALT_MAKE +!include $(HS_ALT_MAKE)/windows/makefiles/sa.make +!endif + # tools.jar is needed by the JDI - SA binding SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 1ae7ddf6681..33fe915e7fe 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -104,6 +104,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/hashtable.hpp" #include "utilities/macros.hpp" + #ifdef TARGET_ARCH_x86 # include "vmStructs_x86.hpp" #endif @@ -168,6 +169,11 @@ #include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp" #include "gc_implementation/g1/vmStructs_g1.hpp" #endif // INCLUDE_ALL_GCS + +#if INCLUDE_TRACE + #include "runtime/vmStructs_trace.hpp" +#endif + #ifdef COMPILER2 #include "opto/addnode.hpp" #include "opto/block.hpp" @@ -1390,6 +1396,8 @@ typedef TwoOopHashtable SymbolTwoOopHashtable; /* unsigned short on Win32 */ \ declare_unsigned_integer_type(u1) \ declare_unsigned_integer_type(u2) \ + declare_unsigned_integer_type(u4) \ + declare_unsigned_integer_type(u8) \ declare_unsigned_integer_type(unsigned) \ \ /*****************************/ \ @@ -2923,6 +2931,11 @@ VMStructEntry VMStructs::localHotSpotVMStructs[] = { GENERATE_STATIC_VM_STRUCT_ENTRY) #endif // INCLUDE_ALL_GCS +#if INCLUDE_TRACE + VM_STRUCTS_TRACE(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, + GENERATE_STATIC_VM_STRUCT_ENTRY) +#endif + VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_STATIC_VM_STRUCT_ENTRY, GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY, @@ -2968,6 +2981,11 @@ VMTypeEntry VMStructs::localHotSpotVMTypes[] = { GENERATE_TOPLEVEL_VM_TYPE_ENTRY) #endif // INCLUDE_ALL_GCS +#if INCLUDE_TRACE + VM_TYPES_TRACE(GENERATE_VM_TYPE_ENTRY, + GENERATE_TOPLEVEL_VM_TYPE_ENTRY) +#endif + VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY, GENERATE_TOPLEVEL_VM_TYPE_ENTRY, GENERATE_OOP_VM_TYPE_ENTRY, @@ -3003,6 +3021,10 @@ VMIntConstantEntry VMStructs::localHotSpotVMIntConstants[] = { VM_INT_CONSTANTS_PARNEW(GENERATE_VM_INT_CONSTANT_ENTRY) #endif // INCLUDE_ALL_GCS +#if INCLUDE_TRACE + VM_INT_CONSTANTS_TRACE(GENERATE_VM_INT_CONSTANT_ENTRY) +#endif + VM_INT_CONSTANTS_CPU(GENERATE_VM_INT_CONSTANT_ENTRY, GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY, GENERATE_C1_VM_INT_CONSTANT_ENTRY, @@ -3065,8 +3087,14 @@ VMStructs::init() { VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY, CHECK_STATIC_VM_STRUCT_ENTRY); + #endif // INCLUDE_ALL_GCS +#if INCLUDE_TRACE + VM_STRUCTS_TRACE(CHECK_NONSTATIC_VM_STRUCT_ENTRY, + CHECK_STATIC_VM_STRUCT_ENTRY); +#endif + VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY, CHECK_STATIC_VM_STRUCT_ENTRY, CHECK_NO_OP, @@ -3105,8 +3133,14 @@ VMStructs::init() { VM_TYPES_G1(CHECK_VM_TYPE_ENTRY, CHECK_SINGLE_ARG_VM_TYPE_NO_OP); + #endif // INCLUDE_ALL_GCS +#if INCLUDE_TRACE + VM_TYPES_TRACE(CHECK_VM_TYPE_ENTRY, + CHECK_SINGLE_ARG_VM_TYPE_NO_OP); +#endif + VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY, CHECK_SINGLE_ARG_VM_TYPE_NO_OP, CHECK_SINGLE_ARG_VM_TYPE_NO_OP, @@ -3169,6 +3203,12 @@ VMStructs::init() { debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT, ENSURE_FIELD_TYPE_PRESENT)); #endif // INCLUDE_ALL_GCS + +#if INCLUDE_TRACE + debug_only(VM_STRUCTS_TRACE(ENSURE_FIELD_TYPE_PRESENT, + ENSURE_FIELD_TYPE_PRESENT)); +#endif + debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, ENSURE_FIELD_TYPE_PRESENT, CHECK_NO_OP, diff --git a/hotspot/src/share/vm/runtime/vmStructs_trace.hpp b/hotspot/src/share/vm/runtime/vmStructs_trace.hpp new file mode 100644 index 00000000000..b959c0f4a1f --- /dev/null +++ b/hotspot/src/share/vm/runtime/vmStructs_trace.hpp @@ -0,0 +1,35 @@ +/* + * 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_RUNTIME_VMSTRUCTS_TRACE_HPP +#define SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP + +#define VM_INT_CONSTANTS_TRACE(a) + +#define VM_STRUCTS_TRACE(a, b) + +#define VM_TYPES_TRACE(a, b) + + +#endif // SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP From 4241d1c605ba0873400b8db18e717cd59a9ab13d Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Tue, 24 Jun 2014 15:50:50 +0200 Subject: [PATCH 117/236] 8027915: TestParallelHeapSizeFlags fails with unexpected heap size on sparcv9 Reviewed-by: jmasa, sjohanss --- .../parallelScavenge/generationSizer.cpp | 7 +- .../parallelScavenge/parMarkBitMap.cpp | 2 +- .../parallelScavenge/psParallelCompact.cpp | 2 +- hotspot/src/share/vm/memory/heap.cpp | 10 ++- hotspot/src/share/vm/prims/jni.cpp | 2 + hotspot/src/share/vm/runtime/os.cpp | 81 +++++++++++++++---- hotspot/src/share/vm/runtime/os.hpp | 18 ++--- hotspot/src/share/vm/runtime/virtualspace.cpp | 6 +- .../arguments/TestParallelHeapSizeFlags.java | 1 - 9 files changed, 89 insertions(+), 40 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp index ff4b53057b8..e5defc98edc 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp @@ -66,9 +66,10 @@ void GenerationSizer::initialize_flags() { void GenerationSizer::initialize_size_info() { trace_gen_sizes("ps heap raw"); - const size_t page_sz = os::page_size_for_region(_min_heap_byte_size, - _max_heap_byte_size, - 8); + const size_t max_page_sz = os::page_size_for_region(_max_heap_byte_size, 8); + const size_t min_pages = 4; // 1 for eden + 1 for each survivor + 1 for old + const size_t min_page_sz = os::page_size_for_region(_min_heap_byte_size, min_pages); + const size_t page_sz = MIN2(max_page_sz, min_page_sz); // Can a page size be something else than a power of two? assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2"); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp index 320e649e7c9..84f7dd0fef7 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parMarkBitMap.cpp @@ -56,7 +56,7 @@ ParMarkBitMap::initialize(MemRegion covered_region) const size_t words = bits / BitsPerWord; const size_t raw_bytes = words * sizeof(idx_t); - const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10); + const size_t page_sz = os::page_size_for_region(raw_bytes, 10); const size_t granularity = os::vm_allocation_granularity(); _reserved_byte_size = align_size_up(raw_bytes, MAX2(page_sz, granularity)); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index 9f552fd1874..e39a8a0997d 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -403,7 +403,7 @@ PSVirtualSpace* ParallelCompactData::create_vspace(size_t count, size_t element_size) { const size_t raw_bytes = count * element_size; - const size_t page_sz = os::page_size_for_region(raw_bytes, raw_bytes, 10); + const size_t page_sz = os::page_size_for_region(raw_bytes, 10); const size_t granularity = os::vm_allocation_granularity(); _reserved_byte_size = align_size_up(raw_bytes, MAX2(page_sz, granularity)); diff --git a/hotspot/src/share/vm/memory/heap.cpp b/hotspot/src/share/vm/memory/heap.cpp index db0105fb3a1..cf137e74a00 100644 --- a/hotspot/src/share/vm/memory/heap.cpp +++ b/hotspot/src/share/vm/memory/heap.cpp @@ -98,9 +98,13 @@ bool CodeHeap::reserve(size_t reserved_size, size_t committed_size, _log2_segment_size = exact_log2(segment_size); // Reserve and initialize space for _memory. - const size_t page_size = os::can_execute_large_page_memory() ? - os::page_size_for_region(committed_size, reserved_size, 8) : - os::vm_page_size(); + size_t page_size = os::vm_page_size(); + if (os::can_execute_large_page_memory()) { + const size_t min_pages = 8; + page_size = MIN2(os::page_size_for_region(committed_size, min_pages), + os::page_size_for_region(reserved_size, min_pages)); + } + const size_t granularity = os::vm_allocation_granularity(); const size_t r_align = MAX2(page_size, granularity); const size_t r_size = align_size_up(reserved_size, r_align); diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 109a31af586..f24adbe0fc8 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -3871,6 +3871,7 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { unit_test_function_call // Forward declaration +void TestOS_test(); void TestReservedSpace_test(); void TestReserveMemorySpecial_test(); void TestVirtualSpace_test(); @@ -3892,6 +3893,7 @@ void TestCodeCacheRemSet_test(); void execute_internal_vm_tests() { if (ExecuteInternalVMTests) { tty->print_cr("Running internal VM tests"); + run_unit_test(TestOS_test()); run_unit_test(TestReservedSpace_test()); run_unit_test(TestReserveMemorySpecial_test()); run_unit_test(TestVirtualSpace_test()); diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 5666aa0d45f..a4b6c361020 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -1303,24 +1303,15 @@ bool os::stack_shadow_pages_available(Thread *thread, methodHandle method) { return (sp > (stack_limit + reserved_area)); } -size_t os::page_size_for_region(size_t region_min_size, size_t region_max_size, - uint min_pages) -{ +size_t os::page_size_for_region(size_t region_size, size_t min_pages) { assert(min_pages > 0, "sanity"); if (UseLargePages) { - const size_t max_page_size = region_max_size / min_pages; + const size_t max_page_size = region_size / min_pages; - for (unsigned int i = 0; _page_sizes[i] != 0; ++i) { - const size_t sz = _page_sizes[i]; - const size_t mask = sz - 1; - if ((region_min_size & mask) == 0 && (region_max_size & mask) == 0) { - // The largest page size with no fragmentation. - return sz; - } - - if (sz <= max_page_size) { - // The largest page size that satisfies the min_pages requirement. - return sz; + for (size_t i = 0; _page_sizes[i] != 0; ++i) { + const size_t page_size = _page_sizes[i]; + if (page_size <= max_page_size && is_size_aligned(region_size, page_size)) { + return page_size; } } } @@ -1548,3 +1539,63 @@ os::SuspendResume::State os::SuspendResume::switch_state(os::SuspendResume::Stat return result; } #endif + +/////////////// Unit tests /////////////// + +#ifndef PRODUCT + +#define assert_eq(a,b) assert(a == b, err_msg(SIZE_FORMAT " != " SIZE_FORMAT, a, b)) + +class TestOS : AllStatic { + static size_t small_page_size() { + return os::vm_page_size(); + } + + static size_t large_page_size() { + const size_t large_page_size_example = 4 * M; + return os::page_size_for_region(large_page_size_example, 1); + } + + static void test_page_size_for_region() { + if (UseLargePages) { + const size_t small_page = small_page_size(); + const size_t large_page = large_page_size(); + + if (large_page > small_page) { + size_t num_small_pages_in_large = large_page / small_page; + size_t page = os::page_size_for_region(large_page, num_small_pages_in_large); + + assert_eq(page, small_page); + } + } + } + + static void test_page_size_for_region_alignment() { + if (UseLargePages) { + const size_t small_page = small_page_size(); + const size_t large_page = large_page_size(); + if (large_page > small_page) { + const size_t unaligned_region = large_page + 17; + size_t page = os::page_size_for_region(unaligned_region, 1); + assert_eq(page, small_page); + + const size_t num_pages = 5; + const size_t aligned_region = large_page * num_pages; + page = os::page_size_for_region(aligned_region, num_pages); + assert_eq(page, large_page); + } + } + } + + public: + static void run_tests() { + test_page_size_for_region(); + test_page_size_for_region_alignment(); + } +}; + +void TestOS_test() { + TestOS::run_tests(); +} + +#endif // PRODUCT diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 2c4355ad9eb..53d3e8d3fbf 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -253,19 +253,11 @@ class os: AllStatic { // Return the default page size. static int vm_page_size(); - // Return the page size to use for a region of memory. The min_pages argument - // is a hint intended to limit fragmentation; it says the returned page size - // should be <= region_max_size / min_pages. Because min_pages is a hint, - // this routine may return a size larger than region_max_size / min_pages. - // - // The current implementation ignores min_pages if a larger page size is an - // exact multiple of both region_min_size and region_max_size. This allows - // larger pages to be used when doing so would not cause fragmentation; in - // particular, a single page can be used when region_min_size == - // region_max_size == a supported page size. - static size_t page_size_for_region(size_t region_min_size, - size_t region_max_size, - uint min_pages); + // Returns the page size to use for a region of memory. + // region_size / min_pages will always be greater than or equal to the + // returned value. + static size_t page_size_for_region(size_t region_size, size_t min_pages); + // Return the largest page size that can be used static size_t max_page_size() { // The _page_sizes array is sorted in descending order. diff --git a/hotspot/src/share/vm/runtime/virtualspace.cpp b/hotspot/src/share/vm/runtime/virtualspace.cpp index 19f699464b2..580c9fc69a9 100644 --- a/hotspot/src/share/vm/runtime/virtualspace.cpp +++ b/hotspot/src/share/vm/runtime/virtualspace.cpp @@ -53,7 +53,7 @@ ReservedSpace::ReservedSpace() : _base(NULL), _size(0), _noaccess_prefix(0), } ReservedSpace::ReservedSpace(size_t size) { - size_t page_size = os::page_size_for_region(size, size, 1); + size_t page_size = os::page_size_for_region(size, 1); bool large_pages = page_size != (size_t)os::vm_page_size(); // Don't force the alignment to be large page aligned, // since that will waste memory. @@ -372,7 +372,7 @@ VirtualSpace::VirtualSpace() { bool VirtualSpace::initialize(ReservedSpace rs, size_t committed_size) { - const size_t max_commit_granularity = os::page_size_for_region(rs.size(), rs.size(), 1); + const size_t max_commit_granularity = os::page_size_for_region(rs.size(), 1); return initialize_with_granularity(rs, committed_size, max_commit_granularity); } @@ -1007,7 +1007,7 @@ class TestVirtualSpace : AllStatic { case Disable: return vs.initialize_with_granularity(rs, 0, os::vm_page_size()); case Commit: - return vs.initialize_with_granularity(rs, 0, os::page_size_for_region(rs.size(), rs.size(), 1)); + return vs.initialize_with_granularity(rs, 0, os::page_size_for_region(rs.size(), 1)); } } diff --git a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java index 947fd0f9c88..2de2826ed5b 100644 --- a/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java +++ b/hotspot/test/gc/arguments/TestParallelHeapSizeFlags.java @@ -22,7 +22,6 @@ */ /* - * @ignore 8027915 * @test TestParallelHeapSizeFlags * @key gc * @bug 8006088 From 33a0064f9793f0dc1485452b45424a860d23729b Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Tue, 24 Jun 2014 07:10:06 -0700 Subject: [PATCH 118/236] 8047939: [TESTBUG] Rewrite test/runtime/8001071/Test8001071.sh Rewrote the test in Java, limited the heap size to avoid time out issues on machines with a lot of memory Reviewed-by: minqi, rdurbin, dcubed --- hotspot/test/runtime/8001071/Test8001071.java | 45 ------------- hotspot/test/runtime/8001071/Test8001071.sh | 63 ------------------- hotspot/test/runtime/Unsafe/RangeCheck.java | 58 +++++++++++++++++ 3 files changed, 58 insertions(+), 108 deletions(-) delete mode 100644 hotspot/test/runtime/8001071/Test8001071.java delete mode 100644 hotspot/test/runtime/8001071/Test8001071.sh create mode 100644 hotspot/test/runtime/Unsafe/RangeCheck.java diff --git a/hotspot/test/runtime/8001071/Test8001071.java b/hotspot/test/runtime/8001071/Test8001071.java deleted file mode 100644 index df03e197de8..00000000000 --- a/hotspot/test/runtime/8001071/Test8001071.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 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. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import sun.misc.Unsafe; -import java.lang.reflect.Field; - -@SuppressWarnings("sunapi") -public class Test8001071 { - public static Unsafe unsafe; - - static { - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - unsafe = (Unsafe) f.get(null); - } catch ( Exception e ) { - e.printStackTrace(); - } - } - - public static void main(String args[]) { - unsafe.getObject(new Test8001071(), Short.MAX_VALUE); - } - -} diff --git a/hotspot/test/runtime/8001071/Test8001071.sh b/hotspot/test/runtime/8001071/Test8001071.sh deleted file mode 100644 index 5fb4a7f9965..00000000000 --- a/hotspot/test/runtime/8001071/Test8001071.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -# Copyright (c) 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. -# -# 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 8001071 -## @summary Add simple range check into VM implemenation of Unsafe access methods -## @compile Test8001071.java -## @run shell Test8001071.sh -## @author filipp.zhinkin@oracle.com - -VERSION=`${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1` - -if [ -n "`echo $VERSION | grep debug`" -o -n "`echo $VERSION | grep jvmg`" ]; then - echo "Build type check passed" - echo "Continue testing" -else - echo "Fastdebug build is required for this test" - exit 0 -fi - -${TESTJAVA}/bin/java -cp ${TESTCLASSES} ${TESTVMOPTS} Test8001071 2>&1 - -HS_ERR_FILE=hs_err_pid*.log - -if [ ! -f $HS_ERR_FILE ] -then - echo "hs_err_pid log file was not found" - echo "Test failed" - exit 1 -fi - -grep "assert(byte_offset < p_size) failed: Unsafe access: offset.*> object's size.*" $HS_ERR_FILE - -if [ "0" = "$?" ]; -then - echo "Range check assertion failed as expected" - echo "Test passed" - exit 0 -else - echo "Range check assertion was not failed" - echo "Test failed" - exit 1 -fi diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java new file mode 100644 index 00000000000..9ded944cb25 --- /dev/null +++ b/hotspot/test/runtime/Unsafe/RangeCheck.java @@ -0,0 +1,58 @@ +/* + * 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 8001071 + * @summary Add simple range check into VM implemenation of Unsafe access methods + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.*; +import sun.misc.Unsafe; + +public class RangeCheck { + + public static void main(String args[]) throws Exception { + if (!Platform.isDebugBuild()) { + System.out.println("Testing assert which requires a debug build. Passing silently."); + return; + } + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + true, + "-Xmx32m", + "-XX:-TransmitErrorReport", + DummyClassWithMainRangeCheck.class.getName()); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldMatch("assert\\(byte_offset < p_size\\) failed: Unsafe access: offset \\d+ > object's size \\d+"); + } + + public static class DummyClassWithMainRangeCheck { + public static void main(String args[]) throws Exception { + Unsafe unsafe = Utils.getUnsafe(); + unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE); + } + } +} From 566786aba609c21e2e08d90c11fe8ef55eb544d3 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 24 Jun 2014 19:43:44 +0530 Subject: [PATCH 119/236] 8047959: bindings created for declarations in eval code are not mutable Reviewed-by: jlaskey, attila --- .../internal/codegen/CodeGenerator.java | 12 ++++ .../internal/codegen/FieldObjectCreator.java | 6 +- .../codegen/LocalVariableTypesCalculator.java | 2 +- .../nashorn/internal/codegen/MapCreator.java | 22 ++++--- .../jdk/nashorn/internal/objects/Global.java | 2 +- .../jdk/nashorn/internal/runtime/Context.java | 21 ++++++- .../jdk/nashorn/internal/runtime/Source.java | 61 ++++++++++++++++--- nashorn/test/script/basic/JDK-8047959.js | 59 ++++++++++++++++++ .../test/script/basic/JDK-8047959.js.EXPECTED | 15 +++++ 9 files changed, 179 insertions(+), 21 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8047959.js create mode 100644 nashorn/test/script/basic/JDK-8047959.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 984440f39bf..110e1109d4a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -211,6 +211,9 @@ final class CodeGenerator extends NodeOperatorVisitor extends ObjectCreator { /** call site flags to be used for invocations */ private final int callSiteFlags; + /** are we creating this field object from 'eval' code? */ + private final boolean evalCode; /** * Constructor @@ -88,7 +90,7 @@ public abstract class FieldObjectCreator extends ObjectCreator { FieldObjectCreator(final CodeGenerator codegen, final List> tuples, final boolean isScope, final boolean hasArguments) { super(codegen, tuples, isScope, hasArguments); this.callSiteFlags = codegen.getCallSiteFlags(); - + this.evalCode = codegen.isEvalCode(); countFields(); findClass(); } @@ -153,7 +155,7 @@ public abstract class FieldObjectCreator extends ObjectCreator { @Override protected PropertyMap makeMap() { assert propertyMap == null : "property map already initialized"; - propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), fieldCount, paddedFieldCount); + propertyMap = newMapCreator(fieldObjectClass).makeFieldMap(hasArguments(), fieldCount, paddedFieldCount, evalCode); return propertyMap; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java index 5ffe4b7f66b..c372d952c0a 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java @@ -584,7 +584,7 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ } setCompilerConstantAsObject(functionNode, CompilerConstants.THIS); - // NOTE: coarse-grained. If we wanted to solve it completely precisely, + // TODO: coarse-grained. If we wanted to solve it completely precisely, // we'd also need to push/pop its type when handling WithNode (so that // it can go back to undefined after a 'with' block. if(functionNode.hasScopeBlock() || functionNode.needsParentScope()) { diff --git a/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java b/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java index 8e7cfa3fd78..d4800f8a892 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/MapCreator.java @@ -63,13 +63,13 @@ public class MapCreator { /** * Constructs a property map based on a set of fields. * - * @param hasArguments does the created object have an "arguments" property + * @param hasArguments does the created object have an "arguments" property * @param fieldCount Number of fields in use. - * @param fieldMaximum Number of fields available. - * + * @param fieldMaximum Number of fields available. + * @param evalCode is this property map created for 'eval' code? * @return New map populated with accessor properties. */ - PropertyMap makeFieldMap(final boolean hasArguments, final int fieldCount, final int fieldMaximum) { + PropertyMap makeFieldMap(final boolean hasArguments, final int fieldCount, final int fieldMaximum, final boolean evalCode) { final List properties = new ArrayList<>(); assert tuples != null; @@ -79,7 +79,7 @@ public class MapCreator { final Class initialType = tuple.getValueType(); if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) { - final int flags = getPropertyFlags(symbol, hasArguments); + final int flags = getPropertyFlags(symbol, hasArguments, evalCode); final Property property = new AccessorProperty( key, flags, @@ -104,7 +104,7 @@ public class MapCreator { //TODO initial type is object here no matter what. Is that right? if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) { - final int flags = getPropertyFlags(symbol, hasArguments); + final int flags = getPropertyFlags(symbol, hasArguments, false); properties.add( new SpillProperty( key, @@ -124,7 +124,7 @@ public class MapCreator { * * @return flags to use for fields */ - static int getPropertyFlags(final Symbol symbol, final boolean hasArguments) { + static int getPropertyFlags(final Symbol symbol, final boolean hasArguments, final boolean evalCode) { int flags = 0; if (symbol.isParam()) { @@ -135,7 +135,13 @@ public class MapCreator { flags |= Property.HAS_ARGUMENTS; } - if (symbol.isScope()) { + // See ECMA 5.1 10.5 Declaration Binding Instantiation. + // Step 2 If code is eval code, then let configurableBindings + // be true else let configurableBindings be false. + // We have to make vars, functions declared in 'eval' code + // configurable. But vars, functions from any other code is + // not configurable. + if (symbol.isScope() && !evalCode) { flags |= Property.NOT_CONFIGURABLE; } diff --git a/nashorn/src/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk/nashorn/internal/objects/Global.java index 469466fe93d..4e2ba68a603 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java @@ -883,7 +883,7 @@ public final class Global extends ScriptObject implements Scope { final Global global = Global.instance(); final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global; - return global.getContext().eval(scope, str.toString(), callThis, location, Boolean.TRUE.equals(strict)); + return global.getContext().eval(scope, str.toString(), callThis, location, Boolean.TRUE.equals(strict), true); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index d521598986a..aae43b11818 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -560,12 +560,29 @@ public final class Context { * @param callThis "this" to be passed to the evaluated code * @param location location of the eval call * @param strict is this {@code eval} call from a strict mode code? + * @return the return value of the {@code eval} + */ + public Object eval(final ScriptObject initialScope, final String string, + final Object callThis, final Object location, final boolean strict) { + return eval(initialScope, string, callThis, location, strict, false); + } + + /** + * Entry point for {@code eval} + * + * @param initialScope The scope of this eval call + * @param string Evaluated code as a String + * @param callThis "this" to be passed to the evaluated code + * @param location location of the eval call + * @param strict is this {@code eval} call from a strict mode code? + * @param evalCall is this called from "eval" builtin? * * @return the return value of the {@code eval} */ - public Object eval(final ScriptObject initialScope, final String string, final Object callThis, final Object location, final boolean strict) { + public Object eval(final ScriptObject initialScope, final String string, + final Object callThis, final Object location, final boolean strict, final boolean evalCall) { final String file = location == UNDEFINED || location == null ? "" : location.toString(); - final Source source = sourceFor(file, string); + final Source source = sourceFor(file, string, evalCall); final boolean directEval = location != UNDEFINED; // is this direct 'eval' call or indirectly invoked eval? final Global global = Context.getGlobal(); ScriptObject scope = initialScope; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Source.java b/nashorn/src/jdk/nashorn/internal/runtime/Source.java index b9f6fd0dba4..d64bbfa26e6 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Source.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Source.java @@ -142,29 +142,34 @@ public final class Source implements Loggable { long lastModified(); char[] array(); + + boolean isEvalCode(); } private static class RawData implements Data { private final char[] array; + private final boolean evalCode; private int hash; - private RawData(final char[] array) { + private RawData(final char[] array, final boolean evalCode) { this.array = Objects.requireNonNull(array); + this.evalCode = evalCode; } - private RawData(final String source) { + private RawData(final String source, final boolean evalCode) { this.array = Objects.requireNonNull(source).toCharArray(); + this.evalCode = evalCode; } private RawData(final Reader reader) throws IOException { - this(readFully(reader)); + this(readFully(reader), false); } @Override public int hashCode() { int h = hash; if (h == 0) { - h = hash = Arrays.hashCode(array); + h = hash = Arrays.hashCode(array) ^ (evalCode? 1 : 0); } return h; } @@ -175,7 +180,8 @@ public final class Source implements Loggable { return true; } if (obj instanceof RawData) { - return Arrays.equals(array, ((RawData)obj).array); + final RawData other = (RawData)obj; + return Arrays.equals(array, other.array) && evalCode == other.evalCode; } return false; } @@ -206,6 +212,10 @@ public final class Source implements Loggable { } + @Override + public boolean isEvalCode() { + return evalCode; + } } private static class URLData implements Data { @@ -287,6 +297,11 @@ public final class Source implements Loggable { return array; } + @Override + public boolean isEvalCode() { + return false; + } + boolean isDeferred() { return array == null; } @@ -368,6 +383,18 @@ public final class Source implements Loggable { return data.array(); } + /** + * Returns a Source instance + * + * @param name source name + * @param content contents as char array + * @param isEval does this represent code from 'eval' call? + * @return source instance + */ + public static Source sourceFor(final String name, final char[] content, final boolean isEval) { + return new Source(name, baseName(name), new RawData(content, isEval)); + } + /** * Returns a Source instance * @@ -377,7 +404,7 @@ public final class Source implements Loggable { * @return source instance */ public static Source sourceFor(final String name, final char[] content) { - return new Source(name, baseName(name), new RawData(content)); + return sourceFor(name, content, false); } /** @@ -385,11 +412,22 @@ public final class Source implements Loggable { * * @param name source name * @param content contents as string + * @param isEval does this represent code from 'eval' call? + * @return source instance + */ + public static Source sourceFor(final String name, final String content, final boolean isEval) { + return new Source(name, baseName(name), new RawData(content, isEval)); + } + + /** + * Returns a Source instance * + * @param name source name + * @param content contents as string * @return source instance */ public static Source sourceFor(final String name, final String content) { - return new Source(name, baseName(name), new RawData(content)); + return sourceFor(name, content, false); } /** @@ -554,6 +592,15 @@ public final class Source implements Loggable { return data.url(); } + /** + * Returns whether this source was submitted via 'eval' call or not. + * + * @return true if this source represents code submitted via 'eval' + */ + public boolean isEvalCode() { + return data.isEvalCode(); + } + /** * Find the beginning of the line containing position. * @param position Index to offending token. diff --git a/nashorn/test/script/basic/JDK-8047959.js b/nashorn/test/script/basic/JDK-8047959.js new file mode 100644 index 00000000000..9ad1c8d1a22 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047959.js @@ -0,0 +1,59 @@ +/* + * 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. + */ + +/** + * JDK-8047959: bindings created for declarations in eval code are not mutable + * + * @test + * @run + */ + +eval("var x=10;"); +print('delete x? ' + delete x); +print('typeof x = ' + typeof x); + +eval("function f() {}"); +print('delete f? ' + delete f); +print('typeof f = ' + typeof f); + +var foo = 223; +print('delete foo? ' + delete foo); +print('typeof foo = ' + typeof foo); + +function func() {} +print('delete func? ' + delete func); +print('typeof func = ' + typeof func); + +eval("var foo = 33;"); +print("delete foo? " + delete foo); +print("typeof foo? " + typeof foo); +print("foo = " + foo); + +var x = "global"; +(function(){ + eval("var x='local'"); + print("x in function = "+ x); + print("delete x? = " + delete x); + print("x after delete = " + x); +})(); +print("x = " + x); diff --git a/nashorn/test/script/basic/JDK-8047959.js.EXPECTED b/nashorn/test/script/basic/JDK-8047959.js.EXPECTED new file mode 100644 index 00000000000..935f1002dfb --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047959.js.EXPECTED @@ -0,0 +1,15 @@ +delete x? false +typeof x = number +delete f? true +typeof f = undefined +delete foo? false +typeof foo = number +delete func? false +typeof func = function +delete foo? false +typeof foo? number +foo = 33 +x in function = local +delete x? = true +x after delete = global +x = global From fd43773a10e08ea31a615b137383a6811ded1f88 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 24 Jun 2014 16:20:15 +0200 Subject: [PATCH 120/236] 8046670: Make CMS metadata aware closures applicable for other collectors Reviewed-by: ehelin, mgerdin --- .../concurrentMarkSweep/cmsOopClosures.hpp | 76 +++++-------------- .../cmsOopClosures.inline.hpp | 21 +---- .../concurrentMarkSweepGeneration.cpp | 31 ++++---- .../concurrentMarkSweepGeneration.hpp | 2 +- hotspot/src/share/vm/memory/iterator.cpp | 1 + hotspot/src/share/vm/memory/iterator.hpp | 49 +++++++++++- .../src/share/vm/memory/iterator.inline.hpp | 47 ++++++++++++ .../vm/oops/instanceClassLoaderKlass.cpp | 7 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 14 +--- .../src/share/vm/oops/instanceMirrorKlass.cpp | 7 +- hotspot/src/share/vm/oops/objArrayKlass.cpp | 7 +- 11 files changed, 139 insertions(+), 123 deletions(-) create mode 100644 hotspot/src/share/vm/memory/iterator.inline.hpp diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp index 1c9f4cba5f2..5f2b6a6b523 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_HPP #include "memory/genOopClosures.hpp" +#include "memory/iterator.hpp" ///////////////////////////////////////////////////////////////// // Closures used by ConcurrentMarkSweepGeneration's collector @@ -48,33 +49,13 @@ class Par_MarkFromRootsClosure; } \ } -// Applies the given oop closure to all oops in all klasses visited. -class CMKlassClosure : public KlassClosure { - friend class CMSOopClosure; - friend class CMSOopsInGenClosure; - - OopClosure* _oop_closure; - - // Used when _oop_closure couldn't be set in an initialization list. - void initialize(OopClosure* oop_closure) { - assert(_oop_closure == NULL, "Should only be called once"); - _oop_closure = oop_closure; - } +// TODO: This duplication of the MetadataAwareOopClosure class is only needed +// because some CMS OopClosures derive from OopsInGenClosure. It would be +// good to get rid of them completely. +class MetadataAwareOopsInGenClosure: public OopsInGenClosure { + KlassToOopClosure _klass_closure; public: - CMKlassClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) { } - - void do_klass(Klass* k); -}; - -// The base class for all CMS marking closures. -// It's used to proxy through the metadata to the oops defined in them. -class CMSOopClosure: public ExtendedOopClosure { - CMKlassClosure _klass_closure; - public: - CMSOopClosure() : ExtendedOopClosure() { - _klass_closure.initialize(this); - } - CMSOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) { + MetadataAwareOopsInGenClosure() { _klass_closure.initialize(this); } @@ -87,26 +68,7 @@ class CMSOopClosure: public ExtendedOopClosure { virtual void do_class_loader_data(ClassLoaderData* cld); }; -// TODO: This duplication of the CMSOopClosure class is only needed because -// some CMS OopClosures derive from OopsInGenClosure. It would be good -// to get rid of them completely. -class CMSOopsInGenClosure: public OopsInGenClosure { - CMKlassClosure _klass_closure; - public: - CMSOopsInGenClosure() { - _klass_closure.initialize(this); - } - - virtual bool do_metadata() { return do_metadata_nv(); } - inline bool do_metadata_nv() { return true; } - - virtual void do_klass(Klass* k); - void do_klass_nv(Klass* k); - - virtual void do_class_loader_data(ClassLoaderData* cld); -}; - -class MarkRefsIntoClosure: public CMSOopsInGenClosure { +class MarkRefsIntoClosure: public MetadataAwareOopsInGenClosure { private: const MemRegion _span; CMSBitMap* _bitMap; @@ -118,7 +80,7 @@ class MarkRefsIntoClosure: public CMSOopsInGenClosure { virtual void do_oop(narrowOop* p); }; -class Par_MarkRefsIntoClosure: public CMSOopsInGenClosure { +class Par_MarkRefsIntoClosure: public MetadataAwareOopsInGenClosure { private: const MemRegion _span; CMSBitMap* _bitMap; @@ -132,7 +94,7 @@ class Par_MarkRefsIntoClosure: public CMSOopsInGenClosure { // A variant of the above used in certain kinds of CMS // marking verification. -class MarkRefsIntoVerifyClosure: public CMSOopsInGenClosure { +class MarkRefsIntoVerifyClosure: public MetadataAwareOopsInGenClosure { private: const MemRegion _span; CMSBitMap* _verification_bm; @@ -147,7 +109,7 @@ class MarkRefsIntoVerifyClosure: public CMSOopsInGenClosure { }; // The non-parallel version (the parallel version appears further below). -class PushAndMarkClosure: public CMSOopClosure { +class PushAndMarkClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; MemRegion _span; @@ -177,7 +139,7 @@ class PushAndMarkClosure: public CMSOopClosure { // synchronization (for instance, via CAS). The marking stack // used in the non-parallel case above is here replaced with // an OopTaskQueue structure to allow efficient work stealing. -class Par_PushAndMarkClosure: public CMSOopClosure { +class Par_PushAndMarkClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; MemRegion _span; @@ -198,7 +160,7 @@ class Par_PushAndMarkClosure: public CMSOopClosure { }; // The non-parallel version (the parallel version appears further below). -class MarkRefsIntoAndScanClosure: public CMSOopsInGenClosure { +class MarkRefsIntoAndScanClosure: public MetadataAwareOopsInGenClosure { private: MemRegion _span; CMSBitMap* _bit_map; @@ -239,7 +201,7 @@ class MarkRefsIntoAndScanClosure: public CMSOopsInGenClosure { // stack and the bitMap are shared, so access needs to be suitably // synchronized. An OopTaskQueue structure, supporting efficient // work stealing, replaces a CMSMarkStack for storing grey objects. -class Par_MarkRefsIntoAndScanClosure: public CMSOopsInGenClosure { +class Par_MarkRefsIntoAndScanClosure: public MetadataAwareOopsInGenClosure { private: MemRegion _span; CMSBitMap* _bit_map; @@ -265,7 +227,7 @@ class Par_MarkRefsIntoAndScanClosure: public CMSOopsInGenClosure { // This closure is used during the concurrent marking phase // following the first checkpoint. Its use is buried in // the closure MarkFromRootsClosure. -class PushOrMarkClosure: public CMSOopClosure { +class PushOrMarkClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; MemRegion _span; @@ -298,7 +260,7 @@ class PushOrMarkClosure: public CMSOopClosure { // This closure is used during the concurrent marking phase // following the first checkpoint. Its use is buried in // the closure Par_MarkFromRootsClosure. -class Par_PushOrMarkClosure: public CMSOopClosure { +class Par_PushOrMarkClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; MemRegion _whole_span; @@ -338,7 +300,7 @@ class Par_PushOrMarkClosure: public CMSOopClosure { // processing phase of the CMS final checkpoint step, as // well as during the concurrent precleaning of the discovered // reference lists. -class CMSKeepAliveClosure: public CMSOopClosure { +class CMSKeepAliveClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; const MemRegion _span; @@ -358,7 +320,7 @@ class CMSKeepAliveClosure: public CMSOopClosure { inline void do_oop_nv(narrowOop* p) { CMSKeepAliveClosure::do_oop_work(p); } }; -class CMSInnerParMarkAndPushClosure: public CMSOopClosure { +class CMSInnerParMarkAndPushClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; MemRegion _span; @@ -379,7 +341,7 @@ class CMSInnerParMarkAndPushClosure: public CMSOopClosure { // A parallel (MT) version of the above, used when // reference processing is parallel; the only difference // is in the do_oop method. -class CMSParKeepAliveClosure: public CMSOopClosure { +class CMSParKeepAliveClosure: public MetadataAwareOopClosure { private: MemRegion _span; OopTaskQueue* _work_queue; diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp index 499ba4b3bea..2980f0d272f 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp @@ -44,33 +44,20 @@ inline void Par_MarkRefsIntoAndScanClosure::trim_queue(uint max) { } } -// CMSOopClosure and CMSoopsInGenClosure are duplicated, +// MetadataAwareOopClosure and MetadataAwareOopsInGenClosure are duplicated, // until we get rid of OopsInGenClosure. -inline void CMSOopClosure::do_klass(Klass* k) { do_klass_nv(k); } -inline void CMSOopsInGenClosure::do_klass(Klass* k) { do_klass_nv(k); } - -inline void CMSOopClosure::do_klass_nv(Klass* k) { - ClassLoaderData* cld = k->class_loader_data(); - do_class_loader_data(cld); -} -inline void CMSOopsInGenClosure::do_klass_nv(Klass* k) { +inline void MetadataAwareOopsInGenClosure::do_klass_nv(Klass* k) { ClassLoaderData* cld = k->class_loader_data(); do_class_loader_data(cld); } +inline void MetadataAwareOopsInGenClosure::do_klass(Klass* k) { do_klass_nv(k); } -inline void CMSOopClosure::do_class_loader_data(ClassLoaderData* cld) { +inline void MetadataAwareOopsInGenClosure::do_class_loader_data(ClassLoaderData* cld) { assert(_klass_closure._oop_closure == this, "Must be"); bool claim = true; // Must claim the class loader data before processing. cld->oops_do(_klass_closure._oop_closure, &_klass_closure, claim); } -inline void CMSOopsInGenClosure::do_class_loader_data(ClassLoaderData* cld) { - assert(_klass_closure._oop_closure == this, "Must be"); - - bool claim = true; // Must claim the class loader data before processing. - cld->oops_do(_klass_closure._oop_closure, &_klass_closure, claim); -} - #endif // SHARE_VM_GC_IMPLEMENTATION_CONCURRENTMARKSWEEP_CMSOOPCLOSURES_INLINE_HPP diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 104b9c4c4e8..c0daf2c32ec 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -49,7 +49,7 @@ #include "memory/genCollectedHeap.hpp" #include "memory/genMarkSweep.hpp" #include "memory/genOopClosures.inline.hpp" -#include "memory/iterator.hpp" +#include "memory/iterator.inline.hpp" #include "memory/padded.hpp" #include "memory/referencePolicy.hpp" #include "memory/resourceArea.hpp" @@ -3123,7 +3123,7 @@ void CMSCollector::verify_after_remark_work_2() { // Mark from roots one level into CMS MarkRefsIntoVerifyClosure notOlder(_span, verification_mark_bm(), markBitMap()); - CMKlassClosure klass_closure(¬Older); + KlassToOopClosure klass_closure(¬Older); gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. gch->gen_process_strong_roots(_cmsGen->level(), @@ -3744,7 +3744,7 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { gch->set_par_threads(0); } else { // The serial version. - CMKlassClosure klass_closure(¬Older); + KlassToOopClosure klass_closure(¬Older); gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel. gch->gen_process_strong_roots(_cmsGen->level(), true, // younger gens are roots @@ -4206,7 +4206,7 @@ void CMSConcMarkingTask::do_scan_and_mark(int i, CompactibleFreeListSpace* sp) { pst->all_tasks_completed(); } -class Par_ConcMarkingClosure: public CMSOopClosure { +class Par_ConcMarkingClosure: public MetadataAwareOopClosure { private: CMSCollector* _collector; CMSConcMarkingTask* _task; @@ -4219,7 +4219,7 @@ class Par_ConcMarkingClosure: public CMSOopClosure { public: Par_ConcMarkingClosure(CMSCollector* collector, CMSConcMarkingTask* task, OopTaskQueue* work_queue, CMSBitMap* bit_map, CMSMarkStack* overflow_stack): - CMSOopClosure(collector->ref_processor()), + MetadataAwareOopClosure(collector->ref_processor()), _collector(collector), _task(task), _span(collector->_span), @@ -4990,7 +4990,7 @@ size_t CMSCollector::preclean_card_table(ConcurrentMarkSweepGeneration* gen, } class PrecleanKlassClosure : public KlassClosure { - CMKlassClosure _cm_klass_closure; + KlassToOopClosure _cm_klass_closure; public: PrecleanKlassClosure(OopClosure* oop_closure) : _cm_klass_closure(oop_closure) {} void do_klass(Klass* k) { @@ -5228,7 +5228,7 @@ void CMSParInitialMarkTask::work(uint worker_id) { _timer.start(); GenCollectedHeap* gch = GenCollectedHeap::heap(); Par_MarkRefsIntoClosure par_mri_cl(_collector->_span, &(_collector->_markBitMap)); - CMKlassClosure klass_closure(&par_mri_cl); + KlassToOopClosure klass_closure(&par_mri_cl); // ---------- young gen roots -------------- { @@ -5302,7 +5302,7 @@ class CMSParRemarkTask: public CMSParMarkTask { }; class RemarkKlassClosure : public KlassClosure { - CMKlassClosure _cm_klass_closure; + KlassToOopClosure _cm_klass_closure; public: RemarkKlassClosure(OopClosure* oop_closure) : _cm_klass_closure(oop_closure) {} void do_klass(Klass* k) { @@ -7741,7 +7741,7 @@ PushAndMarkVerifyClosure::PushAndMarkVerifyClosure( CMSCollector* collector, MemRegion span, CMSBitMap* verification_bm, CMSBitMap* cms_bm, CMSMarkStack* mark_stack): - CMSOopClosure(collector->ref_processor()), + MetadataAwareOopClosure(collector->ref_processor()), _collector(collector), _span(span), _verification_bm(verification_bm), @@ -7794,7 +7794,7 @@ PushOrMarkClosure::PushOrMarkClosure(CMSCollector* collector, MemRegion span, CMSBitMap* bitMap, CMSMarkStack* markStack, HeapWord* finger, MarkFromRootsClosure* parent) : - CMSOopClosure(collector->ref_processor()), + MetadataAwareOopClosure(collector->ref_processor()), _collector(collector), _span(span), _bitMap(bitMap), @@ -7811,7 +7811,7 @@ Par_PushOrMarkClosure::Par_PushOrMarkClosure(CMSCollector* collector, HeapWord* finger, HeapWord** global_finger_addr, Par_MarkFromRootsClosure* parent) : - CMSOopClosure(collector->ref_processor()), + MetadataAwareOopClosure(collector->ref_processor()), _collector(collector), _whole_span(collector->_span), _span(span), @@ -7860,11 +7860,6 @@ void Par_PushOrMarkClosure::handle_stack_overflow(HeapWord* lost) { _overflow_stack->expand(); // expand the stack if possible } -void CMKlassClosure::do_klass(Klass* k) { - assert(_oop_closure != NULL, "Not initialized?"); - k->oops_do(_oop_closure); -} - void PushOrMarkClosure::do_oop(oop obj) { // Ignore mark word because we are running concurrent with mutators. assert(obj->is_oop_or_null(true), "expected an oop or NULL"); @@ -7962,7 +7957,7 @@ PushAndMarkClosure::PushAndMarkClosure(CMSCollector* collector, CMSBitMap* mod_union_table, CMSMarkStack* mark_stack, bool concurrent_precleaning): - CMSOopClosure(rp), + MetadataAwareOopClosure(rp), _collector(collector), _span(span), _bit_map(bit_map), @@ -8035,7 +8030,7 @@ Par_PushAndMarkClosure::Par_PushAndMarkClosure(CMSCollector* collector, ReferenceProcessor* rp, CMSBitMap* bit_map, OopTaskQueue* work_queue): - CMSOopClosure(rp), + MetadataAwareOopClosure(rp), _collector(collector), _span(span), _bit_map(bit_map), diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index 09740b6d57c..7e3ef58605f 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -1444,7 +1444,7 @@ class Par_MarkFromRootsClosure: public BitMapClosure { // The following closures are used to do certain kinds of verification of // CMS marking. -class PushAndMarkVerifyClosure: public CMSOopClosure { +class PushAndMarkVerifyClosure: public MetadataAwareOopClosure { CMSCollector* _collector; MemRegion _span; CMSBitMap* _verification_bm; diff --git a/hotspot/src/share/vm/memory/iterator.cpp b/hotspot/src/share/vm/memory/iterator.cpp index f69eb4ed75d..6cd8e965922 100644 --- a/hotspot/src/share/vm/memory/iterator.cpp +++ b/hotspot/src/share/vm/memory/iterator.cpp @@ -27,6 +27,7 @@ #include "oops/oop.inline.hpp" void KlassToOopClosure::do_klass(Klass* k) { + assert(_oop_closure != NULL, "Not initialized?"); k->oops_do(_oop_closure); } diff --git a/hotspot/src/share/vm/memory/iterator.hpp b/hotspot/src/share/vm/memory/iterator.hpp index 81a845e5056..e91d42974b1 100644 --- a/hotspot/src/share/vm/memory/iterator.hpp +++ b/hotspot/src/share/vm/memory/iterator.hpp @@ -115,9 +115,19 @@ class CLDClosure : public Closure { }; class KlassToOopClosure : public KlassClosure { + friend class MetadataAwareOopClosure; + friend class MetadataAwareOopsInGenClosure; + OopClosure* _oop_closure; - public: - KlassToOopClosure(OopClosure* oop_closure) : _oop_closure(oop_closure) {} + + // Used when _oop_closure couldn't be set in an initialization list. + void initialize(OopClosure* oop_closure) { + assert(_oop_closure == NULL, "Should only be called once"); + _oop_closure = oop_closure; + } + +public: + KlassToOopClosure(OopClosure* oop_closure = NULL) : _oop_closure(oop_closure) {} virtual void do_klass(Klass* k); }; @@ -135,6 +145,29 @@ class CLDToOopClosure : public CLDClosure { void do_cld(ClassLoaderData* cld); }; +// The base class for all concurrent marking closures, +// that participates in class unloading. +// It's used to proxy through the metadata to the oops defined in them. +class MetadataAwareOopClosure: public ExtendedOopClosure { + KlassToOopClosure _klass_closure; + + public: + MetadataAwareOopClosure() : ExtendedOopClosure() { + _klass_closure.initialize(this); + } + MetadataAwareOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) { + _klass_closure.initialize(this); + } + + virtual bool do_metadata() { return do_metadata_nv(); } + inline bool do_metadata_nv() { return true; } + + virtual void do_klass(Klass* k); + void do_klass_nv(Klass* k); + + virtual void do_class_loader_data(ClassLoaderData* cld); +}; + // ObjectClosure is used for iterating through an object space class ObjectClosure : public Closure { @@ -318,4 +351,16 @@ class SymbolClosure : public StackObj { } }; + +// Helper defines for ExtendOopClosure + +#define if_do_metadata_checked(closure, nv_suffix) \ + /* Make sure the non-virtual and the virtual versions match. */ \ + assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ + "Inconsistency in do_metadata"); \ + if (closure->do_metadata##nv_suffix()) + +#define assert_should_ignore_metadata(closure, nv_suffix) \ + assert(!closure->do_metadata##nv_suffix(), "Code to handle metadata is not implemented") + #endif // SHARE_VM_MEMORY_ITERATOR_HPP diff --git a/hotspot/src/share/vm/memory/iterator.inline.hpp b/hotspot/src/share/vm/memory/iterator.inline.hpp new file mode 100644 index 00000000000..cef12666012 --- /dev/null +++ b/hotspot/src/share/vm/memory/iterator.inline.hpp @@ -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. + * + */ + +#ifndef SHARE_VM_MEMORY_ITERATOR_INLINE_HPP +#define SHARE_VM_MEMORY_ITERATOR_INLINE_HPP + +#include "classfile/classLoaderData.hpp" +#include "memory/iterator.hpp" +#include "oops/klass.hpp" +#include "utilities/debug.hpp" + +inline void MetadataAwareOopClosure::do_class_loader_data(ClassLoaderData* cld) { + assert(_klass_closure._oop_closure == this, "Must be"); + + bool claim = true; // Must claim the class loader data before processing. + cld->oops_do(_klass_closure._oop_closure, &_klass_closure, claim); +} + +inline void MetadataAwareOopClosure::do_klass_nv(Klass* k) { + ClassLoaderData* cld = k->class_loader_data(); + do_class_loader_data(cld); +} + +inline void MetadataAwareOopClosure::do_klass(Klass* k) { do_klass_nv(k); } + +#endif // SHARE_VM_MEMORY_ITERATOR_INLINE_HPP diff --git a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp index a92167a9a7d..131ecbfb040 100644 --- a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/shared/markSweep.inline.hpp" #include "gc_interface/collectedHeap.inline.hpp" #include "memory/genOopClosures.inline.hpp" +#include "memory/iterator.inline.hpp" #include "memory/oopFactory.hpp" #include "oops/instanceKlass.hpp" #include "oops/instanceClassLoaderKlass.hpp" @@ -44,12 +45,6 @@ #include "oops/oop.pcgc.inline.hpp" #endif // INCLUDE_ALL_GCS -#define if_do_metadata_checked(closure, nv_suffix) \ - /* Make sure the non-virtual and the virtual versions match. */ \ - assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ - "Inconsistency in do_metadata"); \ - if (closure->do_metadata##nv_suffix()) - // Macro to define InstanceClassLoaderKlass::oop_oop_iterate for virtual/nonvirtual for // all closures. Macros calling macros above for each oop size. // Since ClassLoader objects have only a pointer to the loader_data, they are not diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index a3bb98e43ea..91d00f8fdea 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -35,6 +35,7 @@ #include "jvmtifiles/jvmti.h" #include "memory/genOopClosures.inline.hpp" #include "memory/heapInspection.hpp" +#include "memory/iterator.inline.hpp" #include "memory/metadataFactory.hpp" #include "memory/oopFactory.hpp" #include "oops/fieldStreams.hpp" @@ -2114,12 +2115,6 @@ void InstanceKlass::oop_follow_contents(ParCompactionManager* cm, // closure's do_metadata() method dictates whether the given closure should be // applied to the klass ptr in the object header. -#define if_do_metadata_checked(closure, nv_suffix) \ - /* Make sure the non-virtual and the virtual versions match. */ \ - assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ - "Inconsistency in do_metadata"); \ - if (closure->do_metadata##nv_suffix()) - #define InstanceKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ \ int InstanceKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ @@ -2143,10 +2138,9 @@ int InstanceKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) int InstanceKlass::oop_oop_iterate_backwards##nv_suffix(oop obj, \ OopClosureType* closure) { \ SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::ik); \ - /* header */ \ - if_do_metadata_checked(closure, nv_suffix) { \ - closure->do_klass##nv_suffix(obj->klass()); \ - } \ + \ + assert_should_ignore_metadata(closure, nv_suffix); \ + \ /* instance variables */ \ InstanceKlass_OOP_MAP_REVERSE_ITERATE( \ obj, \ diff --git a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp index fd05124f855..2fd8e48397c 100644 --- a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp @@ -28,6 +28,7 @@ #include "gc_implementation/shared/markSweep.inline.hpp" #include "gc_interface/collectedHeap.inline.hpp" #include "memory/genOopClosures.inline.hpp" +#include "memory/iterator.inline.hpp" #include "memory/oopFactory.hpp" #include "oops/instanceKlass.hpp" #include "oops/instanceMirrorKlass.hpp" @@ -241,12 +242,6 @@ int InstanceMirrorKlass::oop_adjust_pointers(oop obj) { return oop_size(obj); \ -#define if_do_metadata_checked(closure, nv_suffix) \ - /* Make sure the non-virtual and the virtual versions match. */ \ - assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ - "Inconsistency in do_metadata"); \ - if (closure->do_metadata##nv_suffix()) - // Macro to define InstanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for // all closures. Macros calling macros above for each oop size. diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 40b6d1b7ca8..0d17ce64dfd 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -29,6 +29,7 @@ #include "gc_implementation/shared/markSweep.inline.hpp" #include "gc_interface/collectedHeap.inline.hpp" #include "memory/genOopClosures.inline.hpp" +#include "memory/iterator.inline.hpp" #include "memory/metadataFactory.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" @@ -476,12 +477,6 @@ void ObjArrayKlass::oop_follow_contents(ParCompactionManager* cm, } #endif // INCLUDE_ALL_GCS -#define if_do_metadata_checked(closure, nv_suffix) \ - /* Make sure the non-virtual and the virtual versions match. */ \ - assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ - "Inconsistency in do_metadata"); \ - if (closure->do_metadata##nv_suffix()) - #define ObjArrayKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ \ int ObjArrayKlass::oop_oop_iterate##nv_suffix(oop obj, \ From b549ffc3640e59e7bb190458a5cfcb14155f1460 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 24 Jun 2014 17:09:48 +0200 Subject: [PATCH 121/236] 8047373: Clean the ExceptionCache in one pass Also-reviewed-by: kim.barrett@oracle.com Reviewed-by: jmasa, jwilhelm --- hotspot/src/share/vm/code/nmethod.cpp | 47 ++++++++++++--------------- hotspot/src/share/vm/code/nmethod.hpp | 2 +- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index ac141eac3e1..795c700fa1b 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -364,26 +364,29 @@ void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) { set_exception_cache(new_entry); } -void nmethod::remove_from_exception_cache(ExceptionCache* ec) { +void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) { ExceptionCache* prev = NULL; ExceptionCache* curr = exception_cache(); - assert(curr != NULL, "nothing to remove"); - // find the previous and next entry of ec - while (curr != ec) { - prev = curr; - curr = curr->next(); - assert(curr != NULL, "ExceptionCache not found"); - } - // now: curr == ec - ExceptionCache* next = curr->next(); - if (prev == NULL) { - set_exception_cache(next); - } else { - prev->set_next(next); - } - delete curr; -} + while (curr != NULL) { + ExceptionCache* next = curr->next(); + + Klass* ex_klass = curr->exception_type(); + if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) { + if (prev == NULL) { + set_exception_cache(next); + } else { + prev->set_next(next); + } + delete curr; + // prev stays the same. + } else { + prev = curr; + } + + curr = next; + } +} // public method for accessing the exception cache // These are the public access methods. @@ -1619,15 +1622,7 @@ void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) } // Exception cache - ExceptionCache* ec = exception_cache(); - while (ec != NULL) { - Klass* ex_klass = ec->exception_type(); - ExceptionCache* next_ec = ec->next(); - if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) { - remove_from_exception_cache(ec); - } - ec = next_ec; - } + clean_exception_cache(is_alive); // If class unloading occurred we first iterate over all inline caches and // clear ICs where the cached oop is referring to an unloaded klass or method. diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index fa57e9e504d..5ffbde6ad70 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -529,7 +529,7 @@ public: void set_exception_cache(ExceptionCache *ec) { _exception_cache = ec; } address handler_for_exception_and_pc(Handle exception, address pc); void add_handler_for_exception_and_pc(Handle exception, address pc, address handler); - void remove_from_exception_cache(ExceptionCache* ec); + void clean_exception_cache(BoolObjectClosure* is_alive); // implicit exceptions support address continuation_for_implicit_exception(address pc); From aa12c8fbf5b020d168cf29412643bf15514b0439 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 24 Jun 2014 11:23:34 -0400 Subject: [PATCH 122/236] 6642881: Improve performance of Class.getClassLoader() Add classLoader to java/lang/Class instance for fast access Reviewed-by: alanb, lfoltan, rriggs, vlivanov, twisti, mchung, jfranck, dholmes --- jdk/src/share/classes/java/lang/Class.java | 18 ++++++++++++------ .../java/lang/reflect/AccessibleObject.java | 14 +++++++++++--- jdk/src/share/javavm/export/jvm.h | 5 +---- jdk/src/share/native/common/check_code.c | 13 +++---------- jdk/src/share/native/java/lang/Class.c | 5 +---- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/jdk/src/share/classes/java/lang/Class.java b/jdk/src/share/classes/java/lang/Class.java index 71daa390286..ed7fa95e121 100644 --- a/jdk/src/share/classes/java/lang/Class.java +++ b/jdk/src/share/classes/java/lang/Class.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -130,11 +130,15 @@ public final class Class implements java.io.Serializable, } /* - * Constructor. Only the Java Virtual Machine creates Class - * objects. + * Private constructor. Only the Java Virtual Machine creates Class objects. + * This constructor is not used and prevents the default constructor being + * generated. */ - private Class() {} - + private Class(ClassLoader loader) { + // Initialize final field for classLoader. The initialization value of non-null + // prevents future JIT optimizations from assuming this final field is null. + classLoader = loader; + } /** * Converts the object to a string. The string representation is the @@ -677,8 +681,10 @@ public final class Class implements java.io.Serializable, } // Package-private to allow ClassLoader access - native ClassLoader getClassLoader0(); + ClassLoader getClassLoader0() { return classLoader; } + // Initialized in JVM not by private constructor + private final ClassLoader classLoader; /** * Returns an array of {@code TypeVariable} objects that represent the diff --git a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java index a5931e145a7..f85ab432388 100644 --- a/jdk/src/share/classes/java/lang/reflect/AccessibleObject.java +++ b/jdk/src/share/classes/java/lang/reflect/AccessibleObject.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 @@ -129,16 +129,24 @@ public class AccessibleObject implements AnnotatedElement { setAccessible0(this, flag); } - /* Check that you aren't exposing java.lang.Class.. */ + /* Check that you aren't exposing java.lang.Class. or sensitive + fields in java.lang.Class. */ private static void setAccessible0(AccessibleObject obj, boolean flag) throws SecurityException { if (obj instanceof Constructor && flag == true) { Constructor c = (Constructor)obj; if (c.getDeclaringClass() == Class.class) { - throw new SecurityException("Can not make a java.lang.Class" + + throw new SecurityException("Cannot make a java.lang.Class" + " constructor accessible"); } + } else if (obj instanceof Field && flag == true) { + Field f = (Field)obj; + if (f.getDeclaringClass() == Class.class && + f.getName().equals("classLoader")) { + throw new SecurityException("Cannot make java.lang.Class.classLoader" + + " accessible"); + } } obj.override = flag; } diff --git a/jdk/src/share/javavm/export/jvm.h b/jdk/src/share/javavm/export/jvm.h index 2bef0812054..396ca68558e 100644 --- a/jdk/src/share/javavm/export/jvm.h +++ b/jdk/src/share/javavm/export/jvm.h @@ -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 @@ -426,9 +426,6 @@ JVM_GetClassName(JNIEnv *env, jclass cls); JNIEXPORT jobjectArray JNICALL JVM_GetClassInterfaces(JNIEnv *env, jclass cls); -JNIEXPORT jobject JNICALL -JVM_GetClassLoader(JNIEnv *env, jclass cls); - JNIEXPORT jboolean JNICALL JVM_IsInterface(JNIEnv *env, jclass cls); diff --git a/jdk/src/share/native/common/check_code.c b/jdk/src/share/native/common/check_code.c index 92d96b19675..4ffbd67eaf2 100644 --- a/jdk/src/share/native/common/check_code.c +++ b/jdk/src/share/native/common/check_code.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -1357,16 +1357,9 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset) } (*env)->DeleteLocalRef(env, super); - /* The optimizer make cause this to happen on local code */ + /* The optimizer may cause this to happen on local code */ if (not_found) { -#ifdef BROKEN_JAVAC - jobject loader = JVM_GetClassLoader(env, context->class); - int has_loader = (loader != 0); - (*env)->DeleteLocalRef(env, loader); - if (has_loader) -#endif /* BROKEN_JAVAC */ - CCerror(context, - "Illegal use of nonvirtual function call"); + CCerror(context, "Illegal use of nonvirtual function call"); } } } diff --git a/jdk/src/share/native/java/lang/Class.c b/jdk/src/share/native/java/lang/Class.c index b0ba34349d8..c5e717fe0df 100644 --- a/jdk/src/share/native/java/lang/Class.c +++ b/jdk/src/share/native/java/lang/Class.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -45,7 +45,6 @@ extern jboolean VerifyFixClassname(char *utf_name); #define CLS "Ljava/lang/Class;" #define CPL "Lsun/reflect/ConstantPool;" #define STR "Ljava/lang/String;" -#define JCL "Ljava/lang/ClassLoader;" #define FLD "Ljava/lang/reflect/Field;" #define MHD "Ljava/lang/reflect/Method;" #define CTR "Ljava/lang/reflect/Constructor;" @@ -56,7 +55,6 @@ static JNINativeMethod methods[] = { {"getName0", "()" STR, (void *)&JVM_GetClassName}, {"getSuperclass", "()" CLS, NULL}, {"getInterfaces0", "()[" CLS, (void *)&JVM_GetClassInterfaces}, - {"getClassLoader0", "()" JCL, (void *)&JVM_GetClassLoader}, {"isInterface", "()Z", (void *)&JVM_IsInterface}, {"getSigners", "()[" OBJ, (void *)&JVM_GetClassSigners}, {"setSigners", "([" OBJ ")V", (void *)&JVM_SetClassSigners}, @@ -81,7 +79,6 @@ static JNINativeMethod methods[] = { #undef OBJ #undef CLS #undef STR -#undef JCL #undef FLD #undef MHD #undef CTR From d983b0b09c1717c2f7dc39a0b5e9903b712b6172 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Tue, 24 Jun 2014 19:29:41 +0200 Subject: [PATCH 123/236] 8048009: Type info caching accidentally defeated Reviewed-by: hannesw, jlaskey --- .../nashorn/internal/codegen/Compiler.java | 10 ++-------- .../codegen/OptimisticTypesPersistence.java | 20 +++++++++---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index 32888b0c2b0..f5281ba9d56 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -45,7 +45,6 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; @@ -122,11 +121,7 @@ public final class Compiler implements Loggable { * that using whatever was at program point 17 as an int failed. */ private final Map invalidatedProgramPoints; - /** - * The snapshot of invalidatedProgramPoints before the compilation. Used to compare it to invalidatedProgramPoints, - * and if the two are equal, not write the type information to a file. - */ - private final Map invalidatedProgramPointsOnEntry; + /** * Descriptor of the location where we write the type information after compilation. */ @@ -381,7 +376,6 @@ public final class Compiler implements Loggable { this.firstCompileUnitName = firstCompileUnitName(); this.strict = isStrict; - this.invalidatedProgramPointsOnEntry = typeInformationFile == null ? null : new HashMap<>(this.invalidatedProgramPoints); this.optimistic = env._optimistic_types; } @@ -537,7 +531,7 @@ public final class Compiler implements Loggable { time += (env.isTimingEnabled() ? phase.getEndTime() - phase.getStartTime() : 0L); } - if(typeInformationFile != null && !phases.isRestOfCompilation() && !Objects.equals(invalidatedProgramPoints, invalidatedProgramPointsOnEntry)) { + if(typeInformationFile != null && !phases.isRestOfCompilation()) { OptimisticTypesPersistence.store(typeInformationFile, invalidatedProgramPoints); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java b/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java index 317a3cf4f60..b90fa026ddb 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java @@ -136,11 +136,7 @@ public final class OptimisticTypesPersistence { } dout.flush(); } catch(final Exception e) { - final long now = System.currentTimeMillis(); - if(now - lastReportedError > ERROR_REPORT_THRESHOLD) { - getLogger().warning("Failed to write " + file, e); - lastReportedError = now; - } + reportError("write", file, e); } } return null; @@ -190,17 +186,21 @@ public final class OptimisticTypesPersistence { } } } catch (final Exception e) { - final long now = System.currentTimeMillis(); - if(now - lastReportedError > ERROR_REPORT_THRESHOLD) { - getLogger().warning("Failed to read " + file, e); - lastReportedError = now; - } + reportError("read", file, e); return null; } } }); } + private static void reportError(final String msg, final File file, final Exception e) { + final long now = System.currentTimeMillis(); + if(now - lastReportedError > ERROR_REPORT_THRESHOLD) { + getLogger().warning(String.format("Failed to %s %s", msg, file), e); + lastReportedError = now; + } + } + private static File createCacheDir() { if(Options.getBooleanProperty("nashorn.typeInfo.disabled")) { return null; From b531babf09707e260dea2ab5fcd67d20a0caed49 Mon Sep 17 00:00:00 2001 From: Alejandro Murillo Date: Tue, 24 Jun 2014 12:27:51 -0700 Subject: [PATCH 124/236] 8043541: 'fastdebug' is printed twice in java -version Reviewed-by: dholmes, dcubed, jcoomes --- hotspot/make/aix/makefiles/vm.make | 2 -- hotspot/make/bsd/makefiles/vm.make | 2 -- hotspot/make/defs.make | 8 ++++++-- hotspot/make/linux/makefiles/vm.make | 2 -- hotspot/make/solaris/makefiles/vm.make | 2 -- hotspot/make/windows/projectfiles/common/Makefile | 2 +- hotspot/src/share/vm/runtime/vm_version.cpp | 14 ++++++++------ 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/hotspot/make/aix/makefiles/vm.make b/hotspot/make/aix/makefiles/vm.make index b579babfffa..1170b0477d6 100644 --- a/hotspot/make/aix/makefiles/vm.make +++ b/hotspot/make/aix/makefiles/vm.make @@ -82,14 +82,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \ -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \ $(JDK_VER_DEFS) HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" CXXFLAGS = \ ${SYSDEFS} \ ${INCLUDES} \ - ${BUILD_TARGET} \ ${BUILD_USER} \ ${HS_LIB_ARCH} \ ${VM_DISTRO} diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make index 56beb6c6ba5..3a658ab1373 100644 --- a/hotspot/make/bsd/makefiles/vm.make +++ b/hotspot/make/bsd/makefiles/vm.make @@ -81,14 +81,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \ -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \ $(JDK_VER_DEFS) HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" CXXFLAGS = \ ${SYSDEFS} \ ${INCLUDES} \ - ${BUILD_TARGET} \ ${BUILD_USER} \ ${HS_LIB_ARCH} \ ${VM_DISTRO} diff --git a/hotspot/make/defs.make b/hotspot/make/defs.make index 65942d2b53f..70e050eb2e1 100644 --- a/hotspot/make/defs.make +++ b/hotspot/make/defs.make @@ -135,8 +135,12 @@ endif ifeq ($(JDK_MKTG_VERSION),) JDK_MKTG_VERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION) endif -ifeq ($(JDK_VERSION),) - JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION) +ifeq ($(JDK_VERSION),) + ifeq ($(BUILD_FLAVOR), product) + JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION) + else + JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)-$(BUILD_FLAVOR) + endif endif ifeq ($(FULL_VERSION),) FULL_VERSION="$(JDK_VERSION)" diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make index c91463aae13..7e3e5f0f65c 100644 --- a/hotspot/make/linux/makefiles/vm.make +++ b/hotspot/make/linux/makefiles/vm.make @@ -82,14 +82,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \ -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \ $(JDK_VER_DEFS) HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" CXXFLAGS = \ ${SYSDEFS} \ ${INCLUDES} \ - ${BUILD_TARGET} \ ${BUILD_USER} \ ${HS_LIB_ARCH} \ ${VM_DISTRO} diff --git a/hotspot/make/solaris/makefiles/vm.make b/hotspot/make/solaris/makefiles/vm.make index 3e32a57cd92..e0176bf66c2 100644 --- a/hotspot/make/solaris/makefiles/vm.make +++ b/hotspot/make/solaris/makefiles/vm.make @@ -77,14 +77,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \ -DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \ $(JDK_VER_DEFS) HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\"" BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" CXXFLAGS = \ ${SYSDEFS} \ ${INCLUDES} \ - ${BUILD_TARGET} \ ${BUILD_USER} \ ${HS_LIB_ARCH} \ ${VM_DISTRO} diff --git a/hotspot/make/windows/projectfiles/common/Makefile b/hotspot/make/windows/projectfiles/common/Makefile index 1fc1350706e..696b39257aa 100644 --- a/hotspot/make/windows/projectfiles/common/Makefile +++ b/hotspot/make/windows/projectfiles/common/Makefile @@ -116,7 +116,7 @@ JDK_MAJOR_VERSION="\\\"$(JDK_MAJOR_VER)\\\"" JDK_MINOR_VERSION="\\\"$(JDK_MINOR_VER)\\\"" JDK_MICRO_VERSION="\\\"$(JDK_MICRO_VER)\\\"" -ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -define JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) -define JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) -define JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) -define JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER) +ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -define JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) -define JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) -define JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) -define JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER) -define VISUAL_STUDIO_BUILD=true ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) $(ReleaseOptions) $(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp index 9fee996f687..a1779a85fe2 100644 --- a/hotspot/src/share/vm/runtime/vm_version.cpp +++ b/hotspot/src/share/vm/runtime/vm_version.cpp @@ -72,14 +72,16 @@ int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0; #ifndef JRE_RELEASE_VERSION #error JRE_RELEASE_VERSION must be defined #endif -#ifndef HOTSPOT_BUILD_TARGET - #error HOTSPOT_BUILD_TARGET must be defined -#endif -#ifdef PRODUCT - #define VM_RELEASE HOTSPOT_RELEASE_VERSION -#else +// NOTE: Builds within Visual Studio do not define the build target in +// HOTSPOT_RELEASE_VERSION, so it must be done here +#if defined(VISUAL_STUDIO_BUILD) && !defined(PRODUCT) + #ifndef HOTSPOT_BUILD_TARGET + #error HOTSPOT_BUILD_TARGET must be defined + #endif #define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET +#else + #define VM_RELEASE HOTSPOT_RELEASE_VERSION #endif // HOTSPOT_RELEASE_VERSION follows the JDK release version naming convention From 7f84a862efb412ad3fa9d8b9bc456bfb284c7e34 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Tue, 24 Jun 2014 14:07:05 -0700 Subject: [PATCH 125/236] 8048021: Remove @version tag in jaxp repo Reviewed-by: joehw --- .../com/sun/org/apache/bcel/internal/classfile/JavaClass.java | 1 - jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java | 1 - jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java | 1 - .../src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java | 1 - jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java | 1 - .../com/sun/org/apache/xalan/internal/utils/ObjectFactory.java | 1 - .../sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java | 1 - jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java | 1 - .../src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java | 1 - .../com/sun/org/apache/xerces/internal/dom/AttributeMap.java | 1 - .../apache/xerces/internal/dom/CoreDOMImplementationImpl.java | 1 - .../sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java | 1 - .../org/apache/xerces/internal/dom/DOMConfigurationImpl.java | 1 - .../org/apache/xerces/internal/dom/DOMMessageFormatter.java | 1 - .../com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java | 1 - .../org/apache/xerces/internal/dom/DeferredDocumentImpl.java | 1 - .../com/sun/org/apache/xerces/internal/dom/DocumentImpl.java | 1 - .../com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java | 1 - .../sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java | 1 - .../com/sun/org/apache/xerces/internal/dom/NodeListCache.java | 1 - .../sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java | 1 - .../src/com/sun/org/apache/xerces/internal/dom/ParentNode.java | 1 - .../src/com/sun/org/apache/xerces/internal/impl/Constants.java | 1 - jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java | 1 - .../apache/xerces/internal/impl/XML11DocumentScannerImpl.java | 1 - .../org/apache/xerces/internal/impl/XML11EntityScanner.java | 1 - .../xerces/internal/impl/XML11NSDocumentScannerImpl.java | 1 - .../sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java | 1 - .../xerces/internal/impl/XMLDocumentFragmentScannerImpl.java | 1 - .../apache/xerces/internal/impl/XMLDocumentScannerImpl.java | 1 - .../sun/org/apache/xerces/internal/impl/XMLEntityManager.java | 1 - .../sun/org/apache/xerces/internal/impl/XMLErrorReporter.java | 1 - .../apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java | 1 - .../org/apache/xerces/internal/impl/XMLNamespaceBinder.java | 1 - .../com/sun/org/apache/xerces/internal/impl/XMLScanner.java | 1 - .../apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java | 1 - .../sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java | 1 - .../org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java | 1 - .../sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java | 1 - .../org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java | 1 - .../org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java | 1 - .../xerces/internal/impl/dtd/models/DFAContentModel.java | 2 -- .../sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java | 1 - .../org/apache/xerces/internal/impl/dv/DatatypeException.java | 1 - .../org/apache/xerces/internal/impl/dv/SchemaDVFactory.java | 1 - .../org/apache/xerces/internal/impl/dv/ValidationContext.java | 1 - .../org/apache/xerces/internal/impl/dv/util/ByteListImpl.java | 1 - .../apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java | 1 - .../org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java | 1 - .../org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java | 1 - .../apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java | 1 - .../sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java | 1 - .../apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java | 1 - .../sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java | 1 - .../sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java | 1 - .../internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java | 1 - .../sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java | 1 - .../sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java | 1 - .../apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java | 1 - .../apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java | 1 - .../xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java | 1 - .../com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java | 1 - .../sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java | 1 - .../apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java | 1 - .../apache/xerces/internal/impl/msg/XMLMessageFormatter.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_de.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_es.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_fr.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_it.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_ja.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_ko.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_sv.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java | 1 - .../xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java | 1 - .../xerces/internal/impl/validation/ValidationState.java | 1 - .../xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java | 1 - .../xerces/internal/impl/xpath/regex/ParserForXMLSchema.java | 1 - .../apache/xerces/internal/impl/xpath/regex/RegexParser.java | 1 - .../xerces/internal/impl/xpath/regex/RegularExpression.java | 1 - .../sun/org/apache/xerces/internal/impl/xpath/regex/Token.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java | 1 - .../xerces/internal/impl/xs/SubstitutionGroupHandler.java | 1 - .../org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java | 1 - .../org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java | 1 - .../org/apache/xerces/internal/impl/xs/XSAttributeDecl.java | 1 - .../apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java | 1 - .../org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java | 1 - .../org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSConstraints.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSDDescription.java | 1 - .../org/apache/xerces/internal/impl/xs/XSDeclarationPool.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java | 1 - .../org/apache/xerces/internal/impl/xs/XSGrammarBucket.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java | 1 - .../org/apache/xerces/internal/impl/xs/XSMessageFormatter.java | 1 - .../org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/identity/Field.java | 1 - .../org/apache/xerces/internal/impl/xs/identity/Selector.java | 2 -- .../org/apache/xerces/internal/impl/xs/models/CMBuilder.java | 1 - .../apache/xerces/internal/impl/xs/models/CMNodeFactory.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java | 1 - .../xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java | 1 - .../apache/xerces/internal/impl/xs/models/XSCMValidator.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java | 1 - .../org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java | 1 - .../org/apache/xerces/internal/impl/xs/opti/ElementImpl.java | 1 - .../sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java | 1 - .../xerces/internal/impl/xs/opti/SchemaDOMImplementation.java | 1 - .../apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java | 1 - .../xerces/internal/impl/xs/opti/SchemaParsingConfig.java | 1 - .../xerces/internal/impl/xs/traversers/StAXSchemaParser.java | 1 - .../xerces/internal/impl/xs/traversers/XSAttributeChecker.java | 1 - .../impl/xs/traversers/XSDAbstractIDConstraintTraverser.java | 1 - .../impl/xs/traversers/XSDAbstractParticleTraverser.java | 1 - .../internal/impl/xs/traversers/XSDAbstractTraverser.java | 1 - .../impl/xs/traversers/XSDAttributeGroupTraverser.java | 1 - .../internal/impl/xs/traversers/XSDAttributeTraverser.java | 1 - .../internal/impl/xs/traversers/XSDComplexTypeTraverser.java | 1 - .../internal/impl/xs/traversers/XSDElementTraverser.java | 1 - .../xerces/internal/impl/xs/traversers/XSDGroupTraverser.java | 1 - .../apache/xerces/internal/impl/xs/traversers/XSDHandler.java | 1 - .../xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java | 1 - .../internal/impl/xs/traversers/XSDNotationTraverser.java | 1 - .../internal/impl/xs/traversers/XSDSimpleTypeTraverser.java | 1 - .../internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java | 1 - .../internal/impl/xs/traversers/XSDWildcardTraverser.java | 1 - .../xerces/internal/impl/xs/traversers/XSDocumentInfo.java | 1 - .../apache/xerces/internal/impl/xs/util/LSInputListImpl.java | 1 - .../apache/xerces/internal/impl/xs/util/ObjectListImpl.java | 1 - .../org/apache/xerces/internal/impl/xs/util/ShortListImpl.java | 1 - .../apache/xerces/internal/impl/xs/util/StringListImpl.java | 1 - .../org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java | 1 - .../org/apache/xerces/internal/impl/xs/util/XSInputSource.java | 1 - .../apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java | 1 - .../apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java | 1 - .../apache/xerces/internal/impl/xs/util/XSObjectListImpl.java | 1 - .../xerces/internal/jaxp/DocumentBuilderFactoryImpl.java | 1 - .../org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java | 1 - .../org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java | 1 - .../com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java | 1 - .../xerces/internal/jaxp/SchemaValidatorConfiguration.java | 1 - .../org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java | 1 - .../xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java | 1 - .../xerces/internal/jaxp/datatype/DurationDayTimeImpl.java | 1 - .../org/apache/xerces/internal/jaxp/datatype/DurationImpl.java | 1 - .../xerces/internal/jaxp/datatype/DurationYearMonthImpl.java | 1 - .../internal/jaxp/datatype/XMLGregorianCalendarImpl.java | 1 - .../xerces/internal/jaxp/validation/AbstractXMLSchema.java | 1 - .../xerces/internal/jaxp/validation/DOMValidatorHelper.java | 1 - .../apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java | 1 - .../jaxp/validation/JAXPValidationMessageFormatter.java | 1 - .../xerces/internal/jaxp/validation/StreamValidatorHelper.java | 1 - .../xerces/internal/jaxp/validation/ValidatorHandlerImpl.java | 1 - .../apache/xerces/internal/jaxp/validation/ValidatorImpl.java | 1 - .../xerces/internal/jaxp/validation/XMLSchemaFactory.java | 1 - .../jaxp/validation/XMLSchemaValidatorComponentManager.java | 1 - .../internal/jaxp/validation/XSGrammarPoolContainer.java | 1 - .../org/apache/xerces/internal/parsers/AbstractDOMParser.java | 1 - .../org/apache/xerces/internal/parsers/AbstractSAXParser.java | 1 - .../xerces/internal/parsers/BasicParserConfiguration.java | 1 - .../com/sun/org/apache/xerces/internal/parsers/DOMParser.java | 1 - .../sun/org/apache/xerces/internal/parsers/DOMParserImpl.java | 1 - .../org/apache/xerces/internal/parsers/DTDConfiguration.java | 1 - .../xerces/internal/parsers/NonValidatingConfiguration.java | 1 - .../com/sun/org/apache/xerces/internal/parsers/SAXParser.java | 1 - .../apache/xerces/internal/parsers/SecurityConfiguration.java | 1 - .../xerces/internal/parsers/StandardParserConfiguration.java | 1 - .../internal/parsers/XIncludeAwareParserConfiguration.java | 1 - .../org/apache/xerces/internal/parsers/XML11Configuration.java | 1 - .../apache/xerces/internal/parsers/XML11DTDConfiguration.java | 1 - .../internal/parsers/XML11NonValidatingConfiguration.java | 1 - .../org/apache/xerces/internal/parsers/XMLDocumentParser.java | 1 - .../internal/parsers/XMLGrammarCachingConfiguration.java | 1 - .../org/apache/xerces/internal/parsers/XMLGrammarParser.java | 1 - .../apache/xerces/internal/parsers/XMLGrammarPreparser.java | 1 - .../com/sun/org/apache/xerces/internal/parsers/XMLParser.java | 1 - jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java | 1 - .../apache/xerces/internal/util/DatatypeMessageFormatter.java | 1 - .../com/sun/org/apache/xerces/internal/util/EncodingMap.java | 1 - .../xerces/internal/util/JAXPNamespaceContextWrapper.java | 1 - .../xerces/internal/util/ParserConfigurationSettings.java | 1 - .../org/apache/xerces/internal/util/SAXMessageFormatter.java | 1 - .../sun/org/apache/xerces/internal/util/StAXInputSource.java | 1 - .../org/apache/xerces/internal/util/StAXLocationWrapper.java | 1 - .../com/sun/org/apache/xerces/internal/util/SymbolHash.java | 1 - .../src/com/sun/org/apache/xerces/internal/util/XML11Char.java | 1 - .../sun/org/apache/xerces/internal/util/XMLAttributesImpl.java | 1 - jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java | 1 - .../sun/org/apache/xerces/internal/utils/ObjectFactory.java | 1 - .../org/apache/xerces/internal/xinclude/XIncludeHandler.java | 1 - .../xerces/internal/xinclude/XIncludeMessageFormatter.java | 1 - jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java | 1 - .../com/sun/org/apache/xerces/internal/xni/XNIException.java | 1 - .../apache/xerces/internal/xni/parser/XMLComponentManager.java | 1 - .../xerces/internal/xni/parser/XMLConfigurationException.java | 1 - .../apache/xerces/internal/xpointer/ElementSchemePointer.java | 3 --- .../xerces/internal/xpointer/XPointerMessageFormatter.java | 1 - .../sun/org/apache/xerces/internal/xs/datatypes/ByteList.java | 1 - .../org/apache/xerces/internal/xs/datatypes/ObjectList.java | 1 - .../org/apache/xml/internal/serialize/DOMSerializerImpl.java | 1 - .../sun/org/apache/xml/internal/serialize/EncodingInfo.java | 1 - .../org/apache/xml/internal/serialize/SerializerFactory.java | 1 - .../com/sun/org/apache/xml/internal/serializer/Encodings.java | 1 - .../org/apache/xpath/internal/jaxp/XPathExpressionImpl.java | 1 - .../sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java | 1 - jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java | 1 - jaxp/src/javax/xml/XMLConstants.java | 1 - jaxp/src/javax/xml/datatype/DatatypeFactory.java | 1 - jaxp/src/javax/xml/datatype/package.html | 1 - jaxp/src/javax/xml/namespace/QName.java | 1 - jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java | 1 - jaxp/src/javax/xml/parsers/FactoryConfigurationError.java | 1 - jaxp/src/javax/xml/parsers/SAXParserFactory.java | 1 - jaxp/src/javax/xml/validation/SchemaFactoryFinder.java | 1 - jaxp/src/javax/xml/xpath/XPathFactoryFinder.java | 1 - jaxp/src/javax/xml/xpath/package.html | 1 - 229 files changed, 233 deletions(-) diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java b/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java index 4d28f2a92f5..db83c73b299 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/classfile/JavaClass.java @@ -78,7 +78,6 @@ import java.util.StringTokenizer; * class file. Those interested in programatically generating classes * should see the ClassGen class. - * @version $Id: JavaClass.java,v 1.4 2007-07-19 04:34:42 ofung Exp $ * @see com.sun.org.apache.bcel.internal.generic.ClassGen * @author M. Dahm */ diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java b/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java index 5a9e094d460..52b9df945c7 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/util/Class2HTML.java @@ -82,7 +82,6 @@ import com.sun.org.apache.bcel.internal.Constants; * method in the Method's frame will jump to the appropiate method in * the Code frame. * - * @version $Id: Class2HTML.java,v 1.3 2007-07-19 04:34:52 ofung Exp $ * @author M. Dahm */ public class Class2HTML implements Constants diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java b/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java index 0cd5021ddb1..ac4745ea97f 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/util/ClassPath.java @@ -66,7 +66,6 @@ import java.io.*; * Responsible for loading (class) files from the CLASSPATH. Inspired by * sun.tools.ClassPath. * - * @version $Id: ClassPath.java,v 1.4 2007-07-19 04:34:52 ofung Exp $ * @author M. Dahm */ public class ClassPath implements Serializable { diff --git a/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java b/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java index 1540f6d5c8b..d264b047ba1 100644 --- a/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java +++ b/jaxp/src/com/sun/org/apache/bcel/internal/util/JavaWrapper.java @@ -72,7 +72,6 @@ import java.lang.reflect.*; *
java com.sun.org.apache.bcel.internal.util.JavaWrapper -Dbcel.classloader=foo.MyLoader <real.class.name> [arguments]
*

* - * @version $Id: JavaWrapper.java,v 1.3 2007-07-19 04:34:52 ofung Exp $ * @author M. Dahm * @see ClassLoader */ diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java index 095a6e74b96..9b3b0fa46cd 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xalan.internal.utils.SecuritySupport; * * @author Huizhe Wang, Oracle * - * @version $Id: Constants.java,v 1.14 2011-06-07 04:39:40 joehw Exp $ */ public final class XalanConstants { diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java index 034d8eec84b..7d5d104501d 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java @@ -32,7 +32,6 @@ package com.sun.org.apache.xalan.internal.utils; * class and modified to be used as a general utility for creating objects * dynamically. * - * @version $Id: ObjectFactory.java,v 1.11 2010-11-01 04:34:25 joehw Exp $ */ public class ObjectFactory { diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java b/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java index 928da3e9e9d..a6b99891be4 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java @@ -92,7 +92,6 @@ import org.w3c.dom.Node; * of thing but in a much simpler manner.

* * @author Shane_Curcuru@us.ibm.com - * @version $Id: EnvironmentCheck.java,v 1.10 2010-11-01 04:34:13 joehw Exp $ */ public class EnvironmentCheck { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java index 352fba6a18c..873f7be9842 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrImpl.java @@ -109,7 +109,6 @@ import org.w3c.dom.Text; * @author Arnaud Le Hors, IBM * @author Joe Kesselman, IBM * @author Andy Clark, IBM - * @version $Id: AttrImpl.java,v 1.5 2008/06/10 00:59:32 joehw Exp $ * @since PR-DOM-Level-1-19980818. * */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java index 7defc559d01..34de50dccde 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttrNSImpl.java @@ -37,7 +37,6 @@ import org.w3c.dom.DOMException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM - * @version $Id: AttrNSImpl.java,v 1.7 2010-11-01 04:39:37 joehw Exp $ */ public class AttrNSImpl extends AttrImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java index 8d2d054fccc..5f7f4e17340 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/AttributeMap.java @@ -40,7 +40,6 @@ import org.w3c.dom.Node; * * @xerces.internal * - * @version $Id: AttributeMap.java,v 1.7 2010-11-01 04:39:37 joehw Exp $ */ public class AttributeMap extends NamedNodeMapImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java index f20775e3f7a..45b91dc9aa2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDOMImplementationImpl.java @@ -52,7 +52,6 @@ import org.w3c.dom.ls.LSSerializer; * * @xerces.internal * - * @version $Id: CoreDOMImplementationImpl.java,v 1.6 2010-11-01 04:39:37 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class CoreDOMImplementationImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java index 46cbc349ff4..2fb6f8b225d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/CoreDocumentImpl.java @@ -79,7 +79,6 @@ import org.w3c.dom.ls.LSSerializer; * @author Joe Kesselman, IBM * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM - * @version $Id: CoreDocumentImpl.java,v 1.9 2010-11-01 04:39:37 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java index 1e8dcd98817..189abdff259 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMConfigurationImpl.java @@ -68,7 +68,6 @@ import org.w3c.dom.ls.LSResourceResolver; * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems. - * @version $Id: DOMConfigurationImpl.java,v 1.9 2010-11-01 04:39:37 joehw Exp $ */ public class DOMConfigurationImpl extends ParserConfigurationSettings implements XMLParserConfiguration, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java index f7d131fdb9b..1d30c9e76b4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMMessageFormatter.java @@ -31,7 +31,6 @@ import java.util.ResourceBundle; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: DOMMessageFormatter.java,v 1.6 2010-11-01 04:39:38 joehw Exp $ */ public class DOMMessageFormatter { public static final String DOM_DOMAIN = "http://www.w3.org/dom/DOMTR"; diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java index 3758f399230..651bd741432 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DOMNormalizer.java @@ -94,7 +94,6 @@ import org.w3c.dom.Text; * * @author Elena Litani, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @version $Id: DOMNormalizer.java,v 1.9 2010-11-01 04:39:38 joehw Exp $ */ public class DOMNormalizer implements XMLDocumentHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java index 92c03b0baad..8f133b8799a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DeferredDocumentImpl.java @@ -40,7 +40,6 @@ import org.w3c.dom.Node; * * @xerces.internal * - * @version $Id: DeferredDocumentImpl.java,v 1.11 2010-11-01 04:39:38 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class DeferredDocumentImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java index 4cc06483c56..55d43c6df90 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/DocumentImpl.java @@ -76,7 +76,6 @@ import org.w3c.dom.traversal.TreeWalker; * @author Joe Kesselman, IBM * @author Andy Clark, IBM * @author Ralf Pfeiffer, IBM - * @version $Id: DocumentImpl.java,v 1.6 2010/07/20 20:25:24 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class DocumentImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java index 35757db0911..042835e7ce6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ElementNSImpl.java @@ -42,7 +42,6 @@ import org.w3c.dom.DOMException; * * @author Elena litani, IBM * @author Neeraj Bajaj, Sun Microsystems - * @version $Id: ElementNSImpl.java,v 1.7 2010-11-01 04:39:39 joehw Exp $ */ public class ElementNSImpl extends ElementImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java index fcf40479703..f3e0c942758 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NamedNodeMapImpl.java @@ -56,7 +56,6 @@ import org.w3c.dom.Node; * * @xerces.internal * - * @version $Id: NamedNodeMapImpl.java,v 1.8 2010-11-01 04:39:39 joehw Exp $ * @since PR-DOM-Level-1-19980818. */ public class NamedNodeMapImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java index e0923ce9960..585c41e6364 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/NodeListCache.java @@ -30,7 +30,6 @@ import java.io.Serializable; * * @author Arnaud Le Hors, IBM * - * @version $Id: NodeListCache.java,v 1.6 2010/07/20 20:25:25 joehw Exp $ */ class NodeListCache implements Serializable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java index 7b26a9ad96c..272a7c93a18 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/PSVIElementNSImpl.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.*; * * @author Sandy Gao, IBM * - * @version $Id: PSVIElementNSImpl.java,v 1.6 2010/08/20 18:51:54 joehw Exp $ */ public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java index 7725c4c530d..3481afe1f6a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/dom/ParentNode.java @@ -68,7 +68,6 @@ import org.w3c.dom.UserDataHandler; * @author Arnaud Le Hors, IBM * @author Joe Kesselman, IBM * @author Andy Clark, IBM - * @version $Id: ParentNode.java,v 1.6 2009/07/21 20:30:28 joehw Exp $ */ public abstract class ParentNode extends ChildNode { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java index 4eab0fadfe9..147a3ab43a6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Constants.java @@ -31,7 +31,6 @@ import java.util.NoSuchElementException; * * @author Andy Clark, IBM * - * @version $Id: Constants.java,v 1.14 2010-11-01 04:39:40 joehw Exp $ */ public final class Constants { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java index ac62db7dc26..41a2b620b5c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/Version.java @@ -64,7 +64,6 @@ package com.sun.org.apache.xerces.internal.impl; /** * This class defines the version number of the parser. * - * @version $Id: Version.java,v 1.4 2010-11-01 04:39:40 joehw Exp $ */ public class Version { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java index dda470ae873..cf5f3b9059b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11DocumentScannerImpl.java @@ -96,7 +96,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException; * @author Arnaud Le Hors, IBM * @author Eric Ye, IBM * - * @version $Id: XML11DocumentScannerImpl.java,v 1.5 2010/08/04 20:59:09 joehw Exp $ */ public class XML11DocumentScannerImpl extends XMLDocumentScannerImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java index 518c09ab7f6..130c6227511 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11EntityScanner.java @@ -77,7 +77,6 @@ import java.io.IOException; * * @author Michael Glavassevich, IBM * @author Neil Graham, IBM - * @version $Id: XML11EntityScanner.java,v 1.5 2010-11-01 04:39:40 joehw Exp $ */ public class XML11EntityScanner diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java index 7a826dfcc97..7d6b3cbd043 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XML11NSDocumentScannerImpl.java @@ -108,7 +108,6 @@ import javax.xml.stream.events.XMLEvent; * @author Elena Litani, IBM * @author Michael Glavassevich, IBM * @author Sunitha Reddy, Sun Microsystems - * @version $Id: XML11NSDocumentScannerImpl.java,v 1.6 2010-11-01 04:39:40 joehw Exp $ */ public class XML11NSDocumentScannerImpl extends XML11DocumentScannerImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java index d2ede948ac1..74db88ca6cd 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDTDScannerImpl.java @@ -69,7 +69,6 @@ import com.sun.xml.internal.stream.Entity; * @author Glenn Marcy, IBM * @author Eric Ye, IBM * - * @version $Id: XMLDTDScannerImpl.java,v 1.8 2010-11-01 04:39:41 joehw Exp $ */ public class XMLDTDScannerImpl extends XMLScanner diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java index 01468284cd1..fc8b5098a57 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java @@ -78,7 +78,6 @@ import javax.xml.stream.events.XMLEvent; * @author Arnaud Le Hors, IBM * @author Eric Ye, IBM * @author Sunitha Reddy, SUN Microsystems - * @version $Id: XMLDocumentFragmentScannerImpl.java,v 1.19 2010-11-02 19:54:55 joehw Exp $ * */ public class XMLDocumentFragmentScannerImpl diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java index c2d58bd4070..d191de9ba89 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java @@ -65,7 +65,6 @@ import javax.xml.stream.events.XMLEvent; * Refer to the table in unit-test javax.xml.stream.XMLStreamReaderTest.SupportDTD for changes * related to property SupportDTD. * @author Joe Wang, Sun Microsystems - * @version $Id: XMLDocumentScannerImpl.java,v 1.17 2010-11-01 04:39:41 joehw Exp $ */ public class XMLDocumentScannerImpl extends XMLDocumentFragmentScannerImpl{ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index 988fd6f9c60..7a70b3abece 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -83,7 +83,6 @@ import java.util.StringTokenizer; * @author K.Venugopal SUN Microsystems * @author Neeraj Bajaj SUN Microsystems * @author Sunitha Reddy SUN Microsystems - * @version $Id: XMLEntityManager.java,v 1.17 2010-11-01 04:39:41 joehw Exp $ */ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java index 8d0ed6d76fd..e6ce89d3816 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLErrorReporter.java @@ -111,7 +111,6 @@ import org.xml.sax.ErrorHandler; * @author Eric Ye, IBM * @author Andy Clark, IBM * - * @version $Id: XMLErrorReporter.java,v 1.5 2010-11-01 04:39:41 joehw Exp $ */ public class XMLErrorReporter implements XMLComponent { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java index 66b8179b97b..36d72ac51df 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java @@ -58,7 +58,6 @@ import javax.xml.stream.events.XMLEvent; * @author Neeraj Bajaj, Sun Microsystems * @author Venugopal Rao K, Sun Microsystems * @author Elena Litani, IBM - * @version $Id: XMLNSDocumentScannerImpl.java,v 1.11 2010-11-01 04:39:41 joehw Exp $ */ public class XMLNSDocumentScannerImpl extends XMLDocumentScannerImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java index 13c27bc8fed..33a18a84444 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNamespaceBinder.java @@ -97,7 +97,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; * * @author Andy Clark, IBM * - * @version $Id: XMLNamespaceBinder.java,v 1.4 2010-11-01 04:39:41 joehw Exp $ */ public class XMLNamespaceBinder implements XMLComponent, XMLDocumentFilter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java index 0cb44b2c0c0..28fbc69270e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLScanner.java @@ -69,7 +69,6 @@ import com.sun.xml.internal.stream.Entity; * @author Eric Ye, IBM * @author K.Venugopal SUN Microsystems * @author Sunitha Reddy, SUN Microsystems - * @version $Id: XMLScanner.java,v 1.12 2010-11-01 04:39:41 joehw Exp $ */ public abstract class XMLScanner implements XMLComponent { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java index 0b09e34ffc1..c144a2490b6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/BalancedDTDGrammar.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException; * @xerces.internal * * @author Michael Glavassevich, IBM - * @version $Id: BalancedDTDGrammar.java,v 1.1 2010/08/11 07:18:38 joehw Exp $ */ final class BalancedDTDGrammar extends DTDGrammar { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java index 71a9231f71b..f0478f45fb8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/DTDGrammar.java @@ -101,7 +101,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource; * @author Andy Clark, IBM * @author Neil Graham, IBM * - * @version $Id: DTDGrammar.java,v 1.4 2010/08/11 07:18:37 joehw Exp $ */ public class DTDGrammar implements XMLDTDHandler, XMLDTDContentModelHandler, EntityState, Grammar { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java index b9e48e9225e..90a55affe91 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDDescription.java @@ -75,7 +75,6 @@ import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XMLDTDDescription.java,v 1.4 2010/08/11 07:18:38 joehw Exp $ */ public class XMLDTDDescription extends XMLResourceIdentifierImpl implements com.sun.org.apache.xerces.internal.xni.grammars.XMLDTDDescription { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java index ea343942ea5..eea1b94613f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDLoader.java @@ -108,7 +108,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; * @author Neil Graham, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XMLDTDLoader.java,v 1.6 2010-11-01 04:39:42 joehw Exp $ */ public class XMLDTDLoader extends XMLDTDProcessor diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java index 45e1b31e0bc..85bdb7f74c5 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDProcessor.java @@ -113,7 +113,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource; * * @author Neil Graham, IBM * - * @version $Id: XMLDTDProcessor.java,v 1.5 2010-11-01 04:39:42 joehw Exp $ */ public class XMLDTDProcessor implements XMLComponent, XMLDTDFilter, XMLDTDContentModelFilter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java index 05308782e62..01c8c54f7a7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/XMLDTDValidator.java @@ -83,7 +83,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; * @author Jeffrey Rodriguez IBM * @author Neil Graham, IBM * - * @version $Id: XMLDTDValidator.java,v 1.8 2010-11-01 04:39:42 joehw Exp $ */ public class XMLDTDValidator implements XMLComponent, XMLDocumentFilter, XMLDTDValidatorFilter, RevalidationHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java index 9a4e0f5c122..008bd6ff8fe 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dtd/models/DFAContentModel.java @@ -68,7 +68,6 @@ import com.sun.org.apache.xerces.internal.xni.QName; /** - * @version $Id: DFAContentModel.java,v 1.4 2010/08/06 23:49:43 joehw Exp $ * DFAContentModel is the derivative of ContentModel that does * all of the non-trivial element content validation. This class does * the conversion from the regular expression to the DFA that @@ -82,7 +81,6 @@ import com.sun.org.apache.xerces.internal.xni.QName; * * @xerces.internal * - * @version $Id: DFAContentModel.java,v 1.4 2010/08/06 23:49:43 joehw Exp $ */ public class DFAContentModel implements ContentModelValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java index 15afa2e1407..fd7426f7551 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DTDDVFactory.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.utils.ObjectFactory; * * @author Sandy Gao, IBM * - * @version $Id: DTDDVFactory.java,v 1.6 2010-11-01 04:39:43 joehw Exp $ */ public abstract class DTDDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java index f38b1d3797f..363b26844f3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/DatatypeException.java @@ -35,7 +35,6 @@ import java.util.MissingResourceException; * * @author Sandy Gao, IBM * - * @version $Id: DatatypeException.java,v 1.6 2010-11-01 04:39:43 joehw Exp $ */ public class DatatypeException extends Exception { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java index 902d9d3fdea..47646f2dad2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/SchemaDVFactory.java @@ -40,7 +40,6 @@ import com.sun.org.apache.xerces.internal.utils.ObjectFactory; * * @author Sandy Gao, IBM * - * @version $Id: SchemaDVFactory.java,v 1.6 2010-11-01 04:39:43 joehw Exp $ */ public abstract class SchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java index 6ff4d66031e..da8d550a84a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/ValidationContext.java @@ -29,7 +29,6 @@ import java.util.Locale; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: ValidationContext.java,v 1.6 2010/07/23 02:09:29 joehw Exp $ */ public interface ValidationContext { // whether to validate against facets diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java index 984fb2ab404..3357593489d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/util/ByteListImpl.java @@ -31,7 +31,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.ByteList; * * @author Ankit Pasricha, IBM * - * @version $Id: ByteListImpl.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class ByteListImpl extends AbstractList implements ByteList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java index d9d6587379b..64242a5cf95 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/AbstractDateTimeDV.java @@ -47,7 +47,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSDateTime; * @author Len Berman * @author Gopal Sharma, SUN Microsystems Inc. * - * @version $Id: AbstractDateTimeDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public abstract class AbstractDateTimeDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java index fcfa039df43..47185b1725d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/Base64BinaryDV.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.ByteListImpl; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: Base64BinaryDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class Base64BinaryDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java index 198f3aba046..715b0ee040c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseDVFactory.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: BaseDVFactory.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class BaseDVFactory extends SchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java index da30a8f5fed..3cc03f0b449 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/BaseSchemaDVFactory.java @@ -38,7 +38,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @author Sandy Gao, IBM * @author Khaled Noaman, IBM * - * @version $Id: BaseSchemaDVFactory.java,v 1.2 2010-10-26 23:01:03 joehw Exp $ */ public abstract class BaseSchemaDVFactory extends SchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java index 01b0eabcf6d..d302e22fd1a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystems Inc. * - * @version $Id: DateDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DateDV extends DateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java index 6b2011d974d..2a19f8cec9f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DateTimeDV.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: DateTimeDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DateTimeDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java index 1e501f01be4..d0e6ce6021e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayDV.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. - * @version $Id: DayDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DayDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java index dd16f196cd3..8488503acee 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DayTimeDurationDV.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Ankit Pasricha, IBM * - * @version $Id: DayTimeDurationDV.java,v 1.6 2010-11-01 04:39:46 joehw Exp $ */ class DayTimeDurationDV extends DurationDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java index e884d0d62d6..a25d6d7243e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DoubleDV.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSDouble; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: DoubleDV.java,v 1.7 2010-11-01 04:39:46 joehw Exp $ */ public class DoubleDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java index 1ec86d0ae6d..9ad95cc77b4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DurationDV.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. - * @version $Id: DurationDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class DurationDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java index fa7e79e42c8..13d166a8f53 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ExtendedSchemaDVFactoryImpl.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.util.SymbolHash; * * @author Khaled Noaman, IBM * - * @version $Id: ExtendedSchemaDVFactoryImpl.java,v 1.2 2010-10-26 23:01:03 joehw Exp $ */ public class ExtendedSchemaDVFactoryImpl extends BaseSchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java index 9ff0ecfccd9..f2478233564 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/FloatDV.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSFloat; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: FloatDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class FloatDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java index 2b872263637..99bc19709dc 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/HexBinaryDV.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.util.HexBin; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: HexBinaryDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class HexBinaryDV extends TypeValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java index ca074323d37..07d49b0988c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/ListDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: ListDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class ListDV extends TypeValidator{ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java index ea57736397f..175c5ebf2d9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: MonthDV.java,v 1.8 2010-11-01 04:39:47 joehw Exp $ */ public class MonthDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java index 4b4dc118ada..0edc0006ad7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/MonthDayDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: MonthDayDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class MonthDayDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java index 3e0570b51aa..5bb8a4350ed 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/SchemaDVFactoryImpl.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.util.SymbolHash; * @author Neeraj Bajaj, Sun Microsystems, inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDVFactoryImpl.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class SchemaDVFactoryImpl extends BaseSchemaDVFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java index c9bbae21174..4c7bb4dd46d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/TimeDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: TimeDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class TimeDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java index c9c913464e6..fa4a495a571 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDecl.java @@ -60,7 +60,6 @@ import org.w3c.dom.TypeInfo; * @author Sandy Gao, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. * - * @version $Id: XSSimpleTypeDecl.java 3029 2011-04-24 17:50:18Z joehw $ */ public class XSSimpleTypeDecl implements XSSimpleType, TypeInfo { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java index 1b683db3457..318bc69299e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/XSSimpleTypeDelegate.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @xerces.internal * - * @version $Id: XSSimpleTypeDelegate.java,v 1.3 2010-11-01 04:39:47 joehw Exp $ */ public class XSSimpleTypeDelegate implements XSSimpleType { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java index d069c401a0f..02c5058f55c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: YearDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class YearDV extends AbstractDateTimeDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java index 6b96deb1ded..b9fde68ca18 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * @author Elena Litani * @author Gopal Sharma, SUN Microsystem Inc. * - * @version $Id: YearMonthDV.java,v 1.7 2010-11-01 04:39:47 joehw Exp $ */ public class YearMonthDV extends AbstractDateTimeDV{ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java index 4723a65cf32..c11413097ec 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/YearMonthDurationDV.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; * * @author Ankit Pasricha, IBM * - * @version $Id: YearMonthDurationDV.java,v 1.6 2010-11-01 04:39:47 joehw Exp $ */ class YearMonthDurationDV extends DurationDV { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java index adb8c44ab2e..0f7ed95d5a8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter.java @@ -33,7 +33,6 @@ import java.util.ResourceBundle; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java index 1f9d2816165..24c5e41d4d7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_de.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_de.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_de implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java index 164a2513a9e..5dab448b1fb 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_es.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_es.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_es implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java index e4e41292716..1b4974a2e8c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_fr.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_fr.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_fr implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java index e2dd5132d21..66d1b90951c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_it.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_it.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_it implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java index b3fb8563e67..14363761574 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ja.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_ja.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_ja implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java index 3de7757c5bc..a042bdd9afe 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_ko.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_ko.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_ko implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java index 59b3d1d30a7..053445dc06a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_pt_BR.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_pt_BR.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_pt_BR implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java index 00217ae4f7b..bb4d9531d38 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_sv.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_sv.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_sv implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java index 4cfa9686da0..13f6be55cb6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_CN.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_zh_CN.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_zh_CN implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java index 4f34fa2adc5..1965d571783 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/msg/XMLMessageFormatter_zh_TW.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @xerces.internal * * @author Eric Ye, IBM - * @version $Id: XMLMessageFormatter_zh_TW.java 3094 2012-03-21 05:50:01Z joehw $ * */ public class XMLMessageFormatter_zh_TW implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java index a04c57dcef7..686e2b1c916 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/validation/ValidationState.java @@ -34,7 +34,6 @@ import java.util.Locale; * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: ValidationState.java,v 1.7 2010-11-01 04:39:53 joehw Exp $ */ public class ValidationState implements ValidationContext { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java index 202f239feaf..3f5da982fa4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/CaseInsensitiveMap.java @@ -22,7 +22,6 @@ package com.sun.org.apache.xerces.internal.impl.xpath.regex; /** - * @version $Id: CaseInsensitiveMap.java,v 1.1 2010/07/27 06:29:27 joehw Exp $ */ public class CaseInsensitiveMap { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java index 22e2a710c9b..aa18a901dac 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/ParserForXMLSchema.java @@ -29,7 +29,6 @@ import java.util.Locale; * @xerces.internal * * @author TAMURA Kent <kent@trl.ibm.co.jp> - * @version $Id: ParserForXMLSchema.java,v 1.9 2010-11-12 18:09:45 joehw Exp $ */ class ParserForXMLSchema extends RegexParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java index ed1cda9ba3e..5435fc799d9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegexParser.java @@ -31,7 +31,6 @@ import java.util.Vector; * * @xerces.internal * - * @version $Id: RegexParser.java,v 1.8 2010-11-01 04:39:54 joehw Exp $ */ class RegexParser { static final int T_CHAR = 0; diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java index fa488d64ad2..0a996b27c10 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RegularExpression.java @@ -486,7 +486,6 @@ import com.sun.org.apache.xerces.internal.util.IntStack; * @xerces.internal * * @author TAMURA Kent <kent@trl.ibm.co.jp> - * @version $Id: RegularExpression.java,v 1.9 2010/07/27 05:02:34 joehw Exp $ */ public class RegularExpression implements java.io.Serializable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java index a395e47fdc4..5221b6e8612 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/Token.java @@ -28,7 +28,6 @@ import java.util.Hashtable; * * @xerces.internal * - * @version $Id: Token.java,v 1.7 2010/07/27 05:02:34 joehw Exp $ */ class Token implements java.io.Serializable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java index ea450035ffd..06ec54dd9d2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SchemaGrammar.java @@ -75,7 +75,6 @@ import org.xml.sax.SAXException; * @author Sandy Gao, IBM * @author Elena Litani, IBM * - * @version $Id: SchemaGrammar.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class SchemaGrammar implements XSGrammar, XSNamespaceItem { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java index 1fbe4c74cda..f2d4e745af4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/SubstitutionGroupHandler.java @@ -35,7 +35,6 @@ import java.util.Vector; * * @author Sandy Gao, IBM * - * @version $Id: SubstitutionGroupHandler.java,v 1.6 2010-11-01 04:39:55 joehw Exp $ */ public class SubstitutionGroupHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java index d37a0300ed8..63123391ca3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaLoader.java @@ -98,7 +98,6 @@ import org.xml.sax.InputSource; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XMLSchemaLoader.java,v 1.10 2010-11-01 04:39:55 joehw Exp $ */ public class XMLSchemaLoader implements XMLGrammarLoader, XMLComponent, diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java index f7fc09a6d00..fd03b7a8f75 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java @@ -107,7 +107,6 @@ import com.sun.org.apache.xerces.internal.parsers.XMLParser; * @author Elena Litani IBM * @author Andy Clark IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @version $Id: XMLSchemaValidator.java,v 1.16 2010-11-01 04:39:55 joehw Exp $ */ public class XMLSchemaValidator implements XMLComponent, XMLDocumentFilter, FieldActivator, RevalidationHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java index 183c6f22f63..7542c684f69 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeDecl.java @@ -41,7 +41,6 @@ import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSAttributeDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSAttributeDecl implements XSAttributeDeclaration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java index 8e907051eee..fda0899f9da 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeGroupDecl.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xs.XSWildcard; * @author Sandy Gao, IBM * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: XSAttributeGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSAttributeGroupDecl implements XSAttributeGroupDefinition { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java index 174c2852a92..42e64e3c87a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSAttributeUseImpl.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSAttributeUseImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSAttributeUseImpl implements XSAttributeUse { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java index 79f250028b4..3096988cb2e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java @@ -36,7 +36,6 @@ import org.w3c.dom.TypeInfo; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSComplexTypeDecl.java,v 1.8 2010-11-01 04:39:55 joehw Exp $ */ public class XSComplexTypeDecl implements XSComplexTypeDefinition, TypeInfo { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java index c56ad0d1b57..3b5e28c2d77 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSConstraints.java @@ -45,7 +45,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Sandy Gao, IBM * - * @version $Id: XSConstraints.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSConstraints { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java index c35baa8667a..545388002e7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDDescription.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xni.grammars.XMLSchemaDescription; * @author Neil Graham, IBM * @author Neeraj Bajaj, SUN Microsystems. * - * @version $Id: XSDDescription.java,v 1.6 2010-11-01 04:39:55 joehw Exp $ */ public class XSDDescription extends XMLResourceIdentifierImpl implements XMLSchemaDescription { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java index 5578da2a44b..604f50da504 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSDeclarationPool.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl; * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: XSDeclarationPool.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public final class XSDeclarationPool { /** Chunk shift (8). */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java index 190daa779b0..70d5347e5c2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSElementDecl.java @@ -43,7 +43,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSElementDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSElementDecl implements XSElementDeclaration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java index 6d88c5fdd00..456b78ba721 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGrammarBucket.java @@ -31,7 +31,6 @@ import java.util.Vector; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSGrammarBucket.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSGrammarBucket { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java index a710e53b621..3c51b0c5004 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSGroupDecl.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSGroupDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSGroupDecl implements XSModelGroupDefinition { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java index 136d69e2dbb..48fa9c38448 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSLoaderImpl.java @@ -45,7 +45,6 @@ import org.w3c.dom.ls.LSInput; * * @author Michael Glavassevich, IBM * - * @version $Id: XSLoaderImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public final class XSLoaderImpl implements XSLoader, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java index 0a51a3c6b8f..236b7962373 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSMessageFormatter.java @@ -34,7 +34,6 @@ import java.util.ResourceBundle; * @xerces.internal * * @author Elena Litani, IBM - * @version $Id: XSMessageFormatter.java,v 1.6 2010-11-01 04:39:55 joehw Exp $ */ public class XSMessageFormatter implements MessageFormatter { /** diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java index 4414003319c..8f63830c7a6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelGroupImpl.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * * @author Sandy Gao, IBM * - * @version $Id: XSModelGroupImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSModelGroupImpl implements XSModelGroup { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java index bded2950e0b..01201a766ea 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSModelImpl.java @@ -57,7 +57,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Sandy Gao, IBM * - * @version $Id: XSModelImpl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public final class XSModelImpl extends AbstractList implements XSModel, XSNamespaceItemList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java index 94505f9969d..c34f16b8f88 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSNotationDecl.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @xerces.internal * * @author Rahul Srivastava, Sun Microsystems Inc. - * @version $Id: XSNotationDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSNotationDecl implements XSNotationDeclaration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java index 468f652cbc9..cb2ba9a5066 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSParticleDecl.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTerm; * * @author Sandy Gao, IBM * - * @version $Id: XSParticleDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSParticleDecl implements XSParticle { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java index ac3a00eac6c..b56db22ba14 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/XSWildcardDecl.java @@ -38,7 +38,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * @author Sandy Gao, IBM * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: XSWildcardDecl.java,v 1.7 2010-11-01 04:39:55 joehw Exp $ */ public class XSWildcardDecl implements XSWildcard { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java index ca968f8d41e..c00e802e6d4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Field.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * @xerces.internal * * @author Andy Clark, IBM - * @version $Id: Field.java,v 1.6 2010-11-01 04:39:57 joehw Exp $ */ public class Field { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java index f36e5ee3ab3..283e6c1f153 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/identity/Selector.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * @xerces.internal * * @author Andy Clark, IBM - * @version $Id: Selector.java,v 1.7 2010-11-01 04:39:57 joehw Exp $ */ public class Selector { @@ -106,7 +105,6 @@ public class Selector { * Schema identity constraint selector XPath expression. * * @author Andy Clark, IBM - * @version $Id: Selector.java,v 1.7 2010-11-01 04:39:57 joehw Exp $ */ public static class XPath extends com.sun.org.apache.xerces.internal.impl.xpath.XPath { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java index ca8815458d4..e03ca553540 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMBuilder.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.impl.xs.XSParticleDecl; * @author Elena Litani, IBM * @author Sandy Gao, IBM * - * @version $Id: CMBuilder.java,v 1.11 2010/08/06 23:49:43 joehw Exp $ */ public class CMBuilder { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java index 6aa06b8828d..8962280abbb 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/CMNodeFactory.java @@ -35,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; * * @author Neeraj Bajaj * - * @version $Id: CMNodeFactory.java,v 1.7 2010-11-01 04:39:58 joehw Exp $ */ public class CMNodeFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java index f2cf0a7b7c1..d3060915341 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSAllCM.java @@ -35,7 +35,6 @@ import java.util.ArrayList; * @xerces.internal * * @author Pavani Mukthipudi, Sun Microsystems Inc. - * @version $Id: XSAllCM.java,v 1.10 2010-11-01 04:39:58 joehw Exp $ */ public class XSAllCM implements XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java index 46788962e8e..dd7c1184986 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMRepeatingLeaf.java @@ -27,7 +27,6 @@ package com.sun.org.apache.xerces.internal.impl.xs.models; * @xerces.internal * * @author Michael Glavassevich, IBM - * @version $Id: XSCMRepeatingLeaf.java,v 1.1 2010/08/06 23:49:43 joehw Exp $ */ public final class XSCMRepeatingLeaf extends XSCMLeaf { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java index 341d88bcef0..d387ac52261 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSCMValidator.java @@ -34,7 +34,6 @@ import java.util.ArrayList; * * @author Sandy Gao, IBM * @author Elena Litani, IBM - * @version $Id: XSCMValidator.java,v 1.6 2009/07/28 15:18:12 spericas Exp $ */ public interface XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java index e4b5ee280eb..997ca17cb95 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSDFACM.java @@ -45,7 +45,6 @@ import java.util.HashMap; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDFACM.java,v 1.9 2010/08/06 23:49:43 joehw Exp $ */ public class XSDFACM implements XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java index 673211fb196..bf730d692c9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/models/XSEmptyCM.java @@ -37,7 +37,6 @@ import java.util.ArrayList; * * @author Elena Litani, Lisa Martin * @author IBM - * @version $Id: XSEmptyCM.java,v 1.7 2009/07/28 15:18:11 spericas Exp $ */ public class XSEmptyCM implements XSCMValidator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java index 331fc2692bf..89c70ebc0fa 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/AttrImpl.java @@ -73,7 +73,6 @@ import org.w3c.dom.TypeInfo; * * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: AttrImpl.java,v 1.5 2010-11-01 04:40:01 joehw Exp $ */ public class AttrImpl extends NodeImpl implements Attr { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java index 24eebf7e8dc..28a6bd678b2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/ElementImpl.java @@ -31,7 +31,6 @@ import org.w3c.dom.Node; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: ElementImpl.java,v 1.7 2010-11-01 04:40:01 joehw Exp $ */ public class ElementImpl extends DefaultElement { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java index 48d6f1280ea..52ed98f24d9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOM.java @@ -40,7 +40,6 @@ import org.w3c.dom.Node; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDOM.java,v 1.7 2010-11-01 04:40:01 joehw Exp $ */ public class SchemaDOM extends DefaultDocument { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java index 105e6367cfb..eb422a2354a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMImplementation.java @@ -28,7 +28,6 @@ import org.w3c.dom.DocumentType; /** * @xerces.internal * - * @version $Id: SchemaDOMImplementation.java,v 1.2 2010-10-26 23:01:18 joehw Exp $ */ final class SchemaDOMImplementation implements DOMImplementation { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java index be28c8c836c..b8e1d54959e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaDOMParser.java @@ -46,7 +46,6 @@ import org.w3c.dom.Document; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: SchemaDOMParser.java,v 1.8 2010-11-01 04:40:01 joehw Exp $ */ public class SchemaDOMParser extends DefaultXMLDocumentHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java index a9b251e91f1..5c9afc2c25e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/opti/SchemaParsingConfig.java @@ -57,7 +57,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: SchemaParsingConfig.java,v 1.8 2010-11-01 04:40:01 joehw Exp $ */ public class SchemaParsingConfig extends BasicParserConfiguration implements XMLPullParserConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java index 3d7e3afdded..84f04e2e53f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/StAXSchemaParser.java @@ -54,7 +54,6 @@ import org.w3c.dom.Document; * * @xerces.internal * - * @version $Id: StAXSchemaParser.java,v 1.2 2010-10-26 23:01:12 joehw Exp $ */ final class StAXSchemaParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java index f9eea6a4dc4..1a3a41476d3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSAttributeChecker.java @@ -69,7 +69,6 @@ import org.w3c.dom.Element; * @xerces.internal * * @author Sandy Gao, IBM - * @version $Id: XSAttributeChecker.java,v 1.12 2010-11-01 04:40:02 joehw Exp $ */ public class XSAttributeChecker { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java index c6455231eeb..af38b2f73f6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractIDConstraintTraverser.java @@ -36,7 +36,6 @@ import org.w3c.dom.Element; * * @xerces.internal * - * @version $Id: XSDAbstractIDConstraintTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDAbstractIDConstraintTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java index 364a94a850a..0a0569a1fc2 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractParticleTraverser.java @@ -37,7 +37,6 @@ import org.w3c.dom.Element; * * @author Elena Litani, IBM * @author Sandy Gao, IBM - * @version $Id: XSDAbstractParticleTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ abstract class XSDAbstractParticleTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java index a5e97f08b25..7af4c66754d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAbstractTraverser.java @@ -58,7 +58,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Neeraj Bajaj, Sun Microsystems Inc. * - * @version $Id: XSDAbstractTraverser.java,v 1.8 2010-11-01 04:40:02 joehw Exp $ */ abstract class XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java index 0e126704d0b..14d15309ea9 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeGroupTraverser.java @@ -46,7 +46,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: XSDAttributeGroupTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDAttributeGroupTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java index 0aa0b32ec33..6174a7b5ec3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDAttributeTraverser.java @@ -59,7 +59,6 @@ import org.w3c.dom.Element; * * @author Sandy Gao, IBM * @author Neeraj Bajaj, Sun Microsystems, inc. - * @version $Id: XSDAttributeTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDAttributeTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java index cfc98b834b8..b786158ac7c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDComplexTypeTraverser.java @@ -62,7 +62,6 @@ import org.w3c.dom.Element; * * @xerces.internal * - * @version $Id: XSDComplexTypeTraverser.java,v 1.8 2010-11-01 04:40:02 joehw Exp $ */ class XSDComplexTypeTraverser extends XSDAbstractParticleTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java index 0d480580d6a..e0e4c464c21 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDElementTraverser.java @@ -69,7 +69,6 @@ import org.w3c.dom.Element; * * @author Sandy Gao, IBM * - * @version $Id: XSDElementTraverser.java,v 1.9 2010-11-01 04:40:02 joehw Exp $ */ class XSDElementTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java index 915f482ddbe..99e2ec99319 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDGroupTraverser.java @@ -47,7 +47,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Elena Litani, IBM * @author Lisa Martin, IBM - * @version $Id: XSDGroupTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDGroupTraverser extends XSDAbstractParticleTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java index d6a6e948f65..bf6defa6ca7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDHandler.java @@ -131,7 +131,6 @@ import org.xml.sax.helpers.XMLReaderFactory; * @author Neil Graham, IBM * @author Pavani Mukthipudi, Sun Microsystems * - * @version $Id: XSDHandler.java,v 1.9 2010-11-01 04:40:02 joehw Exp $ */ public class XSDHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java index 07d160e2998..7d590acf55f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDKeyrefTraverser.java @@ -35,7 +35,6 @@ import org.w3c.dom.Element; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDKeyrefTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDKeyrefTraverser extends XSDAbstractIDConstraintTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java index 846c9b94326..27acd055d2f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDNotationTraverser.java @@ -45,7 +45,6 @@ import org.w3c.dom.Element; * * @author Rahul Srivastava, Sun Microsystems Inc. * @author Elena Litani, IBM - * @version $Id: XSDNotationTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDNotationTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java index 355881edc84..1564227b1f5 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDSimpleTypeTraverser.java @@ -78,7 +78,6 @@ import org.w3c.dom.Element; * @author Neeraj Bajaj, Sun Microsystems, Inc. * @author Sandy Gao, IBM * - * @version $Id: XSDSimpleTypeTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDSimpleTypeTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java index 054dd9deb04..2e36be5745e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDUniqueOrKeyTraverser.java @@ -35,7 +35,6 @@ import org.w3c.dom.Element; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDUniqueOrKeyTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDUniqueOrKeyTraverser extends XSDAbstractIDConstraintTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java index 60bfb54d88d..c368b74ccfd 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDWildcardTraverser.java @@ -57,7 +57,6 @@ import org.w3c.dom.Element; * @author Rahul Srivastava, Sun Microsystems Inc. * @author Sandy Gao, IBM * - * @version $Id: XSDWildcardTraverser.java,v 1.7 2010-11-01 04:40:02 joehw Exp $ */ class XSDWildcardTraverser extends XSDAbstractTraverser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java index b75639f16a4..b941ea90236 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/traversers/XSDocumentInfo.java @@ -43,7 +43,6 @@ import org.w3c.dom.NamedNodeMap; * @xerces.internal * * @author Neil Graham, IBM - * @version $Id: XSDocumentInfo.java,v 1.5 2007/10/15 22:27:48 spericas Exp $ */ class XSDocumentInfo { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java index c8a93293e05..4f3bb757ed1 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/LSInputListImpl.java @@ -34,7 +34,6 @@ import org.w3c.dom.ls.LSInput; * * @author Michael Glavassevich, IBM * - * @version $Id: LSInputListImpl.java,v 1.2 2010-10-26 23:01:04 joehw Exp $ */ public final class LSInputListImpl extends AbstractList implements LSInputList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java index 9f0a1964cdb..1d29360a05d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ObjectListImpl.java @@ -31,7 +31,6 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.ObjectList; * * @xerces.internal * - * @version $Id: ObjectListImpl.java,v 1.2 2010-10-26 23:01:04 joehw Exp $ */ public final class ObjectListImpl extends AbstractList implements ObjectList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java index 9a3ba385747..9dc0641ef26 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/ShortListImpl.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.XSException; * * @author Sandy Gao, IBM * - * @version $Id: ShortListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public final class ShortListImpl extends AbstractList implements ShortList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java index 5f22628b4f7..cf3d46a494e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/StringListImpl.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.xs.StringList; * * @author Sandy Gao, IBM * - * @version $Id: StringListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public final class StringListImpl extends AbstractList implements StringList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java index 3f83e8373ff..a3f0bc71a37 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSGrammarPool.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSModel; * * @xerces.internal * - * @version $Id: XSGrammarPool.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class XSGrammarPool extends XMLGrammarPoolImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java index 4ca114bbedc..393393c08a0 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSInputSource.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObject; /** * @xerces.internal * - * @version $Id: XSInputSource.java,v 1.2 2010-10-26 23:01:05 joehw Exp $ */ public final class XSInputSource extends XMLInputSource { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java index 63f6f475564..a2c6b29df41 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMap4Types.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; * * @author Sandy Gao, IBM * - * @version $Id: XSNamedMap4Types.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public final class XSNamedMap4Types extends XSNamedMapImpl { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java index 17406566405..b15f1ed47b3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSNamedMapImpl.java @@ -41,7 +41,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObject; * * @author Sandy Gao, IBM * - * @version $Id: XSNamedMapImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class XSNamedMapImpl extends AbstractMap implements XSNamedMap { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java index b5e0de2d52a..7c5b4f7c40f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/xs/util/XSObjectListImpl.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.xs.XSObjectList; * * @author Sandy Gao, IBM * - * @version $Id: XSObjectListImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class XSObjectListImpl extends AbstractList implements XSObjectList { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java index aea63c2eb16..2899ab8dd92 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderFactoryImpl.java @@ -37,7 +37,6 @@ import org.xml.sax.SAXNotSupportedException; /** * @author Rajiv Mordani * @author Edwin Goei - * @version $Id: DocumentBuilderFactoryImpl.java,v 1.8 2010-11-01 04:40:06 joehw Exp $ */ public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory { /** These are DocumentBuilderFactory attributes not DOM attributes */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java index 51f22d713b1..a1d9b1ffb2b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java @@ -58,7 +58,6 @@ import org.xml.sax.SAXNotSupportedException; /** * @author Rajiv Mordani * @author Edwin Goei - * @version $Id: DocumentBuilderImpl.java,v 1.8 2010-11-01 04:40:06 joehw Exp $ */ public class DocumentBuilderImpl extends DocumentBuilder implements JAXPConstants diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java index ae9d99509d9..50c5f3db11d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserFactoryImpl.java @@ -43,7 +43,6 @@ import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter; * @author Rajiv Mordani * @author Edwin Goei * - * @version $Id: SAXParserFactoryImpl.java,v 1.9 2010-11-01 04:40:06 joehw Exp $ */ public class SAXParserFactoryImpl extends SAXParserFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java index 6cc3e9a4678..315b2000ccf 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java @@ -63,7 +63,6 @@ import org.xml.sax.helpers.DefaultHandler; * @author Rajiv Mordani * @author Edwin Goei * - * @version $Id: SAXParserImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ */ public class SAXParserImpl extends javax.xml.parsers.SAXParser implements JAXPConstants, PSVIProvider { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java index 9ef80be7742..f919ec08a81 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/SchemaValidatorConfiguration.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; /** *

Parser configuration for Xerces' XMLSchemaValidator.

* - * @version $Id: SchemaValidatorConfiguration.java,v 1.5 2010-11-01 04:40:06 joehw Exp $ */ final class SchemaValidatorConfiguration implements XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java index 5714da3be57..8129066eb3d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/UnparsedEntityHandler.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource; * Events are forwarded to the registered XMLDTDHandler without modification.

* * @author Michael Glavassevich, IBM - * @version $Id: UnparsedEntityHandler.java,v 1.6 2010-11-01 04:40:07 joehw Exp $ */ final class UnparsedEntityHandler implements XMLDTDFilter, EntityState { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java index 59497a48f5e..aa993a299c5 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DatatypeFactoryImpl.java @@ -58,7 +58,6 @@ import javax.xml.datatype.XMLGregorianCalendar; * * @author Joseph Fialli * @author Jeff Suttor - * @version $Id: DatatypeFactoryImpl.java,v 1.6 2010/05/19 05:02:55 joehw Exp $ */ public class DatatypeFactoryImpl extends DatatypeFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java index 9e5cafda554..83de0154ba6 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationDayTimeImpl.java @@ -46,7 +46,6 @@ import javax.xml.datatype.DatatypeConstants; * * @author Vikram Aroskar * @author Joe Wang - * @version $Revision: 1.2 $, $Date: 2010/05/19 23:20:06 $ * @see XMLGregorianCalendar#add(Duration) */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java index 5286934cba4..b8724a70a34 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java @@ -97,7 +97,6 @@ import javax.xml.datatype.XMLGregorianCalendar; * * @author Kohsuke Kawaguchi * @author Joseph Fialli - * @version $Revision: 1.8 $, $Date: 2010/05/19 23:20:06 $ * @see XMLGregorianCalendar#add(Duration) */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java index abf8c53075f..c4b41b8021b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationYearMonthImpl.java @@ -42,7 +42,6 @@ import javax.xml.datatype.DatatypeConstants; * * @author Vikram Aroskar * @author Joe Wang - * @version $Revision: 1.1 $, $Date: 2010/05/19 05:02:55 $ * @see XMLGregorianCalendar#add(Duration) */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java index 6c629e95184..9026a6f5f61 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/datatype/XMLGregorianCalendarImpl.java @@ -188,7 +188,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * @author Kohsuke Kawaguchi * @author Joseph Fialli * @author Sunitha Reddy - * @version $Revision: 1.14 $, $Date: 2010-11-10 07:41:41 $ * @see javax.xml.datatype.Duration * @since 1.5 */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java index 25e13a7a5ce..2d06bc0555a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/AbstractXMLSchema.java @@ -30,7 +30,6 @@ import javax.xml.validation.ValidatorHandler; *

Abstract implementation of Schema for W3C XML Schemas.

* * @author Michael Glavassevich, IBM - * @version $Id: AbstractXMLSchema.java,v 1.6 2010-11-01 04:40:07 joehw Exp $ */ abstract class AbstractXMLSchema extends Schema implements XSGrammarPoolContainer { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java index 4c69e70c0e4..fe006533b1d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/DOMValidatorHelper.java @@ -63,7 +63,6 @@ import org.xml.sax.SAXException; *

A validator helper for DOMSources.

* * @author Michael Glavassevich, IBM - * @version $Id: DOMValidatorHelper.java,v 1.9 2010-11-01 04:40:08 joehw Exp $ */ final class DOMValidatorHelper implements ValidatorHelper, EntityState { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java index eca00e81d11..ba50c5175b8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/EmptyXMLSchema.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; * which contains no schema components.

* * @author Michael Glavassevich, IBM - * @version $Id: EmptyXMLSchema.java,v 1.6 2010-11-01 04:40:08 joehw Exp $ */ final class EmptyXMLSchema extends AbstractXMLSchema implements XMLGrammarPool { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java index 5c510533c98..8c50c4d477b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/JAXPValidationMessageFormatter.java @@ -29,7 +29,6 @@ import java.util.ResourceBundle; *

Used to format JAXP Validation API error messages using a specified locale.

* * @author Michael Glavassevich, IBM - * @version $Id: JAXPValidationMessageFormatter.java,v 1.5 2010-11-01 04:40:08 joehw Exp $ */ final class JAXPValidationMessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java index d6c04fd984a..9e9f5aefc15 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/StreamValidatorHelper.java @@ -48,7 +48,6 @@ import org.xml.sax.SAXException; * * @author Michael Glavassevich, IBM * @author Sunitha Reddy - * @version $Id: StreamValidatorHelper.java,v 1.7 2010-11-01 04:40:08 joehw Exp $ */ final class StreamValidatorHelper implements ValidatorHelper { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java index fc652af221a..1b6dd4053c1 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorHandlerImpl.java @@ -94,7 +94,6 @@ import org.xml.sax.ext.EntityResolver2; * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) * @author Michael Glavassevich, IBM * - * @version $Id: ValidatorHandlerImpl.java,v 1.10 2010-11-01 04:40:08 joehw Exp $ */ final class ValidatorHandlerImpl extends ValidatorHandler implements DTDHandler, EntityState, PSVIProvider, ValidatorHelper, XMLDocumentHandler { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java index f0d18dda6f2..acf5df06994 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/ValidatorImpl.java @@ -51,7 +51,6 @@ import org.xml.sax.SAXNotSupportedException; * @author Kohsuke Kawaguchi * @author Michael Glavassevich, IBM * @author Sunitha Reddy - * @version $Id: ValidatorImpl.java,v 1.10 2010-11-01 04:40:08 joehw Exp $ */ final class ValidatorImpl extends Validator implements PSVIProvider { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java index f2dadd0fc4a..0bdd28d826f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java @@ -65,7 +65,6 @@ import org.xml.sax.SAXParseException; * {@link SchemaFactory} for XML Schema. * * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) - * @version $Id: XMLSchemaFactory.java,v 1.11 2010-11-01 04:40:08 joehw Exp $ */ public final class XMLSchemaFactory extends SchemaFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java index dcbbabd4d4a..58a74191cf0 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java @@ -55,7 +55,6 @@ import org.xml.sax.ErrorHandler; *

An implementation of XMLComponentManager for a schema validator.

* * @author Michael Glavassevich, IBM - * @version $Id: XMLSchemaValidatorComponentManager.java,v 1.9 2010-11-01 04:40:08 joehw Exp $ */ final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettings implements XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java index 79ef5593b06..431a0f21f01 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/jaxp/validation/XSGrammarPoolContainer.java @@ -26,7 +26,6 @@ import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; *

A container for grammar pools which only contain schema grammars.

* * @author Michael Glavassevich, IBM - * @version $Id: XSGrammarPoolContainer.java,v 1.6 2010-11-01 04:40:08 joehw Exp $ */ public interface XSGrammarPoolContainer { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java index 88ea9518646..5e6c5773fba 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractDOMParser.java @@ -85,7 +85,6 @@ import org.xml.sax.SAXException; * @author Andy Clark, IBM * @author Elena Litani, IBM * - * @version $Id: AbstractDOMParser.java,v 1.10 2010-11-01 04:40:09 joehw Exp $ */ public class AbstractDOMParser extends AbstractXMLDocumentParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java index eea7057417b..881020f0409 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/AbstractSAXParser.java @@ -77,7 +77,6 @@ import org.xml.sax.helpers.LocatorImpl; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: AbstractSAXParser.java,v 1.6 2010-11-01 04:40:09 joehw Exp $ */ public abstract class AbstractSAXParser extends AbstractXMLDocumentParser diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java index 3b352961618..c41f27d5a3f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/BasicParserConfiguration.java @@ -94,7 +94,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: BasicParserConfiguration.java,v 1.6 2010-11-01 04:40:09 joehw Exp $ */ public abstract class BasicParserConfiguration extends ParserConfigurationSettings diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java index f2020efda4b..05814b26396 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParser.java @@ -58,7 +58,6 @@ import org.xml.sax.helpers.LocatorImpl; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: DOMParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class DOMParser extends AbstractDOMParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java index 614c826047e..0053d984291 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DOMParserImpl.java @@ -79,7 +79,6 @@ import org.xml.sax.SAXException; * @author Pavani Mukthipudi, Sun Microsystems Inc. * @author Elena Litani, IBM * @author Rahul Srivastava, Sun Microsystems Inc. - * @version $Id: DOMParserImpl.java,v 1.8 2010-11-01 04:40:09 joehw Exp $ */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java index 0f37f7c375e..ce27b8b1c72 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/DTDConfiguration.java @@ -87,7 +87,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author Andy Clark, IBM * @author Neil Graham, IBM * - * @version $Id: DTDConfiguration.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class DTDConfiguration extends BasicParserConfiguration diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java index 469780136cd..834fdbf487a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/NonValidatingConfiguration.java @@ -59,7 +59,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * include the replacement text of internal entities, and supply default attribute values". * * @author Elena Litani, IBM - * @version $Id: NonValidatingConfiguration.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class NonValidatingConfiguration extends BasicParserConfiguration diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java index 48b8a1ed538..811d957686e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SAXParser.java @@ -37,7 +37,6 @@ import org.xml.sax.SAXNotSupportedException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: SAXParser.java,v 1.7 2010-11-01 04:40:09 joehw Exp $ */ public class SAXParser extends AbstractSAXParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java index 65c85d164ca..7eba8746e59 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/SecurityConfiguration.java @@ -44,7 +44,6 @@ import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; * * @author Neil Graham, IBM * - * @version $Id: SecurityConfiguration.java,v 1.6 2010-11-01 04:40:09 joehw Exp $ */ public class SecurityConfiguration extends XIncludeAwareParserConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java index 7caad5bc25a..5ac09f8f866 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/StandardParserConfiguration.java @@ -64,7 +64,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: StandardParserConfiguration.java,v 1.7 2010-11-01 04:40:10 joehw Exp $ */ public class StandardParserConfiguration extends DTDConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java index 5b795e5357b..9ef0b52222c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XIncludeAwareParserConfiguration.java @@ -39,7 +39,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; * * @author Michael Glavassevich, IBM * - * @version $Id: XIncludeAwareParserConfiguration.java,v 1.5 2010-11-01 04:40:10 joehw Exp $ */ public class XIncludeAwareParserConfiguration extends XML11Configuration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java index bbcbceed10e..c0283f74e3c 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java @@ -78,7 +78,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author Neil Graham, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XML11Configuration.java,v 1.9 2010-11-01 04:40:10 joehw Exp $ */ public class XML11Configuration extends ParserConfigurationSettings implements XMLPullParserConfiguration, XML11Configurable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java index 3dfa85e5bd5..f7591ae608e 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11DTDConfiguration.java @@ -103,7 +103,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author Michael Glavassevich, IBM * @author John Kim, IBM * - * @version $Id: XML11DTDConfiguration.java,v 1.5 2010-11-01 04:40:10 joehw Exp $ */ public class XML11DTDConfiguration extends ParserConfigurationSettings implements XMLPullParserConfiguration, XML11Configurable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java index 43f873013e7..36a284239f3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XML11NonValidatingConfiguration.java @@ -74,7 +74,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLPullParserConfiguration; * @author John Kim, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XML11NonValidatingConfiguration.java,v 1.5 2010-11-01 04:40:10 joehw Exp $ */ public class XML11NonValidatingConfiguration extends ParserConfigurationSettings implements XMLPullParserConfiguration, XML11Configurable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java index 8a89e98f297..eba49fbad92 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLDocumentParser.java @@ -33,7 +33,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: XMLDocumentParser.java,v 1.6 2010-11-01 04:40:10 joehw Exp $ */ public class XMLDocumentParser extends AbstractXMLDocumentParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java index 897b7542fde..4e1181a122f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarCachingConfiguration.java @@ -62,7 +62,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; * * @author Neil Graham, IBM * - * @version $Id: XMLGrammarCachingConfiguration.java,v 1.6 2010-11-01 04:40:10 joehw Exp $ */ public class XMLGrammarCachingConfiguration extends XIncludeAwareParserConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java index 7d88781e679..1089493f2eb 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarParser.java @@ -25,7 +25,6 @@ import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory; import com.sun.org.apache.xerces.internal.util.SymbolTable; /** - * @version $Id: XMLGrammarParser.java,v 1.6 2010-11-01 04:40:10 joehw Exp $ */ public abstract class XMLGrammarParser extends XMLParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java index 6690922da71..71063cc204f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLGrammarPreparser.java @@ -49,7 +49,6 @@ import com.sun.org.apache.xerces.internal.utils.ObjectFactory; * * @author Neil Graham, IBM * - * @version $Id: XMLGrammarPreparser.java,v 1.7 2010-11-01 04:40:10 joehw Exp $ */ public class XMLGrammarPreparser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java index 970cc51cd26..fe7801fcbb3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/parsers/XMLParser.java @@ -49,7 +49,6 @@ import org.xml.sax.SAXNotRecognizedException; * @author Arnaud Le Hors, IBM * @author Andy Clark, IBM * - * @version $Id: XMLParser.java,v 1.5 2007/07/20 14:11:21 spericas Exp $ */ public abstract class XMLParser { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java index da13e8fd1a9..4a00810f106 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/DOMUtil.java @@ -42,7 +42,6 @@ import org.w3c.dom.ls.LSException; * (such as a DTM), we should easily be able to convert our schema * parsing to utilize it. * - * @version $Id: DOMUtil.java,v 1.7 2010-11-01 04:40:14 joehw Exp $ */ public class DOMUtil { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java index b964a8fbfd8..500769db59a 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/DatatypeMessageFormatter.java @@ -29,7 +29,6 @@ import java.util.ResourceBundle; *

Used to format JAXP 1.3 Datatype API error messages using a specified locale.

* * @author Neeraj Bajaj, Sun Microsystems - * @version $Id: DatatypeMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $ */ public class DatatypeMessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java index 8b083a3ba46..8c4748966c4 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/EncodingMap.java @@ -470,7 +470,6 @@ import java.util.Hashtable; * @author TAMURA Kent, IBM * @author Andy Clark, IBM * - * @version $Id$ */ public class EncodingMap { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java index cdf62d01ab9..b14922c9154 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/JAXPNamespaceContextWrapper.java @@ -37,7 +37,6 @@ import com.sun.org.apache.xerces.internal.xni.NamespaceContext; * * @author Michael Glavassevich, IBM * - * @version $Id: JAXPNamespaceContextWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $ */ public final class JAXPNamespaceContextWrapper implements NamespaceContext { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java index a13d8154c96..17281841704 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/ParserConfigurationSettings.java @@ -43,7 +43,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; * * @author Andy Clark, IBM * - * @version $Id: ParserConfigurationSettings.java,v 1.6 2010-11-01 04:40:14 joehw Exp $ */ public class ParserConfigurationSettings implements XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java index 29648a629f9..5c87f4ba497 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/SAXMessageFormatter.java @@ -29,7 +29,6 @@ import java.util.ResourceBundle; * * @author Michael Glavassevich, IBM * - * @version $Id: SAXMessageFormatter.java,v 1.6 2010-11-01 04:40:14 joehw Exp $ */ public class SAXMessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java index 24def72fa7b..6cc9aa6cb48 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXInputSource.java @@ -30,7 +30,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; /** *

An XMLInputSource analogue to javax.xml.transform.stax.StAXSource.

* - * @version $Id: StAXInputSource.java,v 1.2 2010-10-26 23:01:17 joehw Exp $ */ public final class StAXInputSource extends XMLInputSource { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java index 566533d1582..22b806295ac 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/StAXLocationWrapper.java @@ -32,7 +32,6 @@ import com.sun.org.apache.xerces.internal.xni.XMLLocator; * * @author Michael Glavassevich, IBM * - * @version $Id: StAXLocationWrapper.java,v 1.2 2010-10-26 23:01:13 joehw Exp $ */ public final class StAXLocationWrapper implements XMLLocator { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java index dee8383ea4a..ae0aacb723b 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/SymbolHash.java @@ -28,7 +28,6 @@ package com.sun.org.apache.xerces.internal.util; * The hash code uses the same algorithm as SymbolTable class. * * @author Elena Litani - * @version $Id: SymbolHash.java,v 1.7 2010-11-01 04:40:14 joehw Exp $ */ public class SymbolHash { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java index d19518e6afa..8c9e3412e7d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/XML11Char.java @@ -41,7 +41,6 @@ import java.util.Arrays; * @author Neil Graham, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XML11Char.java,v 1.7 2010-11-01 04:40:15 joehw Exp $ */ public class XML11Char { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java index a3b879f2fbc..55717373866 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLAttributesImpl.java @@ -83,7 +83,6 @@ import com.sun.org.apache.xerces.internal.xni.XMLString; * @author Elena Litani, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XMLAttributesImpl.java,v 1.7 2010/05/07 20:13:09 joehw Exp $ */ public class XMLAttributesImpl implements XMLAttributes, XMLBufferListener { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java index 731b31a70ab..b649c34efa8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/XMLChar.java @@ -44,7 +44,6 @@ import java.util.Arrays; * @author Michael Glavassevich, IBM * @author Rahul Srivastava, Sun Microsystems Inc. * - * @version $Id: XMLChar.java,v 1.7 2010-11-01 04:40:15 joehw Exp $ */ public class XMLChar { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java b/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java index 2e4ceeae001..0ec5ad520a3 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java @@ -32,7 +32,6 @@ package com.sun.org.apache.xerces.internal.utils; * when bundled as part of the JDK. *

* - * @version $Id: ObjectFactory.java,v 1.6 2010/04/23 01:44:34 joehw Exp $ */ public final class ObjectFactory { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java index a060f99e091..016a6168873 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java @@ -115,7 +115,6 @@ import java.util.Objects; * @author Peter McCracken, IBM * @author Michael Glavassevich, IBM * - * @version $Id: XIncludeHandler.java,v 1.7 2010-11-01 04:40:18 joehw Exp $ * * @see XIncludeNamespaceSupport */ diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java index 0275615e2fc..4420e29934d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeMessageFormatter.java @@ -32,7 +32,6 @@ import java.util.ResourceBundle; * * @author Peter McCracken, IBM * - * @version $Id: XIncludeMessageFormatter.java,v 1.7 2010-11-01 04:40:18 joehw Exp $ */ public class XIncludeMessageFormatter implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java index 5c47b7a53be..d6d5ce6a63d 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/QName.java @@ -77,7 +77,6 @@ package com.sun.org.apache.xerces.internal.xni; * == were used to compare strings * @author Joe Wang, Oracle * - * @version $Id: QName.java,v 1.6 2010/03/18 19:32:31 joehw Exp $ */ public class QName implements Cloneable { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java index 4247551e5eb..98b9d40abad 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/XNIException.java @@ -32,7 +32,6 @@ package com.sun.org.apache.xerces.internal.xni; * * @author Andy Clark, IBM * - * @version $Id: XNIException.java,v 1.6 2010-11-01 04:40:19 joehw Exp $ */ public class XNIException extends RuntimeException { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java index 80faa6a6d02..1ea05c6babd 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLComponentManager.java @@ -36,7 +36,6 @@ import com.sun.org.apache.xerces.internal.util.PropertyState; * * @author Andy Clark, IBM * - * @version $Id: XMLComponentManager.java,v 1.6 2010-11-01 04:40:22 joehw Exp $ */ public interface XMLComponentManager { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java index b1cd779c483..3f1280d1fb8 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xni/parser/XMLConfigurationException.java @@ -30,7 +30,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException; * * @author Andy Clark, IBM * - * @version $Id: XMLConfigurationException.java,v 1.7 2010-11-01 04:40:22 joehw Exp $ */ public class XMLConfigurationException extends XNIException { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java index 5f44b08289f..33bf6b880e7 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java @@ -38,7 +38,6 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler; * * @xerces.internal * - * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ */ final class ElementSchemePointer implements XPointerPart { @@ -498,7 +497,6 @@ final class ElementSchemePointer implements XPointerPart { * @xerces.internal * * @author Neil Delima, IBM - * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ * */ private final class Tokens { @@ -656,7 +654,6 @@ final class ElementSchemePointer implements XPointerPart { * * @xerces.internal * - * @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $ */ private class Scanner { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java index 36ee4811039..12603a8d722 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java @@ -34,7 +34,6 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport; * * @xerces.internal * - * @version $Id: XPointerMessageFormatter.java,v 1.5 2010-11-01 04:40:26 joehw Exp $ */ final class XPointerMessageFormatter implements MessageFormatter { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java index a1138401296..c1d1edefd03 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ByteList.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.xs.XSException; * * @author Ankit Pasricha, IBM * - * @version $Id: ByteList.java,v 1.7 2010-11-01 04:40:31 joehw Exp $ */ public interface ByteList extends List { diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java index c47853f8ea5..141fb0a7b26 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/xs/datatypes/ObjectList.java @@ -27,7 +27,6 @@ import java.util.List; * * @author Ankit Pasricha, IBM * - * @version $Id: ObjectList.java,v 1.7 2010-11-01 04:40:31 joehw Exp $ */ public interface ObjectList extends List { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java index c9b36c5b07a..eae65068d82 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/DOMSerializerImpl.java @@ -72,7 +72,6 @@ import org.w3c.dom.ls.LSSerializerFilter; * @author Gopal Sharma, Sun Microsystems * @author Arun Yadav, Sun Microsystems * @author Sunitha Reddy, Sun Microsystems - * @version $Id: DOMSerializerImpl.java,v 1.11 2010-11-01 04:40:36 joehw Exp $ */ public class DOMSerializerImpl implements LSSerializer, DOMConfiguration { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java index 9c21756f8b3..252483fc53d 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/EncodingInfo.java @@ -29,7 +29,6 @@ import com.sun.org.apache.xerces.internal.util.EncodingMap; /** * This class represents an encoding. * - * @version $Id: EncodingInfo.java,v 1.6 2007/10/18 03:39:08 joehw Exp $ */ public class EncodingInfo { diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java index 25da0c6517a..2150e31a0b5 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serialize/SerializerFactory.java @@ -32,7 +32,6 @@ import java.util.StringTokenizer; /** * * - * @version $Revision: 1.6 $ $Date: 2010-11-01 04:40:36 $ * @author Scott Boag * @author Assaf Arkin */ diff --git a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java index d4d95ff8cf2..80eb8a5d969 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/Encodings.java @@ -50,7 +50,6 @@ import com.sun.org.apache.xalan.internal.utils.SecuritySupport; * to override encoding names and provide the last printable character * for each encoding. * - * @version $Revision: 1.11 $ $Date: 2010-11-01 04:34:44 $ * @author Assaf Arkin */ diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java index 925ce9c1234..dc64401eda6 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java @@ -52,7 +52,6 @@ import org.xml.sax.InputSource; /** * The XPathExpression interface encapsulates a (compiled) XPath expression. * - * @version $Revision: 1.10 $ * @author Ramesh Mandava */ public class XPathExpressionImpl implements javax.xml.xpath.XPathExpression{ diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java index b050af44674..c649306da4b 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java @@ -36,7 +36,6 @@ import javax.xml.xpath.XPathVariableResolver; /** * The XPathFactory builds XPaths. * - * @version $Revision: 1.11 $ * @author Ramesh Mandava */ public class XPathFactoryImpl extends XPathFactory { diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java index af82f378917..ebd6b2c712f 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java @@ -54,7 +54,6 @@ import java.io.IOException; * of an XPath expression. * * - * @version $Revision: 1.10 $ * @author Ramesh Mandava */ public class XPathImpl implements javax.xml.xpath.XPath { diff --git a/jaxp/src/javax/xml/XMLConstants.java b/jaxp/src/javax/xml/XMLConstants.java index 8e805ec03da..70b8bdfa812 100644 --- a/jaxp/src/javax/xml/XMLConstants.java +++ b/jaxp/src/javax/xml/XMLConstants.java @@ -29,7 +29,6 @@ package javax.xml; *

Utility class to contain basic XML values as constants.

* * @author Jeff Suttor - * @version $Revision: 1.8 $, $Date: 2010/05/25 16:19:45 $ * @see Extensible Markup Language (XML) 1.1 * @see Extensible Markup Language (XML) 1.0 (Second Edition) * @see XML 1.0 Second Edition Specification Errata diff --git a/jaxp/src/javax/xml/datatype/DatatypeFactory.java b/jaxp/src/javax/xml/datatype/DatatypeFactory.java index 8138f98de1d..0a96c5760ef 100644 --- a/jaxp/src/javax/xml/datatype/DatatypeFactory.java +++ b/jaxp/src/javax/xml/datatype/DatatypeFactory.java @@ -72,7 +72,6 @@ import java.util.regex.Pattern; * @author Jeff Suttor * @author Neeraj Bajaj * - * @version $Revision: 1.13 $, $Date: 2010/03/11 23:10:53 $ * @since 1.5 */ public abstract class DatatypeFactory { diff --git a/jaxp/src/javax/xml/datatype/package.html b/jaxp/src/javax/xml/datatype/package.html index af81454af96..de065acc664 100644 --- a/jaxp/src/javax/xml/datatype/package.html +++ b/jaxp/src/javax/xml/datatype/package.html @@ -31,7 +31,6 @@ questions. javax.xml.xpath - diff --git a/jaxp/src/javax/xml/namespace/QName.java b/jaxp/src/javax/xml/namespace/QName.java index 994b2a3816c..4792f772337 100644 --- a/jaxp/src/javax/xml/namespace/QName.java +++ b/jaxp/src/javax/xml/namespace/QName.java @@ -62,7 +62,6 @@ import javax.xml.XMLConstants; *

QName is immutable.

* * @author Jeff Suttor - * @version $Revision: 1.8 $, $Date: 2010/03/18 03:06:17 $ * @see * XML Schema Part2: Datatypes specification * @see diff --git a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java index fa4b618b42a..0625b850986 100644 --- a/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java +++ b/jaxp/src/javax/xml/parsers/DocumentBuilderFactory.java @@ -34,7 +34,6 @@ import javax.xml.validation.Schema; * @author Jeff Suttor * @author Neeraj Bajaj * - * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $ * @since 1.4 */ diff --git a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java index fc3cd6eaa2a..0dc01a91aa9 100644 --- a/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java +++ b/jaxp/src/javax/xml/parsers/FactoryConfigurationError.java @@ -32,7 +32,6 @@ package javax.xml.parsers; * or instantiated. * * @author Jeff Suttor - * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:09 $ * @since 1.4 */ diff --git a/jaxp/src/javax/xml/parsers/SAXParserFactory.java b/jaxp/src/javax/xml/parsers/SAXParserFactory.java index c36033f571f..7de367e702e 100644 --- a/jaxp/src/javax/xml/parsers/SAXParserFactory.java +++ b/jaxp/src/javax/xml/parsers/SAXParserFactory.java @@ -37,7 +37,6 @@ import org.xml.sax.SAXNotSupportedException; * @author Jeff Suttor * @author Neeraj Bajaj * - * @version $Revision: 1.9 $, $Date: 2010/05/25 16:19:44 $ * @since 1.4 */ public abstract class SAXParserFactory { diff --git a/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java b/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java index 907e67a66fa..16b84f636bd 100644 --- a/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java +++ b/jaxp/src/javax/xml/validation/SchemaFactoryFinder.java @@ -40,7 +40,6 @@ import java.util.ServiceLoader; * Implementation of {@link SchemaFactory#newInstance(String)}. * * @author Kohsuke Kawaguchi - * @version $Revision: 1.8 $, $Date: 2010-11-01 04:36:13 $ * @since 1.5 */ class SchemaFactoryFinder { diff --git a/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java b/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java index f99ddc8a0c2..bceeda854e8 100644 --- a/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java +++ b/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java @@ -40,7 +40,6 @@ import java.util.ServiceLoader; * Implementation of {@link XPathFactory#newInstance(String)}. * * @author Kohsuke Kawaguchi - * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:14 $ * @since 1.5 */ class XPathFactoryFinder { diff --git a/jaxp/src/javax/xml/xpath/package.html b/jaxp/src/javax/xml/xpath/package.html index 6f49222a255..82415a2d407 100644 --- a/jaxp/src/javax/xml/xpath/package.html +++ b/jaxp/src/javax/xml/xpath/package.html @@ -32,7 +32,6 @@ questions. - From 90e98e48a18365afedd06a9d6bdc952165c8ada1 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Tue, 24 Jun 2014 15:21:47 -0700 Subject: [PATCH 126/236] 8047925: Add mercurial version checks to get_source.sh Reviewed-by: tbell, mikael --- get_source.sh | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/get_source.sh b/get_source.sh index f83a3766c12..21bafe05609 100644 --- a/get_source.sh +++ b/get_source.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright (c) 2010, 2012, 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 @@ -25,9 +25,48 @@ # questions. # -# Get clones of all nested repositories -sh ./common/bin/hgforest.sh clone "$@" || exit 1 +# Version check + +# required +reqdmajor=1 +reqdminor=5 +reqdrev=0 + +# requested +rqstmajor=2 +rqstminor=6 +rqstrev=3 + +# installed +hgwhere="`which hg 2> /dev/null | grep -v '^no hg in '`" +if [ "x$hgwhere" = "x" ]; then + echo "ERROR: Could not locate Mercurial command" >&2 + exit 126 +fi + +hgversion="`hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \(.*\))\$@\1@p'`" +if [ "x${hgversion}" = "x" ] ; then + echo "ERROR: Could not determine Mercurial version" >&2 + exit 126 +fi + +hgmajor="`echo $hgversion | cut -f 1 -d .`" +hgminor="`echo $hgversion | cut -f 2 -d .`" +hgrev="`echo $hgversion.0 | cut -f 3 -d .`" # rev is omitted for minor and major releases + +# Require +if [ $hgmajor -lt $reqdmajor -o \( $hgmajor -eq $reqdmajor -a $hgminor -lt $reqdminor \) -o \( $hgmajor -eq $reqdmajor -a $hgminor -eq $reqdminor -a $hgrev -lt $reqdrev \) ] ; then + echo "ERROR: Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion" >&2 + exit 126 +fi + +# Request +if [ $hgmajor -lt $rqstmajor -o \( $hgmajor -eq $rqstmajor -a $hgminor -lt $rqstminor \) -o \( $hgmajor -eq $rqstmajor -a $hgminor -eq $rqstminor -a $hgrev -lt $rqstrev \) ] ; then + echo "WARNING: Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion" >&2 +fi + +# Get clones of all absent nested repositories (harmless if already exist) +sh ./common/bin/hgforest.sh clone "$@" || exit $? # Update all existing repositories to the latest sources sh ./common/bin/hgforest.sh pull -u - From 40c9be9c9e3f233ec18616981fed5cec5215d4b4 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Tue, 24 Jun 2014 20:29:52 -0700 Subject: [PATCH 127/236] 8047740: Add hotspot testset to jprt.properties Reviewed-by: dholmes --- make/jprt.properties | 581 +++++++++++++++++++++++++++++++++---------- 1 file changed, 444 insertions(+), 137 deletions(-) diff --git a/make/jprt.properties b/make/jprt.properties index 6e79202c37a..3a10135c56e 100644 --- a/make/jprt.properties +++ b/make/jprt.properties @@ -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 @@ -23,151 +23,458 @@ # questions. # -# Properties for jprt +############## +# +# Global settings +# -# Locked down to jdk9 +# The current release name jprt.tools.default.release=jdk9 -# Unix toolkit to use for building on windows -jprt.windows.jdk8.build.unix.toolkit=cygwin +# Check if this is the equivalent of a hotspot push job +# Interpret -testset hotspot to mean exactly that +my.is.hotspot.job.hotspot=true +my.is.hotspot.job=${my.is.hotspot.job.${jprt.test.set}} -# The different build flavors we want, we override here so we just get these 2 -jprt.build.flavors=product,fastdebug - -# Standard list of jprt build targets for this source tree -jprt.build.targets= \ - solaris_sparcv9_5.11-{product|fastdebug}, \ - solaris_x64_5.11-{product|fastdebug}, \ - linux_i586_2.6-{product|fastdebug}, \ - linux_x64_2.6-{product|fastdebug}, \ - macosx_x64_10.7-{product|fastdebug}, \ - windows_i586_6.1-{product|fastdebug}, \ - windows_x64_6.1-{product|fastdebug} - -# User can select the test set with jprt submit "-testset name" option -jprt.my.test.set=${jprt.test.set} - -# Test target list (no fastdebug & limited c2 testing) -jprt.my.test.target.set= \ - solaris_sparcv9_5.11-product-c2-TESTNAME, \ - solaris_x64_5.11-product-c2-TESTNAME, \ - linux_i586_2.6-product-{c1|c2}-TESTNAME, \ - linux_x64_2.6-product-c2-TESTNAME, \ - macosx_x64_10.7-product-c2-TESTNAME, \ - windows_i586_6.1-product-c1-TESTNAME, \ - windows_x64_6.1-product-c2-TESTNAME - -# Default vm test targets (testset=default) -jprt.vm.default.test.targets= \ - ${jprt.my.test.target.set:TESTNAME=jvm98}, \ - ${jprt.my.test.target.set:TESTNAME=scimark} - -# Default jdk test targets (testset=default) -jprt.make.rule.default.test.targets= \ - ${jprt.my.test.target.set:TESTNAME=langtools_jtreg}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_lang}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_math}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_util} - - -# Default vm test targets (testset=core) -jprt.vm.core.test.targets= - -# Core jdk test targets (testset=core) -jprt.make.rule.core.test.targets= \ - ${jprt.my.test.target.set:TESTNAME=jdk_lang}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_math}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_util}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_io}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_net}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_nio}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_security1}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_security2}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_security3}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_rmi}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_text}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_time}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_other}, \ - ${jprt.my.test.target.set:TESTNAME=core_tools} - -# Svc vm test targets (testset=svc) -jprt.vm.svc.test.targets= - -# Core jdk test targets (testset=svc) -jprt.make.rule.svc.test.targets= \ - ${jprt.my.test.target.set:TESTNAME=jdk_management}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_instrument}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_jmx}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_jdi}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_jfr}, \ - ${jprt.my.test.target.set:TESTNAME=svc_tools} - -# All vm test targets (testset=all) -jprt.vm.all.test.targets= \ - ${jprt.vm.default.test.targets}, \ - ${jprt.my.test.target.set:TESTNAME=runThese}, \ - ${jprt.my.test.target.set:TESTNAME=jbb_default} - -# All jdk test targets (testset=all) -jprt.make.rule.all.test.targets= \ - ${jprt.make.rule.core.test.targets}, \ - ${jprt.make.rule.svc.test.targets}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_awt}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_beans1}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_beans2}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_beans3}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_sound}, \ - ${jprt.my.test.target.set:TESTNAME=jdk_swing} - -# PIT vm test targets (testset=pit) -jprt.vm.pit.test.targets= \ - ${jprt.vm.all.test.targets} - -# PIT jdk test targets (testset=pit) -jprt.make.rule.pit.test.targets= \ - ${jprt.my.test.target.set:TESTNAME=langtools_jtreg}, \ - ${jprt.make.rule.core.test.targets}, \ - ${jprt.make.rule.svc.test.targets} - -# JCK test targets in test/Makefile (no windows) -jprt.my.jck.test.target.set= \ - solaris_sparcv9_5.11-product-c2-JCK7TESTRULE, \ - solaris_x64_5.11-product-c2-JCK7TESTRULE, \ - linux_i586_2.6-product-c1-JCK7TESTRULE, \ - linux_x64_2.6-product-c2-JCK7TESTRULE - -# JCK testset targets (e.g. jprt submit -testset jck ... ) -jprt.make.rule.jck.test.targets= \ - ${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7devtools}, \ - ${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7runtime}, \ - ${jprt.my.jck.test.target.set:JCK7TESTRULE=jck7compiler} - -# Select list to use (allow for testset to be empty too) -jprt.make.rule..test.targets=${jprt.make.rule.default.test.targets} -jprt.make.rule.test.targets=${jprt.make.rule.${jprt.my.test.set}.test.targets} -jprt.vm..test.targets=${jprt.vm.default.test.targets} -jprt.test.targets=${jprt.vm.${jprt.my.test.set}.test.targets} +# Disable syncing the source after builds and tests are done +jprt.sync.push=${my.is.hotspot.job ? false : true} # Directories to be excluded from the source bundles jprt.bundle.exclude.src.dirs=build dist webrev -# Instruct jprt to use configure when building +# Use configure when building jprt.build.use.configure=true -jprt.build.flavor.product.target=jprt_bundle + +# Set make target to use for different build flavors +jprt.build.flavor.debugOpen.target=jprt_bundle jprt.build.flavor.fastdebug.target=jprt_bundle -jprt.build.flavor.debug.target=jprt_bundle +jprt.build.flavor.product.target=jprt_bundle +jprt.build.flavor.productOpen.target=jprt_bundle -# Add these configure args to all builds -jprt.build.configure.args= \ - --with-boot-jdk=$ALT_BOOTDIR \ - --with-jobs=$ALT_PARALLEL_COMPILE_JOBS - -# Add these configure args to 32 bit builds -jprt.i586.build.configure.args= \ - --with-target-bits=32 \ - --with-jvm-variants=client,server - -# Use these configure args to define debug level. -jprt.product.build.configure.args=--with-debug-level=release -jprt.fastdebug.build.configure.args=--with-debug-level=fastdebug +# Use these configure args to define debug level jprt.debug.build.configure.args=--with-debug-level=slowdebug +jprt.fastdebug.build.configure.args=--with-debug-level=fastdebug +jprt.product.build.configure.args=--with-debug-level=release +jprt.debugOpen.build.configure.args=${jprt.debug.build.configure.args} --enable-openjdk-only +jprt.fastdebugOpen.build.configure.args=${jprt.fastdebug.build.configure.args} --enable-openjdk-only +jprt.productOpen.build.configure.args=${jprt.product.build.configure.args} --enable-openjdk-only + +# Select build flavors and build targets +jprt.build.flavors=${my.is.hotspot.job ? ${my.build.flavors.hotspot} : ${my.build.flavors.default}} +jprt.build.targets=${my.is.hotspot.job ? ${my.build.targets.hotspot} : ${my.build.targets.default}} + +# Select test targets - jprt default for jprt.test.set is "default" +jprt.test.targets=${my.test.targets.${jprt.test.set}} +jprt.make.rule.test.targets=${my.make.rule.test.targets.${jprt.test.set}} + +# 7155453: Work-around to prevent popups on OSX from blocking test completion +# but the work-around is added to all platforms to be consistent +jprt.jbb.options=-Djava.awt.headless=true + +######## +# +# Build options (generic) +# + +# Configure args common to all builds +# Also allows for additional, testset specific configure arguments to be set +jprt.build.configure.args= \ + --with-boot-jdk=$ALT_BOOTDIR \ + --with-jobs=$ALT_PARALLEL_COMPILE_JOBS \ + ${my.additional.build.configure.args.${jprt.test.set}} + +# i586 is often cross-compiled from 64-bit machines, so need to set target bits explicitly +jprt.i586.build.configure.args= \ + --with-target-bits=32 + +# i586 platforms have both client and server, but to allow for overriding the exact configuration +# on a per-build flavor basis the value is set for the individual build flavors +my.i586.default.build.configure.args= \ + --with-jvm-variants=client,server +jprt.i586.debug.build.configure.args= \ + ${my.i586.default.build.configure.args} \ + ${jprt.debug.build.configure.args} +jprt.i586.fastdebug.build.configure.args= \ + ${my.i586.default.build.configure.args} \ + ${jprt.fastdebug.build.configure.args} +jprt.i586.product.build.configure.args= \ + ${my.i586.default.build.configure.args} \ + ${jprt.product.build.configure.args} +jprt.i586.debugOpen.build.configure.args= \ + ${my.i586.default.build.configure.args} \ + ${jprt.debugOpen.build.configure.args} +jprt.i586.fastdebugOpen.build.configure.args= \ + ${my.i586.default.build.configure.args} \ + ${jprt.fastdebugOpen.build.configure.args} +jprt.i586.productOpen.build.configure.args= \ + ${my.i586.default.build.configure.args} \ + ${jprt.productOpen.build.configure.args} + +######## +# +# Build targets and options (default/jdk) +# + +# The default build flavors +my.build.flavors.default=fastdebug,product + +# Standard list of jprt build targets for this source tree +my.build.targets.default= \ + solaris_sparcv9_5.11-{product|fastdebug}, \ + solaris_x64_5.11-{product|fastdebug}, \ + linux_i586_2.6-{product|fastdebug}, \ + linux_x64_2.6-{product|fastdebug}, \ + macosx_x64_10.7-{product|fastdebug}, \ + windows_i586_6.1-{product|fastdebug}, \ + windows_x64_6.1-{product|fastdebug} + +# Test target list (no fastdebug & limited c2 testing) +my.test.target.set= \ + solaris_sparcv9_5.11-product-c2-TESTNAME, \ + solaris_x64_5.11-product-c2-TESTNAME, \ + linux_i586_2.6-product-{c1|c2}-TESTNAME, \ + linux_x64_2.6-product-c2-TESTNAME, \ + macosx_x64_10.7-product-c2-TESTNAME, \ + windows_i586_6.1-product-c1-TESTNAME, \ + windows_x64_6.1-product-c2-TESTNAME + +# Default vm test targets (testset=default) +my.test.targets.default= \ + ${my.test.target.set:TESTNAME=jvm98}, \ + ${my.test.target.set:TESTNAME=scimark} + +# Default jdk test targets (testset=default) +my.make.rule.test.targets.default= \ + ${my.test.target.set:TESTNAME=langtools_jtreg}, \ + ${my.test.target.set:TESTNAME=jdk_lang}, \ + ${my.test.target.set:TESTNAME=jdk_math}, \ + ${my.test.target.set:TESTNAME=jdk_util} + +# Default vm test targets (testset=core) +my.test.targets.core= + +# Core jdk test targets (testset=core) +my.make.rule.test.targets.core= \ + ${my.test.target.set:TESTNAME=jdk_lang}, \ + ${my.test.target.set:TESTNAME=jdk_math}, \ + ${my.test.target.set:TESTNAME=jdk_util}, \ + ${my.test.target.set:TESTNAME=jdk_io}, \ + ${my.test.target.set:TESTNAME=jdk_net}, \ + ${my.test.target.set:TESTNAME=jdk_nio}, \ + ${my.test.target.set:TESTNAME=jdk_security1}, \ + ${my.test.target.set:TESTNAME=jdk_security2}, \ + ${my.test.target.set:TESTNAME=jdk_security3}, \ + ${my.test.target.set:TESTNAME=jdk_rmi}, \ + ${my.test.target.set:TESTNAME=jdk_text}, \ + ${my.test.target.set:TESTNAME=jdk_time}, \ + ${my.test.target.set:TESTNAME=jdk_other}, \ + ${my.test.target.set:TESTNAME=core_tools} + +# Svc vm test targets (testset=svc) +my.test.targets.svc= + +# Core jdk test targets (testset=svc) +my.make.rule.test.targets.svc= \ + ${my.test.target.set:TESTNAME=jdk_management}, \ + ${my.test.target.set:TESTNAME=jdk_instrument}, \ + ${my.test.target.set:TESTNAME=jdk_jmx}, \ + ${my.test.target.set:TESTNAME=jdk_jdi}, \ + ${my.test.target.set:TESTNAME=jdk_jfr}, \ + ${my.test.target.set:TESTNAME=svc_tools} + +# All vm test targets (testset=all) +my.test.targets.all= \ + ${my.test.targets.default}, \ + ${my.test.target.set:TESTNAME=runThese}, \ + ${my.test.target.set:TESTNAME=jbb_default} + +# All jdk test targets (testset=all) +my.make.rule.test.targets.all= \ + ${my.make.rule.test.targets.core}, \ + ${my.make.rule.test.targets.svc}, \ + ${my.test.target.set:TESTNAME=jdk_awt}, \ + ${my.test.target.set:TESTNAME=jdk_beans1}, \ + ${my.test.target.set:TESTNAME=jdk_beans2}, \ + ${my.test.target.set:TESTNAME=jdk_beans3}, \ + ${my.test.target.set:TESTNAME=jdk_sound}, \ + ${my.test.target.set:TESTNAME=jdk_swing} + +# PIT vm test targets (testset=pit) +my.test.targets.pit= \ + ${my.test.targets.all} + +# PIT jdk test targets (testset=pit) +my.make.rule.test.targets.pit= \ + ${my.test.target.set:TESTNAME=langtools_jtreg}, \ + ${my.make.rule.test.targets.core}, \ + ${my.make.rule.test.targets.svc} + +# JCK test targets in test/Makefile (no windows) +my.test.target.set.jck= \ + solaris_sparcv9_5.11-product-c2-JCK7TESTRULE, \ + solaris_x64_5.11-product-c2-JCK7TESTRULE, \ + linux_i586_2.6-product-c1-JCK7TESTRULE, \ + linux_x64_2.6-product-c2-JCK7TESTRULE + +# JCK testset targets +my.make.rule.test.targets.jck= \ + ${my.test.target.set.jck:JCK7TESTRULE=jck7devtools}, \ + ${my.test.target.set.jck:JCK7TESTRULE=jck7runtime}, \ + ${my.test.target.set.jck:JCK7TESTRULE=jck7compiler} + + +############# +# +# Hotspot related settings (testset=hotspot) +# + +# The hotspot build flavors +my.build.flavors.hotspot= \ + debugOpen,fastdebug,product,productOpen, \ + ${my.additional.build.flavors.hotspot} + +# Platforms built for hotspot push jobs +my.build.targets.hotspot= \ + solaris_sparcv9_5.11-{product|fastdebug|optimized}, \ + solaris_x64_5.11-{product|fastdebug}, \ + linux_i586_2.6-{product|fastdebug}, \ + linux_x64_2.6-{product|fastdebug|optimized}, \ + macosx_x64_10.7-{product|fastdebug}, \ + windows_i586_6.1-{product|fastdebug}, \ + windows_x64_6.1-{product|fastdebug|optimized}, \ + solaris_x64_5.11-{debugOpen}, \ + linux_x64_2.6-{productOpen}, \ + ${my.additional.build.targets.hotspot} + +# Tests to run on the various platforms for hotspot push jobs +my.test.targets.hotspot.solaris.sparcv9= \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jvm98, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jvm98_nontiered, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-scimark, \ + solaris_sparcv9_5.11-product-c2-runThese, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_SerialGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_ParallelGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_ParNewGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_CMS, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_G1, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCBasher_ParOldGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCOld_SerialGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCOld_ParallelGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCOld_ParNewGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCOld_CMS, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCOld_G1, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-GCOld_ParOldGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jbb_default_nontiered, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jbb_SerialGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jbb_ParallelGC, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jbb_CMS, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jbb_G1, \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-jbb_ParOldGC + +my.test.targets.hotspot.solaris.x64= \ + solaris_x64_5.11-{product|fastdebug}-c2-jvm98, \ + solaris_x64_5.11-{product|fastdebug}-c2-jvm98_nontiered, \ + solaris_x64_5.11-{product|fastdebug}-c2-scimark, \ + solaris_x64_5.11-product-c2-runThese, \ + solaris_x64_5.11-product-c2-runThese_Xcomp, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_SerialGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_ParallelGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_ParNewGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_CMS, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_G1, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCBasher_ParOldGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_SerialGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_ParallelGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_ParNewGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_CMS, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_G1, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_ParOldGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-jbb_default_nontiered, \ + solaris_x64_5.11-{product|fastdebug}-c2-jbb_SerialGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-jbb_ParallelGC, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_CMS, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_G1, \ + solaris_x64_5.11-{product|fastdebug}-c2-GCOld_ParOldGC + +my.test.targets.hotspot.linux.i586= \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-jvm98, \ + linux_i586_2.6-{product|fastdebug}-c2-jvm98_nontiered, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-scimark, \ + linux_i586_2.6-product-c1-runThese_Xcomp, \ + linux_i586_2.6-fastdebug-c1-runThese_Xshare, \ + linux_i586_2.6-fastdebug-c2-runThese_Xcomp, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_ParNewGC, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_CMS, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_G1, \ + linux_i586_2.6-{product|fastdebug}-{c1|c2}-GCBasher_ParOldGC, \ + linux_i586_2.6-product-{c1|c2}-GCOld_SerialGC, \ + linux_i586_2.6-product-{c1|c2}-GCOld_ParallelGC, \ + linux_i586_2.6-product-{c1|c2}-GCOld_ParNewGC, \ + linux_i586_2.6-product-{c1|c2}-GCOld_CMS, \ + linux_i586_2.6-product-{c1|c2}-GCOld_G1, \ + linux_i586_2.6-product-{c1|c2}-GCOld_ParOldGC, \ + linux_i586_2.6-{product|fastdebug}-c1-jbb_SerialGC, \ + linux_i586_2.6-{product|fastdebug}-c2-jbb_default_nontiered, \ + linux_i586_2.6-{product|fastdebug}-c1-jbb_ParallelGC, \ + linux_i586_2.6-{product|fastdebug}-c1-jbb_CMS, \ + linux_i586_2.6-{product|fastdebug}-c1-jbb_G1, \ + linux_i586_2.6-{product|fastdebug}-c1-jbb_ParOldGC + +my.test.targets.hotspot.linux.x64= \ + linux_x64_2.6-{product|fastdebug}-c2-jvm98, \ + linux_x64_2.6-{product|fastdebug}-c2-jvm98_nontiered, \ + linux_x64_2.6-{product|fastdebug}-c2-scimark, \ + linux_x64_2.6-{product|fastdebug}-c2-GCBasher_SerialGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCBasher_ParallelGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCBasher_ParNewGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCBasher_CMS, \ + linux_x64_2.6-{product|fastdebug}-c2-GCBasher_G1, \ + linux_x64_2.6-{product|fastdebug}-c2-GCBasher_ParOldGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCOld_SerialGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCOld_ParallelGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCOld_ParNewGC, \ + linux_x64_2.6-{product|fastdebug}-c2-GCOld_CMS, \ + linux_x64_2.6-{product|fastdebug}-c2-GCOld_G1, \ + linux_x64_2.6-{product|fastdebug}-c2-GCOld_ParOldGC, \ + linux_x64_2.6-{product|fastdebug}-c2-jbb_default_nontiered, \ + linux_x64_2.6-{product|fastdebug}-c2-jbb_ParallelGC, \ + linux_x64_2.6-{product|fastdebug}-c2-jbb_G1, \ + linux_x64_2.6-{product|fastdebug}-c2-jbb_ParOldGC + +my.test.targets.hotspot.macosx.x64= \ + macosx_x64_10.7-{product|fastdebug}-c2-jvm98, \ + macosx_x64_10.7-{product|fastdebug}-c2-jvm98_nontiered, \ + macosx_x64_10.7-{product|fastdebug}-c2-scimark, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCBasher_SerialGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCBasher_ParallelGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCBasher_ParNewGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCBasher_CMS, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCBasher_G1, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCBasher_ParOldGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCOld_SerialGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCOld_ParallelGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCOld_ParNewGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCOld_CMS, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCOld_G1, \ + macosx_x64_10.7-{product|fastdebug}-c2-GCOld_ParOldGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-jbb_default_nontiered, \ + macosx_x64_10.7-{product|fastdebug}-c2-jbb_ParallelGC, \ + macosx_x64_10.7-{product|fastdebug}-c2-jbb_G1, \ + macosx_x64_10.7-{product|fastdebug}-c2-jbb_ParOldGC + +my.test.targets.hotspot.windows.i586= \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-jvm98, \ + windows_i586_6.1-{product|fastdebug}-c2-jvm98_nontiered, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-scimark, \ + windows_i586_6.1-product-{c1|c2}-runThese, \ + windows_i586_6.1-product-{c1|c2}-runThese_Xcomp, \ + windows_i586_6.1-fastdebug-c1-runThese_Xshare, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_ParNewGC, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_CMS, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_G1, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-GCBasher_ParOldGC, \ + windows_i586_6.1-product-{c1|c2}-GCOld_SerialGC, \ + windows_i586_6.1-product-{c1|c2}-GCOld_ParallelGC, \ + windows_i586_6.1-product-{c1|c2}-GCOld_ParNewGC, \ + windows_i586_6.1-product-{c1|c2}-GCOld_CMS, \ + windows_i586_6.1-product-{c1|c2}-GCOld_G1, \ + windows_i586_6.1-product-{c1|c2}-GCOld_ParOldGC, \ + windows_i586_6.1-{product|fastdebug}-{c1|c2}-jbb_default, \ + windows_i586_6.1-{product|fastdebug}-c2-jbb_default_nontiered, \ + windows_i586_6.1-product-{c1|c2}-jbb_ParallelGC, \ + windows_i586_6.1-product-{c1|c2}-jbb_CMS, \ + windows_i586_6.1-product-{c1|c2}-jbb_G1, \ + windows_i586_6.1-product-{c1|c2}-jbb_ParOldGC + +my.test.targets.hotspot.windows.x64= \ + windows_x64_6.1-{product|fastdebug}-c2-jvm98, \ + windows_x64_6.1-{product|fastdebug}-c2-jvm98_nontiered, \ + windows_x64_6.1-{product|fastdebug}-c2-scimark, \ + windows_x64_6.1-product-c2-runThese, \ + windows_x64_6.1-product-c2-runThese_Xcomp, \ + windows_x64_6.1-{product|fastdebug}-c2-GCBasher_SerialGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCBasher_ParallelGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCBasher_ParNewGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCBasher_CMS, \ + windows_x64_6.1-{product|fastdebug}-c2-GCBasher_G1, \ + windows_x64_6.1-{product|fastdebug}-c2-GCBasher_ParOldGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCOld_SerialGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCOld_ParallelGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCOld_ParNewGC, \ + windows_x64_6.1-{product|fastdebug}-c2-GCOld_CMS, \ + windows_x64_6.1-{product|fastdebug}-c2-GCOld_G1, \ + windows_x64_6.1-{product|fastdebug}-c2-GCOld_ParOldGC, \ + windows_x64_6.1-{product|fastdebug}-c2-jbb_default, \ + windows_x64_6.1-{product|fastdebug}-c2-jbb_default_nontiered, \ + windows_x64_6.1-product-c2-jbb_CMS, \ + windows_x64_6.1-product-c2-jbb_ParallelGC, \ + windows_x64_6.1-product-c2-jbb_G1, \ + windows_x64_6.1-product-c2-jbb_ParOldGC + +# Some basic "smoke" tests for OpenJDK builds +my.test.targets.hotspot.open= \ + solaris_x64_5.11-{productOpen|fastdebugOpen}-c2-jvm98, \ + linux_x64_2.6-{productOpen|fastdebugOpen}-c2-jvm98 + +# The complete list of test targets for jprt +my.test.targets.hotspot= \ + ${my.test.targets.hotspot.open}, \ + ${my.test.targets.hotspot.solaris.sparcv9}, \ + ${my.test.targets.hotspot.solaris.x64}, \ + ${my.test.targets.hotspot.linux.i586}, \ + ${my.test.targets.hotspot.linux.x64}, \ + ${my.test.targets.hotspot.macosx.x64}, \ + ${my.test.targets.hotspot.windows.i586}, \ + ${my.test.targets.hotspot.windows.x64}, \ + ${my.test.targets.hotspot.solaris.sparcv9}, \ + ${my.test.targets.hotspot.solaris.x64}, \ + ${my.test.targets.hotspot.linux.x64}, \ + ${my.test.targets.hotspot.windows.i586}, \ + ${my.test.targets.hotspot.windows.x64}, \ + ${my.additional.test.targets.hotspot} + + +# Make file based test targets + +my.make.rule.test.targets.hotspot.clienttests= \ + linux_i586_2.6-*-c1-hotspot_clienttest, \ + windows_i586_6.1-*-c1-hotspot_clienttest + +my.make.rule.test.targets.hotspot.servertests= \ + solaris_sparcv9_5.11-*-c2-hotspot_servertest, \ + solaris_x64_5.11-*-c2-hotspot_servertest, \ + linux_i586_2.6-*-c2-hotspot_servertest, \ + linux_x64_2.6-*-c2-hotspot_servertest, \ + macosx_x64_10.7-*-c2-hotspot_servertest, \ + windows_i586_6.1-*-c2-hotspot_servertest, \ + windows_x64_6.1-*-c2-hotspot_servertest + +my.make.rule.test.targets.hotspot.internalvmtests= \ + solaris_sparcv9_5.11-fastdebug-c2-hotspot_internalvmtests, \ + solaris_x64_5.11-fastdebug-c2-hotspot_internalvmtests, \ + linux_i586_2.6-fastdebug-c2-hotspot_internalvmtests, \ + linux_x64_2.6-fastdebug-c2-hotspot_internalvmtests, \ + macosx_x64_10.7-fastdebug-c2-hotspot_internalvmtests, \ + windows_i586_6.1-fastdebug-c2-hotspot_internalvmtests, \ + windows_x64_6.1-fastdebug-c2-hotspot_internalvmtests + +my.make.rule.test.targets.hotspot.wbapitests= \ + solaris_sparcv9_5.11-{product|fastdebug}-c2-hotspot_wbapitest, \ + solaris_x64_5.11-{product|fastdebug}-c2-hotspot_wbapitest, \ + linux_i586_2.6-{product|fastdebug}-c2-hotspot_wbapitest, \ + linux_x64_2.6-{product|fastdebug}-c2-hotspot_wbapitest, \ + windows_i586_6.1-{product|fastdebug}-c2-hotspot_wbapitest, \ + windows_x64_6.1-{product|fastdebug}-c2-hotspot_wbapitest, \ + linux_i586_2.6-{product|fastdebug}-c1-hotspot_wbapitest, \ + windows_i586_6.1-{product|fastdebug}-c1-hotspot_wbapitest + +my.make.rule.test.targets.hotspot= \ + ${my.make.rule.test.targets.hotspot.clienttests}, \ + ${my.make.rule.test.targets.hotspot.servertests}, \ + ${my.make.rule.test.targets.hotspot.internalvmtests}, \ + ${my.make.rule.test.targets.hotspot.wbapitests}, \ + ${my.additional.make.rule.test.targets.hotspot} From 24fcad36b4207a184af521c901bf16b68b1f329f Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 25 Jun 2014 08:28:01 +0200 Subject: [PATCH 128/236] 8047323: Remove unused _copy_metadata_obj_cl in G1CopyingKeepAliveClosure Reviewed-by: mgerdin, tschatzl --- .../gc_implementation/g1/g1CollectedHeap.cpp | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 012d851d97e..f020f0d53a1 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -5340,17 +5340,14 @@ public: class G1CopyingKeepAliveClosure: public OopClosure { G1CollectedHeap* _g1h; OopClosure* _copy_non_heap_obj_cl; - OopsInHeapRegionClosure* _copy_metadata_obj_cl; G1ParScanThreadState* _par_scan_state; public: G1CopyingKeepAliveClosure(G1CollectedHeap* g1h, OopClosure* non_heap_obj_cl, - OopsInHeapRegionClosure* metadata_obj_cl, G1ParScanThreadState* pss): _g1h(g1h), _copy_non_heap_obj_cl(non_heap_obj_cl), - _copy_metadata_obj_cl(metadata_obj_cl), _par_scan_state(pss) {} @@ -5383,7 +5380,7 @@ public: _par_scan_state->push_on_queue(p); } else { assert(!Metaspace::contains((const void*)p), - err_msg("Otherwise need to call _copy_metadata_obj_cl->do_oop(p) " + err_msg("Unexpectedly found a pointer from metadata: " PTR_FORMAT, p)); _copy_non_heap_obj_cl->do_oop(p); } @@ -5478,22 +5475,18 @@ public: pss.set_evac_failure_closure(&evac_failure_cl); G1ParScanExtRootClosure only_copy_non_heap_cl(_g1h, &pss, NULL); - G1ParScanMetadataClosure only_copy_metadata_cl(_g1h, &pss, NULL); G1ParScanAndMarkExtRootClosure copy_mark_non_heap_cl(_g1h, &pss, NULL); - G1ParScanAndMarkMetadataClosure copy_mark_metadata_cl(_g1h, &pss, NULL); OopClosure* copy_non_heap_cl = &only_copy_non_heap_cl; - OopsInHeapRegionClosure* copy_metadata_cl = &only_copy_metadata_cl; if (_g1h->g1_policy()->during_initial_mark_pause()) { // We also need to mark copied objects. copy_non_heap_cl = ©_mark_non_heap_cl; - copy_metadata_cl = ©_mark_metadata_cl; } // Keep alive closure. - G1CopyingKeepAliveClosure keep_alive(_g1h, copy_non_heap_cl, copy_metadata_cl, &pss); + G1CopyingKeepAliveClosure keep_alive(_g1h, copy_non_heap_cl, &pss); // Complete GC closure G1ParEvacuateFollowersClosure drain_queue(_g1h, &pss, _task_queues, _terminator); @@ -5588,18 +5581,14 @@ public: G1ParScanExtRootClosure only_copy_non_heap_cl(_g1h, &pss, NULL); - G1ParScanMetadataClosure only_copy_metadata_cl(_g1h, &pss, NULL); G1ParScanAndMarkExtRootClosure copy_mark_non_heap_cl(_g1h, &pss, NULL); - G1ParScanAndMarkMetadataClosure copy_mark_metadata_cl(_g1h, &pss, NULL); OopClosure* copy_non_heap_cl = &only_copy_non_heap_cl; - OopsInHeapRegionClosure* copy_metadata_cl = &only_copy_metadata_cl; if (_g1h->g1_policy()->during_initial_mark_pause()) { // We also need to mark copied objects. copy_non_heap_cl = ©_mark_non_heap_cl; - copy_metadata_cl = ©_mark_metadata_cl; } // Is alive closure @@ -5607,7 +5596,7 @@ public: // Copying keep alive closure. Applied to referent objects that need // to be copied. - G1CopyingKeepAliveClosure keep_alive(_g1h, copy_non_heap_cl, copy_metadata_cl, &pss); + G1CopyingKeepAliveClosure keep_alive(_g1h, copy_non_heap_cl, &pss); ReferenceProcessor* rp = _g1h->ref_processor_cm(); @@ -5713,22 +5702,18 @@ void G1CollectedHeap::process_discovered_references(uint no_of_gc_workers) { assert(pss.refs()->is_empty(), "pre-condition"); G1ParScanExtRootClosure only_copy_non_heap_cl(this, &pss, NULL); - G1ParScanMetadataClosure only_copy_metadata_cl(this, &pss, NULL); G1ParScanAndMarkExtRootClosure copy_mark_non_heap_cl(this, &pss, NULL); - G1ParScanAndMarkMetadataClosure copy_mark_metadata_cl(this, &pss, NULL); OopClosure* copy_non_heap_cl = &only_copy_non_heap_cl; - OopsInHeapRegionClosure* copy_metadata_cl = &only_copy_metadata_cl; if (_g1h->g1_policy()->during_initial_mark_pause()) { // We also need to mark copied objects. copy_non_heap_cl = ©_mark_non_heap_cl; - copy_metadata_cl = ©_mark_metadata_cl; } // Keep alive closure. - G1CopyingKeepAliveClosure keep_alive(this, copy_non_heap_cl, copy_metadata_cl, &pss); + G1CopyingKeepAliveClosure keep_alive(this, copy_non_heap_cl, &pss); // Serial Complete GC closure G1STWDrainQueueClosure drain_queue(this, &pss); From c3148bb6cb97d764ceecb21711843e1e09bd20a5 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 25 Jun 2014 08:56:57 +0200 Subject: [PATCH 129/236] 8047326: Consolidate all CompiledIC::CompiledIC implementations and move it to compiledIC.cpp Reviewed-by: vlivanov, ehelin --- hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp | 28 ------------------- hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp | 28 ------------------- hotspot/src/cpu/x86/vm/compiledIC_x86.cpp | 28 ------------------- hotspot/src/cpu/zero/vm/compiledIC_zero.cpp | 28 ------------------- hotspot/src/share/vm/code/compiledIC.cpp | 24 ++++++++++++++++ 5 files changed, 24 insertions(+), 112 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp index b24b3c4c895..ab100745af4 100644 --- a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp @@ -50,34 +50,6 @@ bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { return is_icholder_entry(call->destination()); } -//----------------------------------------------------------------------------- -// High-level access to an inline cache. Guaranteed to be MT-safe. - -CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) - : _ic_call(call) -{ - address ic_call = call->instruction_address(); - - assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass nmethod"); - assert(nm->contains(ic_call), "must be in nmethod"); - - // Search for the ic_call at the given address. - RelocIterator iter(nm, ic_call, ic_call+1); - bool ret = iter.next(); - assert(ret == true, "relocInfo must exist at this address"); - assert(iter.addr() == ic_call, "must find ic_call"); - if (iter.type() == relocInfo::virtual_call_type) { - virtual_call_Relocation* r = iter.virtual_call_reloc(); - _is_optimized = false; - _value = nativeMovConstReg_at(r->cached_value()); - } else { - assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); - _is_optimized = true; - _value = NULL; - } -} - // ---------------------------------------------------------------------------- // A PPC CompiledStaticCall looks like this: diff --git a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp index 92d494fc0ca..a4b2a094a5b 100644 --- a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp @@ -50,34 +50,6 @@ bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { return is_icholder_entry(call->destination()); } -//----------------------------------------------------------------------------- -// High-level access to an inline cache. Guaranteed to be MT-safe. - -CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) - : _ic_call(call) -{ - address ic_call = call->instruction_address(); - - assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass nmethod"); - assert(nm->contains(ic_call), "must be in nmethod"); - - // Search for the ic_call at the given address. - RelocIterator iter(nm, ic_call, ic_call+1); - bool ret = iter.next(); - assert(ret == true, "relocInfo must exist at this address"); - assert(iter.addr() == ic_call, "must find ic_call"); - if (iter.type() == relocInfo::virtual_call_type) { - virtual_call_Relocation* r = iter.virtual_call_reloc(); - _is_optimized = false; - _value = nativeMovConstReg_at(r->cached_value()); - } else { - assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); - _is_optimized = true; - _value = NULL; - } -} - // ---------------------------------------------------------------------------- #define __ _masm. diff --git a/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp b/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp index 26d56b86ab3..9537ef971f7 100644 --- a/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp +++ b/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp @@ -47,34 +47,6 @@ bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { return is_icholder_entry(call->destination()); } -//----------------------------------------------------------------------------- -// High-level access to an inline cache. Guaranteed to be MT-safe. - -CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) - : _ic_call(call) -{ - address ic_call = call->instruction_address(); - - assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass nmethod"); - assert(nm->contains(ic_call), "must be in nmethod"); - - // Search for the ic_call at the given address. - RelocIterator iter(nm, ic_call, ic_call+1); - bool ret = iter.next(); - assert(ret == true, "relocInfo must exist at this address"); - assert(iter.addr() == ic_call, "must find ic_call"); - if (iter.type() == relocInfo::virtual_call_type) { - virtual_call_Relocation* r = iter.virtual_call_reloc(); - _is_optimized = false; - _value = nativeMovConstReg_at(r->cached_value()); - } else { - assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); - _is_optimized = true; - _value = NULL; - } -} - // ---------------------------------------------------------------------------- #define __ _masm. diff --git a/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp b/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp index 6fa39ea078b..143dc317380 100644 --- a/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp +++ b/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp @@ -58,34 +58,6 @@ bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { return is_icholder_entry(call->destination()); } -//----------------------------------------------------------------------------- -// High-level access to an inline cache. Guaranteed to be MT-safe. - -CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) - : _ic_call(call) -{ - address ic_call = call->instruction_address(); - - assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass nmethod"); - assert(nm->contains(ic_call), "must be in nmethod"); - - // Search for the ic_call at the given address. - RelocIterator iter(nm, ic_call, ic_call+1); - bool ret = iter.next(); - assert(ret == true, "relocInfo must exist at this address"); - assert(iter.addr() == ic_call, "must find ic_call"); - if (iter.type() == relocInfo::virtual_call_type) { - virtual_call_Relocation* r = iter.virtual_call_reloc(); - _is_optimized = false; - _value = nativeMovConstReg_at(r->cached_value()); - } else { - assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); - _is_optimized = true; - _value = NULL; - } -} - // ---------------------------------------------------------------------------- void CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf) { diff --git a/hotspot/src/share/vm/code/compiledIC.cpp b/hotspot/src/share/vm/code/compiledIC.cpp index 9a038164689..2ce7c3c6793 100644 --- a/hotspot/src/share/vm/code/compiledIC.cpp +++ b/hotspot/src/share/vm/code/compiledIC.cpp @@ -159,6 +159,30 @@ address CompiledIC::stub_address() const { //----------------------------------------------------------------------------- // High-level access to an inline cache. Guaranteed to be MT-safe. +CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) + : _ic_call(call) +{ + address ic_call = call->instruction_address(); + + assert(ic_call != NULL, "ic_call address must be set"); + assert(nm != NULL, "must pass nmethod"); + assert(nm->contains(ic_call), "must be in nmethod"); + + // Search for the ic_call at the given address. + RelocIterator iter(nm, ic_call, ic_call+1); + bool ret = iter.next(); + assert(ret == true, "relocInfo must exist at this address"); + assert(iter.addr() == ic_call, "must find ic_call"); + if (iter.type() == relocInfo::virtual_call_type) { + virtual_call_Relocation* r = iter.virtual_call_reloc(); + _is_optimized = false; + _value = nativeMovConstReg_at(r->cached_value()); + } else { + assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call"); + _is_optimized = true; + _value = NULL; + } +} bool CompiledIC::set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS) { assert(CompiledIC_lock->is_locked() || SafepointSynchronize::is_at_safepoint(), ""); From 801975f4ca3c514d0cc03b95c020ef815bbbfa9f Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Wed, 25 Jun 2014 09:19:09 +0200 Subject: [PATCH 130/236] 8033332: missing types in TemplateInterpreterGenerator::generate_result_handler_for Add missing case statements for T_LONG and T_VOID to generate_result_handler_for(..). Reviewed-by: iveresov, anoll --- hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 265455bf285..1e49ce1c6a4 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -280,6 +280,8 @@ address TemplateInterpreterGenerator::generate_result_handler_for(BasicType type case T_BYTE : __ sign_extend_byte (rax); break; case T_SHORT : __ sign_extend_short(rax); break; case T_INT : /* nothing to do */ break; + case T_LONG : /* nothing to do */ break; + case T_VOID : /* nothing to do */ break; case T_DOUBLE : case T_FLOAT : { const Register t = InterpreterRuntime::SignatureHandlerGenerator::temp(); From 5b7c529bb2188fe4641cc9b4f8e548e6555afaa5 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Wed, 25 Jun 2014 10:55:10 +0200 Subject: [PATCH 131/236] 8047819: G1 HeapRegionDCTOC does not need to inherit ContiguousSpaceDCTOC Reviewed-by: stefank, tschatzl --- .../vm/gc_implementation/g1/heapRegion.cpp | 21 +++++++------ .../vm/gc_implementation/g1/heapRegion.hpp | 30 ++----------------- 2 files changed, 12 insertions(+), 39 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp index f81ce0d6226..037d76ca8aa 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp @@ -49,7 +49,7 @@ HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1, HeapRegion* hr, ExtendedOopClosure* cl, CardTableModRefBS::PrecisionStyle precision, FilterKind fk) : - ContiguousSpaceDCTOC(hr, cl, precision, NULL), + DirtyCardToOopClosure(hr, cl, precision, NULL), _hr(hr), _fk(fk), _g1(g1) { } FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r, @@ -78,19 +78,18 @@ HeapWord* walk_mem_region_loop(ClosureType* cl, G1CollectedHeap* g1h, return cur; } -void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr, - HeapWord* bottom, - HeapWord* top, - ExtendedOopClosure* cl) { +void HeapRegionDCTOC::walk_mem_region(MemRegion mr, + HeapWord* bottom, + HeapWord* top) { G1CollectedHeap* g1h = _g1; int oop_size; ExtendedOopClosure* cl2 = NULL; - FilterIntoCSClosure intoCSFilt(this, g1h, cl); - FilterOutOfRegionClosure outOfRegionFilt(_hr, cl); + FilterIntoCSClosure intoCSFilt(this, g1h, _cl); + FilterOutOfRegionClosure outOfRegionFilt(_hr, _cl); switch (_fk) { - case NoFilterKind: cl2 = cl; break; + case NoFilterKind: cl2 = _cl; break; case IntoCSFilterKind: cl2 = &intoCSFilt; break; case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break; default: ShouldNotReachHere(); @@ -112,17 +111,17 @@ void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr, // We replicate the loop below for several kinds of possible filters. switch (_fk) { case NoFilterKind: - bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top); + bottom = walk_mem_region_loop(_cl, g1h, _hr, bottom, top); break; case IntoCSFilterKind: { - FilterIntoCSClosure filt(this, g1h, cl); + FilterIntoCSClosure filt(this, g1h, _cl); bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); break; } case OutOfRegionFilterKind: { - FilterOutOfRegionClosure filt(_hr, cl); + FilterOutOfRegionClosure filt(_hr, _cl); bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top); break; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp index 25ffe1c8264..d6f93651117 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp @@ -71,7 +71,7 @@ class nmethod; // in the concurrent marker used by G1 to filter remembered // sets. -class HeapRegionDCTOC : public ContiguousSpaceDCTOC { +class HeapRegionDCTOC : public DirtyCardToOopClosure { public: // Specification of possible DirtyCardToOopClosure filtering. enum FilterKind { @@ -85,39 +85,13 @@ protected: FilterKind _fk; G1CollectedHeap* _g1; - void walk_mem_region_with_cl(MemRegion mr, - HeapWord* bottom, HeapWord* top, - ExtendedOopClosure* cl); - - // We don't specialize this for FilteringClosure; filtering is handled by - // the "FilterKind" mechanism. But we provide this to avoid a compiler - // warning. - void walk_mem_region_with_cl(MemRegion mr, - HeapWord* bottom, HeapWord* top, - FilteringClosure* cl) { - HeapRegionDCTOC::walk_mem_region_with_cl(mr, bottom, top, - (ExtendedOopClosure*)cl); - } - - // Get the actual top of the area on which the closure will - // operate, given where the top is assumed to be (the end of the - // memory region passed to do_MemRegion) and where the object - // at the top is assumed to start. For example, an object may - // start at the top but actually extend past the assumed top, - // in which case the top becomes the end of the object. - HeapWord* get_actual_top(HeapWord* top, HeapWord* top_obj) { - return ContiguousSpaceDCTOC::get_actual_top(top, top_obj); - } - // Walk the given memory region from bottom to (actual) top // looking for objects and applying the oop closure (_cl) to // them. The base implementation of this treats the area as // blocks, where a block may or may not be an object. Sub- // classes should override this to provide more accurate // or possibly more efficient walking. - void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top) { - Filtering_DCTOC::walk_mem_region(mr, bottom, top); - } + void walk_mem_region(MemRegion mr, HeapWord* bottom, HeapWord* top); public: HeapRegionDCTOC(G1CollectedHeap* g1, From dee1364e7ce0abd7f6aa62e522262c09cc70b86a Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 25 Jun 2014 17:08:47 +0530 Subject: [PATCH 132/236] 8048071: eval within 'with' statement does not use correct scope if with scope expression has a copy of eval Reviewed-by: hannesw, jlaskey --- .../internal/codegen/CodeGenerator.java | 23 ++++- .../jdk/nashorn/internal/ir/IdentNode.java | 11 +++ nashorn/test/script/basic/JDK-8048071.js | 85 +++++++++++++++++++ .../test/script/basic/JDK-8048071.js.EXPECTED | 11 +++ 4 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8048071.js create mode 100644 nashorn/test/script/basic/JDK-8048071.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index 110e1109d4a..de971ab0308 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -1290,13 +1290,26 @@ final class CodeGenerator extends NodeOperatorVisitor Date: Wed, 25 Jun 2014 14:36:24 +0200 Subject: [PATCH 133/236] 8048079: Persistent code store is broken after optimistic types merge Reviewed-by: sundar, jlaskey, attila --- .../internal/codegen/CompilationPhase.java | 8 +-- .../jdk/nashorn/internal/runtime/Context.java | 16 ++--- .../RecompilableScriptFunctionData.java | 70 +++---------------- nashorn/test/script/basic/JDK-8048079_1.js | 35 ++++++++++ .../script/basic/JDK-8048079_1.js.EXPECTED | 3 + nashorn/test/script/basic/JDK-8048079_2.js | 35 ++++++++++ .../script/basic/JDK-8048079_2.js.EXPECTED | 3 + .../runtime/CodeStoreAndPathTest.java | 2 +- 8 files changed, 96 insertions(+), 76 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8048079_1.js create mode 100644 nashorn/test/script/basic/JDK-8048079_1.js.EXPECTED create mode 100644 nashorn/test/script/basic/JDK-8048079_2.js create mode 100644 nashorn/test/script/basic/JDK-8048079_2.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java index 85b805060cc..8b3819266f4 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CompilationPhase.java @@ -502,7 +502,7 @@ enum CompilationPhase { Class rootClass = null; long length = 0L; - final CodeInstaller codeInstaller = compiler.getCodeInstaller(); + final CodeInstaller codeInstaller = compiler.getCodeInstaller(); final Map bytecode = compiler.getBytecode(); @@ -527,12 +527,10 @@ enum CompilationPhase { final Object[] constants = compiler.getConstantData().toArray(); codeInstaller.initialize(installedClasses.values(), compiler.getSource(), constants); - // index recompilable script function datas in the constant pool - final Map rfns = new IdentityHashMap<>(); + // initialize transient fields on recompilable script function data for (final Object constant: constants) { if (constant instanceof RecompilableScriptFunctionData) { - final RecompilableScriptFunctionData rfn = (RecompilableScriptFunctionData)constant; - rfns.put(rfn, rfn); + ((RecompilableScriptFunctionData)constant).initTransients(compiler.getSource(), codeInstaller); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index aae43b11818..a70f80d43d9 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -444,15 +444,11 @@ public final class Context { } if (env._persistent_cache) { - if (env._lazy_compilation || env._optimistic_types) { - getErr().println("Can not use persistent class caching with lazy compilation or optimistic compilation."); - } else { - try { - final String cacheDir = Options.getStringProperty("nashorn.persistent.code.cache", "nashorn_code_cache"); - codeStore = new CodeStore(cacheDir); - } catch (final IOException e) { - throw new RuntimeException("Error initializing code cache", e); - } + try { + final String cacheDir = Options.getStringProperty("nashorn.persistent.code.cache", "nashorn_code_cache"); + codeStore = new CodeStore(cacheDir); + } catch (final IOException e) { + throw new RuntimeException("Error initializing code cache", e); } } @@ -1179,7 +1175,7 @@ public final class Context { for (final Object constant : constants) { if (constant instanceof RecompilableScriptFunctionData) { - ((RecompilableScriptFunctionData) constant).setCodeAndSource(installedClasses, source); + ((RecompilableScriptFunctionData) constant).initTransients(source, installer); } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index b2c0ed6b57f..fc14707730b 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -28,7 +28,6 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.lookup.Lookup.MH; import java.io.IOException; -import java.io.Serializable; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -56,7 +55,6 @@ import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.logging.DebugLogger; import jdk.nashorn.internal.runtime.logging.Loggable; import jdk.nashorn.internal.runtime.logging.Logger; -import jdk.nashorn.internal.scripts.JS; /** * This is a subclass that represents a script function that may be regenerated, @@ -85,9 +83,6 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp /** Source from which FunctionNode was parsed. */ private transient Source source; - /** Allows us to retrieve the method handle for this function once the code is compiled */ - private MethodLocator methodLocator; - /** Token of this function within the source. */ private final long token; @@ -239,15 +234,18 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp } /** - * Setter for code and source + * Initialize transient fields on deserialized instances * - * @param code map of code, class name to class * @param source source + * @param installer code installer */ - public void setCodeAndSource(final Map> code, final Source source) { - this.source = source; - if (methodLocator != null) { - methodLocator.setClass(code.get(methodLocator.getClassName())); + public void initTransients(final Source source, final CodeInstaller installer) { + if (this.source == null && this.installer == null) { + this.source = source; + this.installer = installer; + } else if (this.source != source || this.installer != installer) { + // Existing values must be same as those passed as parameters + throw new IllegalArgumentException(); } } @@ -529,7 +527,6 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp throw new IllegalStateException(functionNode.getName() + " id=" + functionNode.getId()); } addCode(functionNode); - methodLocator = new MethodLocator(functionNode); } private CompiledFunction addCode(final MethodHandle target, final Map invalidatedProgramPoints, final int fnFlags) { @@ -592,12 +589,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp synchronized (code) { CompiledFunction existingBest = super.getBest(callSiteType, runtimeScope); if (existingBest == null) { - if(code.isEmpty() && methodLocator != null) { - // This is a deserialized object, reconnect from method handle - existingBest = addCode(methodLocator.getMethodHandle(), null, methodLocator.getFunctionFlags()); - } else { - existingBest = addCode(compileTypeSpecialization(callSiteType, runtimeScope), callSiteType); - } + existingBest = addCode(compileTypeSpecialization(callSiteType, runtimeScope), callSiteType); } assert existingBest != null; @@ -709,48 +701,6 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp return true; } - /** - * Helper class that allows us to retrieve the method handle for this function once it has been generated. - */ - private static class MethodLocator implements Serializable { - private transient Class clazz; - private final String className; - private final String methodName; - private final MethodType methodType; - private final int functionFlags; - - private static final long serialVersionUID = -5420835725902966692L; - - MethodLocator(final FunctionNode functionNode) { - this.className = functionNode.getCompileUnit().getUnitClassName(); - this.methodName = functionNode.getName(); - this.methodType = new FunctionSignature(functionNode).getMethodType(); - this.functionFlags = functionNode.getFlags(); - - assert className != null; - assert methodName != null; - } - - void setClass(final Class clazz) { - if (!JS.class.isAssignableFrom(clazz)) { - throw new IllegalArgumentException(); - } - this.clazz = clazz; - } - - String getClassName() { - return className; - } - - MethodHandle getMethodHandle() { - return MH.findStatic(LOOKUP, clazz, methodName, methodType); - } - - int getFunctionFlags() { - return functionFlags; - } - } - private void readObject(final java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); createLogger(); diff --git a/nashorn/test/script/basic/JDK-8048079_1.js b/nashorn/test/script/basic/JDK-8048079_1.js new file mode 100644 index 00000000000..fcd21219e02 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048079_1.js @@ -0,0 +1,35 @@ +/* + * 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 + * 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. + */ + +/** + * JDK-8048079: Persistent code store is broken after optimistic types merge + * + * @test + * @run + * @option -pcc + * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache + * @fork + */ + +load(__DIR__ + 'prototype.js'); +load(__DIR__ + 'yui.js'); diff --git a/nashorn/test/script/basic/JDK-8048079_1.js.EXPECTED b/nashorn/test/script/basic/JDK-8048079_1.js.EXPECTED new file mode 100644 index 00000000000..371f63a54d5 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048079_1.js.EXPECTED @@ -0,0 +1,3 @@ +parsed and compiled ok prototype.js +parsed and compiled ok yui-min.js +parsed and compiled ok yui.js diff --git a/nashorn/test/script/basic/JDK-8048079_2.js b/nashorn/test/script/basic/JDK-8048079_2.js new file mode 100644 index 00000000000..fcd21219e02 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048079_2.js @@ -0,0 +1,35 @@ +/* + * 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 + * 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. + */ + +/** + * JDK-8048079: Persistent code store is broken after optimistic types merge + * + * @test + * @run + * @option -pcc + * @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache + * @fork + */ + +load(__DIR__ + 'prototype.js'); +load(__DIR__ + 'yui.js'); diff --git a/nashorn/test/script/basic/JDK-8048079_2.js.EXPECTED b/nashorn/test/script/basic/JDK-8048079_2.js.EXPECTED new file mode 100644 index 00000000000..371f63a54d5 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048079_2.js.EXPECTED @@ -0,0 +1,3 @@ +parsed and compiled ok prototype.js +parsed and compiled ok yui-min.js +parsed and compiled ok yui.js diff --git a/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java b/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java index f6b72d3cd15..b7999dfc4de 100644 --- a/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java +++ b/nashorn/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java @@ -96,7 +96,7 @@ public class CodeStoreAndPathTest { final String codeCache = "build/nashorn_code_cache"; final String oldUserDir = System.getProperty("user.dir"); - private static final String[] ENGINE_OPTIONS = new String[]{"--persistent-code-cache", "--optimistic-types=false", "--lazy-compilation=false"}; + private static final String[] ENGINE_OPTIONS = new String[]{"--persistent-code-cache"}; public void checkCompiledScripts(final DirectoryStream stream, int numberOfScripts) throws IOException { for (final Path file : stream) { From cfa1c5e67c3348c579126a2923976b475d10d93a Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Wed, 25 Jun 2014 16:53:13 +0200 Subject: [PATCH 134/236] 8047820: G1 Block offset table does not need to support generic Space classes Reviewed-by: tschatzl, stefank --- .../g1/g1BlockOffsetTable.cpp | 60 +++++++++---------- .../g1/g1BlockOffsetTable.hpp | 31 +++------- .../g1/g1BlockOffsetTable.inline.hpp | 31 +++++----- .../vm/gc_implementation/g1/heapRegion.hpp | 2 +- .../g1/heapRegion.inline.hpp | 2 + 5 files changed, 55 insertions(+), 71 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp index 14d0126e224..c07fa50f04d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" +#include "gc_implementation/g1/heapRegion.hpp" #include "memory/space.hpp" #include "oops/oop.inline.hpp" #include "runtime/java.hpp" @@ -98,6 +99,20 @@ bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const { return (delta & right_n_bits(LogN_words)) == (size_t)NoBits; } +void G1BlockOffsetSharedArray::set_offset_array(HeapWord* left, HeapWord* right, u_char offset) { + check_index(index_for(right - 1), "right address out of range"); + assert(left < right, "Heap addresses out of order"); + size_t num_cards = pointer_delta(right, left) >> LogN_words; + if (UseMemSetInBOT) { + memset(&_offset_array[index_for(left)], offset, num_cards); + } else { + size_t i = index_for(left); + const size_t end = i + num_cards; + for (; i < end; i++) { + _offset_array[i] = offset; + } + } +} ////////////////////////////////////////////////////////////////////// // G1BlockOffsetArray @@ -107,7 +122,7 @@ G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr, bool init_to_zero) : G1BlockOffsetTable(mr.start(), mr.end()), _unallocated_block(_bottom), - _array(array), _csp(NULL), + _array(array), _gsp(NULL), _init_to_zero(init_to_zero) { assert(_bottom <= _end, "arguments out of order"); if (!_init_to_zero) { @@ -117,9 +132,8 @@ G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array, } } -void G1BlockOffsetArray::set_space(Space* sp) { - _sp = sp; - _csp = sp->toContiguousSpace(); +void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) { + _gsp = sp; } // The arguments follow the normal convention of denoting @@ -378,7 +392,7 @@ G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const { } // Otherwise, find the block start using the table. HeapWord* q = block_at_or_preceding(addr, false, 0); - HeapWord* n = q + _sp->block_size(q); + HeapWord* n = q + block_size(q); return forward_to_block_containing_addr_const(q, n, addr); } @@ -406,31 +420,17 @@ G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q, err_msg("next_boundary is beyond the end of the covered region " " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT, next_boundary, _array->_end)); - if (csp() != NULL) { - if (addr >= csp()->top()) return csp()->top(); - while (next_boundary < addr) { - while (n <= next_boundary) { - q = n; - oop obj = oop(q); - if (obj->klass_or_null() == NULL) return q; - n += obj->size(); - } - assert(q <= next_boundary && n > next_boundary, "Consequence of loop"); - // [q, n) is the block that crosses the boundary. - alloc_block_work2(&next_boundary, &next_index, q, n); - } - } else { - while (next_boundary < addr) { - while (n <= next_boundary) { - q = n; - oop obj = oop(q); - if (obj->klass_or_null() == NULL) return q; - n += _sp->block_size(q); - } - assert(q <= next_boundary && n > next_boundary, "Consequence of loop"); - // [q, n) is the block that crosses the boundary. - alloc_block_work2(&next_boundary, &next_index, q, n); + if (addr >= gsp()->top()) return gsp()->top(); + while (next_boundary < addr) { + while (n <= next_boundary) { + q = n; + oop obj = oop(q); + if (obj->klass_or_null() == NULL) return q; + n += obj->size(); } + assert(q <= next_boundary && n > next_boundary, "Consequence of loop"); + // [q, n) is the block that crosses the boundary. + alloc_block_work2(&next_boundary, &next_index, q, n); } return forward_to_block_containing_addr_const(q, n, addr); } @@ -637,7 +637,7 @@ block_start_unsafe_const(const void* addr) const { assert(_bottom <= addr && addr < _end, "addr must be covered by this Array"); HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); - HeapWord* n = q + _sp->block_size(q); + HeapWord* n = q + block_size(q); return forward_to_block_containing_addr_const(q, n, addr); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp index 56dca4d26f8..5395899f143 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp @@ -52,8 +52,8 @@ // consolidation. // Forward declarations -class ContiguousSpace; class G1BlockOffsetSharedArray; +class G1OffsetTableContigSpace; class G1BlockOffsetTable VALUE_OBJ_CLASS_SPEC { friend class VMStructs; @@ -157,6 +157,8 @@ private: return _offset_array[index]; } + void set_offset_array(HeapWord* left, HeapWord* right, u_char offset); + void set_offset_array(size_t index, u_char offset) { check_index(index, "index out of range"); check_offset(offset, "offset too large"); @@ -170,21 +172,6 @@ private: _offset_array[index] = (u_char) pointer_delta(high, low); } - void set_offset_array(HeapWord* left, HeapWord* right, u_char offset) { - check_index(index_for(right - 1), "right address out of range"); - assert(left < right, "Heap addresses out of order"); - size_t num_cards = pointer_delta(right, left) >> LogN_words; - if (UseMemSetInBOT) { - memset(&_offset_array[index_for(left)], offset, num_cards); - } else { - size_t i = index_for(left); - const size_t end = i + num_cards; - for (; i < end; i++) { - _offset_array[i] = offset; - } - } - } - void set_offset_array(size_t left, size_t right, u_char offset) { check_index(right, "right index out of range"); assert(left <= right, "indexes out of order"); @@ -281,11 +268,7 @@ private: G1BlockOffsetSharedArray* _array; // The space that owns this subregion. - Space* _sp; - - // If "_sp" is a contiguous space, the field below is the view of "_sp" - // as a contiguous space, else NULL. - ContiguousSpace* _csp; + G1OffsetTableContigSpace* _gsp; // If true, array entries are initialized to 0; otherwise, they are // initialized to point backwards to the beginning of the covered region. @@ -310,7 +293,9 @@ private: protected: - ContiguousSpace* csp() const { return _csp; } + G1OffsetTableContigSpace* gsp() const { return _gsp; } + + inline size_t block_size(const HeapWord* p) const; // Returns the address of a block whose start is at most "addr". // If "has_max_index" is true, "assumes "max_index" is the last valid one @@ -363,7 +348,7 @@ public: // "this" to be passed as a parameter to a member constructor for // the containing concrete subtype of Space. // This would be legal C++, but MS VC++ doesn't allow it. - void set_space(Space* sp); + void set_space(G1OffsetTableContigSpace* sp); // Resets the covered region to the given "mr". void set_region(MemRegion mr); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp index 5ae3bc1cdeb..24f97f35dcb 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.inline.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_INLINE_HPP #include "gc_implementation/g1/g1BlockOffsetTable.hpp" +#include "gc_implementation/g1/heapRegion.hpp" #include "memory/space.hpp" inline HeapWord* G1BlockOffsetTable::block_start(const void* addr) { @@ -69,6 +70,11 @@ G1BlockOffsetSharedArray::address_for_index(size_t index) const { return result; } +inline size_t +G1BlockOffsetArray::block_size(const HeapWord* p) const { + return gsp()->block_size(p); +} + inline HeapWord* G1BlockOffsetArray::block_at_or_preceding(const void* addr, bool has_max_index, @@ -88,7 +94,7 @@ G1BlockOffsetArray::block_at_or_preceding(const void* addr, // to go back by. size_t n_cards_back = BlockOffsetArray::entry_to_cards_back(offset); q -= (N_words * n_cards_back); - assert(q >= _sp->bottom(), "Went below bottom!"); + assert(q >= gsp()->bottom(), "Went below bottom!"); index -= n_cards_back; offset = _array->offset_array(index); } @@ -101,21 +107,12 @@ inline HeapWord* G1BlockOffsetArray:: forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n, const void* addr) const { - if (csp() != NULL) { - if (addr >= csp()->top()) return csp()->top(); - while (n <= addr) { - q = n; - oop obj = oop(q); - if (obj->klass_or_null() == NULL) return q; - n += obj->size(); - } - } else { - while (n <= addr) { - q = n; - oop obj = oop(q); - if (obj->klass_or_null() == NULL) return q; - n += _sp->block_size(q); - } + if (addr >= gsp()->top()) return gsp()->top(); + while (n <= addr) { + q = n; + oop obj = oop(q); + if (obj->klass_or_null() == NULL) return q; + n += obj->size(); } assert(q <= n, "wrong order for q and addr"); assert(addr < n, "wrong order for addr and n"); @@ -126,7 +123,7 @@ inline HeapWord* G1BlockOffsetArray::forward_to_block_containing_addr(HeapWord* q, const void* addr) { if (oop(q)->klass_or_null() == NULL) return q; - HeapWord* n = q + _sp->block_size(q); + HeapWord* n = q + block_size(q); // In the normal case, where the query "addr" is a card boundary, and the // offset table chunks are the same size as cards, the block starting at // "q" will contain addr, so the test below will fail, and we'll fall diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp index d6f93651117..0b9fce740fb 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp @@ -25,7 +25,7 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_HPP -#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" +#include "gc_implementation/g1/g1BlockOffsetTable.hpp" #include "gc_implementation/g1/g1_specialized_oop_closures.hpp" #include "gc_implementation/g1/survRateGroup.hpp" #include "gc_implementation/shared/ageTable.hpp" diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp index d88bc07ad07..b85c448d161 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp @@ -25,6 +25,8 @@ #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_INLINE_HPP #define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_INLINE_HPP +#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" + inline HeapWord* G1OffsetTableContigSpace::allocate(size_t size) { HeapWord* res = ContiguousSpace::allocate(size); if (res != NULL) { From 4d4642117ef0fa1c2fdf3b951f1c119af2bd37f5 Mon Sep 17 00:00:00 2001 From: Andrey Zakharov Date: Wed, 25 Jun 2014 17:22:58 +0200 Subject: [PATCH 135/236] 8026847: [TESTBUG] gc/g1/TestSummarizeRSetStats* tests launch 32bit jvm with UseCompressedOops The test launched a 32 bit VM with UseCompressedOops enabled. This is not supported on 32 bit VMs, causing a test failure. Investigation showed that the use of this flag is not required at all, so simply remove it. Reviewed-by: tschatzl, jwilhelm --- hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java b/hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java index 096a7c675b5..1ab8322291b 100644 --- a/hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java +++ b/hotspot/test/gc/g1/TestSummarizeRSetStatsTools.java @@ -88,7 +88,6 @@ public class TestSummarizeRSetStatsTools { ArrayList finalargs = new ArrayList(); String[] defaultArgs = new String[] { "-XX:+UseG1GC", - "-XX:+UseCompressedOops", "-Xmn4m", "-Xmx20m", "-XX:InitiatingHeapOccupancyPercent=100", // we don't want the additional GCs due to initial marking From 9fddfef33f5a296a6559de14332225785260dd51 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Wed, 25 Jun 2014 21:36:48 +0200 Subject: [PATCH 136/236] 8046783: Add hidden field to methods for event based tracing Reviewed-by: sla, mgronlun --- hotspot/src/share/vm/trace/tracetypes.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/trace/tracetypes.xml b/hotspot/src/share/vm/trace/tracetypes.xml index eb1c708eadb..f41dfc03f3e 100644 --- a/hotspot/src/share/vm/trace/tracetypes.xml +++ b/hotspot/src/share/vm/trace/tracetypes.xml @@ -98,6 +98,7 @@ Now we can use the content + data type in declaring event fields. + Date: Wed, 25 Jun 2014 13:03:29 -0700 Subject: [PATCH 137/236] 8048076: [TESTBUG] runtime/Unsafe/RangeCheck.java fails with -Xcomp Compiler intrinsics doesn't have this assert, disabled the intrinsics to make sure we go through the VM Reviewed-by: lfoltan, coleenp --- hotspot/test/runtime/Unsafe/RangeCheck.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java index 9ded944cb25..4d4ea2e048a 100644 --- a/hotspot/test/runtime/Unsafe/RangeCheck.java +++ b/hotspot/test/runtime/Unsafe/RangeCheck.java @@ -43,6 +43,7 @@ public class RangeCheck { true, "-Xmx32m", "-XX:-TransmitErrorReport", + "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert DummyClassWithMainRangeCheck.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); From ddccb627525fad9a412b61208a464a7312b5c243 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Thu, 26 Jun 2014 03:26:20 -0700 Subject: [PATCH 138/236] 8048185: [TESTBUG] need a JTREG test for the fix of JDK-8042796 (OLD and/or OBSOLETE method(s) found) Need to integrate the jtreg unit test for the fixed bug JDK-8042796 Reviewed-by: dcubed, coleenp --- .../instrument/RedefineMethodDelInvoke.sh | 98 +++++++++++++++++++ .../RedefineMethodDelInvokeAgent.java | 43 ++++++++ .../RedefineMethodDelInvokeApp.java | 75 ++++++++++++++ .../RedefineMethodDelInvokeTarget.java | 42 ++++++++ .../RedefineMethodDelInvokeTarget_1.java | 37 +++++++ .../RedefineMethodDelInvokeTarget_2.java | 32 ++++++ 6 files changed, 327 insertions(+) create mode 100644 jdk/test/java/lang/instrument/RedefineMethodDelInvoke.sh create mode 100644 jdk/test/java/lang/instrument/RedefineMethodDelInvokeAgent.java create mode 100644 jdk/test/java/lang/instrument/RedefineMethodDelInvokeApp.java create mode 100644 jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget.java create mode 100644 jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_1.java create mode 100644 jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_2.java diff --git a/jdk/test/java/lang/instrument/RedefineMethodDelInvoke.sh b/jdk/test/java/lang/instrument/RedefineMethodDelInvoke.sh new file mode 100644 index 00000000000..f1f9ac6db7e --- /dev/null +++ b/jdk/test/java/lang/instrument/RedefineMethodDelInvoke.sh @@ -0,0 +1,98 @@ +# +# 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 8042796 +# @summary jvmtiRedefineClasses.cpp: guarantee(false) failed: OLD and/or OBSOLETE method(s) found +# @author Daniel D. Daugherty +# @author Serguei Spitsyn +# +# @run shell MakeJAR3.sh RedefineMethodDelInvokeAgent 'Can-Redefine-Classes: true' +# @run build RedefineMethodDelInvokeApp +# @run shell RedefineMethodDelInvoke.sh +# + +if [ "${TESTJAVA}" = "" ] +then + echo "TESTJAVA not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${COMPILEJAVA}" = "" ] +then + COMPILEJAVA="${TESTJAVA}" +fi +echo "COMPILEJAVA=${COMPILEJAVA}" + +if [ "${TESTSRC}" = "" ] +then + echo "TESTSRC not set. Test cannot execute. Failed." + exit 1 +fi + +if [ "${TESTCLASSES}" = "" ] +then + echo "TESTCLASSES not set. Test cannot execute. Failed." + exit 1 +fi + +JAVAC="${COMPILEJAVA}"/bin/javac +JAVA="${TESTJAVA}"/bin/java + +cp "${TESTSRC}"/RedefineMethodDelInvokeTarget_1.java \ + RedefineMethodDelInvokeTarget.java +"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . RedefineMethodDelInvokeTarget.java +mv RedefineMethodDelInvokeTarget.java RedefineMethodDelInvokeTarget_1.java +mv RedefineMethodDelInvokeTarget.class RedefineMethodDelInvokeTarget_1.class + +cp "${TESTSRC}"/RedefineMethodDelInvokeTarget_2.java \ + RedefineMethodDelInvokeTarget.java +"${JAVAC}" ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . RedefineMethodDelInvokeTarget.java +mv RedefineMethodDelInvokeTarget.java RedefineMethodDelInvokeTarget_2.java +mv RedefineMethodDelInvokeTarget.class RedefineMethodDelInvokeTarget_2.class + +"${JAVA}" ${TESTVMOPTS} -javaagent:RedefineMethodDelInvokeAgent.jar \ + -classpath "${TESTCLASSES}" RedefineMethodDelInvokeApp > output.log 2>&1 + +result=$? +if [ "$result" = 0 ]; then + echo "The test returned expected exit code: $result" +else + echo "FAIL: the test returned unexpected exit code: $result" + exit $result +fi + +cat output.log + +MESG="Exception" +grep "$MESG" output.log +result=$? +if [ "$result" = 0 ]; then + echo "FAIL: found '$MESG' in the test output" + result=1 +else + echo "PASS: did NOT find '$MESG' in the test output" + result=0 +fi + +exit $result diff --git a/jdk/test/java/lang/instrument/RedefineMethodDelInvokeAgent.java b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeAgent.java new file mode 100644 index 00000000000..2a3532f794e --- /dev/null +++ b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeAgent.java @@ -0,0 +1,43 @@ +/* + * 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. + */ + +import java.lang.instrument.Instrumentation; + +public class RedefineMethodDelInvokeAgent { + private static Instrumentation instrumentation; + + private RedefineMethodDelInvokeAgent() { + } + + public static void premain(String agentArgs, Instrumentation inst) { + System.out.println("Hello from RedefineMethodDelInvokeAgent!"); + System.out.println("isRedefineClassesSupported()=" + + inst.isRedefineClassesSupported()); + + instrumentation = inst; + } + + public static Instrumentation getInstrumentation() { + return instrumentation; + } +} diff --git a/jdk/test/java/lang/instrument/RedefineMethodDelInvokeApp.java b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeApp.java new file mode 100644 index 00000000000..1cd354e85e5 --- /dev/null +++ b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeApp.java @@ -0,0 +1,75 @@ +/* + * 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. + */ + +import java.io.*; +import java.lang.instrument.*; + +public class RedefineMethodDelInvokeApp { + public static void main(String args[]) { + System.out.println("Hello from RedefineMethodDelInvokeApp!"); + + try { + new RedefineMethodDelInvokeApp().doTest(); + } catch (Exception ex) { + System.out.println("Exception has been caught"); + ex.printStackTrace(); + System.exit(1); + } + System.exit(0); + } + + private void doTest() throws Exception { + RedefineMethodDelInvokeTarget target = + new RedefineMethodDelInvokeTarget(); + + System.out.println("RedefineMethodDelInvokeApp: invoking myMethod0(), myMethod1(), myMethod2()"); + target.test(); + + // delete myMethod2() + do_redefine(1); + + System.out.println("RedefineMethodDelInvokeApp: invoking myMethod0(), myMethod1()"); + target.test(); + + // delete myMethod1() + do_redefine(2); + + System.out.println("RedefineMethodDelInvokeApp: invoking myMethod0()"); + target.test(); + } + + private static void do_redefine(int counter) throws Exception { + File f = new File("RedefineMethodDelInvokeTarget_" + counter + + ".class"); + System.out.println("Reading test class from " + f); + InputStream redefineStream = new FileInputStream(f); + + byte[] redefineBuffer = NamedBuffer.loadBufferFromStream(redefineStream); + + ClassDefinition redefineParamBlock = new ClassDefinition( + RedefineMethodDelInvokeTarget.class, redefineBuffer); + + RedefineMethodDelInvokeAgent.getInstrumentation().redefineClasses( + new ClassDefinition[] {redefineParamBlock}); + } +} diff --git a/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget.java b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget.java new file mode 100644 index 00000000000..5bfcae45552 --- /dev/null +++ b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget.java @@ -0,0 +1,42 @@ +/* + * 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. + */ + +public class RedefineMethodDelInvokeTarget { + public void test() { + myMethod0(); + } + + public static void myMethod0() { + System.out.println("Target 0: myMethod0: Calling myMethod1()"); + myMethod1(); + } + + private static void myMethod1() { + System.out.println("Target 0: myMethod1: Calling myMethod2()"); + myMethod2(); + } + + private static void myMethod2() { + System.out.println("Target 0: myMethod2"); + } +} diff --git a/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_1.java b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_1.java new file mode 100644 index 00000000000..170e41eba5a --- /dev/null +++ b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_1.java @@ -0,0 +1,37 @@ +/* + * 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. + */ + +public class RedefineMethodDelInvokeTarget { + public void test() { + myMethod0(); + } + + public static void myMethod0() { + System.out.println("Target 1: myMethod0: Calling myMethod1()"); + myMethod1(); + } + + private static void myMethod1() { + System.out.println("Target 1: myMethod1"); + } +} diff --git a/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_2.java b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_2.java new file mode 100644 index 00000000000..2513c52f528 --- /dev/null +++ b/jdk/test/java/lang/instrument/RedefineMethodDelInvokeTarget_2.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +public class RedefineMethodDelInvokeTarget { + public void test() { + myMethod0(); + } + + public static void myMethod0() { + System.out.println("Target 2: myMethod0"); + } +} From 9dde0bfa35258bbc04ad2a3f81d4a6259fb41582 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 26 Jun 2014 13:12:32 +0200 Subject: [PATCH 139/236] 8047357: More precise synthetic return + unreachable throw Reviewed-by: lagergren, sundar --- .../internal/codegen/AssignSymbols.java | 8 ++-- .../internal/codegen/CodeGenerator.java | 2 +- .../codegen/LocalVariableTypesCalculator.java | 46 ++++++++++++++++++- .../jdk/nashorn/internal/codegen/Lower.java | 25 ---------- .../src/jdk/nashorn/internal/ir/Block.java | 7 ++- .../src/jdk/nashorn/internal/ir/CaseNode.java | 7 ++- .../internal/ir/ExpressionStatement.java | 5 -- .../jdk/nashorn/internal/ir/IdentNode.java | 4 +- nashorn/src/jdk/nashorn/internal/ir/Node.java | 28 ----------- .../jdk/nashorn/internal/ir/Statement.java | 30 +++++++++++- .../src/jdk/nashorn/internal/ir/Terminal.java | 37 +++++++++++++++ .../nashorn/internal/ir/debug/ASTWriter.java | 6 ++- .../internal/ir/debug/PrintVisitor.java | 10 ++-- nashorn/test/script/basic/JDK-8047057.js | 4 +- nashorn/test/script/basic/JDK-8047357.js | 32 +++++++++++++ .../test/script/basic/JDK-8047357.js.EXPECTED | 2 + 16 files changed, 173 insertions(+), 80 deletions(-) create mode 100644 nashorn/src/jdk/nashorn/internal/ir/Terminal.java create mode 100644 nashorn/test/script/basic/JDK-8047357.js create mode 100644 nashorn/test/script/basic/JDK-8047357.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java b/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java index 65e65c785a1..0659e3f5c3e 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/AssignSymbols.java @@ -209,7 +209,7 @@ final class AssignSymbols extends NodeOperatorVisitor implements if (varNode.isFunctionDeclaration()) { symbol.setIsFunctionDeclaration(); } - return varNode.setName((IdentNode)ident.setSymbol(symbol)); + return varNode.setName(ident.setSymbol(symbol)); } return varNode; } @@ -217,7 +217,7 @@ final class AssignSymbols extends NodeOperatorVisitor implements } private IdentNode compilerConstantIdentifier(final CompilerConstants cc) { - return (IdentNode)createImplicitIdentifier(cc.symbolName()).setSymbol(lc.getCurrentFunction().compilerConstant(cc)); + return createImplicitIdentifier(cc.symbolName()).setSymbol(lc.getCurrentFunction().compilerConstant(cc)); } /** @@ -263,7 +263,7 @@ final class AssignSymbols extends NodeOperatorVisitor implements final Symbol nameSymbol = fn.getBody().getExistingSymbol(name.getName()); assert nameSymbol != null; - return (VarNode)synthVar.setName((IdentNode)name.setSymbol(nameSymbol)).accept(this); + return (VarNode)synthVar.setName(name.setSymbol(nameSymbol)).accept(this); } private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { @@ -522,7 +522,7 @@ final class AssignSymbols extends NodeOperatorVisitor implements final Symbol paramSymbol = body.getExistingSymbol(param.getName()); assert paramSymbol != null; assert paramSymbol.isParam() : paramSymbol + " " + paramSymbol.getFlags(); - newParams.add((IdentNode)param.setSymbol(paramSymbol)); + newParams.add(param.setSymbol(paramSymbol)); // parameters should not be slots for a function that uses variable arity signature if (isVarArg) { diff --git a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java index de971ab0308..bfb9851c0f3 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -1097,7 +1097,7 @@ final class CodeGenerator extends NodeOperatorVisitor{ private boolean reachable = true; // Return type of the function private Type returnType = Type.UNKNOWN; + // Synthetic return node that we must insert at the end of the function if it's end is reachable. + private ReturnNode syntheticReturn; // Topmost current split node (if any) private SplitNode topSplit; @@ -845,6 +849,10 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ @Override public boolean enterThrowNode(final ThrowNode throwNode) { + if(!reachable) { + return false; + } + throwNode.getExpression().accept(this); jumpToCatchBlock(throwNode); doesNotContinueSequentially(); @@ -1031,6 +1039,15 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ @Override public Node leaveBlock(final Block block) { if(lc.isFunctionBody()) { + if(reachable) { + // reachable==true means we can reach the end of the function without an explicit return statement. We + // need to insert a synthetic one then. This logic used to be in Lower.leaveBlock(), but Lower's + // reachability analysis (through Terminal.isTerminal() flags) is not precise enough so + // Lower$BlockLexicalContext.afterSetStatements will sometimes think the control flow terminates even + // when it didn't. Example: function() { switch((z)) { default: {break; } throw x; } }. + createSyntheticReturn(block); + assert !reachable; + } // We must calculate the return type here (and not in leaveFunctionNode) as it can affect the liveness of // the :return symbol and thus affect conversion type liveness calculations for it. calculateReturnType(); @@ -1089,6 +1106,23 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ retSymbol.setNeedsSlot(true); } } + + private void createSyntheticReturn(final Block body) { + final FunctionNode functionNode = lc.getCurrentFunction(); + final long token = functionNode.getToken(); + final int finish = functionNode.getFinish(); + final List statements = body.getStatements(); + final int lineNumber = statements.isEmpty() ? functionNode.getLineNumber() : statements.get(statements.size() - 1).getLineNumber(); + final IdentNode returnExpr; + if(functionNode.isProgram()) { + returnExpr = new IdentNode(token, finish, RETURN.symbolName()).setSymbol(getCompilerConstantSymbol(functionNode, RETURN)); + } else { + returnExpr = null; + } + syntheticReturn = new ReturnNode(lineNumber, token, finish, returnExpr); + syntheticReturn.accept(this); + } + /** * Leave a breakable node. If there's a join point associated with its break label (meaning there was at least one * break statement to the end of the node), insert the join point into the flow. @@ -1177,6 +1211,16 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ return node; } + @Override + public Node leaveBlock(final Block block) { + if(inOuterFunction && syntheticReturn != null && lc.isFunctionBody()) { + final ArrayList stmts = new ArrayList<>(block.getStatements()); + stmts.add((ReturnNode)syntheticReturn.accept(this)); + return block.setStatements(lc, stmts); + } + return super.leaveBlock(block); + } + @Override public Node leaveFunctionNode(final FunctionNode nestedFunctionNode) { inOuterFunction = true; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java index 3da0f778712..352270d05dd 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Lower.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Lower.java @@ -75,7 +75,6 @@ import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.CodeInstaller; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.JSType; -import jdk.nashorn.internal.runtime.ScriptRuntime; import jdk.nashorn.internal.runtime.Source; import jdk.nashorn.internal.runtime.logging.DebugLogger; import jdk.nashorn.internal.runtime.logging.Loggable; @@ -159,30 +158,6 @@ final class Lower extends NodeOperatorVisitor implements Lo return context.getLogger(this.getClass()); } - @Override - public Node leaveBlock(final Block block) { - //now we have committed the entire statement list to the block, but we need to truncate - //whatever is after the last terminal. block append won't append past it - - - if (lc.isFunctionBody()) { - final FunctionNode currentFunction = lc.getCurrentFunction(); - final boolean isProgram = currentFunction.isProgram(); - final Statement last = lc.getLastStatement(); - final ReturnNode returnNode = new ReturnNode( - last == null ? currentFunction.getLineNumber() : last.getLineNumber(), //TODO? - currentFunction.getToken(), - currentFunction.getFinish(), - isProgram ? - compilerConstant(RETURN) : - LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)); - - returnNode.accept(this); - } - - return block; - } - @Override public boolean enterBreakNode(final BreakNode breakNode) { addStatement(breakNode); diff --git a/nashorn/src/jdk/nashorn/internal/ir/Block.java b/nashorn/src/jdk/nashorn/internal/ir/Block.java index d8a84b6ef47..9d4356db6e7 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Block.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Block.java @@ -41,7 +41,7 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor; * IR representation for a list of statements. */ @Immutable -public class Block extends Node implements BreakableNode, Flags { +public class Block extends Node implements BreakableNode, Terminal, Flags { /** List of statements */ protected final List statements; @@ -231,6 +231,11 @@ public class Block extends Node implements BreakableNode, Flags { return flags; } + /** + * Is this a terminal block, i.e. does it end control flow like ending with a throw or return? + * + * @return true if this node statement is terminal + */ @Override public boolean isTerminal() { return getFlag(IS_TERMINAL); diff --git a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java index 1c4cf3279c1..aae6d71f03d 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/CaseNode.java @@ -36,7 +36,7 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor; * Case nodes are not BreakableNodes, but the SwitchNode is */ @Immutable -public final class CaseNode extends Node implements JoinPredecessor, Labels { +public final class CaseNode extends Node implements JoinPredecessor, Labels, Terminal { /** Test expression. */ private final Expression test; @@ -77,6 +77,11 @@ public final class CaseNode extends Node implements JoinPredecessor, Labels { this.conversion = conversion; } + /** + * Is this a terminal case node, i.e. does it end control flow like having a throw or return? + * + * @return true if this node statement is terminal + */ @Override public boolean isTerminal() { return body.isTerminal(); diff --git a/nashorn/src/jdk/nashorn/internal/ir/ExpressionStatement.java b/nashorn/src/jdk/nashorn/internal/ir/ExpressionStatement.java index e4e15788f7c..45870ff0920 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/ExpressionStatement.java +++ b/nashorn/src/jdk/nashorn/internal/ir/ExpressionStatement.java @@ -56,11 +56,6 @@ public final class ExpressionStatement extends Statement { this.expression = expression; } - @Override - public boolean isTerminal() { - return expression.isTerminal(); - } - @Override public Node accept(final NodeVisitor visitor) { if (visitor.enterExpressionStatement(this)) { diff --git a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java index 652c5860f72..3d4d7348979 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/IdentNode.java @@ -110,7 +110,7 @@ public final class IdentNode extends Expression implements PropertyKey, Function * @return a temporary identifier for the symbol. */ public static IdentNode createInternalIdentifier(final Symbol symbol) { - return (IdentNode)new IdentNode(Token.toDesc(TokenType.IDENT, 0, 0), 0, symbol.getName()).setSymbol(symbol); + return new IdentNode(Token.toDesc(TokenType.IDENT, 0, 0), 0, symbol.getName()).setSymbol(symbol); } @Override @@ -180,7 +180,7 @@ public final class IdentNode extends Expression implements PropertyKey, Function * @param symbol the symbol * @return new node */ - public Expression setSymbol(final Symbol symbol) { + public IdentNode setSymbol(final Symbol symbol) { if (this.symbol == symbol) { return this; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/Node.java b/nashorn/src/jdk/nashorn/internal/ir/Node.java index 4b290c3c2dd..191d702ab64 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Node.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Node.java @@ -143,15 +143,6 @@ public abstract class Node implements Cloneable { */ public abstract void toString(final StringBuilder sb, final boolean printType); - /** - * Check if this node has terminal flags, i.e. ends or breaks control flow - * - * @return true if terminal - */ - public boolean hasTerminalFlags() { - return isTerminal() || hasGoto(); - } - /** * Get the finish position for this node in the source string * @return finish @@ -168,15 +159,6 @@ public abstract class Node implements Cloneable { this.finish = finish; } - /** - * Check if this function repositions control flow with goto like - * semantics, for example {@link BreakNode} or a {@link ForNode} with no test - * @return true if node has goto semantics - */ - public boolean hasGoto() { - return false; - } - /** * Get start position for node * @return start position @@ -249,16 +231,6 @@ public abstract class Node implements Cloneable { return token; } - /** - * Is this a terminal Node, i.e. does it end control flow like a throw or return - * expression does? - * - * @return true if this node is terminal - */ - public boolean isTerminal() { - return false; - } - //on change, we have to replace the entire list, that's we can't simple do ListIterator.set static List accept(final NodeVisitor visitor, final Class clazz, final List list) { boolean changed = false; diff --git a/nashorn/src/jdk/nashorn/internal/ir/Statement.java b/nashorn/src/jdk/nashorn/internal/ir/Statement.java index 6b171cb9597..b436f71fb0a 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/Statement.java +++ b/nashorn/src/jdk/nashorn/internal/ir/Statement.java @@ -30,7 +30,7 @@ package jdk.nashorn.internal.ir; * made up of statements. The only node subclass that needs to keep token and * location information is the Statement */ -public abstract class Statement extends Node { +public abstract class Statement extends Node implements Terminal { private final int lineNumber; @@ -77,4 +77,32 @@ public abstract class Statement extends Node { return lineNumber; } + /** + * Is this a terminal statement, i.e. does it end control flow like a throw or return? + * + * @return true if this node statement is terminal + */ + @Override + public boolean isTerminal() { + return false; + } + + /** + * Check if this statement repositions control flow with goto like + * semantics, for example {@link BreakNode} or a {@link ForNode} with no test + * @return true if statement has goto semantics + */ + public boolean hasGoto() { + return false; + } + + /** + * Check if this statement has terminal flags, i.e. ends or breaks control flow + * + * @return true if has terminal flags + */ + public final boolean hasTerminalFlags() { + return isTerminal() || hasGoto(); + } } + diff --git a/nashorn/src/jdk/nashorn/internal/ir/Terminal.java b/nashorn/src/jdk/nashorn/internal/ir/Terminal.java new file mode 100644 index 00000000000..3f5c25bc0f6 --- /dev/null +++ b/nashorn/src/jdk/nashorn/internal/ir/Terminal.java @@ -0,0 +1,37 @@ +/* + * 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.internal.ir; + +/** + * Interface for AST nodes that can have a flag determining if they can terminate function control flow. + */ +public interface Terminal { + /** + * Returns true if this AST node is (or contains) a statement that terminates function control flow. + * @return true if this AST node is (or contains) a statement that terminates function control flow. + */ + public boolean isTerminal(); +} diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java b/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java index 87f3c6c50dd..52e3c0e025f 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java @@ -38,7 +38,9 @@ import jdk.nashorn.internal.ir.Block; import jdk.nashorn.internal.ir.Expression; import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.Node; +import jdk.nashorn.internal.ir.Statement; import jdk.nashorn.internal.ir.Symbol; +import jdk.nashorn.internal.ir.Terminal; import jdk.nashorn.internal.ir.TernaryNode; import jdk.nashorn.internal.ir.annotations.Ignore; import jdk.nashorn.internal.ir.annotations.Reference; @@ -144,11 +146,11 @@ public final class ASTWriter { String status = ""; - if (node.isTerminal()) { + if (node instanceof Terminal && ((Terminal)node).isTerminal()) { status += " Terminal"; } - if (node.hasGoto()) { + if (node instanceof Statement && ((Statement)node).hasGoto()) { status += " Goto "; } diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java index df903513b9c..52e9b66311e 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java @@ -182,9 +182,9 @@ public final class PrintVisitor extends NodeVisitor { final List statements = block.getStatements(); - for (final Node statement : statements) { - if (printLineNumbers && (statement instanceof Statement)) { - final int lineNumber = ((Statement)statement).getLineNumber(); + for (final Statement statement : statements) { + if (printLineNumbers) { + final int lineNumber = statement.getLineNumber(); sb.append('\n'); if (lineNumber != lastLineNumber) { indent(); @@ -196,10 +196,6 @@ public final class PrintVisitor extends NodeVisitor { statement.accept(this); - if (statement instanceof FunctionNode) { - continue; - } - int lastIndex = sb.length() - 1; char lastChar = sb.charAt(lastIndex); while (Character.isWhitespace(lastChar) && lastIndex >= 0) { diff --git a/nashorn/test/script/basic/JDK-8047057.js b/nashorn/test/script/basic/JDK-8047057.js index 84183f19059..f13e36e4941 100644 --- a/nashorn/test/script/basic/JDK-8047057.js +++ b/nashorn/test/script/basic/JDK-8047057.js @@ -45,8 +45,8 @@ function makeFuncExpectError(code, ErrorType) { } } -// makeFuncAndCall("switch(0) { default: {break;} return }"); -// makeFuncAndCall("L: { { break L; } return; }"); +makeFuncAndCall("switch(0) { default: {break;} return }"); +makeFuncAndCall("L: { { break L; } return; }"); makeFuncAndCall("L: { while(0) break L; return; }"); makeFuncExpectError("L: {while(0) break L; return [](); }", TypeError); // makeFuncAndCall("do with({}) break ; while(0);"); diff --git a/nashorn/test/script/basic/JDK-8047357.js b/nashorn/test/script/basic/JDK-8047357.js new file mode 100644 index 00000000000..20e2bb4f020 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047357.js @@ -0,0 +1,32 @@ +/* + * 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 + * 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. + */ + +/** + * JDK-8047357: More precise synthetic return + unreachable throw + * + * @test + * @run + */ + +print((function() { switch(0) { default: {var x; break ; } throw x; } })()); +print((function() { switch(0) { default: {break;} return; } })()); diff --git a/nashorn/test/script/basic/JDK-8047357.js.EXPECTED b/nashorn/test/script/basic/JDK-8047357.js.EXPECTED new file mode 100644 index 00000000000..d4f80bf8362 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047357.js.EXPECTED @@ -0,0 +1,2 @@ +undefined +undefined From 3168df50f587c1ff71942d7e8c08cc83250bfbfc Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 26 Jun 2014 15:36:15 +0200 Subject: [PATCH 140/236] 8047371: local variable declaration in TypeEvaluator should use ScriptObject.addOwnProperty instead of .set Reviewed-by: jlaskey, lagergren --- .../internal/codegen/TypeEvaluator.java | 10 ++++-- nashorn/test/script/basic/JDK-8047371.js | 32 +++++++++++++++++++ .../test/script/basic/JDK-8047371.js.EXPECTED | 1 + 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8047371.js create mode 100644 nashorn/test/script/basic/JDK-8047371.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/codegen/TypeEvaluator.java b/nashorn/src/jdk/nashorn/internal/codegen/TypeEvaluator.java index 97dbb90c789..2c90a3eb846 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/TypeEvaluator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/TypeEvaluator.java @@ -25,6 +25,10 @@ package jdk.nashorn.internal.codegen; +import static jdk.nashorn.internal.runtime.Property.NOT_CONFIGURABLE; +import static jdk.nashorn.internal.runtime.Property.NOT_ENUMERABLE; +import static jdk.nashorn.internal.runtime.Property.NOT_WRITABLE; + import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.AccessNode; import jdk.nashorn.internal.ir.Expression; @@ -43,8 +47,8 @@ import jdk.nashorn.internal.runtime.ScriptRuntime; * Used during recompilation. */ final class TypeEvaluator { - final Compiler compiler; - final ScriptObject runtimeScope; + private final Compiler compiler; + private final ScriptObject runtimeScope; TypeEvaluator(final Compiler compiler, final ScriptObject runtimeScope) { this.compiler = compiler; @@ -123,7 +127,7 @@ final class TypeEvaluator { " scope="+runtimeScope; if (runtimeScope.findProperty(symbolName, false) == null) { - runtimeScope.set(symbolName, ScriptRuntime.UNDEFINED, true); + runtimeScope.addOwnProperty(symbolName, NOT_WRITABLE | NOT_ENUMERABLE | NOT_CONFIGURABLE, ScriptRuntime.UNDEFINED); } } diff --git a/nashorn/test/script/basic/JDK-8047371.js b/nashorn/test/script/basic/JDK-8047371.js new file mode 100644 index 00000000000..fb380c7806f --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047371.js @@ -0,0 +1,32 @@ +/* + * 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 + * 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. + */ + +/** + * JDK-8047371: local variable declaration in TypeEvaluator should use ScriptObject.addOwnProperty instead of .set + * + * @test + * @run + */ + +print((function(){ var a=1; with({ get a() { return false } }) return a })()); + diff --git a/nashorn/test/script/basic/JDK-8047371.js.EXPECTED b/nashorn/test/script/basic/JDK-8047371.js.EXPECTED new file mode 100644 index 00000000000..c508d5366f7 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047371.js.EXPECTED @@ -0,0 +1 @@ +false From 147f6a092662c7c96afe2b9a8c94023b7790df12 Mon Sep 17 00:00:00 2001 From: Igor Veresov Date: Thu, 26 Jun 2014 12:01:44 -0700 Subject: [PATCH 141/236] 8048298: Clang needs to lower optimization level for some files Optimization options need to be lowered for some files when using clang 5.0 and 5.1 Reviewed-by: twisti --- hotspot/make/bsd/makefiles/gcc.make | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index 8dd2a8dccbf..b2b925b2e1c 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -322,9 +322,20 @@ endif # Work around some compiler bugs. ifeq ($(USE_CLANG), true) + # Clang 4.2 ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) OPT_CFLAGS/unsafe.o += -O1 + # Clang 5.0 + else ifeq ($(shell expr $(CC_VER_MAJOR) = 5 \& $(CC_VER_MINOR) = 0), 1) + OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) + OPT_CFLAGS/unsafe.o += -O1 + # Clang 5.1 + else ifeq ($(shell expr $(CC_VER_MAJOR) = 5 \& $(CC_VER_MINOR) = 1), 1) + OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) + OPT_CFLAGS/unsafe.o += -O1 + else + $(error "Update compiler workarounds for Clang $(CC_VER_MAJOR).$(CC_VER_MINOR)") endif else # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. From 8f69a3e4a8e708a2ac44e012ef3300ead4a4860a Mon Sep 17 00:00:00 2001 From: Marcus Lagergren Date: Fri, 27 Jun 2014 10:47:44 +0200 Subject: [PATCH 142/236] 8048505: ScriptingFunctions.readFully couldn't handle file names represented as ConsStrings Reviewed-by: sundar, hannesw --- .../internal/runtime/ScriptingFunctions.java | 4 +- nashorn/test/script/basic/JDK-8048505.js | 52 +++++++++++++++++++ .../test/script/basic/JDK-8048505.js.EXPECTED | 7 +++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8048505.js create mode 100644 nashorn/test/script/basic/JDK-8048505.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java index 78747acb64f..2113b79c22e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java @@ -107,8 +107,8 @@ public final class ScriptingFunctions { if (file instanceof File) { f = (File)file; - } else if (file instanceof String) { - f = new java.io.File((String)file); + } else if (file instanceof String || file instanceof ConsString) { + f = new java.io.File(((CharSequence)file).toString()); } if (f == null || !f.isFile()) { diff --git a/nashorn/test/script/basic/JDK-8048505.js b/nashorn/test/script/basic/JDK-8048505.js new file mode 100644 index 00000000000..4ee8fe16bbd --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048505.js @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/** + * Read fully parameter test + * + * @test + * @option -scripting + * @run + */ + +var str = __FILE__; +var first = readFully(str); +print(typeof str); + +var str2 = __FILE__.substring(0,5); +var str3 = __FILE__.substring(5); +print(typeof str2); +print(typeof str3); + +var cons = str2 + str3; +print(typeof cons); + +var second = readFully(cons); + +var f = new java.io.File(str); +print(typeof f); +var third = readFully(f); + +print(first.length() == second.length()); +print(first.length() == third.length()); + diff --git a/nashorn/test/script/basic/JDK-8048505.js.EXPECTED b/nashorn/test/script/basic/JDK-8048505.js.EXPECTED new file mode 100644 index 00000000000..ed5daae86f7 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048505.js.EXPECTED @@ -0,0 +1,7 @@ +string +string +string +string +object +true +true From 95d24c736121971701d88c2aa079fe4d86bdd314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Fri, 27 Jun 2014 13:33:36 +0200 Subject: [PATCH 143/236] 8047812: Ensure ClassLoaderDataGraph::classes_unloading_do only delivers klasses from CLDs with non-reclaimed class loader oops Reviewed-by: coleenp, sspitsyn, ehelin --- hotspot/src/share/vm/classfile/classLoaderData.cpp | 10 +++++++++- hotspot/src/share/vm/classfile/classLoaderData.hpp | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index efbde89ee30..d4a137f2d8d 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -549,6 +549,7 @@ bool ClassLoaderData::contains_klass(Klass* klass) { // GC root of class loader data created. ClassLoaderData* ClassLoaderDataGraph::_head = NULL; ClassLoaderData* ClassLoaderDataGraph::_unloading = NULL; +ClassLoaderData* ClassLoaderDataGraph::_saved_unloading = NULL; ClassLoaderData* ClassLoaderDataGraph::_saved_head = NULL; bool ClassLoaderDataGraph::_should_purge = false; @@ -656,7 +657,9 @@ void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) { void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); - for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) { + // Only walk the head until any clds not purged from prior unloading + // (CMS doesn't purge right away). + for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) { cld->classes_do(f); } } @@ -704,6 +707,11 @@ bool ClassLoaderDataGraph::do_unloading(BoolObjectClosure* is_alive_closure) { ClassLoaderData* data = _head; ClassLoaderData* prev = NULL; bool seen_dead_loader = false; + + // Save previous _unloading pointer for CMS which may add to unloading list before + // purging and we don't want to rewalk the previously unloaded class loader data. + _saved_unloading = _unloading; + // mark metadata seen on the stack and code cache so we can delete // unneeded entries. bool has_redefined_a_class = JvmtiExport::has_redefined_a_class(); diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 82ae72c1164..35088a7fbbe 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -66,6 +66,7 @@ class ClassLoaderDataGraph : public AllStatic { static ClassLoaderData* _unloading; // CMS support. static ClassLoaderData* _saved_head; + static ClassLoaderData* _saved_unloading; static bool _should_purge; static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS); From 4b428d5833b11be7a465635d30dd588b3dc906ce Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 27 Jun 2014 21:54:16 +0530 Subject: [PATCH 144/236] 8046013: TypeError: Cannot apply "with" to non script object Reviewed-by: lagergren, hannesw --- .../internal/objects/NativeObject.java | 26 +++++++++ .../internal/runtime/ScriptRuntime.java | 19 ++++++- .../nashorn/internal/runtime/WithObject.java | 19 ++++++- nashorn/test/script/basic/JDK-8046013.js | 57 +++++++++++++++++++ .../test/script/basic/JDK-8046013.js.EXPECTED | 4 ++ .../api/scripting/ScriptEngineTest.java | 14 +++++ 6 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8046013.js create mode 100644 nashorn/test/script/basic/JDK-8046013.js.EXPECTED diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java index 30ffbabff9e..08ad24cc8a7 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java @@ -716,6 +716,32 @@ public final class NativeObject { return target; } + /* + * Binds the source mirror object's properties to the target object. Binding + * properties allows two-way read/write for the properties of the source object. + * All inherited, enumerable properties are also bound. This method is used to + * to make 'with' statement work with ScriptObjectMirror as scope object. + * + * @param target the target object to which the source object's properties are bound + * @param source the source object whose properties are bound to the target + * @return the target object after property binding + */ + public static Object bindAllProperties(final ScriptObject target, final ScriptObjectMirror source) { + final Set keys = source.keySet(); + // make accessor properties using dynamic invoker getters and setters + final AccessorProperty[] props = new AccessorProperty[keys.size()]; + int idx = 0; + for (String name : keys) { + final MethodHandle getter = Bootstrap.createDynamicInvoker("dyn:getMethod|getProp|getElem:" + name, MIRROR_GETTER_TYPE); + final MethodHandle setter = Bootstrap.createDynamicInvoker("dyn:setProp|setElem:" + name, MIRROR_SETTER_TYPE); + props[idx] = AccessorProperty.create(name, 0, getter, setter); + idx++; + } + + target.addBoundProperties(source, props); + return target; + } + private static void bindBeanProperties(final ScriptObject targetObj, final Object source, final Collection readablePropertyNames, final Collection writablePropertyNames, final Collection methodNames) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java index 580e95d80ea..337d92699e3 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java @@ -49,6 +49,7 @@ import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.codegen.CompilerConstants.Call; import jdk.nashorn.internal.ir.debug.JSONWriter; import jdk.nashorn.internal.objects.Global; +import jdk.nashorn.internal.objects.NativeObject; import jdk.nashorn.internal.parser.Lexer; import jdk.nashorn.internal.runtime.linker.Bootstrap; @@ -478,9 +479,21 @@ public final class ScriptRuntime { throw typeError(global, "cant.apply.with.to.null"); } - final Object wrappedExpr = JSType.toScriptObject(global, expression); - if (wrappedExpr instanceof ScriptObject) { - return new WithObject(scope, (ScriptObject)wrappedExpr); + if (expression instanceof ScriptObjectMirror) { + final Object unwrapped = ScriptObjectMirror.unwrap(expression, global); + if (unwrapped instanceof ScriptObject) { + return new WithObject(scope, (ScriptObject)unwrapped); + } else { + // foreign ScriptObjectMirror + ScriptObject exprObj = global.newObject(); + NativeObject.bindAllProperties(exprObj, (ScriptObjectMirror)expression); + return new WithObject(scope, exprObj); + } + } else { + final Object wrappedExpr = JSType.toScriptObject(global, expression); + if (wrappedExpr instanceof ScriptObject) { + return new WithObject(scope, (ScriptObject)wrappedExpr); + } } throw typeError(global, "cant.apply.with.to.non.scriptobject"); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java index 24c5e3d9ff8..ac5f5a76e4a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/WithObject.java @@ -31,6 +31,8 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.lang.invoke.SwitchPoint; +import jdk.nashorn.api.scripting.AbstractJSObject; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; @@ -312,7 +314,22 @@ public final class WithObject extends ScriptObject implements Scope { @SuppressWarnings("unused") private static Object bindToExpression(final Object fn, final Object receiver) { - return fn instanceof ScriptFunction ? bindToExpression((ScriptFunction) fn, receiver) : fn; + if (fn instanceof ScriptFunction) { + return bindToExpression((ScriptFunction) fn, receiver); + } else if (fn instanceof ScriptObjectMirror) { + final ScriptObjectMirror mirror = (ScriptObjectMirror)fn; + if (mirror.isFunction()) { + // We need to make sure correct 'this' is used for calls with Ident call + // expressions. We do so here using an AbstractJSObject instance. + return new AbstractJSObject() { + public Object call(final Object thiz, final Object... args) { + return mirror.call(withFilterExpression(receiver), args); + } + }; + } + } + + return fn; } private static Object bindToExpression(final ScriptFunction fn, final Object receiver) { diff --git a/nashorn/test/script/basic/JDK-8046013.js b/nashorn/test/script/basic/JDK-8046013.js new file mode 100644 index 00000000000..e3a5ac4e9be --- /dev/null +++ b/nashorn/test/script/basic/JDK-8046013.js @@ -0,0 +1,57 @@ +/* + * 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. + */ + +/** + * JDK-8046013: TypeError: Cannot apply "with" to non script object + * + * @test + * @run + */ + +var obj = loadWithNewGlobal({ + script: "({ f: 33 })", + name: "test" +}); + +with (obj) { + print("f = " + f); +} + +var obj2 = loadWithNewGlobal({ + script: "var obj = Object.create({ foo: 42 }); obj.bar = 'hello'; obj", + name: "test2" +}); + +with (obj2) { + print("foo = " + foo); + print("bar = " + bar); +} + +var obj3 = loadWithNewGlobal({ + script: "({ f: 33, func: function() { print('this.f =', this.f); } })", + name: "test" +}); + +with(obj3) { + func(); +} diff --git a/nashorn/test/script/basic/JDK-8046013.js.EXPECTED b/nashorn/test/script/basic/JDK-8046013.js.EXPECTED new file mode 100644 index 00000000000..4b612ed6693 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8046013.js.EXPECTED @@ -0,0 +1,4 @@ +f = 33 +foo = 42 +bar = hello +this.f = 33 diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index 6989d6c646f..87d9b5ef35b 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -593,6 +593,20 @@ public class ScriptEngineTest { } } + // @bug 8046013: TypeError: Cannot apply "with" to non script object + @Test + public void withOnMirrorTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + + final Object obj = e.eval("({ foo: 'hello'})"); + final Object[] arr = new Object[1]; + arr[0] = obj; + e.put("arr", arr); + final Object res = e.eval("var res; with(arr[0]) { res = foo; }; res"); + assertEquals(res, "hello"); + } + private static void checkProperty(final ScriptEngine e, final String name) throws ScriptException { final String value = System.getProperty(name); From 8f73a84a15dacfa2cfa6caac3c2a7f1edad0b00f Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Fri, 27 Jun 2014 14:00:50 -0700 Subject: [PATCH 145/236] 8047720: Xprof hangs on Solaris Update use of PeriodicTask_lock in WatcherThread::stop() to avoid safepoint deadlock. Reviewed-by: mgronlun, coleenp --- hotspot/src/share/vm/runtime/thread.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index f66a056aa51..05cb340ae85 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1358,14 +1358,24 @@ void WatcherThread::make_startable() { } void WatcherThread::stop() { - { - MutexLockerEx ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag); - _should_terminate = true; - OrderAccess::fence(); // ensure WatcherThread sees update in main loop + // Get the PeriodicTask_lock if we can. If we cannot, then the + // WatcherThread is using it and we don't want to block on that lock + // here because that might cause a safepoint deadlock depending on + // what the current WatcherThread tasks are doing. + bool have_lock = PeriodicTask_lock->try_lock(); + _should_terminate = true; + OrderAccess::fence(); // ensure WatcherThread sees update in main loop + + if (have_lock) { WatcherThread* watcher = watcher_thread(); - if (watcher != NULL) + if (watcher != NULL) { + // If we managed to get the lock, then we should unpark the + // WatcherThread so that it can see we want it to stop. watcher->unpark(); + } + + PeriodicTask_lock->unlock(); } // it is ok to take late safepoints here, if needed From 729fe3ec72418c9c13a20da49268d8ebf1202ecd Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Fri, 27 Jun 2014 17:54:54 -0700 Subject: [PATCH 146/236] 8047162: [javadoc] index files are non deterministic Reviewed-by: jjg --- .../doclets/internal/toolkit/util/Util.java | 91 ++++++++++--------- .../javadoc/testOrdering/TestOrdering.java | 25 +++++ .../sun/javadoc/testOrdering/src-2/a/A.java | 32 +++++++ .../testOrdering/src-2/a/something.java | 36 ++++++++ .../sun/javadoc/testOrdering/src-2/b/B.java | 32 +++++++ .../testOrdering/src-2/b/something.java | 27 ++++++ .../testOrdering/src-2/e/something.java | 27 ++++++ .../testOrdering/src-2/something/J.java | 29 ++++++ .../src-2/something/package-info.java | 26 ++++++ .../src-2/something/something.java | 27 ++++++ 10 files changed, 309 insertions(+), 43 deletions(-) create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java create mode 100644 langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java index f546229aba4..b70c612533a 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java @@ -812,21 +812,24 @@ public class Util { collator.setStrength(caseSensitive ? Collator.TERTIARY : Collator.SECONDARY); return collator.compare(s1, s2); } + /** - * A comparator for index file uses, + * A comparator for index file presentations, * 1. this sorts first on simple names - * 2. if equal, case insensitive comparison of Parameter types - * 3. if equal, case sensitive comparison of Parameter types - * 4. if equal, compare the FQNs of the entities - * 5. if equal, then compare the DocKinds ex: Package, Interface etc. + * 2. if equal, then compare the DocKind ex: Package, Interface etc. + * 3a. if equal and if the type is of ExecutableMemberDoc(Constructor, Fields), + * a case insensitive comparison of parameter types + * 3b. if equal, a case sensitive comparison of parameter types + * 4. finally, if equal, compare the FQNs of the entities * @return a comparator for index file use */ public static Comparator makeComparatorForIndexUse() { return new Util.DocComparator() { /** - * compare two given Doc entities, first sort on name, if - * applicable on the method's parameter types, and finally on the - * fully qualified name of the entity. + * Compare two given Doc entities, first sort on name, then on the kinds, + * then on the parameters only if the type is an instance of ExecutableMemberDocs, + * the parameters are compared ignoring the case first, then a case sensitive comparison, + * and finally the fully qualified names. * * @param d1 - a Doc element. * @param d2 - a Doc element. @@ -838,7 +841,11 @@ public class Util { if (result != 0) { return result; } - if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { + result = compareDocKinds(d1, d2); + if (result != 0) { + return result; + } + if (hasParameters(d1)) { Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters(); Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters(); result = compareParameters(false, param1, param2); @@ -846,31 +853,28 @@ public class Util { return result; } result = compareParameters(true, param1, param2); + if (result != 0) { + return result; + } } - if (result != 0) { - return result; - } - result = compareFullyQualifiedNames(d1, d2); - if (result != 0) { - return result; - } - return compareDocKinds(d1, d2); + return compareFullyQualifiedNames(d1, d2); } }; } - /** - * Comparator for ClassUse representations, this sorts on member names, - * fully qualified member names and then the parameter types if applicable, - * and finally the Doc kinds ie. package, class, interface etc. + * Comparator for ClassUse presentations, and sorts as follows: + * 1. member names + * 2. then fully qualified member names + * 3. then parameter types if applicable + * 4. finally the Doc kinds ie. package, class, interface etc. * @return a comparator to sort classes and members for class use */ public static Comparator makeComparatorForClassUse() { return new Util.DocComparator() { /** - * compare two given Doc entities, first sort on name, and if - * applicable on the fully qualified name, and finally if applicable - * on the parameter types. + * Compare two given Doc entities, first sort on name, and if + * applicable on the fully qualified name, and if applicable + * on the parameter types, and finally the DocKind. * @param d1 - a Doc element. * @param d2 - a Doc element. * @return a negative integer, zero, or a positive integer as the first @@ -885,7 +889,7 @@ public class Util { if (result != 0) { return result; } - if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { + if (hasParameters(d1) && hasParameters(d2)) { Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters(); Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters(); result = compareParameters(false, param1, param2); @@ -898,53 +902,54 @@ public class Util { } }; } - - /** * A general purpose comparator to sort Doc entities, basically provides the building blocks * for creating specific comparators for an use-case. * @param a Doc entity */ static abstract class DocComparator implements Comparator { - static enum DocKinds { + static enum DocKind { PACKAGE, - FIELD, - ENUM, - ANNOTATION, - INTERFACE, CLASS, + ENUM, + INTERFACE, + ANNOTATION, + FIELD, CONSTRUCTOR, METHOD }; - private DocKinds getValue(Doc d) { + boolean hasParameters(Doc d) { + return d instanceof ExecutableMemberDoc; + } + DocKind getDocKind(Doc d) { if (d.isAnnotationType() || d.isAnnotationTypeElement()) { - return DocKinds.ANNOTATION; + return DocKind.ANNOTATION; } else if (d.isEnum() || d.isEnumConstant()) { - return DocKinds.ENUM; + return DocKind.ENUM; } else if (d.isField()) { - return DocKinds.FIELD; + return DocKind.FIELD; } else if (d.isInterface()) { - return DocKinds.INTERFACE; + return DocKind.INTERFACE; } else if (d.isClass()) { - return DocKinds.CLASS; + return DocKind.CLASS; } else if (d.isConstructor()) { - return DocKinds.CONSTRUCTOR; + return DocKind.CONSTRUCTOR; } else if (d.isMethod()) { - return DocKinds.METHOD; + return DocKind.METHOD; } else { - return DocKinds.PACKAGE; + return DocKind.PACKAGE; } } /** * Compares two Doc entities' kinds, and these are ordered as defined in - * the DocKinds enumeration. + * the DocKind enumeration. * @param d1 the first Doc object * @param d2 the second Doc object * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ protected int compareDocKinds(Doc d1, Doc d2) { - return getValue(d1).compareTo(getValue(d2)); + return getDocKind(d1).compareTo(getDocKind(d2)); } /** * Compares two parameter arrays by comparing each Type of the parameter in the array, diff --git a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java index 98cc674525b..638b2542fd8 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java +++ b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java @@ -117,6 +117,31 @@ public class TestOrdering extends JavadocTester { checkExit(Exit.OK); checkOrder("index-all.html", composeTestVectors()); } + + @Test + void testIndexTypeClustering() { + javadoc("-d", "out-3", + "-sourcepath", testSrc("src-2"), + "-use", + "a", + "b", + "e", + "something"); + checkOrder("index-all.html", typeTestVectors); + checkExit(Exit.OK); + } + String[] typeTestVectors = { + "something - package something", + "something - Class in", + "something - Enum in", + "something - Interface in", + "something - Annotation Type in", + "something - Variable in class", + "something() - Constructor", + "something() - Method in class a. - Method in class a. - Method in class something. testList = new ArrayList<>(); diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java new file mode 100644 index 00000000000..603bfc12ff5 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/A.java @@ -0,0 +1,32 @@ +/* + * 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. + */ +package a; +/** + * A class + */ +public class A { + /** + * a method + */ + public void something() {} +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java new file mode 100644 index 00000000000..9869b22bd98 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/a/something.java @@ -0,0 +1,36 @@ +/* + * 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. + */ +package a; +/** + * A class + */ +public class something { + /** + * A constructor + */ + public something() {} + /** + * a method + */ + public void something() {} +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java new file mode 100644 index 00000000000..5eea0f5de3d --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/B.java @@ -0,0 +1,32 @@ +/* + * 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. + */ +package b; +/** + * Another class + */ +public class B { + /** + * a field + */ + public Object something; +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java new file mode 100644 index 00000000000..ea8726d2057 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/b/something.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package b; +/** + * an annotation + */ +public @interface something{} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java new file mode 100644 index 00000000000..0120a2e84fa --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/e/something.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package e; +/** + * An enum + */ +public enum something {} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java new file mode 100644 index 00000000000..bc1da1fea79 --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/J.java @@ -0,0 +1,29 @@ +/* + * 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. + */ +package something; +public class J { + /** + * a method + */ + public void something(){} +} diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java new file mode 100644 index 00000000000..f712a9fb5ab --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/package-info.java @@ -0,0 +1,26 @@ +/* + * 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. + */ +/** + * A package + */ +package something; diff --git a/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java new file mode 100644 index 00000000000..890e0c5d2bc --- /dev/null +++ b/langtools/test/com/sun/javadoc/testOrdering/src-2/something/something.java @@ -0,0 +1,27 @@ +/* + * 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. + */ +package something; +/** + * An interface + */ +public interface something {} From b4d4c8a3922f6563013d4e997e149bd0198222d2 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Mon, 30 Jun 2014 08:28:29 +0200 Subject: [PATCH 147/236] 8048003: test/compiler/8009761/Test8009761.java failed with: java.lang.RuntimeException: static java.lang.Object Test8009761.m3(boolean,boolean) not compiled Compile m3 with C1 if C2 is not available. Reviewed-by: twisti, anoll --- .../test/compiler/8009761/Test8009761.java | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/hotspot/test/compiler/8009761/Test8009761.java b/hotspot/test/compiler/8009761/Test8009761.java index 39a25748348..ed0f94665e4 100644 --- a/hotspot/test/compiler/8009761/Test8009761.java +++ b/hotspot/test/compiler/8009761/Test8009761.java @@ -21,11 +21,7 @@ * questions. */ -import com.sun.management.HotSpotDiagnosticMXBean; -import com.sun.management.VMOption; import sun.hotspot.WhiteBox; -import sun.management.ManagementFactoryHelper; - import java.lang.reflect.Method; /* @@ -40,6 +36,7 @@ import java.lang.reflect.Method; public class Test8009761 { private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static int COMP_LEVEL_SIMPLE = 1; private static int COMP_LEVEL_FULL_OPTIMIZATION = 4; private static Method m3 = null; @@ -236,7 +233,7 @@ public class Test8009761 { static public void main(String[] args) { // Make sure background compilation is disabled - if (backgroundCompilationEnabled()) { + if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) { throw new RuntimeException("Background compilation enabled"); } @@ -256,7 +253,11 @@ public class Test8009761 { c1 = count; // Force the compilation of m3() that will inline m1() - WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION); + if(!WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION)) { + // C2 compiler not available, compile with C1 + WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_SIMPLE); + } + // Because background compilation is disabled, method should now be compiled if(!WHITE_BOX.isMethodCompiled(m3)) { throw new RuntimeException(m3 + " not compiled"); @@ -278,19 +279,4 @@ public class Test8009761 { System.out.println("PASSED " + c1); } } - - /** - * Checks if background compilation (-XX:+BackgroundCompilation) is enabled. - * @return True if background compilation is enabled, false otherwise - */ - private static boolean backgroundCompilationEnabled() { - HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); - VMOption backgroundCompilation; - try { - backgroundCompilation = diagnostic.getVMOption("BackgroundCompilation"); - } catch (IllegalArgumentException e) { - return false; - } - return Boolean.valueOf(backgroundCompilation.getValue()); - } } From bc6fafb55ae82cc0ada83ffaecf13428d12b7e2d Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Mon, 30 Jun 2014 14:58:52 -0400 Subject: [PATCH 148/236] 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms Fix the matching of format string parameter types to the actual argument types for the PPC64 and CPP-Interpreter files in the same way as 8037816 already did it for all the other files Reviewed-by: stefank, coleenp, dholmes --- hotspot/src/cpu/ppc/vm/assembler_ppc.cpp | 4 ++-- hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp | 4 ++-- hotspot/src/cpu/ppc/vm/frame_ppc.cpp | 4 ++-- hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp | 4 ++-- hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp | 4 ++-- hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp | 20 +++++++++---------- hotspot/src/cpu/ppc/vm/ppc.ad | 2 +- hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp | 6 +++--- .../src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 18 ++++++++--------- .../vm/interpreter/bytecodeInterpreter.cpp | 16 +++++++-------- .../bytecodeInterpreterProfiling.hpp | 12 +++++------ 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp index f9e49e1f4a8..6ab0f8a61bd 100644 --- a/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.cpp @@ -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. * Copyright 2012, 2014 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -693,7 +693,7 @@ void Assembler::test_asm() { // PPC 1, section 4.6.7 Floating-Point Compare Instructions fcmpu( CCR7, F24, F25); - tty->print_cr("\ntest_asm disassembly (0x%lx 0x%lx):", code()->insts_begin(), code()->insts_end()); + tty->print_cr("\ntest_asm disassembly (0x%lx 0x%lx):", p2i(code()->insts_begin()), p2i(code()->insts_end())); code()->decode(); } diff --git a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp index ab100745af4..1b54594d09c 100644 --- a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp @@ -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 @@ -175,7 +175,7 @@ void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) if (TraceICs) { ResourceMark rm; tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s", - instruction_address(), + p2i(instruction_address()), callee->name_and_sig_as_C_string()); } diff --git a/hotspot/src/cpu/ppc/vm/frame_ppc.cpp b/hotspot/src/cpu/ppc/vm/frame_ppc.cpp index 6df316d1b87..ff177e6231a 100644 --- a/hotspot/src/cpu/ppc/vm/frame_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/frame_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright 2012, 2014 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -140,7 +140,7 @@ frame frame::sender(RegisterMap* map) const { void frame::patch_pc(Thread* thread, address pc) { if (TracePcPatching) { tty->print_cr("patch_pc at address " PTR_FORMAT " [" PTR_FORMAT " -> " PTR_FORMAT "]", - &((address*) _sp)[-1], ((address*) _sp)[-1], pc); + p2i(&((address*) _sp)[-1]), p2i(((address*) _sp)[-1]), p2i(pc)); } own_abi()->lr = (uint64_t)pc; _cb = CodeCache::find_blob(pc); diff --git a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp index 8f026ac0d0c..ce10145ed90 100644 --- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp @@ -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. * Copyright 2012, 2014 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -3099,7 +3099,7 @@ const char* stop_types[] = { }; static void stop_on_request(int tp, const char* msg) { - tty->print("PPC assembly code requires stop: (%s) %s\n", (void *)stop_types[tp%/*stop_end*/4], msg); + tty->print("PPC assembly code requires stop: (%s) %s\n", stop_types[tp%/*stop_end*/4], msg); guarantee(false, err_msg("PPC assembly code requires stop: %s", msg)); } diff --git a/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp b/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp index 4383d61f7fd..89c0344a5fe 100644 --- a/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/methodHandles_ppc.cpp @@ -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. * Copyright 2012, 2014 SAP AG. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -464,7 +464,7 @@ void trace_method_handle_stub(const char* adaptername, strstr(adaptername, "linkTo") == NULL); // static linkers don't have MH const char* mh_reg_name = has_mh ? "R23_method_handle" : "G23"; tty->print_cr("MH %s %s="INTPTR_FORMAT " sp=" INTPTR_FORMAT, - adaptername, mh_reg_name, (intptr_t) mh, entry_sp); + adaptername, mh_reg_name, (intptr_t) mh, (intptr_t) entry_sp); if (Verbose) { tty->print_cr("Registers:"); diff --git a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp index f6249450de1..6f40af06f40 100644 --- a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012, 2013 SAP AG. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012, 2014 SAP AG. 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 @@ -147,9 +147,9 @@ void NativeCall::verify() { address addr = addr_at(0); if (!NativeCall::is_call_at(addr)) { - tty->print_cr("not a NativeCall at " PTR_FORMAT, addr); + tty->print_cr("not a NativeCall at " PTR_FORMAT, p2i(addr)); // TODO: PPC port: Disassembler::decode(addr - 20, addr + 20, tty); - fatal(err_msg("not a NativeCall at " PTR_FORMAT, addr)); + fatal(err_msg("not a NativeCall at " PTR_FORMAT, p2i(addr))); } } #endif // ASSERT @@ -160,9 +160,9 @@ void NativeFarCall::verify() { NativeInstruction::verify(); if (!NativeFarCall::is_far_call_at(addr)) { - tty->print_cr("not a NativeFarCall at " PTR_FORMAT, addr); + tty->print_cr("not a NativeFarCall at " PTR_FORMAT, p2i(addr)); // TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); - fatal(err_msg("not a NativeFarCall at " PTR_FORMAT, addr)); + fatal(err_msg("not a NativeFarCall at " PTR_FORMAT, p2i(addr))); } } #endif // ASSERT @@ -306,9 +306,9 @@ void NativeMovConstReg::verify() { if (! (cb != NULL && MacroAssembler::is_calculate_address_from_global_toc_at(addr, cb->content_begin())) && ! (cb != NULL && MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) && ! MacroAssembler::is_bl(*((int*) addr))) { - tty->print_cr("not a NativeMovConstReg at " PTR_FORMAT, addr); + tty->print_cr("not a NativeMovConstReg at " PTR_FORMAT, p2i(addr)); // TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); - fatal(err_msg("not a NativeMovConstReg at " PTR_FORMAT, addr)); + fatal(err_msg("not a NativeMovConstReg at " PTR_FORMAT, p2i(addr))); } } } @@ -344,9 +344,9 @@ void NativeJump::verify() { NativeInstruction::verify(); if (!NativeJump::is_jump_at(addr)) { - tty->print_cr("not a NativeJump at " PTR_FORMAT, addr); + tty->print_cr("not a NativeJump at " PTR_FORMAT, p2i(addr)); // TODO: PPC port: Disassembler::decode(addr, 20, 20, tty); - fatal(err_msg("not a NativeJump at " PTR_FORMAT, addr)); + fatal(err_msg("not a NativeJump at " PTR_FORMAT, p2i(addr))); } } #endif // ASSERT diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index d2d51379a22..9087959fe1e 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -1329,7 +1329,7 @@ void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const { if (!false /* TODO: PPC port C->is_frameless_method()*/) { st->print("save return pc\n\t"); - st->print("push frame %d\n\t", -framesize); + st->print("push frame %ld\n\t", -framesize); } } #endif diff --git a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp index 32fb22ce229..28f992f41b8 100644 --- a/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp @@ -352,7 +352,7 @@ void VM_Version::determine_section_size() { if (PrintAssembly) { ttyLocker ttyl; - tty->print_cr("Decoding section size detection stub at " INTPTR_FORMAT " before execution:", code); + tty->print_cr("Decoding section size detection stub at " INTPTR_FORMAT " before execution:", p2i(code)); Disassembler::decode((u_char*)code, (u_char*)code_end, tty); tty->print_cr("Time loop1 :%f", loop1_seconds); tty->print_cr("Time loop2 :%f", loop2_seconds); @@ -435,7 +435,7 @@ void VM_Version::determine_features() { // Print the detection code. if (PrintAssembly) { ttyLocker ttyl; - tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", code); + tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code)); Disassembler::decode((u_char*)code, (u_char*)code_end, tty); } @@ -468,7 +468,7 @@ void VM_Version::determine_features() { // Print the detection code. if (PrintAssembly) { ttyLocker ttyl; - tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " after execution:", code); + tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " after execution:", p2i(code)); Disassembler::decode((u_char*)code, (u_char*)code_end, tty); } diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index ccfd54ba9de..d7fd74d219a 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012, 2013 SAP AG. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012, 2014 SAP AG. 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 @@ -307,7 +307,7 @@ JVM_handle_linux_signal(int sig, // doesn't work for us. We use: ((NativeInstruction*)pc)->is_safepoint_poll()) { if (TraceTraps) { - tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", pc); + tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc)); } stub = SharedRuntime::get_poll_stub(pc); } @@ -316,7 +316,7 @@ JVM_handle_linux_signal(int sig, else if (sig == SIGTRAP && TrapBasedICMissChecks && nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) { if (TraceTraps) { - tty->print_cr("trap: ic_miss_check at " INTPTR_FORMAT " (SIGTRAP)", pc); + tty->print_cr("trap: ic_miss_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc)); } stub = SharedRuntime::get_ic_miss_stub(); } @@ -325,7 +325,7 @@ JVM_handle_linux_signal(int sig, else if (sig == SIGTRAP && TrapBasedNullChecks && nativeInstruction_at(pc)->is_sigtrap_null_check()) { if (TraceTraps) { - tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGTRAP)", pc); + tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc)); } stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); } @@ -335,7 +335,7 @@ JVM_handle_linux_signal(int sig, CodeCache::contains((void*) pc) && !MacroAssembler::needs_explicit_null_check((intptr_t) info->si_addr)) { if (TraceTraps) { - tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", pc); + tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc)); } stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); } @@ -345,7 +345,7 @@ JVM_handle_linux_signal(int sig, else if (sig == SIGTRAP && TrapBasedRangeChecks && nativeInstruction_at(pc)->is_sigtrap_range_check()) { if (TraceTraps) { - tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", pc); + tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc)); } stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); } @@ -572,7 +572,7 @@ void os::print_context(outputStream *st, void *context) { st->cr(); intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); + st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); st->cr(); @@ -580,7 +580,7 @@ void os::print_context(outputStream *st, void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Linux::ucontext_get_pc(uc); - st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); + st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc)); print_hex_dump(st, pc - 64, pc + 64, /*instrsize=*/4); st->cr(); } diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index cdb99f58670..323f67fc1f6 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -2783,11 +2783,11 @@ run: if (TraceExceptions) { ttyLocker ttyl; ResourceMark rm; - tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), (void*)except_oop()); + tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), p2i(except_oop())); tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string()); tty->print_cr(" at bci %d, continuing at %d for thread " INTPTR_FORMAT, - istate->bcp() - (intptr_t)METHOD->code_base(), - continuation_bci, THREAD); + (int)(istate->bcp() - METHOD->code_base()), + (int)continuation_bci, p2i(THREAD)); } // for AbortVMOnException flag NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); @@ -2799,11 +2799,11 @@ run: if (TraceExceptions) { ttyLocker ttyl; ResourceMark rm; - tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), (void*)except_oop()); + tty->print_cr("Exception <%s> (" INTPTR_FORMAT ")", except_oop->print_value_string(), p2i(except_oop())); tty->print_cr(" thrown in interpreter method <%s>", METHOD->print_value_string()); tty->print_cr(" at bci %d, unwinding for thread " INTPTR_FORMAT, - istate->bcp() - (intptr_t)METHOD->code_base(), - THREAD); + (int)(istate->bcp() - METHOD->code_base()), + p2i(THREAD)); } // for AbortVMOnException flag NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); @@ -3402,7 +3402,7 @@ BytecodeInterpreter::print() { tty->print_cr("osr._osr_buf: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_buf); tty->print_cr("osr._osr_entry: " INTPTR_FORMAT, (uintptr_t) this->_result._osr._osr_entry); tty->print_cr("prev_link: " INTPTR_FORMAT, (uintptr_t) this->_prev_link); - tty->print_cr("native_mirror: " INTPTR_FORMAT, (void*) this->_oop_temp); + tty->print_cr("native_mirror: " INTPTR_FORMAT, (uintptr_t) this->_oop_temp); tty->print_cr("stack_base: " INTPTR_FORMAT, (uintptr_t) this->_stack_base); tty->print_cr("stack_limit: " INTPTR_FORMAT, (uintptr_t) this->_stack_limit); tty->print_cr("monitor_base: " INTPTR_FORMAT, (uintptr_t) this->_monitor_base); diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreterProfiling.hpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreterProfiling.hpp index 095a989cc01..86b6c22822f 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreterProfiling.hpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreterProfiling.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. - * Copyright 2012, 2013 SAP AG. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012, 2014 SAP AG. 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 @@ -86,11 +86,11 @@ " \t-> " PTR_FORMAT "(%d)", \ (int) THREAD->osthread()->thread_id(), \ BCI(), \ - MDX(), \ + p2i(MDX()), \ (MDX() == NULL \ ? 0 \ : istate->method()->method_data()->dp_to_di((address)MDX())), \ - mdx, \ + p2i(mdx), \ istate->method()->method_data()->dp_to_di((address)mdx) \ ); \ }; \ @@ -107,7 +107,7 @@ MethodData *md = istate->method()->method_data(); \ tty->cr(); \ tty->print("method data at mdx " PTR_FORMAT "(0) for", \ - md->data_layout_at(md->bci_to_di(0))); \ + p2i(md->data_layout_at(md->bci_to_di(0)))); \ istate->method()->print_short_name(tty); \ tty->cr(); \ if (md != NULL) { \ @@ -115,7 +115,7 @@ address mdx = (address) MDX(); \ if (mdx != NULL) { \ tty->print_cr("current mdx " PTR_FORMAT "(%d)", \ - mdx, \ + p2i(mdx), \ istate->method()->method_data()->dp_to_di(mdx)); \ } \ } else { \ From a3765464cba6e08e3e099df08e1c868695b9fd51 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Mon, 30 Jun 2014 10:04:05 +0200 Subject: [PATCH 149/236] 8047973: Quarantine compiler/ciReplay/* Reviewed-by: vlivanov --- hotspot/test/compiler/ciReplay/TestSA.sh | 1 + hotspot/test/compiler/ciReplay/TestVM.sh | 1 + hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh | 1 + 3 files changed, 3 insertions(+) diff --git a/hotspot/test/compiler/ciReplay/TestSA.sh b/hotspot/test/compiler/ciReplay/TestSA.sh index 6ea2c53a6ce..61d93652f25 100644 --- a/hotspot/test/compiler/ciReplay/TestSA.sh +++ b/hotspot/test/compiler/ciReplay/TestSA.sh @@ -26,6 +26,7 @@ ## ## @test ## @bug 8011675 +## @ignore 8032226, 8031978 ## @summary testing of ciReplay with using generated by SA replay.txt ## @author igor.ignatyev@oracle.com ## @run shell TestSA.sh diff --git a/hotspot/test/compiler/ciReplay/TestVM.sh b/hotspot/test/compiler/ciReplay/TestVM.sh index e58d63e16fa..c972c607947 100644 --- a/hotspot/test/compiler/ciReplay/TestVM.sh +++ b/hotspot/test/compiler/ciReplay/TestVM.sh @@ -26,6 +26,7 @@ ## ## @test ## @bug 8011675 +## @ignore 8031978 ## @summary testing of ciReplay with using generated by VM replay.txt ## @author igor.ignatyev@oracle.com ## @run shell TestVM.sh diff --git a/hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh b/hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh index d961d42541d..4d0ee773c44 100644 --- a/hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh +++ b/hotspot/test/compiler/ciReplay/TestVM_no_comp_level.sh @@ -26,6 +26,7 @@ ## ## @test ## @bug 8011675 +## @ignore 8031978 ## @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level ## @author igor.ignatyev@oracle.com ## @run shell TestVM_no_comp_level.sh From 51aad86e6b4d0c6b2f432257edb7ac89f03d9e1d Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 30 Jun 2014 20:23:16 +0530 Subject: [PATCH 150/236] 8048718: JSON.parse('{"0":0, "64":0}') throws ArrayindexOutOfBoundsException Reviewed-by: lagergren, hannesw, attila --- .../internal/runtime/ScriptObject.java | 1 + nashorn/test/script/basic/JDK-8048718.js | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 nashorn/test/script/basic/JDK-8048718.js diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 90003b38f67..1987d317100 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -691,6 +691,7 @@ public abstract class ScriptObject implements PropertyAccess { assert isValidArrayIndex(index) : "invalid array index"; final long longIndex = ArrayIndex.toLongIndex(index); doesNotHaveEnsureDelete(longIndex, getArray().length(), false); + setArray(getArray().ensure(longIndex)); setArray(getArray().set(index, value, false)); } diff --git a/nashorn/test/script/basic/JDK-8048718.js b/nashorn/test/script/basic/JDK-8048718.js new file mode 100644 index 00000000000..08b0e3f8879 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048718.js @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/** + * JDK-8048718: JSON.parse('{"0":0, "64":0}') throws ArrayindexOutOfBoundsException + * + * @test + * @run + */ + +var obj = JSON.parse('{"0":0, "64":0}'); +if ("1" in obj) { + fail("found element at index 1"); +} + +if ("63" in obj) { + fail("found element at index 63"); +} + +if (obj[0] != 0) { + fail("expected obj[0] to be 0"); +} + +if (obj[64] != 0) { + fail("expected obj[64] to be 0"); +} + +for (var i in obj) { + if (i != "0" && i != "64") { + fail("invalid property " + i); + } +} From 670eff1ee6647423054a697b624d6075998d5373 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 30 Jun 2014 17:08:06 +0200 Subject: [PATCH 151/236] 6707032: Division by zero warning not suppressed properly in some cases Delay reporting of the division by zero warning until annotations are resolved, so that @SuppressWarnings works correctly. Reviewed-by: vromero --- .../com/sun/tools/javac/comp/Check.java | 18 +++++++++++++++--- .../javac/warnings/suppress/T6707032.java | 18 ++++++++++++++++++ .../tools/javac/warnings/suppress/T6707032.out | 3 +++ .../suppress/VerifySuppressWarnings.java | 10 ++++++---- 4 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 langtools/test/tools/javac/warnings/suppress/T6707032.java create mode 100644 langtools/test/tools/javac/warnings/suppress/T6707032.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index 43728013aa9..44275993165 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -271,6 +271,14 @@ public class Check { log.warning(LintCategory.STATIC, pos, msg, args); } + /** Warn about division by integer constant zero. + * @param pos Position to be used for error reporting. + */ + void warnDivZero(DiagnosticPosition pos) { + if (lint.isEnabled(LintCategory.DIVZERO)) + log.warning(LintCategory.DIVZERO, pos, "div.zero"); + } + /** * Report any deferred diagnostics. */ @@ -3393,15 +3401,19 @@ public class Check { * @param operator The operator for the expression * @param operand The right hand operand for the expression */ - void checkDivZero(DiagnosticPosition pos, Symbol operator, Type operand) { + void checkDivZero(final DiagnosticPosition pos, Symbol operator, Type operand) { if (operand.constValue() != null - && lint.isEnabled(LintCategory.DIVZERO) && operand.getTag().isSubRangeOf(LONG) && ((Number) (operand.constValue())).longValue() == 0) { int opc = ((OperatorSymbol)operator).opcode; if (opc == ByteCodes.idiv || opc == ByteCodes.imod || opc == ByteCodes.ldiv || opc == ByteCodes.lmod) { - log.warning(LintCategory.DIVZERO, pos, "div.zero"); + deferredLintHandler.report(new DeferredLintHandler.LintLogger() { + @Override + public void report() { + warnDivZero(pos); + } + }); } } } diff --git a/langtools/test/tools/javac/warnings/suppress/T6707032.java b/langtools/test/tools/javac/warnings/suppress/T6707032.java new file mode 100644 index 00000000000..5a13d737863 --- /dev/null +++ b/langtools/test/tools/javac/warnings/suppress/T6707032.java @@ -0,0 +1,18 @@ +/** + * @test /nodynamiccopyright/ + * @bug 6707032 + * @summary Verify that \\@SuppressWarnings("divzero") works for constant initializers + * @build VerifySuppressWarnings + * @compile/ref=T6707032.out -XDrawDiagnostics -Xlint:divzero T6707032.java + * @run main VerifySuppressWarnings T6707032.java + */ + +public class T6707032 { + public static final int D1 = T6707032b.D0; + public static final int D2 = 1/0; +} + +class T6707032b { + public static final int D0 = 1/0; + public static final int D3 = T6707032.D2; +} diff --git a/langtools/test/tools/javac/warnings/suppress/T6707032.out b/langtools/test/tools/javac/warnings/suppress/T6707032.out new file mode 100644 index 00000000000..83b38a1562f --- /dev/null +++ b/langtools/test/tools/javac/warnings/suppress/T6707032.out @@ -0,0 +1,3 @@ +T6707032.java:12:36: compiler.warn.div.zero +T6707032.java:16:36: compiler.warn.div.zero +2 warnings diff --git a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java index 037f2a1764a..dad2ebecd72 100644 --- a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java +++ b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -55,11 +55,12 @@ import javax.tools.SimpleJavaFileObject; * the @SuppressWarnings annotation on the declaration and verifies than no * warnings are produced inside the declaration, but all are produced outside it. * - * Currently only works with unchecked,deprecation,cast warnings. + * Currently only works with unchecked,deprecation,cast,divzero warnings. */ public class VerifySuppressWarnings { - private static final List STANDARD_PARAMS = Arrays.asList("-Xlint:unchecked,deprecation,cast", "-Xjcov"); + private static final List STANDARD_PARAMS = + Arrays.asList("-Xlint:unchecked,deprecation,cast,divzero"); public static void main(String... args) throws IOException, URISyntaxException { if (args.length != 1) throw new IllegalStateException("Must provide class name!"); @@ -133,7 +134,8 @@ public class VerifySuppressWarnings { }.scan(cut, null); for (final int[] declarationSpan : declarationSpans) { - final String suppressWarnings = "@SuppressWarnings({\"deprecation\", \"unchecked\", \"serial\"})"; + final String suppressWarnings = + "@SuppressWarnings({\"deprecation\", \"unchecked\", \"serial\", \"divzero\"})"; final String updatedContent = testContent.substring(0, declarationSpan[0]) + suppressWarnings + testContent.substring(declarationSpan[0]); final List> foundErrors = new ArrayList<>(diagnostics); DiagnosticListener verifyDiagnostics = new DiagnosticListener() { From 3e0fd99223bc26c3784df881f46859b2da49477a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Mon, 30 Jun 2014 17:31:28 +0200 Subject: [PATCH 152/236] 8048586: String concatenation with optimistic types is slow Reviewed-by: lagergren, attila --- .../codegen/LocalVariableTypesCalculator.java | 4 +- .../internal/codegen/types/ObjectType.java | 2 + .../nashorn/internal/codegen/types/Type.java | 16 ++++++++ .../jdk/nashorn/internal/runtime/JSType.java | 13 ++++++ nashorn/test/script/basic/JDK-8048586.js | 41 +++++++++++++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/script/basic/JDK-8048586.js diff --git a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java index 9a6bcef259d..df763c1ba4f 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java @@ -1196,7 +1196,9 @@ final class LocalVariableTypesCalculator extends NodeVisitor{ } else if(binaryNode.isOptimisticUndecidedType()) { // At this point, we can assign a static type to the optimistic binary ADD operator as now we know // the types of its operands. - return binaryNode.setType(Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType())); + final Type type = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType()); + // Use Type.CHARSEQUENCE instead of Type.STRING to avoid conversion of ConsStrings to Strings. + return binaryNode.setType(type.equals(Type.STRING) ? Type.CHARSEQUENCE : type); } return binaryNode; } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/types/ObjectType.java b/nashorn/src/jdk/nashorn/internal/codegen/types/ObjectType.java index 50cc02fc9ea..0ccf6644a59 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/types/ObjectType.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/types/ObjectType.java @@ -171,6 +171,8 @@ class ObjectType extends Type { invokestatic(method, JSType.TO_BOOLEAN); } else if (to.isString()) { invokestatic(method, JSType.TO_PRIMITIVE_TO_STRING); + } else if (to.isCharSequence()) { + invokestatic(method, JSType.TO_PRIMITIVE_TO_CHARSEQUENCE); } else { throw new UnsupportedOperationException("Illegal conversion " + this + " -> " + to + " " + isString() + " " + toString); } diff --git a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java index 18b2c0d3a77..1fc648039ff 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/types/Type.java @@ -416,6 +416,15 @@ public abstract class Type implements Comparable, BytecodeOps { return this.equals(Type.STRING); } + /** + * Determines whether a type is a CHARSEQUENCE type used internally strings + * + * @return true if CharSequence (internal string) type, false otherwise + */ + public boolean isCharSequence() { + return this.equals(Type.CHARSEQUENCE); + } + /** * Determine if two types are equivalent, i.e. need no conversion * @@ -799,6 +808,13 @@ public abstract class Type implements Comparable, BytecodeOps { */ public static final Type STRING = putInCache(new ObjectType(String.class)); + /** + * This is the CharSequence singleton used to represent JS strings internally + * (either a {@code java.lang.String} or {@code jdk.nashorn.internal.runtime.ConsString}. + */ + public static final Type CHARSEQUENCE = putInCache(new ObjectType(CharSequence.class)); + + /** * This is the object singleton, used for all object types */ diff --git a/nashorn/src/jdk/nashorn/internal/runtime/JSType.java b/nashorn/src/jdk/nashorn/internal/runtime/JSType.java index 1d4e409fd3d..388761c4655 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/JSType.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/JSType.java @@ -130,6 +130,9 @@ public enum JSType { /** Combined call to toPrimitive followed by toString. */ public static final Call TO_PRIMITIVE_TO_STRING = staticCall(JSTYPE_LOOKUP, JSType.class, "toPrimitiveToString", String.class, Object.class); + /** Combined call to toPrimitive followed by toCharSequence. */ + public static final Call TO_PRIMITIVE_TO_CHARSEQUENCE = staticCall(JSTYPE_LOOKUP, JSType.class, "toPrimitiveToCharSequence", CharSequence.class, Object.class); + /** Throw an unwarranted optimism exception */ public static final Call THROW_UNWARRANTED = staticCall(JSTYPE_LOOKUP, JSType.class, "throwUnwarrantedOptimismException", Object.class, Object.class, int.class); @@ -487,6 +490,16 @@ public enum JSType { return toString(toPrimitive(obj)); } + /** + * Like {@link #toPrimitiveToString(Object)}, but avoids conversion of ConsString to String. + * + * @param obj an object + * @return the CharSequence form of the primitive form of the object + */ + public static CharSequence toPrimitiveToCharSequence(final Object obj) { + return toCharSequence(toPrimitive(obj)); + } + /** * JavaScript compliant conversion of number to boolean * diff --git a/nashorn/test/script/basic/JDK-8048586.js b/nashorn/test/script/basic/JDK-8048586.js new file mode 100644 index 00000000000..03941985877 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8048586.js @@ -0,0 +1,41 @@ +/* + * 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 + * 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. + */ + +/** + * JDK-8048586: String concatenation with optimistic types is slow + * + * @test + * @run + */ + +var body = ''; + +for (var i = 0; i < 1024 * 1024; i++) { + body += 'hello world\n'; +} + +body = ''; + +for (var i = 0; i < 1024 * 1024; i++) { + body = body + 'hello world\n'; +} From fb7a37edd7911ede6e9230885e1628fadca44efd Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 30 Jun 2014 14:09:56 -0700 Subject: [PATCH 153/236] 8037948: Improve documentation for org.w3c.dom package Reviewed-by: lancea, henryjen, alanb --- .../internal/resolver/readers/DOMCatalogReader.java | 1 - jaxp/src/org/w3c/dom/package.html | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java b/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java index c5740cb1c66..bd14b28ae39 100644 --- a/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java +++ b/jaxp/src/com/sun/org/apache/xml/internal/resolver/readers/DOMCatalogReader.java @@ -57,7 +57,6 @@ import sun.reflect.misc.ReflectUtil; *

The selection of CatalogParsers is made on the basis of the QName * of the root element of the document.

* - *

This class requires the Java API for XML Parsing.

* * @see Catalog * @see CatalogReader diff --git a/jaxp/src/org/w3c/dom/package.html b/jaxp/src/org/w3c/dom/package.html index b53925625a2..a95de6c6ea7 100644 --- a/jaxp/src/org/w3c/dom/package.html +++ b/jaxp/src/org/w3c/dom/package.html @@ -3,12 +3,10 @@ org.w3c.dom package -Provides the interfaces for the Document Object Model (DOM) which is a -component API of the Java API for XML -Processing. The Document Object Model Level 2 Core API allows programs -to dynamically access and update the content and structure of documents. -See the specification -for more information. +Provides the interfaces for the Document Object Model (DOM). Supports the +Document Object Model Level 2 Core APIi, +Document Object Model (DOM) Level 3 Core, +and Document Object Model (DOM) Level 3 Load and Save. @since 1.4 From f5c7c3c790e07ad25c01aa737801fc2f0debbe0a Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 30 Jun 2014 14:27:37 -0700 Subject: [PATCH 154/236] 8048302: Update bug reporting URL in make/Javadoc.gmk 8048321: Enable doclint warnings in build of docs from langtools Reviewed-by: tbell --- make/Javadoc.gmk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index aebdb21a8b2..d95f9dc1ad1 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -118,7 +118,7 @@ DOCSDIR_URL = {@docroot}/$(GET2DOCSDIR) COPYRIGHT_URL = $(DOCSDIR_URL)/legal/cpyr.html # Url to bug filing site -BUG_SUBMIT_URL = http://bugreport.sun.com/bugreport/ +BUG_SUBMIT_URL = http://bugreport.java.com/bugreport/ # Common line for how to submit a bug or rfe BUG_SUBMIT_LINE = Submit a bug or feature @@ -442,7 +442,7 @@ $(DOCLETAPI_INDEX_FILE): $(DOCLETAPI_OPTIONS_FILE) $(DOCLETAPI_PACKAGES_FILE) $( $(DOCLETAPI_OPTIONS_FILE): $(prep-target) @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ - $(call OptionOnly,-Xdoclint:none) ; \ + $(call OptionOnly,-Xdoclint:all) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-breakiterator) ; \ @@ -499,7 +499,7 @@ $(TAGLETAPI_INDEX_FILE): $(TAGLETAPI_OPTIONS_FILE) $(TAGLETAPI_PACKAGES_FILE) $( $(TAGLETAPI_OPTIONS_FILE): $(prep-target) @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ - $(call OptionOnly,-Xdoclint:none) ; \ + $(call OptionOnly,-Xdoclint:all) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionOnly,-nonavbar) ; \ @@ -1074,7 +1074,7 @@ $(TREEAPI_INDEX_HTML): $(TREEAPI_OPTIONS_FILE) $(TREEAPI_PACKAGES_FILE) $(COREAP $(TREEAPI_OPTIONS_FILE): $(prep-target) @($(call OptionOnly,$(COMMON_JAVADOCFLAGS)) ; \ - $(call OptionOnly,-Xdoclint:none) ; \ + $(call OptionOnly,-Xdoclint:all) ; \ $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH)) ; \ $(call OptionPair,-encoding,ascii) ; \ $(call OptionPair,-doctitle,$(TREEAPI_DOCTITLE)) ; \ From 61183bb10c7b9b6fa353a24309fc72596f862c6e Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 30 Jun 2014 18:04:13 -0700 Subject: [PATCH 155/236] 8023276: Java SE should include the full DOM API from JAXP Reviewed-by: lancea, mchung, alanb --- make/common/CORE_PKGS.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/common/CORE_PKGS.gmk b/make/common/CORE_PKGS.gmk index 9c85da65ec7..fc7dddadff1 100644 --- a/make/common/CORE_PKGS.gmk +++ b/make/common/CORE_PKGS.gmk @@ -39,8 +39,6 @@ EXCLUDE_PKGS = \ org.w3c.dom.css \ org.w3c.dom.html \ org.w3c.dom.stylesheets \ - org.w3c.dom.traversal \ - org.w3c.dom.ranges \ org.omg.stub.javax.management.remote.rmi # @@ -294,6 +292,8 @@ CORE_PKGS = \ org.w3c.dom.events \ org.w3c.dom.bootstrap \ org.w3c.dom.ls \ + org.w3c.dom.ranges \ + org.w3c.dom.traversal \ org.w3c.dom.views \ org.xml.sax \ org.xml.sax.ext \ From d929c9ead876be6a1d35e2468386ebeaa3521dc0 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Tue, 1 Jul 2014 09:02:45 +0200 Subject: [PATCH 156/236] 8007987: ciConstantPoolCache::_keys should be array of 32bit int The type of ciConstantPoolCache::_keys is changed to int which is sufficient to store the 2 byte constant pool indices. Reviewed-by: twisti, coleenp --- hotspot/src/share/vm/ci/ciConstantPoolCache.cpp | 2 +- hotspot/src/share/vm/ci/ciConstantPoolCache.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp b/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp index a277e421a32..6ceacdc5a5a 100644 --- a/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp +++ b/hotspot/src/share/vm/ci/ciConstantPoolCache.cpp @@ -38,7 +38,7 @@ ciConstantPoolCache::ciConstantPoolCache(Arena* arena, int expected_size) { _elements = new (arena) GrowableArray(arena, expected_size, 0, 0); - _keys = new (arena) GrowableArray(arena, expected_size, 0, 0); + _keys = new (arena) GrowableArray(arena, expected_size, 0, 0); } // ------------------------------------------------------------------ diff --git a/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp b/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp index 30ebcac2079..17cf77681e0 100644 --- a/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp +++ b/hotspot/src/share/vm/ci/ciConstantPoolCache.hpp @@ -35,7 +35,7 @@ // Usage note: this klass has nothing to do with ConstantPoolCache*. class ciConstantPoolCache : public ResourceObj { private: - GrowableArray* _keys; + GrowableArray* _keys; GrowableArray* _elements; int find(int index); From 0231fb818fe07d31b2444934bb973f33f6fc5a6f Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 1 Jul 2014 13:09:40 +0400 Subject: [PATCH 157/236] 8047996: Quarantine compiler/whitebox tests Reviewed-by: vlivanov --- hotspot/test/compiler/tiered/NonTieredLevelsTest.java | 1 + hotspot/test/compiler/tiered/TieredLevelsTest.java | 1 + hotspot/test/compiler/whitebox/ClearMethodStateTest.java | 1 + hotspot/test/compiler/whitebox/DeoptimizeAllTest.java | 1 + hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java | 1 + .../test/compiler/whitebox/EnqueueMethodForCompilationTest.java | 1 + hotspot/test/compiler/whitebox/GetNMethodTest.java | 1 + hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java | 1 + 8 files changed, 8 insertions(+) diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java index 13411a0dd73..08321b87266 100644 --- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java @@ -25,6 +25,7 @@ import java.util.function.IntPredicate; /** * @test NonTieredLevelsTest + * @ignore 8046268 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build NonTieredLevelsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java index 9fb2254d0b5..4b9a0a4a906 100644 --- a/hotspot/test/compiler/tiered/TieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java @@ -23,6 +23,7 @@ /** * @test TieredLevelsTest + * @ignore 8046268 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build TieredLevelsTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java index 89fff68460f..195221658cf 100644 --- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java +++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java @@ -25,6 +25,7 @@ import java.util.function.Function; /* * @test ClearMethodStateTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build ClearMethodStateTest diff --git a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java index ea4e36400eb..a5b9d794c66 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java @@ -23,6 +23,7 @@ /* * @test DeoptimizeAllTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build DeoptimizeAllTest diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java index 0b9ffd2d9db..e257a1e5e25 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java @@ -23,6 +23,7 @@ /* * @test DeoptimizeMethodTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build DeoptimizeMethodTest diff --git a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java index d9139dd3674..4acebb2b123 100644 --- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java +++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java @@ -23,6 +23,7 @@ /* * @test EnqueueMethodForCompilationTest + * @ignore 8046268 * @bug 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build EnqueueMethodForCompilationTest diff --git a/hotspot/test/compiler/whitebox/GetNMethodTest.java b/hotspot/test/compiler/whitebox/GetNMethodTest.java index bb95f01b991..9800f3a3eb3 100644 --- a/hotspot/test/compiler/whitebox/GetNMethodTest.java +++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java @@ -26,6 +26,7 @@ import sun.hotspot.code.NMethod; /* * @test GetNMethodTest + * @ignore 8046268 * @bug 8038240 * @library /testlibrary /testlibrary/whitebox * @build GetNMethodTest diff --git a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java index d6586879778..604175c38ef 100644 --- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java +++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java @@ -23,6 +23,7 @@ /* * @test MakeMethodNotCompilableTest + * @ignore 8046268 * @bug 8012322 8006683 8007288 8022832 * @library /testlibrary /testlibrary/whitebox * @build MakeMethodNotCompilableTest From 81f8f932251d03b563869fa059405e0db9afe453 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 1 Jul 2014 17:37:39 +0530 Subject: [PATCH 158/236] 8047359: large string size RangeError should be thrown rather than reporting negative length Reviewed-by: hannesw, attila --- nashorn/make/build.xml | 3 +- .../dynalink/beans/OverloadedMethod.java | 2 +- ...mpositeTypeBasedGuardingDynamicLinker.java | 3 +- .../internal/codegen/FunctionSignature.java | 2 +- .../internal/ir/debug/NashornClassReader.java | 2 +- .../nashorn/internal/objects/NativeDate.java | 1 + .../nashorn/internal/runtime/ConsString.java | 3 ++ .../internal/runtime/ScriptRuntime.java | 7 ++- .../jdk/nashorn/internal/runtime/Source.java | 1 + .../runtime/UserAccessorProperty.java | 4 +- .../runtime/arrays/ByteBufferArrayData.java | 2 +- .../internal/runtime/linker/InvokeByName.java | 2 +- .../runtime/resources/Messages.properties | 1 + nashorn/test/script/basic/JDK-8047359.js | 47 +++++++++++++++++++ 14 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8047359.js diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 1b28e9bdcbe..a872f358e6d 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -125,8 +125,7 @@ encoding="${javac.encoding}" includeantruntime="false" fork="true"> - - + diff --git a/nashorn/src/jdk/internal/dynalink/beans/OverloadedMethod.java b/nashorn/src/jdk/internal/dynalink/beans/OverloadedMethod.java index 75332859f17..70ec495a7ac 100644 --- a/nashorn/src/jdk/internal/dynalink/beans/OverloadedMethod.java +++ b/nashorn/src/jdk/internal/dynalink/beans/OverloadedMethod.java @@ -152,7 +152,7 @@ class OverloadedMethod { @SuppressWarnings("unused") private MethodHandle selectMethod(final Object[] args) throws NoSuchMethodException { - final Class[] argTypes = new Class[args.length]; + final Class[] argTypes = new Class[args.length]; for(int i = 0; i < argTypes.length; ++i) { final Object arg = args[i]; argTypes[i] = arg == null ? ClassString.NULL_CLASS : arg.getClass(); diff --git a/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java b/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java index 814fc6936bf..91946969370 100644 --- a/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java +++ b/nashorn/src/jdk/internal/dynalink/support/CompositeTypeBasedGuardingDynamicLinker.java @@ -111,7 +111,7 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin private final TypeBasedGuardingDynamicLinker[] linkers; private final List[] singletonLinkers; - @SuppressWarnings("unchecked") + @SuppressWarnings(value={"unchecked", "rawtypes"}) ClassToLinker(final TypeBasedGuardingDynamicLinker[] linkers) { this.linkers = linkers; singletonLinkers = new List[linkers.length]; @@ -120,6 +120,7 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin } } + @SuppressWarnings("fallthrough") @Override protected List computeValue(final Class clazz) { List list = NO_LINKER; diff --git a/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java b/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java index 627623b378e..5e06794609c 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/FunctionSignature.java @@ -141,7 +141,7 @@ public final class FunctionSignature { paramTypeList.add(paramType.getTypeClass()); } - this.methodType = MH.type(returnType.getTypeClass(), paramTypeList.toArray(new Class[paramTypes.length])); + this.methodType = MH.type(returnType.getTypeClass(), paramTypeList.toArray(new Class[paramTypes.length])); } /** diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/NashornClassReader.java b/nashorn/src/jdk/nashorn/internal/ir/debug/NashornClassReader.java index 3fd2ce96750..87eb18df73c 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/debug/NashornClassReader.java +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/NashornClassReader.java @@ -443,7 +443,7 @@ public class NashornClassReader extends ClassReader { @Override protected Label readLabel(final int offset, final Label[] labels) { final Label label = super.readLabel(offset, labels); - label.info = (int)offset; + label.info = offset; return label; } diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java index b3661df7eb2..0f42998d261 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeDate.java @@ -909,6 +909,7 @@ public final class NativeDate extends ScriptObject { sb.append(n); } + @SuppressWarnings("fallthrough") private static String toStringImpl(final Object self, final int format) { final NativeDate nd = getNativeDate(self); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java b/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java index 41e2c49e938..3d1979d6c62 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ConsString.java @@ -57,6 +57,9 @@ public final class ConsString implements CharSequence { this.left = left; this.right = right; length = left.length() + right.length(); + if (length < 0) { + throw new IllegalArgumentException("too big concatenated String"); + } } @Override diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java index 337d92699e3..a73b7ab992f 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java @@ -27,6 +27,7 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.codegen.CompilerConstants.staticCall; import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup; +import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError; import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError; import static jdk.nashorn.internal.runtime.ECMAErrors.syntaxError; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; @@ -531,7 +532,11 @@ public final class ScriptRuntime { if (xPrim instanceof String || yPrim instanceof String || xPrim instanceof ConsString || yPrim instanceof ConsString) { - return new ConsString(JSType.toCharSequence(xPrim), JSType.toCharSequence(yPrim)); + try { + return new ConsString(JSType.toCharSequence(xPrim), JSType.toCharSequence(yPrim)); + } catch (final IllegalArgumentException iae) { + throw rangeError(iae, "concat.string.too.big"); + } } return JSType.toNumber(xPrim) + JSType.toNumber(yPrim); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Source.java b/nashorn/src/jdk/nashorn/internal/runtime/Source.java index d64bbfa26e6..b5829eee735 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Source.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Source.java @@ -306,6 +306,7 @@ public final class Source implements Loggable { return array == null; } + @SuppressWarnings("try") protected void checkPermissionAndClose() throws IOException { try (InputStream in = url.openStream()) { // empty diff --git a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java index 03a17f7bc0c..0a29d8911a6 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/UserAccessorProperty.java @@ -201,7 +201,7 @@ public final class UserAccessorProperty extends SpillProperty { @Override public Object getObjectValue(final ScriptObject self, final ScriptObject owner) { - return userAccessorGetter(getAccessors((owner != null) ? owner : (ScriptObject)self), self); + return userAccessorGetter(getAccessors((owner != null) ? owner : self), self); } @Override @@ -221,7 +221,7 @@ public final class UserAccessorProperty extends SpillProperty { @Override public void setValue(final ScriptObject self, final ScriptObject owner, final Object value, final boolean strict) { - userAccessorSetter(getAccessors((owner != null) ? owner : (ScriptObject)self), strict ? getKey() : null, self, value); + userAccessorSetter(getAccessors((owner != null) ? owner : self), strict ? getKey() : null, self, value); } @Override diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java index b76d0756ea5..85f1b433383 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ByteBufferArrayData.java @@ -150,7 +150,7 @@ final class ByteBufferArrayData extends ArrayData { @Override public Object getObject(final int index) { - return (int)(0x0ff & buf.get(index)); + return 0x0ff & buf.get(index); } @Override diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java index e6d13c20c9a..19fe6bd758c 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/InvokeByName.java @@ -90,7 +90,7 @@ public final class InvokeByName { if(plength == 0) { finalPtypes = new Class[] { Object.class, targetClass }; } else { - finalPtypes = new Class[plength + 2]; + finalPtypes = new Class[plength + 2]; finalPtypes[0] = Object.class; finalPtypes[1] = targetClass; System.arraycopy(ptypes, 0, finalPtypes, 2, plength); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties index 29785a3f70e..53cb4a68290 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties @@ -151,6 +151,7 @@ range.error.invalid.precision=precision argument toPrecision() must be in [1, 21 range.error.invalid.radix=radix argument must be in [2, 36] range.error.invalid.date=Invalid Date range.error.too.many.errors=Script contains too many errors: {0} errors +range.error.concat.string.too.big=Concatenated String is too big reference.error.not.defined="{0}" is not defined reference.error.cant.be.used.as.lhs="{0}" can not be used as the left-hand side of assignment diff --git a/nashorn/test/script/basic/JDK-8047359.js b/nashorn/test/script/basic/JDK-8047359.js new file mode 100644 index 00000000000..812f3414347 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047359.js @@ -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. + */ + +/** + * JDK-8047359: large string size RangeError should be thrown rather than reporting negative length + * + * @test + * @run + */ + +try { + var s = " "; for (var i=0;i<31;++i) s+=s; s.length; + throw new Error("should have thrown RangeError!"); +} catch (e) { + if (! (e instanceof RangeError)) { + fail("RangeError expected, got " + e); + } +} + +try { + var s = " "; for (var i=0;i<31;++i) s+=s; + throw new Error("should have thrown RangeError!"); +} catch (e) { + if (! (e instanceof RangeError)) { + fail("RangeError expected, got " + e); + } +} From 68c76d1731c14dd39a22fd2481feeb5f68e715b1 Mon Sep 17 00:00:00 2001 From: Sean Coffey Date: Tue, 1 Jul 2014 15:17:55 +0100 Subject: [PATCH 159/236] 7095856: OutputStreamHook doesn't handle null values Reviewed-by: lancea, msheppar --- .../com/sun/corba/se/impl/io/OutputStreamHook.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java b/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java index 1748397d065..6908cad9a83 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java @@ -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 @@ -35,7 +35,8 @@ import java.io.IOException; import java.io.OutputStream; import java.io.ObjectOutputStream; import java.io.ObjectOutput; -import java.util.Hashtable; +import java.util.Map; +import java.util.HashMap; import org.omg.CORBA.INTERNAL; @@ -49,7 +50,7 @@ public abstract class OutputStreamHook extends ObjectOutputStream */ private class HookPutFields extends ObjectOutputStream.PutField { - private Hashtable fields = new Hashtable(); + private Map fields = new HashMap<>(); /** * Put the value of the named boolean field into the persistent field. @@ -140,7 +141,6 @@ public abstract class OutputStreamHook extends ObjectOutputStream public OutputStreamHook() throws java.io.IOException { super(); - } public void defaultWriteObject() throws IOException { From 9baf436fd6211d3ffa6b06037c4e81eb9466847e Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 1 Jul 2014 17:23:46 +0100 Subject: [PATCH 160/236] 8048905: More tweaking with langtools intellij support Add support for 'jtreg.home' property; fix code width to be 80; disable import optimizations Reviewed-by: vromero --- langtools/make/build.xml | 1 + langtools/make/intellij/ant.xml | 1 + langtools/make/intellij/codeStyleSettings.xml | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 langtools/make/intellij/codeStyleSettings.xml diff --git a/langtools/make/build.xml b/langtools/make/build.xml index 04c09d9fa6a..a8a6ffe4104 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -761,6 +761,7 @@ +